mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-09 10:33:41 +02:00
Workaround Android bug
This commit is contained in:
@@ -826,8 +826,12 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||
builder.setContentIntent(piUpdate);
|
||||
}
|
||||
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(Helper.NOTIFICATION_UPDATE, builder.build());
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(Helper.NOTIFICATION_UPDATE, builder.build());
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2838,7 +2838,11 @@ class Core {
|
||||
Notification notification = builder.build();
|
||||
Log.i("Notifying tag=" + tag + " id=" + id +
|
||||
(Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? "" : " channel=" + notification.getChannelId()));
|
||||
nm.notify(tag, 1, notification);
|
||||
try {
|
||||
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) {
|
||||
lastUnsent = unsent;
|
||||
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(Helper.NOTIFICATION_SEND, getNotificationService().build());
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(Helper.NOTIFICATION_SEND, getNotificationService().build());
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -228,8 +232,12 @@ public class ServiceSend extends ServiceBase {
|
||||
lastSuitable = suitable;
|
||||
EntityLog.log(ServiceSend.this, "Service send suitable=" + suitable);
|
||||
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(Helper.NOTIFICATION_SEND, getNotificationService().build());
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(Helper.NOTIFICATION_SEND, getNotificationService().build());
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
|
||||
if (suitable)
|
||||
executor.submit(new Runnable() {
|
||||
@@ -495,10 +503,14 @@ public class ServiceSend extends ServiceBase {
|
||||
|
||||
if (ex instanceof AuthenticationFailedException ||
|
||||
ex instanceof SendFailedException) {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify("send:" + message.identity, 1,
|
||||
Core.getNotificationError(this, "error", ident.name, ex)
|
||||
.build());
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify("send:" + message.identity, 1,
|
||||
Core.getNotificationError(this, "error", ident.name, ex)
|
||||
.build());
|
||||
} catch (Throwable ex1) {
|
||||
Log.w(ex1);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
|
||||
@@ -508,9 +520,13 @@ public class ServiceSend extends ServiceBase {
|
||||
long delayed = now - message.last_attempt;
|
||||
if (delayed > IDENTITY_ERROR_AFTER * 60 * 1000L) {
|
||||
Log.i("Reporting send error after=" + delayed);
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify("send:" + message.identity, 1,
|
||||
Core.getNotificationError(this, "warning", ident.name, ex).build());
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify("send:" + message.identity, 1,
|
||||
Core.getNotificationError(this, "warning", ident.name, ex).build());
|
||||
} catch (Throwable ex1) {
|
||||
Log.w(ex1);
|
||||
}
|
||||
}
|
||||
|
||||
throw ex;
|
||||
|
||||
@@ -277,8 +277,24 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
fts = false;
|
||||
WorkerFts.cancel(ServiceSynchronize.this);
|
||||
}
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(lastAccounts, lastOperations).build());
|
||||
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
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)
|
||||
@@ -859,11 +875,14 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
boolean max = isMaxConnections(message);
|
||||
if (max)
|
||||
state.setMaxConnections();
|
||||
if (!max || state.getBackoff() > CONNECT_BACKOFF_MAX) {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify("alert:" + account.id, 1,
|
||||
getNotificationAlert(account.name, message).build());
|
||||
}
|
||||
if (!max || state.getBackoff() > CONNECT_BACKOFF_MAX)
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify("alert:" + account.id, 1,
|
||||
getNotificationAlert(account.name, message).build());
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
} finally {
|
||||
wlFolder.release();
|
||||
}
|
||||
@@ -904,10 +923,14 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
Log.e(ex);
|
||||
|
||||
if (!ioError) {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify("receive:" + account.id, 1,
|
||||
Core.getNotificationError(this, "error", account.name, ex)
|
||||
.build());
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify("receive:" + account.id, 1,
|
||||
Core.getNotificationError(this, "error", account.name, ex)
|
||||
.build());
|
||||
} catch (Throwable ex1) {
|
||||
Log.w(ex1);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
@@ -927,10 +950,14 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
getString(R.string.title_no_sync,
|
||||
Helper.getDateTimeInstance(this, DateFormat.SHORT, DateFormat.SHORT)
|
||||
.format(account.last_connected)), ex);
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify("receive:" + account.id, 1,
|
||||
Core.getNotificationError(this, "warning", account.name, warning)
|
||||
.build());
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify("receive:" + account.id, 1,
|
||||
Core.getNotificationError(this, "warning", account.name, warning)
|
||||
.build());
|
||||
} catch (Throwable ex1) {
|
||||
Log.w(ex1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1601,8 +1628,12 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
"Updated network=" + network +
|
||||
" capabilities " + capabilities +
|
||||
" suitable=" + lastSuitable);
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(lastAccounts, lastOperations).build());
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(lastAccounts, lastOperations).build());
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user