Workaround Android bug

pull/174/head
M66B 6 years ago
parent cba5b297df
commit 58b8a9e8e3

@ -826,8 +826,12 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
builder.setContentIntent(piUpdate); builder.setContentIntent(piUpdate);
} }
try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(Helper.NOTIFICATION_UPDATE, builder.build()); nm.notify(Helper.NOTIFICATION_UPDATE, builder.build());
} catch (Throwable ex) {
Log.w(ex);
}
} }
@Override @Override

@ -2838,7 +2838,11 @@ class Core {
Notification notification = builder.build(); Notification notification = builder.build();
Log.i("Notifying tag=" + tag + " id=" + id + Log.i("Notifying tag=" + tag + " id=" + id +
(Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? "" : " channel=" + notification.getChannelId())); (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? "" : " channel=" + notification.getChannelId()));
try {
nm.notify(tag, 1, notification); nm.notify(tag, 1, notification);
} catch (Throwable ex) {
Log.w(ex);
}
} }
} }
} }

@ -89,8 +89,12 @@ public class ServiceSend extends ServiceBase {
if (unsent != null && lastUnsent != unsent) { if (unsent != null && lastUnsent != unsent) {
lastUnsent = unsent; lastUnsent = unsent;
try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(Helper.NOTIFICATION_SEND, getNotificationService().build()); nm.notify(Helper.NOTIFICATION_SEND, getNotificationService().build());
} catch (Throwable ex) {
Log.w(ex);
}
} }
} }
}); });
@ -228,8 +232,12 @@ public class ServiceSend extends ServiceBase {
lastSuitable = suitable; lastSuitable = suitable;
EntityLog.log(ServiceSend.this, "Service send suitable=" + suitable); EntityLog.log(ServiceSend.this, "Service send suitable=" + suitable);
try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(Helper.NOTIFICATION_SEND, getNotificationService().build()); nm.notify(Helper.NOTIFICATION_SEND, getNotificationService().build());
} catch (Throwable ex) {
Log.w(ex);
}
if (suitable) if (suitable)
executor.submit(new Runnable() { executor.submit(new Runnable() {
@ -495,10 +503,14 @@ public class ServiceSend extends ServiceBase {
if (ex instanceof AuthenticationFailedException || if (ex instanceof AuthenticationFailedException ||
ex instanceof SendFailedException) { ex instanceof SendFailedException) {
try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify("send:" + message.identity, 1, nm.notify("send:" + message.identity, 1,
Core.getNotificationError(this, "error", ident.name, ex) Core.getNotificationError(this, "error", ident.name, ex)
.build()); .build());
} catch (Throwable ex1) {
Log.w(ex1);
}
throw ex; throw ex;
} }
@ -508,9 +520,13 @@ public class ServiceSend extends ServiceBase {
long delayed = now - message.last_attempt; long delayed = now - message.last_attempt;
if (delayed > IDENTITY_ERROR_AFTER * 60 * 1000L) { if (delayed > IDENTITY_ERROR_AFTER * 60 * 1000L) {
Log.i("Reporting send error after=" + delayed); Log.i("Reporting send error after=" + delayed);
try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify("send:" + message.identity, 1, nm.notify("send:" + message.identity, 1,
Core.getNotificationError(this, "warning", ident.name, ex).build()); Core.getNotificationError(this, "warning", ident.name, ex).build());
} catch (Throwable ex1) {
Log.w(ex1);
}
} }
throw ex; throw ex;

@ -277,8 +277,24 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
fts = false; fts = false;
WorkerFts.cancel(ServiceSynchronize.this); WorkerFts.cancel(ServiceSynchronize.this);
} }
try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(lastAccounts, lastOperations).build()); nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(lastAccounts, lastOperations).build());
} catch (Throwable ex) {
/*
java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.lang.Iterable.iterator()' on a null object reference
at android.app.ApplicationPackageManager.getUserIfProfile(ApplicationPackageManager.java:2167)
at android.app.ApplicationPackageManager.getUserBadgeForDensity(ApplicationPackageManager.java:1002)
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(SourceFile:355)
at androidx.core.app.NotificationCompatBuilder.build(SourceFile:247)
at androidx.core.app.NotificationCompat$Builder.build(SourceFile:1677)
*/
Log.w(ex);
}
} }
if (!runService) if (!runService)
@ -859,10 +875,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
boolean max = isMaxConnections(message); boolean max = isMaxConnections(message);
if (max) if (max)
state.setMaxConnections(); state.setMaxConnections();
if (!max || state.getBackoff() > CONNECT_BACKOFF_MAX) { if (!max || state.getBackoff() > CONNECT_BACKOFF_MAX)
try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify("alert:" + account.id, 1, nm.notify("alert:" + account.id, 1,
getNotificationAlert(account.name, message).build()); getNotificationAlert(account.name, message).build());
} catch (Throwable ex) {
Log.w(ex);
} }
} finally { } finally {
wlFolder.release(); wlFolder.release();
@ -904,10 +923,14 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
Log.e(ex); Log.e(ex);
if (!ioError) { if (!ioError) {
try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify("receive:" + account.id, 1, nm.notify("receive:" + account.id, 1,
Core.getNotificationError(this, "error", account.name, ex) Core.getNotificationError(this, "error", account.name, ex)
.build()); .build());
} catch (Throwable ex1) {
Log.w(ex1);
}
throw ex; throw ex;
} }
} }
@ -927,10 +950,14 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
getString(R.string.title_no_sync, getString(R.string.title_no_sync,
Helper.getDateTimeInstance(this, DateFormat.SHORT, DateFormat.SHORT) Helper.getDateTimeInstance(this, DateFormat.SHORT, DateFormat.SHORT)
.format(account.last_connected)), ex); .format(account.last_connected)), ex);
try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify("receive:" + account.id, 1, nm.notify("receive:" + account.id, 1,
Core.getNotificationError(this, "warning", account.name, warning) Core.getNotificationError(this, "warning", account.name, warning)
.build()); .build());
} catch (Throwable ex1) {
Log.w(ex1);
}
} }
} }
@ -1601,8 +1628,12 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
"Updated network=" + network + "Updated network=" + network +
" capabilities " + capabilities + " capabilities " + capabilities +
" suitable=" + lastSuitable); " suitable=" + lastSuitable);
try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(lastAccounts, lastOperations).build()); nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(lastAccounts, lastOperations).build());
} catch (Throwable ex) {
Log.w(ex);
}
} }
} }
}; };

Loading…
Cancel
Save