diff --git a/briar-android/src/main/java/org/briarproject/briar/android/BriarService.java b/briar-android/src/main/java/org/briarproject/briar/android/BriarService.java index 46a01180e..4d8ad78c4 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/BriarService.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/BriarService.java @@ -22,6 +22,7 @@ import org.briarproject.bramble.api.system.AndroidExecutor; import org.briarproject.briar.R; import org.briarproject.briar.android.logout.HideUiActivity; import org.briarproject.briar.android.navdrawer.NavDrawerActivity; +import org.briarproject.briar.android.splash.SplashScreenActivity; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; @@ -227,6 +228,7 @@ public class BriarService extends Service { super.onLowMemory(); LOG.warning("Memory is low"); shutdownFromBackground(); + showLowMemoryShutdownNotification(); } private void shutdownFromBackground() { @@ -251,6 +253,24 @@ public class BriarService extends Service { }).start(); } + private void showLowMemoryShutdownNotification() { + androidExecutor.runOnUiThread(() -> { + NotificationCompat.Builder b = new NotificationCompat.Builder( + BriarService.this, FAILURE_CHANNEL_ID); + b.setSmallIcon(android.R.drawable.stat_notify_error); + b.setContentTitle(getText( + R.string.low_memory_shutdown_notification_title)); + b.setContentText(getText( + R.string.low_memory_shutdown_notification_text)); + Intent i = new Intent(this, SplashScreenActivity.class); + b.setContentIntent(PendingIntent.getActivity(this, 0, i, 0)); + b.setAutoCancel(true); + Object o = getSystemService(NOTIFICATION_SERVICE); + NotificationManager nm = (NotificationManager) o; + nm.notify(FAILURE_NOTIFICATION_ID, b.build()); + }); + } + /** * Waits for all services to start before returning. */ diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml index 1842654de..a4b0b554d 100644 --- a/briar-android/src/main/res/values/strings.xml +++ b/briar-android/src/main/res/values/strings.xml @@ -415,4 +415,7 @@ QR code Show QR code fullscreen + + Signed out of Briar + Signed out due to lack of memory.