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

Commit 517d7fb8 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Credential UI should not respond to background taps

The click listener already ignores taps when in non-biometric mode.
However, the view is still included in the accessibility hierarchy.
This change does the following when the UI transitions to credential mode:
  1) removes the click listener for "code correctness"
  2) removes the background view from accessibility hierarchy so that it
     cannot be focused/announced when talk back is enabled

Bug: 143564809

Test: atest AuthContainerViewTest
Test: manual test with talkback enabled
Change-Id: I36727599897a7cec1a99558c6fc2b61f311d1998
parent 2c551679
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ public class AuthContainerView extends LinearLayout
    @VisibleForTesting @Nullable AuthBiometricView mBiometricView;
    @VisibleForTesting @Nullable AuthCredentialView mCredentialView;

    private final ImageView mBackgroundView;
    @VisibleForTesting final ImageView mBackgroundView;
    @VisibleForTesting final ScrollView mBiometricScrollView;
    private final View mPanelView;

@@ -333,6 +333,12 @@ public class AuthContainerView extends LinearLayout
                throw new IllegalStateException("Unknown credential type: " + credentialType);
        }

        // The background is used for detecting taps / cancelling authentication. Since the
        // credential view is full-screen and should not be canceled from background taps,
        // disable it.
        mBackgroundView.setOnClickListener(null);
        mBackgroundView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);

        mCredentialView.setContainerView(this);
        mCredentialView.setEffectiveUserId(mEffectiveUserId);
        mCredentialView.setCredentialType(credentialType);
+14 −0
Original line number Diff line number Diff line
@@ -177,6 +177,20 @@ public class AuthContainerViewTest extends SysuiTestCase {
        assertEquals(Utils.CREDENTIAL_PATTERN, mAuthContainer.mCredentialView.mCredentialType);
    }

    @Test
    public void testCredentialUI_disablesClickingOnBackground() {
        // In the credential view, clicking on the background (to cancel authentication) is not
        // valid. Thus, the listener should be null, and it should not be in the accessibility
        // hierarchy.
        initializeContainer(Authenticators.DEVICE_CREDENTIAL);

        mAuthContainer.onAttachedToWindowInternal();

        verify(mAuthContainer.mBackgroundView).setOnClickListener(eq(null));
        verify(mAuthContainer.mBackgroundView).setImportantForAccessibility(
                eq(View.IMPORTANT_FOR_ACCESSIBILITY_NO));
    }

    @Test
    public void testLayoutParams_hasSecureWindowFlag() {
        final IBinder windowToken = mock(IBinder.class);