OSDN Git Service

Add temperature config for high temp warning.
authorAndrew Sapperstein <asapperstein@google.com>
Fri, 6 Jan 2017 00:45:37 +0000 (16:45 -0800)
committerAndrew Sapperstein <asapperstein@google.com>
Fri, 6 Jan 2017 00:45:37 +0000 (16:45 -0800)
Adds an integer resource (config_warningTemperature) that is used
to display the high temp warning. If it is set to less than 0,
the value from HardwarePropertiesManager#getDeviceTemperatures(
HardwarePropertiesManager.DEVICE_TEMPERATURE_SKIN,
HardwarePropertiesManager.TEMPERATURE_THROTTLING) is used instead.

Test: manual
Bug: 30995038
Change-Id: I05aa1b5930c6c151ebac439dfd5c00b3305dc46d

packages/SystemUI/res/values/config.xml
packages/SystemUI/src/com/android/systemui/power/PowerUI.java

index c025f93..50ef392 100644 (file)
 
     <bool name="quick_settings_show_full_alarm">false</bool>
 
+    <!-- Whether to show a warning notification when the device reaches a certain temperature. -->
     <bool name="config_showTemperatureWarning">false</bool>
 
+    <!-- Temp at which to show a warning notification if config_showTemperatureWarning is true.
+         If < 0, uses the value from HardwarePropertiesManager#getDeviceTemperatures. -->
+    <integer name="config_warningTemperature">-1</integer>
+
 </resources>
index d4bb994..8988801 100644 (file)
@@ -225,16 +225,20 @@ public class PowerUI extends SystemUI {
             return;
         }
 
-        // Get the throttling temperature. No need to check if we're not throttling.
-        float[] throttlingTemps = mHardwarePropertiesManager.getDeviceTemperatures(
-                HardwarePropertiesManager.DEVICE_TEMPERATURE_SKIN,
-                HardwarePropertiesManager.TEMPERATURE_THROTTLING);
-        if (throttlingTemps == null
-                || throttlingTemps.length == 0
-                || throttlingTemps[0] == HardwarePropertiesManager.UNDEFINED_TEMPERATURE) {
-            return;
+        mThrottlingTemp = mContext.getResources().getInteger(R.integer.config_warningTemperature);
+
+        if (mThrottlingTemp < 0f) {
+            // Get the throttling temperature. No need to check if we're not throttling.
+            float[] throttlingTemps = mHardwarePropertiesManager.getDeviceTemperatures(
+                    HardwarePropertiesManager.DEVICE_TEMPERATURE_SKIN,
+                    HardwarePropertiesManager.TEMPERATURE_THROTTLING);
+            if (throttlingTemps == null
+                    || throttlingTemps.length == 0
+                    || throttlingTemps[0] == HardwarePropertiesManager.UNDEFINED_TEMPERATURE) {
+                return;
+            }
+            mThrottlingTemp = throttlingTemps[0];
         }
-        mThrottlingTemp = throttlingTemps[0];
 
         // We have passed all of the checks, start checking the temp
         updateTemperatureWarning();