Add a new config for checking BatteryManager show/hide rule

Bug: 271387663
Test: presubmit
Change-Id: If24b5e6de630afe972ad7ff7af866cb587db0a56
This commit is contained in:
ykhung
2023-03-05 10:54:01 +08:00
parent 82d5103f07
commit 3ae46cd6ec
4 changed files with 30 additions and 12 deletions

View File

@@ -50,8 +50,13 @@ public class BatteryManagerPreferenceController extends BasePreferenceController
@Override
public int getAvailabilityStatus() {
return mPowerUsageFeatureProvider.isBatteryManagerSupported()
&& mPowerUsageFeatureProvider.isAdaptiveChargingSupported()
if (!mPowerUsageFeatureProvider.isBatteryManagerSupported()) {
return UNSUPPORTED_ON_DEVICE;
}
if (!mContext.getResources().getBoolean(R.bool.config_battery_manager_consider_ac)) {
return AVAILABLE_UNSEARCHABLE;
}
return mPowerUsageFeatureProvider.isAdaptiveChargingSupported()
? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
}