Merge "Allow except-idle whitelisted apps to start BG services in EBS" into pi-dev
am: 205a5581ae
Change-Id: Ie5d327d5efa90946d92fe3a7063fec988fe56fcd
This commit is contained in:
@@ -207,7 +207,7 @@ public abstract class ActivityManagerInternal {
|
||||
/**
|
||||
* Allow DeviceIdleController to tell us about what apps are whitelisted.
|
||||
*/
|
||||
public abstract void setDeviceIdleWhitelist(int[] appids);
|
||||
public abstract void setDeviceIdleWhitelist(int[] allAppids, int[] exceptIdleAppids);
|
||||
|
||||
/**
|
||||
* Update information about which app IDs are on the temp whitelist.
|
||||
|
||||
@@ -1535,7 +1535,8 @@ public class DeviceIdleController extends SystemService
|
||||
filter.addAction(Intent.ACTION_SCREEN_ON);
|
||||
getContext().registerReceiver(mInteractivityReceiver, filter);
|
||||
|
||||
mLocalActivityManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAllAppIdArray);
|
||||
mLocalActivityManager.setDeviceIdleWhitelist(
|
||||
mPowerSaveWhitelistAllAppIdArray, mPowerSaveWhitelistExceptIdleAppIdArray);
|
||||
mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAllAppIdArray);
|
||||
|
||||
mLocalActivityManager.registerScreenObserver(mScreenObserver);
|
||||
@@ -2576,11 +2577,8 @@ public class DeviceIdleController extends SystemService
|
||||
mPowerSaveWhitelistUserAppIdArray = buildAppIdArray(null,
|
||||
mPowerSaveWhitelistUserApps, mPowerSaveWhitelistUserAppIds);
|
||||
if (mLocalActivityManager != null) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Setting activity manager whitelist to "
|
||||
+ Arrays.toString(mPowerSaveWhitelistAllAppIdArray));
|
||||
}
|
||||
mLocalActivityManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAllAppIdArray);
|
||||
mLocalActivityManager.setDeviceIdleWhitelist(
|
||||
mPowerSaveWhitelistAllAppIdArray, mPowerSaveWhitelistExceptIdleAppIdArray);
|
||||
}
|
||||
if (mLocalPowerManager != null) {
|
||||
if (DEBUG) {
|
||||
|
||||
@@ -1376,10 +1376,15 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
DeviceIdleController.LocalService mLocalDeviceIdleController;
|
||||
|
||||
/**
|
||||
* Set of app ids that are whitelisted for device idle and thus background check.
|
||||
* Power-save whitelisted app-ids (not including except-idle-whitelisted ones).
|
||||
*/
|
||||
int[] mDeviceIdleWhitelist = new int[0];
|
||||
|
||||
/**
|
||||
* Power-save whitelisted app-ids (including except-idle-whitelisted ones).
|
||||
*/
|
||||
int[] mDeviceIdleExceptIdleWhitelist = new int[0];
|
||||
|
||||
/**
|
||||
* Set of app ids that are temporarily allowed to escape bg check due to high-pri message
|
||||
*/
|
||||
@@ -9185,7 +9190,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
// If force-background-check is enabled, restrict all apps that aren't whitelisted.
|
||||
if (mForceBackgroundCheck &&
|
||||
!UserHandle.isCore(uid) &&
|
||||
!isOnDeviceIdleWhitelistLocked(uid)) {
|
||||
!isOnDeviceIdleWhitelistLocked(uid, /*allowExceptIdleToo=*/ true)) {
|
||||
if (DEBUG_BACKGROUND_CHECK) {
|
||||
Slog.i(TAG, "Force background check: " +
|
||||
uid + "/" + packageName + " restricted");
|
||||
@@ -9223,7 +9228,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
}
|
||||
|
||||
// Is this app on the battery whitelist?
|
||||
if (isOnDeviceIdleWhitelistLocked(uid)) {
|
||||
if (isOnDeviceIdleWhitelistLocked(uid, /*allowExceptIdleToo=*/ false)) {
|
||||
if (DEBUG_BACKGROUND_CHECK) {
|
||||
Slog.i(TAG, "App " + uid + "/" + packageName
|
||||
+ " on idle whitelist; not restricted in background");
|
||||
@@ -9265,9 +9270,12 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
? appRestrictedInBackgroundLocked(uid, packageName, packageTargetSdk)
|
||||
: appServicesRestrictedInBackgroundLocked(uid, packageName,
|
||||
packageTargetSdk);
|
||||
if (DEBUG_BACKGROUND_CHECK) Slog.d(TAG, "checkAllowBackground: uid=" + uid
|
||||
+ " pkg=" + packageName + " startMode=" + startMode
|
||||
+ " onwhitelist=" + isOnDeviceIdleWhitelistLocked(uid));
|
||||
if (DEBUG_BACKGROUND_CHECK) {
|
||||
Slog.d(TAG, "checkAllowBackground: uid=" + uid
|
||||
+ " pkg=" + packageName + " startMode=" + startMode
|
||||
+ " onwhitelist=" + isOnDeviceIdleWhitelistLocked(uid, false)
|
||||
+ " onwhitelist(ei)=" + isOnDeviceIdleWhitelistLocked(uid, true));
|
||||
}
|
||||
if (startMode == ActivityManager.APP_START_MODE_DELAYED) {
|
||||
// This is an old app that has been forced into a "compatible as possible"
|
||||
// mode of background check. To increase compatibility, we will allow other
|
||||
@@ -9294,9 +9302,14 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
/**
|
||||
* @return whether a UID is in the system, user or temp doze whitelist.
|
||||
*/
|
||||
boolean isOnDeviceIdleWhitelistLocked(int uid) {
|
||||
boolean isOnDeviceIdleWhitelistLocked(int uid, boolean allowExceptIdleToo) {
|
||||
final int appId = UserHandle.getAppId(uid);
|
||||
return Arrays.binarySearch(mDeviceIdleWhitelist, appId) >= 0
|
||||
|
||||
final int[] whitelist = allowExceptIdleToo
|
||||
? mDeviceIdleExceptIdleWhitelist
|
||||
: mDeviceIdleWhitelist;
|
||||
|
||||
return Arrays.binarySearch(whitelist, appId) >= 0
|
||||
|| Arrays.binarySearch(mDeviceIdleTempWhitelist, appId) >= 0
|
||||
|| mPendingTempWhitelist.indexOfKey(uid) >= 0;
|
||||
}
|
||||
@@ -16838,6 +16851,8 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
}
|
||||
}
|
||||
pw.println(" mDeviceIdleWhitelist=" + Arrays.toString(mDeviceIdleWhitelist));
|
||||
pw.println(" mDeviceIdleExceptIdleWhitelist="
|
||||
+ Arrays.toString(mDeviceIdleExceptIdleWhitelist));
|
||||
pw.println(" mDeviceIdleTempWhitelist=" + Arrays.toString(mDeviceIdleTempWhitelist));
|
||||
if (mPendingTempWhitelist.size() > 0) {
|
||||
pw.println(" mPendingTempWhitelist:");
|
||||
@@ -26290,9 +26305,10 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceIdleWhitelist(int[] appids) {
|
||||
public void setDeviceIdleWhitelist(int[] allAppids, int[] exceptIdleAppids) {
|
||||
synchronized (ActivityManagerService.this) {
|
||||
mDeviceIdleWhitelist = appids;
|
||||
mDeviceIdleWhitelist = allAppids;
|
||||
mDeviceIdleExceptIdleWhitelist = exceptIdleAppids;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user