summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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();
}