[B&R] backup the battery optimization mode for installed apps
BYPASS_INCLUSIVE_LANGUAGE_REASON=legacy method name Test command for backup manager: adb shell bmgr backupnow com.android.settings adb shell dumpsys backup | grep Current Bug: 192523697 Test: make SettingsRoboTests Change-Id: I4671e48a9d3b315362b451384db637d5cae36a4d
This commit is contained in:
@@ -59,20 +59,25 @@ public class BatteryOptimizeUtils {
|
||||
mAllowListed = mPowerAllowListBackend.isAllowlisted(mPackageName);
|
||||
}
|
||||
|
||||
public AppUsageState getAppUsageState() {
|
||||
refreshState();
|
||||
if (!mAllowListed && mMode == AppOpsManager.MODE_IGNORED) {
|
||||
/** Gets the {@link AppUsageState} based on mode and allowed list. */
|
||||
public static AppUsageState getAppUsageState(int mode, boolean isAllowListed) {
|
||||
if (!isAllowListed && mode == AppOpsManager.MODE_IGNORED) {
|
||||
return AppUsageState.RESTRICTED;
|
||||
} else if (mAllowListed && mMode == AppOpsManager.MODE_ALLOWED) {
|
||||
} else if (isAllowListed && mode == AppOpsManager.MODE_ALLOWED) {
|
||||
return AppUsageState.UNRESTRICTED;
|
||||
} else if (!mAllowListed && mMode == AppOpsManager.MODE_ALLOWED) {
|
||||
} else if (!isAllowListed && mode == AppOpsManager.MODE_ALLOWED) {
|
||||
return AppUsageState.OPTIMIZED;
|
||||
} else {
|
||||
Log.d(TAG, "get unknown app usage state.");
|
||||
return AppUsageState.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/** Gets the current {@link AppUsageState}. */
|
||||
public AppUsageState getAppUsageState() {
|
||||
refreshState();
|
||||
return getAppUsageState(mMode, mAllowListed);
|
||||
}
|
||||
|
||||
public void setAppUsageState(AppUsageState state) {
|
||||
switch (state) {
|
||||
case RESTRICTED:
|
||||
|
||||
Reference in New Issue
Block a user