Make battery shutdown temperature configurable

Bug 7079455

Change-Id: I448f21231bf0548ef975f99482576acb24a1a70e
diff --git a/services/java/com/android/server/BatteryService.java b/services/java/com/android/server/BatteryService.java
index f0989e7..fe8529b 100644
--- a/services/java/com/android/server/BatteryService.java
+++ b/services/java/com/android/server/BatteryService.java
@@ -116,6 +116,7 @@
 
     private int mLowBatteryWarningLevel;
     private int mLowBatteryCloseWarningLevel;
+    private int mShutdownBatteryTemperature;
 
     private int mPlugType;
     private int mLastPlugType = -1; // Extra state so we can detect first run
@@ -138,6 +139,8 @@
                 com.android.internal.R.integer.config_lowBatteryWarningLevel);
         mLowBatteryCloseWarningLevel = mContext.getResources().getInteger(
                 com.android.internal.R.integer.config_lowBatteryCloseWarningLevel);
+        mShutdownBatteryTemperature = mContext.getResources().getInteger(
+                com.android.internal.R.integer.config_shutdownBatteryTemperature);
 
         mPowerSupplyObserver.startObserving("SUBSYSTEM=power_supply");
 
@@ -228,9 +231,11 @@
     }
 
     private final void shutdownIfOverTemp() {
-        // shut down gracefully if temperature is too high (> 68.0C)
-        // wait until the system has booted before attempting to display the shutdown dialog.
-        if (mBatteryTemperature > 680 && ActivityManagerNative.isSystemReady()) {
+        // shut down gracefully if temperature is too high (> 68.0C by default)
+        // wait until the system has booted before attempting to display the
+        // shutdown dialog.
+        if (mBatteryTemperature > mShutdownBatteryTemperature
+                && ActivityManagerNative.isSystemReady()) {
             Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
             intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
             intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -259,7 +264,7 @@
         } else {
             mPlugType = BATTERY_PLUGGED_NONE;
         }
-        
+
         // Let the battery stats keep track of the current level.
         try {
             mBatteryStats.setBatteryState(mBatteryStatus, mBatteryHealth,
@@ -268,7 +273,7 @@
         } catch (RemoteException e) {
             // Should never happen.
         }
-        
+
         shutdownIfNoPower();
         shutdownIfOverTemp();