mirror of https://github.com/M66B/FairEmail.git
Start foreground not allowed
This commit is contained in:
parent
96be6d30a1
commit
27e955a13f
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue