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

Commit 897f6366 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Fix boost charging, also expose test API

Bug: 124437856
Bug: 111360323
Test: atest CtsBatterySavingTestCases
Change-Id: I7cf25e9dca669ae1bb5d9bb62ada35a59ca26f6f
parent 32981ff4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1281,6 +1281,10 @@ package android.net.util {

package android.os {

  public class BatteryManager {
    method @RequiresPermission("android.permission.POWER_SAVER") public boolean setChargingStateUpdateDelayMillis(int);
  }

  public class Build {
    method public static boolean is64BitAbi(String);
  }
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.Manifest.permission;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.Context;
import android.content.Intent;
import android.hardware.health.V1_0.Constants;
@@ -386,6 +387,7 @@ public class BatteryManager {
     */
    @RequiresPermission(permission.POWER_SAVER)
    @SystemApi
    @TestApi
    public boolean setChargingStateUpdateDelayMillis(int delayMillis) {
        try {
            return mBatteryStats.setChargingStateUpdateDelayMillis(delayMillis);
+2 −4
Original line number Diff line number Diff line
@@ -12775,13 +12775,11 @@ public class BatteryStatsImpl extends BatteryStats {
                    // charging even if it happens to go down a level.
                    changed |= setChargingLocked(true);
                    mLastChargeStepLevel = level;
                }
                if (!mCharging) {
                } else if (!mCharging) {
                    if (mLastChargeStepLevel < level) {
                        // We have not reported that we are charging, but the level has gone up,
                        // but we would like to not have tons of activity from charging-constraint
                        // jobs, so instead of reporting ACTION_CHARGING immediately, we defer it.
                        mLastChargeStepLevel = level;
                        if (!mHandler.hasCallbacks(mDeferSetCharging)) {
                            mHandler.postDelayed(
                                    mDeferSetCharging,
@@ -12800,9 +12798,9 @@ public class BatteryStatsImpl extends BatteryStats {
                        // power supplied isn't enough, so consider the device to now be
                        // discharging.
                        changed |= setChargingLocked(false);
                        mLastChargeStepLevel = level;
                    }
                }
                mLastChargeStepLevel = level;
                if (mLastChargeStepLevel != level && mMaxChargeStepLevel < level) {
                    mChargeStepTracker.addLevelSteps(level - mLastChargeStepLevel,
                            modeBits, elapsedRealtime);