Call noteAppRestrictionChanged when toggling restrictions/exemptions
This is to log the reasons for restriction level change and force stop
Bug: 333882527
Test: statsd_testdrive 863
Toggle battery restrictions manually for an app and verify logging
of reason
atest BatteryOptimizeUtilsTest
Change-Id: Ifcc99efc1b6acc5a992f7d952967210b07319f2e
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -386,6 +387,14 @@ public class BatteryUtils {
|
||||
// Control whether app could run in the background if it is pre O app
|
||||
mAppOpsManager.setMode(AppOpsManager.OP_RUN_IN_BACKGROUND, uid, packageName, mode);
|
||||
}
|
||||
// Notify system of reason for change
|
||||
if (isForceAppStandbyEnabled(uid, packageName) != (mode == AppOpsManager.MODE_IGNORED)) {
|
||||
mContext.getSystemService(ActivityManager.class).noteAppRestrictionEnabled(
|
||||
packageName, uid, ActivityManager.RESTRICTION_LEVEL_BACKGROUND_RESTRICTED,
|
||||
mode == AppOpsManager.MODE_IGNORED,
|
||||
ActivityManager.RESTRICTION_REASON_USER,
|
||||
"settings", 0);
|
||||
}
|
||||
// Control whether app could run jobs in the background
|
||||
mAppOpsManager.setMode(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, uid, packageName, mode);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user