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:
Alex Johnston
2023-02-06 18:21:55 +00:00
parent 02c3e876f4
commit 2747dc6e8c
13 changed files with 57 additions and 53 deletions

View File

@@ -43,14 +43,14 @@ public class AppStatePowerBridge extends AppStateBaseBridge {
final int N = apps.size();
for (int i = 0; i < N; i++) {
AppEntry app = apps.get(i);
app.extraInfo = mBackend.isAllowlisted(app.info.packageName)
app.extraInfo = mBackend.isAllowlisted(app.info.packageName, app.info.uid)
? Boolean.TRUE : Boolean.FALSE;
}
}
@Override
protected void updateExtraInfo(AppEntry app, String pkg, int uid) {
app.extraInfo = mBackend.isAllowlisted(pkg) ? Boolean.TRUE : Boolean.FALSE;
app.extraInfo = mBackend.isAllowlisted(pkg, uid) ? Boolean.TRUE : Boolean.FALSE;
}
public static final AppFilter FILTER_POWER_ALLOWLISTED = new CompoundFilter(