Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit feb9de64 authored by Wei Wang's avatar Wei Wang
Browse files

PowerUI: poll thermal sensor in handler

Fixes: 120037422
Bug: 116866524
Test: adb logcat |grep SystemUIBootTiming
Change-Id: I2b76aa43bb093a884080809ef0f984de65ce4729
parent 82fec85c
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -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);
        }
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -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();
    }