Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2e9b569 authored by Lei Yu's avatar Lei Yu Committed by Android (Google) Code Review
Browse files

Merge "Hook up Adaptive Battery to new flag." into pi-dev

parents f778a91a df5beee6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -52,15 +52,15 @@ public class SmartBatteryPreferenceController extends BasePreferenceController i
    public void updateState(Preference preference) {
        super.updateState(preference);
        final boolean smartBatteryOn = Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.APP_STANDBY_ENABLED, ON) == ON;
                Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, ON) == ON;
        ((SwitchPreference) preference).setChecked(smartBatteryOn);
    }

    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        final boolean smartBatteryOn = (Boolean) newValue;
        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.APP_STANDBY_ENABLED,
                smartBatteryOn ? ON : OFF);
        Settings.Global.putInt(mContext.getContentResolver(),
                Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, smartBatteryOn ? ON : OFF);
        return true;
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ public class AnomalyDetectionJobService extends JobService {
            final int uid = extractUidFromStatsDimensionsValue(intentDimsValue);
            final boolean autoFeatureOn = powerUsageFeatureProvider.isSmartBatterySupported()
                    ? Settings.Global.getInt(contentResolver,
                            Settings.Global.APP_STANDBY_ENABLED, ON) == ON
                            Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, ON) == ON
                    : Settings.Global.getInt(contentResolver,
                            Settings.Global.APP_AUTO_RESTRICTION_ENABLED, ON) == ON;
            final String packageName = batteryUtils.getPackageName(uid);
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ public class BatteryManagerPreferenceController extends BasePreferenceController
        super.updateState(preference);
        final int num = BatteryTipUtils.getRestrictedAppsList(mAppOpsManager, mUserManager).size();
        final String setting = mPowerUsageFeatureProvider.isSmartBatterySupported()
                ? Settings.Global.APP_STANDBY_ENABLED
                ? Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED
                : Settings.Global.APP_AUTO_RESTRICTION_ENABLED;
        final boolean featureOn =
                Settings.Global.getInt(mContext.getContentResolver(), setting, ON) == ON;
+2 −1
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ public class SmartBatteryDetector implements BatteryTipDetector {
    public BatteryTip detect() {
        // Show it if there is no other tips shown
        final boolean smartBatteryOff = Settings.Global.getInt(mContentResolver,
                Settings.Global.APP_STANDBY_ENABLED, 1) == 0 || mPolicy.testSmartBatteryTip;
                Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, 1) == 0
                || mPolicy.testSmartBatteryTip;
        final int state =
                smartBatteryOff ? BatteryTip.StateType.NEW : BatteryTip.StateType.INVISIBLE;
        return new SmartBatteryTip(state);
+4 −2
Original line number Diff line number Diff line
@@ -107,10 +107,12 @@ public class SmartBatteryPreferenceControllerTest {
    }

    private void putSmartBatteryValue(int value) {
        Settings.Global.putInt(mContentResolver, Settings.Global.APP_STANDBY_ENABLED, value);
        Settings.Global.putInt(mContentResolver,
                Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, value);
    }

    private int getSmartBatteryValue() {
        return Settings.Global.getInt(mContentResolver, Settings.Global.APP_STANDBY_ENABLED, ON);
        return Settings.Global.getInt(mContentResolver,
                Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, ON);
    }
}
Loading