Revert "Add PowerSaveWhitelistExceptIdle as Optimizted modes condition"

- Reverts commit e7cca4cd81
 - Add try-catch to handle unexpected operate

Reason for revert: Previous fix will cause a side effect which makes app stuck at Optimize mode after switching state from Unrestricted to Optimize, add a try catch to handle previous issue first

BYPASS_INCLUSIVE_LANGUAGE_REASON=legacy naming, not edit by this code change

Bug: 199892006
Test: make SettingsRoboTests
Change-Id: I3b1850ab66bbf4cd605f14152a244a8ed7edd578
Merged-In: I3b1850ab66bbf4cd605f14152a244a8ed7edd578
This commit is contained in:
Wesley.CW Wang
2021-10-18 16:46:58 +08:00
committed by Wesley Wang
parent 3efe6e59f7
commit d11dec2f82
10 changed files with 10 additions and 72 deletions

View File

@@ -89,8 +89,16 @@ public class BatteryOptimizeUtils {
return getAppOptimizationMode(mMode, mAllowListed);
}
/** Sets the {@link OptimizationMode} for associated app. */
public void setAppOptimizationMode(@OptimizationMode int mode) {
try {
setAppUsageStateInternal(mode);
} catch (Exception e) {
Log.e(TAG, "setAppUsageState() is failed for " + mPackageName, e);
}
}
/** Sets the {@link OptimizationMode} for associated app. */
public void setAppUsageStateInternal(@OptimizationMode int mode) {
if (getAppOptimizationMode(mMode, mAllowListed) == mode) {
Log.w(TAG, "set the same optimization mode for: " + mPackageName);
return;
@@ -130,13 +138,6 @@ public class BatteryOptimizeUtils {
|| mPowerAllowListBackend.isDefaultActiveApp(mPackageName);
}
/**
* Return {@code true} if this package is in allow list except idle app.
*/
public boolean isAllowlistedExceptIdleApp() {
return mPowerAllowListBackend.isAllowlistedExceptIdle(mPackageName);
}
String getPackageName() {
return mPackageName == null ? UNKNOWN_PACKAGE : mPackageName;
}