Add restrict app detail page

1. Move force standby action to BatteryUtils
2. Add click action for restricted preference(go to detail page)
3. Build app list in detail page using packageOps list

Bug: 71502850
Test: RunSettingsRoboTests
Change-Id: I1e6733e5402e7a854b07a8bbb43a86255276bfaa
This commit is contained in:
jackqdyulei
2018-01-08 15:46:55 -08:00
parent 48bd637d19
commit 0fb2d68f97
11 changed files with 405 additions and 55 deletions

View File

@@ -398,6 +398,19 @@ public class BatteryUtils {
return timeMs * 1000;
}
public void setForceAppStandby(int uid, String packageName,
int mode) {
final boolean isPreOApp = isLegacyApp(packageName);
if (isPreOApp) {
// Control whether app could run in the background if it is pre O app
mAppOpsManager.setMode(AppOpsManager.OP_RUN_IN_BACKGROUND, uid, packageName,
mode);
}
// Control whether app could run jobs in the background
mAppOpsManager.setMode(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, uid, packageName,
mode);
}
public void initBatteryStatsHelper(BatteryStatsHelper statsHelper, Bundle bundle,
UserManager userManager) {
statsHelper.create(bundle);
@@ -481,5 +494,18 @@ public class BatteryUtils {
return 0;
}
public boolean isLegacyApp(final String packageName) {
try {
ApplicationInfo info = mPackageManager.getApplicationInfo(packageName,
PackageManager.GET_META_DATA);
return info.targetSdkVersion < Build.VERSION_CODES.O;
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Cannot find package: " + packageName, e);
}
return false;
}
}