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

Commit 95e89cae authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Fix jank when pin/pattern is shown

- Only update layout params of status bar window when needed
- Do not update security method all the time, only when needed (only
  when reset gets called)
- Check for actual used security method when updating states for
  bouncer

Bug: 18505838
Change-Id: Ib3d0021c0cc364fa5598e06e0a2bae059ae79cbe
parent 803a6dc0
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -399,8 +399,6 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
                    showPrimarySecurityScreen(false);
                    break;
            }
        } else {
            showPrimarySecurityScreen(false);
        }
        if (finish) {
            mSecurityCallback.finish();
@@ -556,6 +554,10 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
        return mSecurityModel.getSecurityMode();
    }

    public SecurityMode getCurrentSecurityMode() {
        return mCurrentSecuritySelection;
    }

    public void verifyUnlock() {
        mIsVerifyUnlockOnly = true;
        showSecurityScreen(getSecurityMode());
+5 −2
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa
    /**
     * Called when the view needs to be shown.
     */
    public void show() {
    public void showPrimarySecurityScreen() {
        if (DEBUG) Log.d(TAG, "show()");
        mSecurityContainer.showPrimarySecurityScreen(false);
    }
@@ -224,7 +224,6 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa
     */
    public void onResume() {
        if (DEBUG) Log.d(TAG, "screen on, instance " + Integer.toHexString(hashCode()));
        mSecurityContainer.showPrimarySecurityScreen(false);
        mSecurityContainer.onResume(KeyguardSecurityView.SCREEN_ON);
        requestFocus();
    }
@@ -473,6 +472,10 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa
        return mSecurityContainer.getSecurityMode();
    }

    public SecurityMode getCurrentSecurityMode() {
        return mSecurityContainer.getCurrentSecurityMode();
    }

    protected abstract void onUserSwitching(boolean switching);

    protected abstract void onCreateOptions(Bundle options);
+1 −0
Original line number Diff line number Diff line
@@ -957,6 +957,7 @@ public class KeyguardViewMediator extends SystemUI {
        // if the keyguard is already showing, don't bother
        if (mStatusBarKeyguardViewManager.isShowing()) {
            if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing");
            resetStateLocked();
            return;
        }

+27 −11
Original line number Diff line number Diff line
@@ -57,13 +57,14 @@ public class KeyguardBouncer {
        mWindowManager = windowManager;
    }

    public void show() {
    public void show(boolean resetSecuritySelection) {
        ensureView();
        if (resetSecuritySelection) {
            // showPrimarySecurityScreen() updates the current security method. This is needed in
            // case we are already showing and the current security method changed.
            mKeyguardView.showPrimarySecurityScreen();
        }
        if (mRoot.getVisibility() == View.VISIBLE || mShowingSoon) {

            // show() updates the current security method. This is needed in case we are already
            // showing and the current security method changed.
            mKeyguardView.show();
            return;
        }

@@ -74,7 +75,7 @@ public class KeyguardBouncer {

            // Split up the work over multiple frames.
            mChoreographer.postCallbackDelayed(Choreographer.CALLBACK_ANIMATION, mShowRunnable,
                    null, 48);
                    null, 16);
        }
    }

@@ -96,7 +97,7 @@ public class KeyguardBouncer {
    public void showWithDismissAction(OnDismissAction r) {
        ensureView();
        mKeyguardView.setOnDismissAction(r);
        show();
        show(false /* resetSecuritySelection */);
    }

    public void hide(boolean destroyView) {
@@ -152,7 +153,11 @@ public class KeyguardBouncer {
    }

    public void prepare() {
        boolean wasInitialized = mRoot != null;
        ensureView();
        if (wasInitialized) {
            mKeyguardView.showPrimarySecurityScreen();
        }
    }

    private void ensureView() {
@@ -184,14 +189,25 @@ public class KeyguardBouncer {
    }

    /**
     * @return True if and only if the current security method should be shown before showing
     *         the notifications on Keyguard, like SIM PIN/PUK.
     * @return True if and only if the security method should be shown before showing the
     * notifications on Keyguard, like SIM PIN/PUK.
     */
    public boolean needsFullscreenBouncer() {
        if (mKeyguardView != null) {
            SecurityMode mode = mKeyguardView.getSecurityMode();
            return mode == SecurityMode.SimPin
                    || mode == SecurityMode.SimPuk;
            return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
        }
        return false;
    }

    /**
     * Like {@link #needsFullscreenBouncer}, but uses the currently visible security method, which
     * makes this method much faster.
     */
    public boolean isFullscreenBouncer() {
        if (mKeyguardView != null) {
            SecurityMode mode = mKeyguardView.getCurrentSecurityMode();
            return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
        }
        return false;
    }
+4 −4
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ public class StatusBarKeyguardViewManager {

            // The keyguard might be showing (already). So we need to hide it.
            mPhoneStatusBar.hideKeyguard();
            mBouncer.show();
            mBouncer.show(true /* resetSecuritySelection */);
        } else {
            mPhoneStatusBar.showKeyguard();
            mBouncer.hide(false /* destroyView */);
@@ -120,7 +120,7 @@ public class StatusBarKeyguardViewManager {

    private void showBouncer() {
        if (mShowing) {
            mBouncer.show();
            mBouncer.show(false /* resetSecuritySelection */);
        }
        updateStates();
    }
@@ -130,7 +130,7 @@ public class StatusBarKeyguardViewManager {
            if (!afterKeyguardGone) {
                mBouncer.showWithDismissAction(r);
            } else {
                mBouncer.show();
                mBouncer.show(false /* resetSecuritySelection */);
                mAfterKeyguardGoneAction = r;
            }
        }
@@ -354,7 +354,7 @@ public class StatusBarKeyguardViewManager {
        boolean showing = mShowing;
        boolean occluded = mOccluded;
        boolean bouncerShowing = mBouncer.isShowing();
        boolean bouncerDismissible = !mBouncer.needsFullscreenBouncer();
        boolean bouncerDismissible = !mBouncer.isFullscreenBouncer();

        if ((bouncerDismissible || !showing) != (mLastBouncerDismissible || !mLastShowing)
                || mFirstUpdate) {
Loading