Added option to check if an app is whitelisted for deviceidle.

Currently, there are only options to get the whole list:

  adb shell dumpsys deviceidle whitelist

Or to add/remove an app:

  adb shell dumpsys deviceidle whitelist +my.app
  adb shell dumpsys deviceidle whitelist -my.app

This change add an option to get the status of an app, so it can be used
on CTS tests:

  adb shell dumpsys deviceidle whitelist =my.app

BUG: 27127112
Change-Id: Ife4b8e2efa51e4ba5e1e2263e59884e5054f1e0a
This commit is contained in:
Felipe Leme
2016-02-10 13:51:54 -08:00
parent 2b63730837
commit f8a462319f

View File

@@ -1262,6 +1262,12 @@ public class DeviceIdleController extends SystemService
return false;
}
public boolean getPowerSaveWhitelistAppInternal(String name) {
synchronized (this) {
return mPowerSaveWhitelistUserApps.containsKey(name);
}
}
public String[] getSystemPowerWhitelistExceptIdleInternal() {
synchronized (this) {
int size = mPowerSaveWhitelistAppsExceptIdle.size();
@@ -2307,8 +2313,8 @@ public class DeviceIdleController extends SystemService
android.Manifest.permission.DEVICE_POWER, null);
do {
if (arg.length() < 1 || (arg.charAt(0) != '-'
&& arg.charAt(0) != '+')) {
pw.println("Package must be prefixed with + or -: " + arg);
&& arg.charAt(0) != '+' && arg.charAt(0) != '=')) {
pw.println("Package must be prefixed with +, -, or =: " + arg);
return -1;
}
char op = arg.charAt(0);
@@ -2319,10 +2325,12 @@ public class DeviceIdleController extends SystemService
} else {
pw.println("Unknown package: " + pkg);
}
} else {
} else if (op == '-') {
if (removePowerSaveWhitelistAppInternal(pkg)) {
pw.println("Removed: " + pkg);
}
} else {
pw.println(getPowerSaveWhitelistAppInternal(pkg));
}
} while ((arg=shell.getNextArg()) != null);
} else {