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,6 +874,7 @@ 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) {
try {
String action = (intent == null ? null : intent.getAction()); String action = (intent == null ? null : intent.getAction());
String reason = (intent == null ? null : intent.getStringExtra("reason")); String reason = (intent == null ? null : intent.getStringExtra("reason"));
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling, EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
@ -889,8 +890,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
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,8 +936,20 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
default: default:
Log.w("Unknown action: " + action); Log.w("Unknown action: " + action);
} }
}
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(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;