Prevent crash

pull/178/head
M66B 5 years ago
parent fc33f471bb
commit d8a15daa82

@ -134,11 +134,27 @@ public class Widget extends AppWidgetProvider {
return;
}
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, Widget.class));
Intent intent = new Intent(context, Widget.class);
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
context.sendBroadcast(intent);
try {
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, Widget.class));
Intent intent = new Intent(context, Widget.class);
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
context.sendBroadcast(intent);
} catch (Throwable ex) {
Log.e(ex);
/*
java.lang.RuntimeException: system server dead?
at android.appwidget.AppWidgetManager.getAppWidgetIds(AppWidgetManager.java:1053)
at eu.faircode.email.Widget.update(SourceFile:111)
at eu.faircode.email.ServiceSynchronize$6.onChanged(SourceFile:460)
at eu.faircode.email.ServiceSynchronize$6.onChanged(SourceFile:439)
at androidx.lifecycle.LiveData.considerNotify(SourceFile:131)
at androidx.lifecycle.LiveData.dispatchingValue(SourceFile:149)
at androidx.lifecycle.LiveData.setValue(SourceFile:307)
at androidx.lifecycle.LiveData$1.run(SourceFile:91)
Caused by: android.os.DeadObjectException
*/
}
}
}

@ -107,8 +107,24 @@ public class WidgetUnified extends AppWidgetProvider {
return;
}
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetUnified.class));
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.lv);
try {
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetUnified.class));
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.lv);
} catch (Throwable ex) {
Log.e(ex);
/*
java.lang.RuntimeException: system server dead?
at android.appwidget.AppWidgetManager.getAppWidgetIds(AppWidgetManager.java:1053)
at eu.faircode.email.Widget.update(SourceFile:111)
at eu.faircode.email.ServiceSynchronize$6.onChanged(SourceFile:460)
at eu.faircode.email.ServiceSynchronize$6.onChanged(SourceFile:439)
at androidx.lifecycle.LiveData.considerNotify(SourceFile:131)
at androidx.lifecycle.LiveData.dispatchingValue(SourceFile:149)
at androidx.lifecycle.LiveData.setValue(SourceFile:307)
at androidx.lifecycle.LiveData$1.run(SourceFile:91)
Caused by: android.os.DeadObjectException
*/
}
}
}
}

Loading…
Cancel
Save