From 1cac83218c95d5bb3a17275272cc5d15c7fe4a3b Mon Sep 17 00:00:00 2001 From: Andrew Sapperstein Date: Thu, 5 Jan 2017 16:45:37 -0800 Subject: [PATCH] Add temperature config for high temp warning. 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 (cherry picked from commit 7518471ab69a23130b8cc6852e1b3d58809c97b2) --- packages/SystemUI/res/values/config.xml | 5 +++++ .../com/android/systemui/power/PowerUI.java | 22 +++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index cf20c273fc1e0..b89ce47ded02c 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -284,6 +284,11 @@ false + false + + -1 + diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java index bdb22951a9b2d..d9b4cab31f8ae 100644 --- a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java +++ b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java @@ -224,16 +224,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();