diff options
| -rw-r--r-- | core/res/res/values/config.xml | 3 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 1 | ||||
| -rw-r--r-- | services/core/java/com/android/server/BatteryService.java | 7 |
3 files changed, 11 insertions, 0 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 6cd6eb4b8df9..ceb431e3e3cd 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -1394,6 +1394,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> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 24b39bc1225e..fb7633517a0a 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2083,6 +2083,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" /> diff --git a/services/core/java/com/android/server/BatteryService.java b/services/core/java/com/android/server/BatteryService.java index e9d4d76c6131..b9a3c0c41841 100644 --- a/services/core/java/com/android/server/BatteryService.java +++ b/services/core/java/com/android/server/BatteryService.java @@ -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; } |