Skip to content

Commit f3c74f3

Browse files
author
Brian Muramatsu
committed
Make battery shutdown temperature configurable
Bug 7079455 Change-Id: I448f21231bf0548ef975f99482576acb24a1a70e
1 parent 34a75df commit f3c74f3

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

core/res/res/values/config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@
471471
Also, the battery stats are flushed to disk when we hit this level. -->
472472
<integer name="config_criticalBatteryWarningLevel">4</integer>
473473

474+
<!-- Shutdown if the battery temperature exceeds (this value * 0.1) Celsius. -->
475+
<integer name="config_shutdownBatteryTemperature">680</integer>
476+
474477
<!-- Display low battery warning when battery level dips to this value -->
475478
<!-- Display low battery warning when battery level dips to this value -->
476479
<integer name="config_lowBatteryWarningLevel">15</integer>

core/res/res/values/public.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,7 @@
15441544
<java-symbol type="integer" name="config_screenBrightnessSettingMaximum" />
15451545
<java-symbol type="integer" name="config_screenBrightnessSettingDefault" />
15461546
<java-symbol type="integer" name="config_screenBrightnessDim" />
1547+
<java-symbol type="integer" name="config_shutdownBatteryTemperature" />
15471548
<java-symbol type="integer" name="config_virtualKeyQuietTimeMillis" />
15481549
<java-symbol type="layout" name="am_compat_mode_dialog" />
15491550
<java-symbol type="layout" name="launch_warning" />

services/java/com/android/server/BatteryService.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public class BatteryService extends Binder {
116116

117117
private int mLowBatteryWarningLevel;
118118
private int mLowBatteryCloseWarningLevel;
119+
private int mShutdownBatteryTemperature;
119120

120121
private int mPlugType;
121122
private int mLastPlugType = -1; // Extra state so we can detect first run
@@ -138,6 +139,8 @@ public BatteryService(Context context, LightsService lights) {
138139
com.android.internal.R.integer.config_lowBatteryWarningLevel);
139140
mLowBatteryCloseWarningLevel = mContext.getResources().getInteger(
140141
com.android.internal.R.integer.config_lowBatteryCloseWarningLevel);
142+
mShutdownBatteryTemperature = mContext.getResources().getInteger(
143+
com.android.internal.R.integer.config_shutdownBatteryTemperature);
141144

142145
mPowerSupplyObserver.startObserving("SUBSYSTEM=power_supply");
143146

@@ -228,9 +231,11 @@ private final void shutdownIfNoPower() {
228231
}
229232

230233
private final void shutdownIfOverTemp() {
231-
// shut down gracefully if temperature is too high (> 68.0C)
232-
// wait until the system has booted before attempting to display the shutdown dialog.
233-
if (mBatteryTemperature > 680 && ActivityManagerNative.isSystemReady()) {
234+
// shut down gracefully if temperature is too high (> 68.0C by default)
235+
// wait until the system has booted before attempting to display the
236+
// shutdown dialog.
237+
if (mBatteryTemperature > mShutdownBatteryTemperature
238+
&& ActivityManagerNative.isSystemReady()) {
234239
Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
235240
intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
236241
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -259,7 +264,7 @@ private void processValues() {
259264
} else {
260265
mPlugType = BATTERY_PLUGGED_NONE;
261266
}
262-
267+
263268
// Let the battery stats keep track of the current level.
264269
try {
265270
mBatteryStats.setBatteryState(mBatteryStatus, mBatteryHealth,
@@ -268,7 +273,7 @@ private void processValues() {
268273
} catch (RemoteException e) {
269274
// Should never happen.
270275
}
271-
276+
272277
shutdownIfNoPower();
273278
shutdownIfOverTemp();
274279

0 commit comments

Comments
 (0)