Disable the optimization mode preference if the app is not settable

https://screenshot.googleplex.com/BbQyEv6YCjPVwUF (allowlist)
https://screenshot.googleplex.com/3hTb8TQwGMQqcwS
https://screenshot.googleplex.com/6hdTAT2yNFucD9N (system app)
https://screenshot.googleplex.com/77T5JyAD5nZJpDT (normal app)

Fix: 281566984
Test: make test RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.fuelgauge.*
Change-Id: If7aa4b61bc806daa570187da24b7f454cd069dec
This commit is contained in:
ykhung
2023-05-15 15:02:52 +08:00
committed by YK Hung
parent 62193a6f56
commit 5cd3a7298e
10 changed files with 35 additions and 38 deletions

View File

@@ -128,11 +128,10 @@ public class BatteryOptimizeUtils {
mContext, mode, mUid, mPackageName, mBatteryUtils, mPowerAllowListBackend, action);
}
/**
* Return {@code true} if package name is valid (can get an uid).
*/
public boolean isValidPackageName() {
return mBatteryUtils.getPackageUid(mPackageName) != BatteryUtils.UID_NULL;
/** Return {@code true} if it is disabled for default optimized mode only. */
public boolean isDisabledForOptimizeModeOnly() {
return getAllowList(mContext).contains(mPackageName)
|| mBatteryUtils.getPackageUid(mPackageName) == BatteryUtils.UID_NULL;
}
/**