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

Commit 8d786931 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

The big keyguard transition refactor (6/n)

Cleanup:
- Make sure all the state is nicely dumped.
- Remove some unused stuff.
- Fix a flicker when occluded -> unlocked

Bug: 32057734
Change-Id: Id87e26adccef740d608b325c2dc1f6db14dd4ec3
parent ab7ad389
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ oneway interface IKeyguardService {

    void addStateMonitorCallback(IKeyguardStateCallback callback);
    void verifyUnlock(IKeyguardExitCallback callback);
    void keyguardDone(boolean authenticated, boolean wakeup);
    void dismiss(boolean allowWhileOccluded);
    void onDreamingStarted();
    void onDreamingStopped();
@@ -93,10 +92,4 @@ oneway interface IKeyguardService {
     * @param fadeoutDuration the duration of the exit animation, in milliseconds
     */
    void startKeyguardExitAnimation(long startTime, long fadeoutDuration);

    /**
     * Notifies the Keyguard that the activity that was starting has now been drawn and it's safe
     * to start the keyguard dismiss sequence.
     */
    void onActivityDrawn();
}
+0 −6
Original line number Diff line number Diff line
@@ -75,12 +75,6 @@ public interface ViewMediatorCallback {
     */
    void playTrustedSound();

    /**
     * @return true if and only if Keyguard is showing or if Keyguard is disabled by an external app
     *         (legacy API)
     */
    boolean isInputRestricted();

    /**
     * @return true if the screen is on
     */
+0 −15
Original line number Diff line number Diff line
@@ -80,15 +80,6 @@ public class KeyguardService extends Service {
            Trace.endSection();
        }

        @Override // Binder interface
        public void keyguardDone(boolean authenticated, boolean wakeup) {
            Trace.beginSection("KeyguardService.mBinder#keyguardDone");
            checkPermission();
            // TODO: Remove wakeup
            mKeyguardViewMediator.keyguardDone(authenticated);
            Trace.endSection();
        }

        @Override // Binder interface
        public void setOccluded(boolean isOccluded, boolean animate) {
            Trace.beginSection("KeyguardService.mBinder#setOccluded");
@@ -202,12 +193,6 @@ public class KeyguardService extends Service {
            mKeyguardViewMediator.startKeyguardExitAnimation(startTime, fadeoutDuration);
            Trace.endSection();
        }

        @Override
        public void onActivityDrawn() {
            checkPermission();
            mKeyguardViewMediator.onActivityDrawn();
        }
    };
}
+19 −58
Original line number Diff line number Diff line
@@ -135,7 +135,6 @@ public class KeyguardViewMediator extends SystemUI {

    private static final boolean DEBUG = KeyguardConstants.DEBUG;
    private static final boolean DEBUG_SIM_STATES = KeyguardConstants.DEBUG_SIM_STATES;
    private final static boolean DBG_WAKE = false;

    private final static String TAG = "KeyguardViewMediator";

@@ -145,25 +144,23 @@ public class KeyguardViewMediator extends SystemUI {
            "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_LOCK";

    // used for handler messages
    private static final int SHOW = 2;
    private static final int HIDE = 3;
    private static final int RESET = 4;
    private static final int VERIFY_UNLOCK = 5;
    private static final int NOTIFY_FINISHED_GOING_TO_SLEEP = 6;
    private static final int NOTIFY_SCREEN_TURNING_ON = 7;
    private static final int KEYGUARD_DONE = 9;
    private static final int KEYGUARD_DONE_DRAWING = 10;
    private static final int KEYGUARD_DONE_AUTHENTICATING = 11;
    private static final int SET_OCCLUDED = 12;
    private static final int KEYGUARD_TIMEOUT = 13;
    private static final int DISMISS = 17;
    private static final int START_KEYGUARD_EXIT_ANIM = 18;
    private static final int ON_ACTIVITY_DRAWN = 19;
    private static final int KEYGUARD_DONE_PENDING_TIMEOUT = 20;
    private static final int NOTIFY_STARTED_WAKING_UP = 21;
    private static final int NOTIFY_SCREEN_TURNED_ON = 22;
    private static final int NOTIFY_SCREEN_TURNED_OFF = 23;
    private static final int NOTIFY_STARTED_GOING_TO_SLEEP = 24;
    private static final int SHOW = 1;
    private static final int HIDE = 2;
    private static final int RESET = 3;
    private static final int VERIFY_UNLOCK = 4;
    private static final int NOTIFY_FINISHED_GOING_TO_SLEEP = 5;
    private static final int NOTIFY_SCREEN_TURNING_ON = 6;
    private static final int KEYGUARD_DONE = 7;
    private static final int KEYGUARD_DONE_DRAWING = 8;
    private static final int SET_OCCLUDED = 9;
    private static final int KEYGUARD_TIMEOUT = 10;
    private static final int DISMISS = 11;
    private static final int START_KEYGUARD_EXIT_ANIM = 12;
    private static final int KEYGUARD_DONE_PENDING_TIMEOUT = 13;
    private static final int NOTIFY_STARTED_WAKING_UP = 14;
    private static final int NOTIFY_SCREEN_TURNED_ON = 15;
    private static final int NOTIFY_SCREEN_TURNED_OFF = 16;
    private static final int NOTIFY_STARTED_GOING_TO_SLEEP = 17;

    /**
     * The default amount of time we stay awake (used for all key input)
@@ -184,11 +181,6 @@ public class KeyguardViewMediator extends SystemUI {
     */
    private static final int KEYGUARD_DONE_DRAWING_TIMEOUT_MS = 2000;

    /**
     * Secure setting whether analytics are collected on the keyguard.
     */
    private static final String KEYGUARD_ANALYTICS_SETTING = "keyguard_analytics";

    /**
     * Boolean option for doKeyguardLocked/doKeyguardTimeout which, when set to true, forces the
     * keyguard to show even if it is disabled for the current user.
@@ -209,16 +201,9 @@ public class KeyguardViewMediator extends SystemUI {
    /** High level access to the power manager for WakeLocks */
    private PowerManager mPM;

    /** High level access to the window manager for dismissing keyguard animation */
    private IWindowManager mWM;


    /** TrustManager for letting it know when we change visibility */
    private TrustManager mTrustManager;

    /** SearchManager for determining whether or not search assistant is available */
    private SearchManager mSearchManager;

    /**
     * Used to keep the device awake while to ensure the keyguard finishes opening before
     * we sleep.
@@ -342,8 +327,6 @@ public class KeyguardViewMediator extends SystemUI {
    private boolean mWakeAndUnlocking;
    private IKeyguardDrawnCallback mDrawnCallback;

    private boolean mIsPerUserLock;

    KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {

        @Override
@@ -533,7 +516,7 @@ public class KeyguardViewMediator extends SystemUI {
            }

            if (!mKeyguardDonePending) {
                KeyguardViewMediator.this.keyguardDone(true /* authenticated */);
                KeyguardViewMediator.this.handleKeyguardDone(true /* authenticated */);
            }
            if (strongAuth) {
                mUpdateMonitor.reportSuccessfulStrongAuthUnlockAttempt();
@@ -584,7 +567,7 @@ public class KeyguardViewMediator extends SystemUI {
            if (mKeyguardDonePending) {
                // Somebody has called keyguardDonePending before, which means that we are
                // authenticated
                KeyguardViewMediator.this.keyguardDone(true /* authenticated */);
                KeyguardViewMediator.this.handleKeyguardDone(true /* authenticated */);
            }
            Trace.endSection();
        }
@@ -599,11 +582,6 @@ public class KeyguardViewMediator extends SystemUI {
            KeyguardViewMediator.this.playTrustedSound();
        }

        @Override
        public boolean isInputRestricted() {
            return KeyguardViewMediator.this.isInputRestricted();
        }

        @Override
        public boolean isScreenOn() {
            return mDeviceInteractive;
@@ -645,7 +623,6 @@ public class KeyguardViewMediator extends SystemUI {

    private void setupLocked() {
        mPM = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mWM = WindowManagerGlobal.getWindowManagerService();
        mTrustManager = (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE);

        mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
@@ -720,14 +697,12 @@ public class KeyguardViewMediator extends SystemUI {
     * Let us know that the system is ready after startup.
     */
    public void onSystemReady() {
        mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
        synchronized (this) {
            if (DEBUG) Log.d(TAG, "onSystemReady");
            mSystemReady = true;
            doKeyguardLocked(null);
            mUpdateMonitor.registerCallback(mUpdateCallback);
        }
        mIsPerUserLock = StorageManager.isFileEncryptedNativeOrEmulated();
        // Most services aren't available until the system reaches the ready state, so we
        // send it here when the device first boots.
        maybeSendUserPresentBroadcast();
@@ -1513,9 +1488,6 @@ public class KeyguardViewMediator extends SystemUI {
                    Trace.beginSection("KeyguardViewMediator#handleMessage KEYGUARD_DONE_PENDING_TIMEOUT");
                    Log.w(TAG, "Timeout while waiting for activity drawn!");
                    Trace.endSection();
                    // Fall through.
                case ON_ACTIVITY_DRAWN:
                    handleOnActivityDrawn();
                    break;
            }
        }
@@ -1743,13 +1715,6 @@ public class KeyguardViewMediator extends SystemUI {
        Trace.endSection();
    }

    private void handleOnActivityDrawn() {
        if (DEBUG) Log.d(TAG, "handleOnActivityDrawn: mKeyguardDonePending=" + mKeyguardDonePending);
        if (mKeyguardDonePending) {
            mStatusBarKeyguardViewManager.onActivityDrawn();
        }
    }

    private void handleStartKeyguardExitAnimation(long startTime, long fadeoutDuration) {
        Trace.beginSection("KeyguardViewMediator#handleStartKeyguardExitAnimation");
        if (DEBUG) Log.d(TAG, "handleStartKeyguardExitAnimation startTime=" + startTime
@@ -1960,10 +1925,6 @@ public class KeyguardViewMediator extends SystemUI {
        Trace.endSection();
    }

    public void onActivityDrawn() {
        mHandler.sendEmptyMessage(ON_ACTIVITY_DRAWN);
    }

    public ViewMediatorCallback getViewMediatorCallback() {
        return mViewMediatorCallback;
    }
+0 −17
Original line number Diff line number Diff line
@@ -559,19 +559,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        return mBouncer.interceptMediaKey(event);
    }

    public void onActivityDrawn() {
        if (mPhoneStatusBar.isCollapsing()) {
            mPhoneStatusBar.addPostCollapseAction(new Runnable() {
                @Override
                public void run() {
                    mViewMediatorCallback.readyForKeyguardDone();
                }
            });
        } else {
            mViewMediatorCallback.readyForKeyguardDone();
        }
    }

    public void readyForKeyguardDone() {
        mViewMediatorCallback.readyForKeyguardDone();
    }
@@ -588,10 +575,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        return mBouncer.isSecure() || mLockPatternUtils.isSecure(userId);
    }

    public boolean isInputRestricted() {
        return mViewMediatorCallback.isInputRestricted();
    }

    public void keyguardGoingAway() {
        mPhoneStatusBar.keyguardGoingAway();
    }
Loading