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

Commit ff168dc4 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

12/n: Add LockPatternView for setDeviceCredentialAllowed(true)

Includes lock icon, title, subtitle, description, lock pattern view.
Corner radius and padding animates nicely from !=0 --> 0.

Support for password/pin will come in a subsequent CL.
Unit tests for AuthCredentialView will be added when
password/pin are implemented.

Support for persisting across configuration changes
and landscape view will also be added in a subsequent
change.

Test: BiometricPromptDemo with the following:
      1) Confirm pattern, callback received
      2) Rejected, error string shown
      3) Lockout (5 attempts), countdown string shown,
         pattern view disabled until countdown is over
      4) Cancel pattern auth, callback received
Test: atest BiometricServiceTest
Test: atest com.android.systemui.biometrics

Change-Id: Idc01e33be0074a6c8a43f60b172a4391bfbe5e8a
parent 396a8412
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
    /**
     * @hide
     */
    public static final int DISMISSED_REASON_CONFIRMED = 1;
    public static final int DISMISSED_REASON_BIOMETRIC_CONFIRMED = 1;

    /**
     * Dialog is done animating away after user clicked on the button set via
@@ -114,7 +114,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
     * Authenticated, confirmation not required. Dialog animated away.
     * @hide
     */
    public static final int DISMISSED_REASON_CONFIRM_NOT_REQUIRED = 4;
    public static final int DISMISSED_REASON_BIOMETRIC_CONFIRM_NOT_REQUIRED = 4;

    /**
     * Error message shown on SystemUI. When BiometricService receives this, the UI is already
@@ -129,6 +129,11 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
     */
    public static final int DISMISSED_REASON_SERVER_REQUESTED = 6;

    /**
     * @hide
     */
    public static final int DISMISSED_REASON_CREDENTIAL_CONFIRMED = 7;

    private static class ButtonInfo {
        Executor executor;
        DialogInterface.OnClickListener listener;
@@ -368,7 +373,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
        @Override
        public void onDialogDismissed(int reason) throws RemoteException {
            // Check the reason and invoke OnClickListener(s) if necessary
            if (reason == DISMISSED_REASON_CONFIRMED) {
            if (reason == DISMISSED_REASON_BIOMETRIC_CONFIRMED) {
                mPositiveButtonInfo.executor.execute(() -> {
                    mPositiveButtonInfo.listener.onClick(null, DialogInterface.BUTTON_POSITIVE);
                });
+2 −0
Original line number Diff line number Diff line
@@ -38,4 +38,6 @@ oneway interface IBiometricServiceReceiverInternal {
    void onDialogDismissed(int reason);
    // Notifies that the user has pressed the "try again" button on SystemUI
    void onTryAgainPressed();
    // Notifies that the user has pressed the "use password" button on SystemUI
    void onDeviceCredentialPressed();
}
+27 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2019 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="32dp"
    android:height="32dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
    <path
        android:fillColor="?android:attr/colorAccent"
        android:pathData="M12,15m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
    <path
        android:fillColor="?android:attr/colorAccent"
        android:pathData="M18,8h-1.5V5.5C16.5,3.01 14.49,1 12,1S7.5,3.01 7.5,5.5V8H6c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V10C20,8.9 19.1,8 18,8zM9.5,5.5C9.5,4.12 10.62,3 12,3c1.38,0 2.5,1.12 2.5,2.5V8h-5V5.5zM18,20H6V10h1.5h9H18V20z"/>
</vector>
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@
        android:elevation="@dimen/biometric_dialog_elevation"/>

    <ScrollView
        android:id="@+id/scrollview"
        android:id="@+id/biometric_scrollview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|bottom"
+98 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2019 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<com.android.systemui.biometrics.AuthCredentialView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/contents"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center_horizontal"
    android:elevation="@dimen/biometric_dialog_elevation">

    <Space
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_weight="1"/>

    <ImageView
        android:layout_width="32dp"
        android:layout_height="32dp"
        android:background="@drawable/auth_dialog_lock"/>

    <TextView
        android:id="@+id/title"
        android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="24dp"
        android:layout_marginTop="12dp"
        android:textSize="20sp"
        android:gravity="center"
        android:textColor="?android:attr/textColorPrimary"/>

    <TextView
        android:id="@+id/subtitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="24dp"
        android:layout_marginTop="8dp"
        android:textSize="16sp"
        android:gravity="center"
        android:textColor="?android:attr/textColorPrimary"/>

    <TextView
        android:id="@+id/description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="24dp"
        android:layout_marginTop="8dp"
        android:gravity="center"
        android:textSize="16sp"
        android:textColor="?android:attr/textColorPrimary"/>

    <Space
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_weight="3"/>

    <TextView
        android:id="@+id/error"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="24dp"
        android:textSize="16sp"
        android:gravity="center"
        android:textColor="?android:attr/colorError"/>

    <com.android.internal.widget.LockPatternView
        android:id="@+id/lockPattern"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="40dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:clipChildren="false"
        android:clipToPadding="false"
        style="@style/LockPatternStyleBiometricPrompt"/>

    <Space
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_weight="1"/>

</com.android.systemui.biometrics.AuthCredentialView>
 No newline at end of file
Loading