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

Commit 975bdc96 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add a config to enable/disable shutdown-if-no-power in BatteryService" into main

parents bd8bd81a 8af0da9e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1404,6 +1404,9 @@
    <!-- Shutdown if the battery temperature exceeds (this value * 0.1) Celsius. -->
    <integer name="config_shutdownBatteryTemperature">680</integer>

    <!-- Shutdown if battery is critically low and the device is not powered. -->
    <bool name="config_shutdownIfNoPower">true</bool>

    <!-- Display low battery warning when battery level dips to this value -->
    <integer name="config_lowBatteryWarningLevel">20</integer>

+1 −0
Original line number Diff line number Diff line
@@ -2094,6 +2094,7 @@
  <java-symbol type="integer" name="config_autoBrightnessShortTermModelTimeout" />
  <java-symbol type="integer" name="config_progressTimeoutFallbackHome" />
  <java-symbol type="integer" name="config_shutdownBatteryTemperature" />
  <java-symbol type="bool" name="config_shutdownIfNoPower" />
  <java-symbol type="integer" name="config_undockedHdmiRotation" />
  <java-symbol type="integer" name="config_virtualKeyQuietTimeMillis" />
  <java-symbol type="integer" name="config_brightness_ramp_rate_fast" />
+7 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server;

import static android.os.Flags.stateOfHealthPublic;

import static com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import static com.android.server.health.Utils.copyV1Battery;

@@ -166,6 +167,7 @@ public final class BatteryService extends SystemService {
    private int mLowBatteryCloseWarningLevel;
    private int mBatteryNearlyFullLevel;
    private int mShutdownBatteryTemperature;
    private boolean mShutdownIfNoPower;

    private static String sSystemUiPackage;

@@ -230,6 +232,8 @@ public final class BatteryService extends SystemService {
                com.android.internal.R.integer.config_lowBatteryCloseWarningBump);
        mShutdownBatteryTemperature = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_shutdownBatteryTemperature);
        mShutdownIfNoPower = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_shutdownIfNoPower);
        sSystemUiPackage = mContext.getResources().getString(
                com.android.internal.R.string.config_systemUi);

@@ -391,6 +395,9 @@ public final class BatteryService extends SystemService {
        if (mHealthInfo.batteryCapacityLevel != BatteryCapacityLevel.UNSUPPORTED) {
            return (mHealthInfo.batteryCapacityLevel == BatteryCapacityLevel.CRITICAL);
        }
        if (!mShutdownIfNoPower) {
            return false;
        }
        if (mHealthInfo.batteryLevel > 0) {
            return false;
        }