Implement OP_SYSTEM_EXEMPT_FROM_POWER_RESTRICTIONS exemption
OP_SYSTEM_EXEMPT_FROM_POWER_RESTRICTIONS details: * An app with this appop will be made exempt from all power restrictions, including app standby and doze. * In addition, the app will be able to start fgs from the bg, and the user will not be able to stop fgs run by the app. Changes: * Implement the OP_SYSTEM_EXEMPT_FROM_POWER_RESTRICTIONS Bug: 246330879 Test: atest PowerAllowlistBackendTest Manual testing: - Give OP_SYSTEM_EXEMPT_FROM_POWER_RESTRICTIONS appop to TestDPC app - Verify the app can start fg services from the bg - Verify fgs started by the app cannot be stopped - Verify the app cannot be put into background restricted via Settings Change-Id: If9e76076c59195f1e6e5f3eee3c8e7a0c754d8de
This commit is contained in:
@@ -153,7 +153,7 @@ public final class BatteryBackupHelper implements BackupHelper {
|
||||
// Ignores default optimized/unknown state or system/default apps.
|
||||
if (optimizationMode == BatteryOptimizeUtils.MODE_OPTIMIZED
|
||||
|| optimizationMode == BatteryOptimizeUtils.MODE_UNKNOWN
|
||||
|| isSystemOrDefaultApp(info.packageName)) {
|
||||
|| isSystemOrDefaultApp(info.packageName, info.uid)) {
|
||||
continue;
|
||||
}
|
||||
final String packageOptimizeMode =
|
||||
@@ -191,8 +191,9 @@ public final class BatteryBackupHelper implements BackupHelper {
|
||||
continue;
|
||||
}
|
||||
final String packageName = results[0];
|
||||
final int uid = BatteryUtils.getInstance(mContext).getPackageUid(packageName);
|
||||
// Ignores system/default apps.
|
||||
if (isSystemOrDefaultApp(packageName)) {
|
||||
if (isSystemOrDefaultApp(packageName, uid)) {
|
||||
Log.w(TAG, "ignore from isSystemOrDefaultApp():" + packageName);
|
||||
continue;
|
||||
}
|
||||
@@ -253,10 +254,10 @@ public final class BatteryBackupHelper implements BackupHelper {
|
||||
return mPowerAllowlistBackend;
|
||||
}
|
||||
|
||||
private boolean isSystemOrDefaultApp(String packageName) {
|
||||
private boolean isSystemOrDefaultApp(String packageName, int uid) {
|
||||
final PowerAllowlistBackend powerAllowlistBackend = getPowerAllowlistBackend();
|
||||
return powerAllowlistBackend.isSysAllowlisted(packageName)
|
||||
|| powerAllowlistBackend.isDefaultActiveApp(packageName);
|
||||
|| powerAllowlistBackend.isDefaultActiveApp(packageName, uid);
|
||||
}
|
||||
|
||||
private ArraySet<ApplicationInfo> getInstalledApplications() {
|
||||
|
||||
Reference in New Issue
Block a user