Skip to content
Snippets Groups Projects
Commit 2f7d5b86 authored by Torsten Grote's avatar Torsten Grote
Browse files

Merge branch 'hide-ui-if-not-in-foreground' into 'master'

Don't hide UI on low memory if we're in the foreground

See merge request akwizgran/briar!839
parents b026031d e2d636e2
No related branches found
No related tags found
No related merge requests found
package org.briarproject.briar.android;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
......@@ -30,6 +32,7 @@ import java.util.logging.Logger;
import javax.annotation.Nullable;
import javax.inject.Inject;
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
......@@ -248,8 +251,10 @@ public class BriarService extends Service {
LOG.info("Trim memory: running low");
} else if (level == TRIM_MEMORY_RUNNING_CRITICAL) {
LOG.info("Trim memory: running critically low");
// Clear the UI to save some memory
hideUi();
// If we're not in the foreground, clear the UI to save memory
RunningAppProcessInfo info = new RunningAppProcessInfo();
ActivityManager.getMyMemoryState(info);
if (info.importance != IMPORTANCE_FOREGROUND) hideUi();
} else if (LOG.isLoggable(INFO)) {
LOG.info("Trim memory: unknown level " + level);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment