Allow apps to bypass Power Save restrictions when launched from a Notification's PendingIntent.
This scenario typically happens when the device is on Doze Mode and a
notification action is triggered from a Wear device.
In a nutshell, the workflow is:
- ProcessRecord has a flag telling whether a process has "whitelist
management" privileges.
- When NotificationManager binds a new NotificationListenerService, it
sets the BIND_ALLOW_WHITELIST_MANAGEMENT flag.
- On bind(), ActiveService asserts that only system apps can set that
flag.
- On computeOomAdjLocked(), ActivityManagerService sets the
ProcessRecord flag if necessary.
- Upon creating a notification, NotificationManager calls AM to mark its
PendingIntents as coming from a notification.
- When PendingIntentRecord sends it to the target, it checks if it's
from a notification and if so calls AM to do the temp whitelist.
- On unbind(), ActiveService removes the ProcessRecord flag if necessary.
Fixes: 28818704
Change-Id: I00d46036a2cbb73f7f733fd35bf0b743a02807a1
diff --git a/services/core/java/com/android/server/am/ProcessRecord.java b/services/core/java/com/android/server/am/ProcessRecord.java
index da18f32..691fd2a 100644
--- a/services/core/java/com/android/server/am/ProcessRecord.java
+++ b/services/core/java/com/android/server/am/ProcessRecord.java
@@ -194,6 +194,8 @@
// Process is currently hosting a backup agent for backup or restore
public boolean inFullBackup;
+ // App is allowed to manage whitelists such as temporary Power Save mode whitelist.
+ boolean whitelistManager;
void dump(PrintWriter pw, String prefix) {
final long now = SystemClock.uptimeMillis();
@@ -376,6 +378,9 @@
}
pw.println();
}
+ if (whitelistManager) {
+ pw.print(prefix); pw.print("whitelistManager="); pw.println(whitelistManager);
+ }
if (activities.size() > 0) {
pw.print(prefix); pw.println("Activities:");
for (int i=0; i<activities.size(); i++) {