diff --git a/app/src/main/java/eu/faircode/email/ServiceExternal.java b/app/src/main/java/eu/faircode/email/ServiceExternal.java index 32387d49c3..d5421f04a7 100644 --- a/app/src/main/java/eu/faircode/email/ServiceExternal.java +++ b/app/src/main/java/eu/faircode/email/ServiceExternal.java @@ -69,7 +69,14 @@ public class ServiceExternal extends ServiceBase { public void onCreate() { Log.i("Service external create"); super.onCreate(); - startForeground(NotificationHelper.NOTIFICATION_EXTERNAL, getNotification()); + try { + startForeground(NotificationHelper.NOTIFICATION_EXTERNAL, getNotification()); + } catch (Throwable ex) { + if (Helper.isPlayStoreInstall()) + Log.i(ex); + else + Log.e(ex); + } } @Override @@ -92,7 +99,14 @@ public class ServiceExternal extends ServiceBase { Log.logExtras(intent); super.onStartCommand(intent, flags, startId); - startForeground(NotificationHelper.NOTIFICATION_EXTERNAL, getNotification()); + try { + startForeground(NotificationHelper.NOTIFICATION_EXTERNAL, getNotification()); + } catch (Throwable ex) { + if (Helper.isPlayStoreInstall()) + Log.i(ex); + else + Log.e(ex); + } if (intent == null) return START_NOT_STICKY; diff --git a/app/src/main/java/eu/faircode/email/ServiceSend.java b/app/src/main/java/eu/faircode/email/ServiceSend.java index e05a575af8..775b194286 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSend.java +++ b/app/src/main/java/eu/faircode/email/ServiceSend.java @@ -106,7 +106,14 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar public void onCreate() { EntityLog.log(this, "Service send create"); super.onCreate(); - startForeground(NotificationHelper.NOTIFICATION_SEND, getNotificationService(false)); + try { + startForeground(NotificationHelper.NOTIFICATION_SEND, getNotificationService(false)); + } catch (Throwable ex) { + if (Helper.isPlayStoreInstall()) + Log.i(ex); + else + Log.e(ex); + } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); retry_max = prefs.getInt("send_retry_max", RETRY_MAX_DEFAULT); @@ -241,7 +248,14 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar @Override public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); - startForeground(NotificationHelper.NOTIFICATION_SEND, getNotificationService(false)); + try { + startForeground(NotificationHelper.NOTIFICATION_SEND, getNotificationService(false)); + } catch (Throwable ex) { + if (Helper.isPlayStoreInstall()) + Log.i(ex); + else + Log.e(ex); + } Log.i("Send intent=" + intent); Log.logExtras(intent); diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 1ace9f8552..5aab6dac04 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -205,8 +205,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences startForeground(NotificationHelper.NOTIFICATION_SYNCHRONIZE, getNotificationService(null, null)); } catch (Throwable ex) { - Log.e(ex); - stopSelf(); + if (Helper.isPlayStoreInstall()) + Log.i(ex); + else + Log.e(ex); } isOptimizing = Boolean.FALSE.equals(Helper.isIgnoringOptimizations(this)); @@ -1114,8 +1116,15 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences if (isBackgroundService(this)) stopForeground(true); else - startForeground(NotificationHelper.NOTIFICATION_SYNCHRONIZE, - getNotificationService(null, null)); + try { + startForeground(NotificationHelper.NOTIFICATION_SYNCHRONIZE, + getNotificationService(null, null)); + } catch (Throwable ex) { + if (Helper.isPlayStoreInstall()) + Log.i(ex); + else + Log.e(ex); + } if (action != null) { switch (action.split(":")[0]) { @@ -3549,7 +3558,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences else ContextCompat.startForegroundService(context, intent); } catch (Throwable ex) { - Log.e(ex); + if (Helper.isPlayStoreInstall()) + Log.i(ex); + else + Log.e(ex); } }