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

Commit 20d4c6a6 authored by Aaron Liu's avatar Aaron Liu
Browse files

Destroy and reinflate bouncer before showing

Due to various bugs and settingns changes, it makes sense to entirely
refresh the bouncer view before showing. This should significantly
reduce the number of incoming bugs where bouncer is not showing or is
not responding to settings changes.

**Ensure that password view shows by ensuring that mDisappearAnimation running is set back to false.

Fixes: 260958175
Fixes: 266840428
Fixes: 268226007
Fixes: 267363062
Test: open sim pin, sim puk, password, pattern, pin.
Test: change pattern visible to see changes reflected on screen.
Test: change show password characters to see changes reflected on
screen.

Change-Id: Ib2b0ab829eb2eaff6de0dea1268fd934f30e645f
parent c573766a
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -206,6 +206,13 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
        mKeyguardSecurityContainerController.reset();
    }

    /**
     * Reinflate the view flipper child view.
     */
    public void reinflateViewFlipper() {
        mKeyguardSecurityContainerController.reinflateViewFlipper();
    }

    /**
     * Dismisses the keyguard by going to the next screen or making it gone.
     * @param targetUserId a user that needs to be the foreground user at the dismissal completion.
@@ -232,12 +239,9 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
    /**
     * Starts the animation when the Keyguard gets shown.
     */
    public void appear(int statusBarHeight) {
    public void appear() {
        // We might still be collapsed and the view didn't have time to layout yet or still
        // be small, let's wait on the predraw to do the animation in that case.
        if (mView.getHeight() != 0 && mView.getHeight() != statusBarHeight) {
            mKeyguardSecurityContainerController.startAppearAnimation();
        } else {
        mView.getViewTreeObserver().addOnPreDrawListener(
                new ViewTreeObserver.OnPreDrawListener() {
                    @Override
@@ -249,7 +253,6 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
                });
        mView.requestLayout();
    }
    }

    /**
     * Show a string explaining why the security view needs to be solved.
+6 −3
Original line number Diff line number Diff line
@@ -743,17 +743,20 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
    }

    private void reloadColors() {
        resetViewFlipper();
        reinflateViewFlipper();
        mView.reloadColors();
    }

    /** Handles density or font scale changes. */
    private void onDensityOrFontScaleChanged() {
        resetViewFlipper();
        reinflateViewFlipper();
        mView.onDensityOrFontScaleChanged();
    }

    private void resetViewFlipper() {
    /**
     * Reinflate the view flipper child view.
     */
    public void reinflateViewFlipper() {
        mSecurityViewFlipperController.clearViews();
        mSecurityViewFlipperController.getSecurityView(mCurrentSecurityMode,
                mKeyguardSecurityCallback);
+3 −13
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.view.ViewGroup
import android.window.OnBackAnimationCallback
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.internal.policy.SystemBarUtils
import com.android.keyguard.KeyguardHostViewController
import com.android.keyguard.KeyguardSecurityModel
import com.android.keyguard.KeyguardUpdateMonitor
@@ -98,14 +97,14 @@ object KeyguardBouncerViewBinder {
                    viewModel.setBouncerViewDelegate(delegate)
                    launch {
                        viewModel.show.collect {
                            // Reset Security Container entirely.
                            hostViewController.reinflateViewFlipper()
                            hostViewController.showPromptReason(it.promptReason)
                            it.errorMessage?.let { errorMessage ->
                                hostViewController.showErrorMessage(errorMessage)
                            }
                            hostViewController.showPrimarySecurityScreen()
                            hostViewController.appear(
                                SystemBarUtils.getStatusBarHeight(view.context)
                            )
                            hostViewController.appear()
                            hostViewController.onResume()
                        }
                    }
@@ -159,15 +158,6 @@ object KeyguardBouncerViewBinder {
                        }
                    }

                    launch {
                        viewModel.isBouncerVisible
                            .filter { !it }
                            .collect {
                                // Remove existing input for security reasons.
                                hostViewController.resetSecurityContainer()
                            }
                    }

                    launch {
                        viewModel.keyguardPosition.collect { position ->
                            hostViewController.updateKeyguardPosition(position)
+8 −0
Original line number Diff line number Diff line
@@ -600,6 +600,14 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
                any(KeyguardSecurityCallback.class));
    }

    @Test
    public void testReinflateViewFlipper() {
        mKeyguardSecurityContainerController.reinflateViewFlipper();
        verify(mKeyguardSecurityViewFlipperController).clearViews();
        verify(mKeyguardSecurityViewFlipperController).getSecurityView(any(SecurityMode.class),
                any(KeyguardSecurityCallback.class));
    }

    private KeyguardSecurityContainer.SwipeListener getRegisteredSwipeListener() {
        mKeyguardSecurityContainerController.onViewAttached();
        verify(mView).setSwipeListener(mSwipeListenerArgumentCaptor.capture());