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

Commit aa448d02 authored by Andrew Zeng's avatar Andrew Zeng
Browse files

DO NOT MERGE Notify keyguard of when power button is pressed.

This is done on wear power button doesn't turn off the screen,
when the device wakes from keyguard UI isn't visible yet, so
it needs to react to power press in some way.

Bug: 35147955
Change-Id: I22619ea446770d09b53370e9244215646b60a9db
parent 92e6a1d9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -98,4 +98,10 @@ oneway interface IKeyguardService {
     * to start the keyguard dismiss sequence.
     */
    void onActivityDrawn();

    /**
     * Notifies the Keyguard that the power key was pressed while locked and launched Home rather
     * than putting the device to sleep or waking up.
     */
    void onShortPowerPressedGoHome();
}
+6 −0
Original line number Diff line number Diff line
@@ -202,6 +202,12 @@ public class KeyguardService extends Service {
            checkPermission();
            mKeyguardViewMediator.onActivityDrawn();
        }

        @Override
        public void onShortPowerPressedGoHome() {
            checkPermission();
            mKeyguardViewMediator.onShortPowerPressedGoHome();
        }
    };
}
+4 −0
Original line number Diff line number Diff line
@@ -1943,6 +1943,10 @@ public class KeyguardViewMediator extends SystemUI {
        mHandler.sendEmptyMessage(ON_ACTIVITY_DRAWN);
    }

    public void onShortPowerPressedGoHome() {
        // do nothing
    }

    public ViewMediatorCallback getViewMediatorCallback() {
        return mViewMediatorCallback;
    }
+11 −3
Original line number Diff line number Diff line
@@ -1301,20 +1301,28 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    launchHomeFromHotKey();
                    break;
                case SHORT_PRESS_POWER_GO_HOME:
                    launchHomeFromHotKey(true /* awakenFromDreams */, false /*respectKeyguard*/);
                    shortPressPowerGoHome();
                    break;
                case SHORT_PRESS_POWER_CLOSE_IME_OR_GO_HOME:
                    if (mWindowManagerFuncs.isInputMethodWindowVisible()) {
                        mWindowManagerFuncs.hideCurrentInputMethod();
                    } else {
                        launchHomeFromHotKey(true /* awakenFromDreams */,
                            false /*respectKeyguard*/);
                        shortPressPowerGoHome();
                    }
                    break;
            }
        }
    }

    private void shortPressPowerGoHome() {
        launchHomeFromHotKey(true /* awakenFromDreams */, false /*respectKeyguard*/);
        if (isKeyguardShowingAndNotOccluded()) {
            // Notify keyguard so it can do any special handling for the power button since the
            // device will not power off and only launch home.
            mKeyguardDelegate.onShortPowerPressedGoHome();
        }
    }

    private void powerMultiPressAction(long eventTime, boolean interactive, int behavior) {
        switch (behavior) {
            case MULTI_PRESS_POWER_NOTHING:
+6 −0
Original line number Diff line number Diff line
@@ -427,6 +427,12 @@ public class KeyguardServiceDelegate {
        }
    }

    public void onShortPowerPressedGoHome() {
        if (mKeyguardService != null) {
            mKeyguardService.onShortPowerPressedGoHome();
        }
    }

    public void dump(String prefix, PrintWriter pw) {
        pw.println(prefix + TAG);
        prefix += "  ";
Loading