summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wei Wang <wvw@google.com> 2018-11-26 14:35:17 -0800
committer Wei Wang <wvw@google.com> 2018-11-27 16:44:49 +0000
commitfeb9de64f1c91a07a063a847bcb07c33e902a059 (patch)
tree990bdd047621abf535cb1e8fafb184e6c9f5b0c9
parent82fec85ccb5b8257acef34e2fdb4ddc3020af357 (diff)
PowerUI: poll thermal sensor in handler
Fixes: 120037422 Bug: 116866524 Test: adb logcat |grep SystemUIBootTiming Change-Id: I2b76aa43bb093a884080809ef0f984de65ce4729
-rw-r--r--packages/SystemUI/src/com/android/systemui/power/PowerUI.java15
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java5
2 files changed, 9 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
index 5d33ffdb30af..f0543454073d 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
@@ -411,13 +411,8 @@ public class PowerUI extends SystemUI {
setNextLogTime();
- // This initialization method may be called on a configuration change. Only one set of
- // ongoing callbacks should be occurring, so remove any now. updateTemperatureWarning will
- // schedule an ongoing callback.
- mHandler.removeCallbacks(mUpdateTempCallback);
-
// We have passed all of the checks, start checking the temp
- updateTemperatureWarning();
+ mHandler.post(mUpdateTempCallback);
}
private void showThermalShutdownDialog() {
@@ -448,6 +443,8 @@ public class PowerUI extends SystemUI {
logTemperatureStats();
+ // Remove any pending callbacks as we only want to enable one
+ mHandler.removeCallbacks(mUpdateTempCallback);
mHandler.postDelayed(mUpdateTempCallback, TEMPERATURE_INTERVAL);
}
@@ -553,11 +550,7 @@ public class PowerUI extends SystemUI {
// Thermal event received from vendor thermal management subsystem
private final class ThermalEventListener extends IThermalEventListener.Stub {
@Override public void notifyThrottling(Temperature temp) {
- // Trigger an update of the temperature warning. Only one
- // callback can be enabled at a time, so remove any existing
- // callback; updateTemperatureWarning will schedule another one.
- mHandler.removeCallbacks(mUpdateTempCallback);
- updateTemperatureWarning();
+ mHandler.post(mUpdateTempCallback);
}
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java
index 221cbe9427ba..c28e74e7c6a1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java
@@ -37,6 +37,7 @@ import android.os.PowerManager;
import android.provider.Settings;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.testing.TestableResources;
@@ -127,6 +128,8 @@ public class PowerUITest extends SysuiTestCase {
resources.addOverride(R.integer.config_warningTemperature, 55);
mPowerUI.start();
+ // Guarantees mHandler has processed all messages.
+ TestableLooper.get(this).processAllMessages();
verify(mMockWarnings).showHighTemperatureWarning();
}
@@ -139,6 +142,8 @@ public class PowerUITest extends SysuiTestCase {
resources.addOverride(R.integer.config_warningTemperature, 55);
mPowerUI.start();
+ // Guarantees mHandler has processed all messages.
+ TestableLooper.get(this).processAllMessages();
verify(mMockWarnings).showHighTemperatureWarning();
}