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

Commit a778ee8b authored by Sean Stout's avatar Sean Stout
Browse files

Release display suspend blocker when shutting down DPC

This CL fixes an issue where it was possible for a suspend blocker to be
permanently held when shutting down a DPC.

A DPC usually releases the acquired suspend blocker either shorly after
acquiring it or posting a Runnable which clears the suspend blocker.

However in the case that a DPC has "unfinished business" this is not the
case and the suspend blocker will be released at an unknown future point
in time.

When shutting down a DPC, check for unfinished business and release the
suspend blocker if necessary.

Bug: 182086821
Change-Id: I7faa3bddd0c6ad9ac548c0778371405af70189f9
parent 71cf0b48
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -865,6 +865,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    private void cleanupHandlerThreadAfterStop() {
        setProximitySensorEnabled(false);
        mHandler.removeCallbacksAndMessages(null);
        if (mUnfinishedBusiness) {
            mCallbacks.releaseSuspendBlocker();
            mUnfinishedBusiness = false;
        }
        if (mPowerState != null) {
            mPowerState.stop();
            mPowerState = null;
@@ -1692,12 +1696,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        }
    }

    private final Runnable mCleanListener = new Runnable() {
        @Override
        public void run() {
            sendUpdatePowerState();
        }
    };
    private final Runnable mCleanListener = this::sendUpdatePowerState;

    private void setProximitySensorEnabled(boolean enable) {
        if (enable) {