Show the stop button in the task manager for user allowlisted apps
Meanwhile, still hide the stop button for those system apps in the pre-configured doze idle allowlist. Bug: 230997412 Test: Manual - Unrestrict app in battery settings & check task manager Change-Id: Ief0a0020fc195f3b7beb67ef297ae91630d8a1c2
This commit is contained in:
@@ -420,7 +420,7 @@ class FgsManagerController @Inject constructor(
|
||||
PowerExemptionManager.REASON_SYSTEM_UID,
|
||||
PowerExemptionManager.REASON_DEVICE_DEMO_MODE -> UIControl.HIDE_ENTRY
|
||||
|
||||
PowerExemptionManager.REASON_ALLOWLISTED_PACKAGE,
|
||||
PowerExemptionManager.REASON_SYSTEM_ALLOW_LISTED,
|
||||
PowerExemptionManager.REASON_DEVICE_OWNER,
|
||||
PowerExemptionManager.REASON_DISALLOW_APPS_CONTROL,
|
||||
PowerExemptionManager.REASON_DPO_PROTECTED_APP,
|
||||
|
||||
@@ -265,6 +265,20 @@ public final class AppRestrictionController {
|
||||
*/
|
||||
private int[] mDeviceIdleExceptIdleAllowlist = new int[0]; // No lock is needed.
|
||||
|
||||
/**
|
||||
* The pre-configured system app-ids in the power-save allow list.
|
||||
*
|
||||
* @see #mDeviceIdleAllowlist.
|
||||
*/
|
||||
private final ArraySet<Integer> mSystemDeviceIdleAllowlist = new ArraySet<>();
|
||||
|
||||
/**
|
||||
* The pre-configured system app-ids in the power-save allow list, except-idle.
|
||||
*
|
||||
* @see #mDeviceIdleExceptIdleAllowlist.
|
||||
*/
|
||||
private final ArraySet<Integer> mSystemDeviceIdleExceptIdleAllowlist = new ArraySet<>();
|
||||
|
||||
private final Object mLock = new Object();
|
||||
private final Object mSettingsLock = new Object();
|
||||
private final Injector mInjector;
|
||||
@@ -1511,14 +1525,33 @@ public final class AppRestrictionController {
|
||||
}
|
||||
|
||||
private void initBgRestrictionExemptioFromSysConfig() {
|
||||
mBgRestrictionExemptioFromSysConfig =
|
||||
SystemConfig.getInstance().getBgRestrictionExemption();
|
||||
final SystemConfig sysConfig = SystemConfig.getInstance();
|
||||
mBgRestrictionExemptioFromSysConfig = sysConfig.getBgRestrictionExemption();
|
||||
if (DEBUG_BG_RESTRICTION_CONTROLLER) {
|
||||
final ArraySet<String> exemptedPkgs = mBgRestrictionExemptioFromSysConfig;
|
||||
for (int i = exemptedPkgs.size() - 1; i >= 0; i--) {
|
||||
Slog.i(TAG, "bg-restriction-exemption: " + exemptedPkgs.valueAt(i));
|
||||
}
|
||||
}
|
||||
loadAppIdsFromPackageList(sysConfig.getAllowInPowerSaveExceptIdle(),
|
||||
mSystemDeviceIdleExceptIdleAllowlist);
|
||||
loadAppIdsFromPackageList(sysConfig.getAllowInPowerSave(), mSystemDeviceIdleAllowlist);
|
||||
}
|
||||
|
||||
private void loadAppIdsFromPackageList(ArraySet<String> packages, ArraySet<Integer> apps) {
|
||||
final PackageManager pm = mInjector.getPackageManager();
|
||||
for (int i = packages.size() - 1; i >= 0; i--) {
|
||||
final String pkg = packages.valueAt(i);
|
||||
try {
|
||||
final ApplicationInfo ai = pm.getApplicationInfo(pkg,
|
||||
PackageManager.MATCH_SYSTEM_ONLY);
|
||||
if (ai == null) {
|
||||
continue;
|
||||
}
|
||||
apps.add(UserHandle.getAppId(ai.uid));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isExemptedFromSysConfig(String packageName) {
|
||||
@@ -2685,6 +2718,13 @@ public final class AppRestrictionController {
|
||||
|| Arrays.binarySearch(mDeviceIdleExceptIdleAllowlist, appId) >= 0;
|
||||
}
|
||||
|
||||
boolean isOnSystemDeviceIdleAllowlist(int uid) {
|
||||
final int appId = UserHandle.getAppId(uid);
|
||||
|
||||
return mSystemDeviceIdleAllowlist.contains(appId)
|
||||
|| mSystemDeviceIdleExceptIdleAllowlist.contains(appId);
|
||||
}
|
||||
|
||||
void setDeviceIdleAllowlist(int[] allAppids, int[] exceptIdleAppids) {
|
||||
mDeviceIdleAllowlist = allAppids;
|
||||
mDeviceIdleExceptIdleAllowlist = exceptIdleAppids;
|
||||
@@ -2703,6 +2743,9 @@ public final class AppRestrictionController {
|
||||
if (UserHandle.isCore(uid)) {
|
||||
return REASON_SYSTEM_UID;
|
||||
}
|
||||
if (isOnSystemDeviceIdleAllowlist(uid)) {
|
||||
return REASON_SYSTEM_ALLOW_LISTED;
|
||||
}
|
||||
if (isOnDeviceIdleAllowlist(uid)) {
|
||||
return REASON_ALLOWLISTED_PACKAGE;
|
||||
}
|
||||
@@ -2748,7 +2791,7 @@ public final class AppRestrictionController {
|
||||
} else if (isExemptedFromSysConfig(pkg)) {
|
||||
return REASON_SYSTEM_ALLOW_LISTED;
|
||||
} else if (mConstantsObserver.mBgRestrictionExemptedPackages.contains(pkg)) {
|
||||
return REASON_ALLOWLISTED_PACKAGE;
|
||||
return REASON_SYSTEM_ALLOW_LISTED;
|
||||
} else if (pm.isPackageStateProtected(pkg, userId)) {
|
||||
return REASON_DPO_PROTECTED_APP;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user