Prevent crash

This commit is contained in:
M66B 2021-10-12 07:27:07 +02:00
parent faa71279e4
commit b5a61240b0
1 changed files with 28 additions and 16 deletions

View File

@ -874,23 +874,23 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
String action = (intent == null ? null : intent.getAction()); try {
String reason = (intent == null ? null : intent.getStringExtra("reason")); String action = (intent == null ? null : intent.getAction());
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling, String reason = (intent == null ? null : intent.getStringExtra("reason"));
"### Service command " + intent + EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
" action=" + action + " reason=" + reason); "### Service command " + intent +
Log.logExtras(intent); " action=" + action + " reason=" + reason);
Log.logExtras(intent);
super.onStartCommand(intent, flags, startId); super.onStartCommand(intent, flags, startId);
if (isBackgroundService(this)) if (isBackgroundService(this))
stopForeground(true); stopForeground(true);
else else
startForeground(NotificationHelper.NOTIFICATION_SYNCHRONIZE, startForeground(NotificationHelper.NOTIFICATION_SYNCHRONIZE,
getNotificationService(null, null).build()); getNotificationService(null, null).build());
if (action != null) if (action != null) {
try {
switch (action.split(":")[0]) { switch (action.split(":")[0]) {
case "enable": case "enable":
onEnable(intent); onEnable(intent);
@ -936,9 +936,21 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
default: default:
Log.w("Unknown action: " + action); Log.w("Unknown action: " + action);
} }
} catch (Throwable ex) {
Log.e(ex);
} }
} catch (Throwable ex) {
Log.e(ex);
/*
at android.app.ApplicationPackageManager.getUserIfProfile(ApplicationPackageManager.java:2190)
at android.app.ApplicationPackageManager.getUserBadgeForDensity(ApplicationPackageManager.java:1006)
at android.app.Notification$Builder.getProfileBadgeDrawable(Notification.java:2890)
at android.app.Notification$Builder.hasThreeLines(Notification.java:3105)
at android.app.Notification$Builder.build(Notification.java:3659)
at androidx.core.app.NotificationCompatBuilder.buildInternal(NotificationCompatBuilder:426)
at androidx.core.app.NotificationCompatBuilder.build(NotificationCompatBuilder:318)
at androidx.core.app.NotificationCompat$Builder.build(NotificationCompat:2346)
at eu.faircode.email.ServiceSynchronize.onStartCommand(ServiceSynchronize:890)
*/
}
return START_STICKY; return START_STICKY;
} }