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

Unverified Commit d2339e1e authored by ezio84's avatar ezio84 Committed by Michael Bestas
Browse files

PhoneWindowManager: Allow torch and track skip during ambient display



This allows long press power button for torch and long press
volume buttons for track skip to work during ambient display.

Co-authored-by: default avatarrazorloves <razorloves@gmail.com>
Co-authored-by: default avatarSam Mortimer <sam@mortimer.me.uk>
Change-Id: I2463579e056364652b549524bc9775da4fa35b1f
parent c160ce02
Loading
Loading
Loading
Loading
+25 −10
Original line number Diff line number Diff line
@@ -1188,7 +1188,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                // Abort possibly stuck animations only when power key up without long press case.
                mHandler.post(mWindowManagerFuncs::triggerAnimationFailsafe);
                // See if we deferred screen wake because long press power for torch is enabled
                if (mResolvedLongPressOnPowerBehavior == LONG_PRESS_POWER_TORCH && !isScreenOn()) {
                if (mResolvedLongPressOnPowerBehavior == LONG_PRESS_POWER_TORCH &&
                        (!isScreenOn() || isDozeMode())) {
                    wakeUpFromWakeKey(event);
                }
            }
@@ -1695,11 +1696,24 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return mAssistUtils.getAssistComponentForUser(mCurrentUserId) != null;
    }

    private boolean isDozeMode() {
        IDreamManager dreamManager = getDreamManager();

        try {
            if (dreamManager != null && dreamManager.isDreaming()) {
                return true;
            }
        } catch (RemoteException e) {
            Slog.e(TAG, "RemoteException when checking if dreaming", e);
        }
        return false;
    }

    private int getResolvedLongPressOnPowerBehavior() {
        if (FactoryTest.isLongPressOnPowerOffEnabled()) {
            return LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;
        }
        if (mTorchLongPressPowerEnabled && (!isScreenOn() || mTorchEnabled)) {
        if (mTorchLongPressPowerEnabled && (!isScreenOn() || isDozeMode() || mTorchEnabled)) {
            return LONG_PRESS_POWER_TORCH;
        }

@@ -6069,6 +6083,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            return false;
        }

        final boolean isDozing = isDozeMode();

        if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP)
                && isDozing) {
            return false;
        }

        // Send events to keyguard while the screen is on and it's showing.
        if (isKeyguardShowingAndNotOccluded()) {
            return true;
@@ -6078,15 +6099,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (isDefaultDisplay) {
            // Send events to a dozing dream since the dream is in control of the state of the
            // screen.
            IDreamManager dreamManager = getDreamManager();

            try {
                if (dreamManager != null && dreamManager.isDreaming()) {
            if (isDozing) {
                return true;
            }
            } catch (RemoteException e) {
                Slog.e(TAG, "RemoteException when checking if dreaming", e);
            }
        }

        // Otherwise, consume events since the user can't see what is being