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

Commit e51cf7ae authored by Jim Miller's avatar Jim Miller
Browse files

Simplify wake management code in keyguard.

Removes onWakeKey/Motion handling from keyguard since it's no longer used.
The legacy code was originally intended to have keyguard filter wake events
which is now done in PhoneWindowManager. Ultimately it just needs to call
PowerManager.wakeUp() since keyguard no longer filters these keys.

Change-Id: I5b8ef9b422abf850a85b57f21944e5eb09fbedc2
parent 5729b81a
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -30,8 +30,6 @@ interface IKeyguardService {
    oneway void keyguardDone(boolean authenticated, boolean wakeup);
    oneway void setHidden(boolean isHidden);
    oneway void dismiss();
    oneway void onWakeKeyWhenKeyguardShowing(int keyCode);
    oneway void onWakeMotionWhenKeyguardShowing();
    oneway void onDreamingStarted();
    oneway void onDreamingStopped();
    oneway void onScreenTurnedOff(int reason);
+2 −41
Original line number Diff line number Diff line
@@ -119,6 +119,8 @@ public class KeyguardHostView extends KeyguardViewBase {

    protected int mClientGeneration;

    protected boolean mShowSecurityWhenReturn;

    /*package*/ interface UserSwitcherCallback {
        void hideSecurityView(int duration);
        void showSecurityView();
@@ -872,14 +874,6 @@ public class KeyguardHostView extends KeyguardViewBase {
        }
    };

    protected boolean mShowSecurityWhenReturn;

    @Override
    public void reset() {
        mIsVerifyUnlockOnly = false;
        mAppWidgetContainer.setCurrentPage(getWidgetPosition(R.id.keyguard_status_view));
    }

    /**
     * Sets an action to perform when keyguard is dismissed.
     * @param action
@@ -1029,39 +1023,6 @@ public class KeyguardHostView extends KeyguardViewBase {
        showPrimarySecurityScreen(false);
    }

    private boolean isSecure() {
        SecurityMode mode = mSecurityModel.getSecurityMode();
        switch (mode) {
            case Pattern:
                return mLockPatternUtils.isLockPatternEnabled();
            case Password:
            case PIN:
                return mLockPatternUtils.isLockPasswordEnabled();
            case SimPin:
            case SimPuk:
            case Account:
                return true;
            case None:
                return false;
            default:
                throw new IllegalStateException("Unknown security mode " + mode);
        }
    }

    @Override
    public void wakeWhenReadyTq(int keyCode) {
        if (DEBUG) Log.d(TAG, "onWakeKey");
        if (keyCode == KeyEvent.KEYCODE_MENU && isSecure()) {
            if (DEBUG) Log.d(TAG, "switching screens to unlock screen because wake key was MENU");
            showSecurityScreen(SecurityMode.None);
        } else {
            if (DEBUG) Log.d(TAG, "poking wake lock immediately");
        }
        if (mViewMediatorCallback != null) {
            mViewMediatorCallback.wakeUp();
        }
    }

    @Override
    public void verifyUnlock() {
        SecurityMode securityMode = mSecurityModel.getSecurityMode();
+0 −8
Original line number Diff line number Diff line
@@ -93,14 +93,6 @@ public class KeyguardService extends Service {
        public void dismiss() {
            mKeyguardViewMediator.dismiss();
        }
        public void onWakeKeyWhenKeyguardShowing(int keyCode) {
            checkPermission();
            mKeyguardViewMediator.onWakeKeyWhenKeyguardShowing(keyCode);
        }
        public void onWakeMotionWhenKeyguardShowing() {
            checkPermission();
            mKeyguardViewMediator.onWakeMotionWhenKeyguardShowing();
        }
        public void onDreamingStarted() {
            checkPermission();
            mKeyguardViewMediator.onDreamingStarted();
+0 −20
Original line number Diff line number Diff line
@@ -89,11 +89,6 @@ public abstract class KeyguardViewBase extends FrameLayout {
        setBackground(mBackgroundDrawable);
    }

    /**
     * Called when you need to reset the state of your view.
     */
    abstract public void reset();

    /**
     * Called when the screen turned off.
     */
@@ -109,21 +104,6 @@ public abstract class KeyguardViewBase extends FrameLayout {
     */
    abstract public void show();

    /**
     * Called when a key has woken the device to give us a chance to adjust our
     * state according the the key.  We are responsible for waking the device
     * (by poking the wake lock) once we are ready.
     *
     * The 'Tq' suffix is per the documentation in {@link android.view.WindowManagerPolicy}.
     * Be sure not to take any action that takes a long time; any significant
     * action should be posted to a handler.
     *
     * @param keyCode The wake key, which may be relevant for configuring the
     *   keyguard.  May be {@link KeyEvent#KEYCODE_UNKNOWN} if waking for a reason
     *   other than a key press.
     */
    abstract public void wakeWhenReadyTq(int keyCode);

    /**
     * Verify that the user can get past the keyguard securely.  This is called,
     * for example, when the phone disables the keyguard but then wants to launch
+0 −21
Original line number Diff line number Diff line
@@ -383,27 +383,6 @@ public class KeyguardViewManager {
        mKeyguardView.verifyUnlock();
    }

    /**
     * A key has woken the device.  We use this to potentially adjust the state
     * of the lock screen based on the key.
     *
     * The 'Tq' suffix is per the documentation in {@link android.view.WindowManagerPolicy}.
     * Be sure not to take any action that takes a long time; any significant
     * action should be posted to a handler.
     *
     * @param keyCode The wake key.  May be {@link KeyEvent#KEYCODE_UNKNOWN} if waking
     * for a reason other than a key press.
     */
    public boolean wakeWhenReadyTq(int keyCode) {
        if (DEBUG) Log.d(TAG, "wakeWhenReady(" + keyCode + ")");
        if (mKeyguardView != null) {
            mKeyguardView.wakeWhenReadyTq(keyCode);
            return true;
        }
        Log.w(TAG, "mKeyguardView is null in wakeWhenReadyTq");
        return false;
    }

    /**
     * Hides the keyguard view
     */
Loading