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

Commit 8110ebb5 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

16/n: Add PIN/Password

Bug: 140127687

Make AuthCredentialView abstract, and have the following subclasses
 1) AuthCredentialPatternView
 2) AuthCredentialPasswordView

Back button cancels password authentication

Test: manual test with pattern, pin, password
Test: atest com.android.systemui.biometrics

Change-Id: I95e42144616a59827da25d10d063990452714f76
parent 86f1b8e3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
  ~ limitations under the License.
  -->

<com.android.systemui.biometrics.AuthCredentialView
<com.android.systemui.biometrics.AuthCredentialPatternView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
@@ -110,4 +110,4 @@

    </LinearLayout>

</com.android.systemui.biometrics.AuthCredentialView>
 No newline at end of file
</com.android.systemui.biometrics.AuthCredentialPatternView>
 No newline at end of file
+101 −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.AuthCredentialPasswordView
    xmlns:android="http://schemas.android.com/apk/res/android"
    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="1"/>

    <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"/>

    <EditText
        android:id="@+id/lockPassword"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="100dp"
        android:layout_marginRight="100dp"
        android:layout_width="208dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:inputType="textPassword"
        android:maxLength="500"
        android:textSize="16sp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:imeOptions="flagForceAscii"
        style="@style/LockPatternStyleBiometricPrompt"/>

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

</com.android.systemui.biometrics.AuthCredentialPasswordView>
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
  ~ limitations under the License.
  -->

<com.android.systemui.biometrics.AuthCredentialView
<com.android.systemui.biometrics.AuthCredentialPatternView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
@@ -94,4 +94,4 @@
        android:layout_height="0dp"
        android:layout_weight="1"/>

</com.android.systemui.biometrics.AuthCredentialView>
 No newline at end of file
</com.android.systemui.biometrics.AuthCredentialPatternView>
 No newline at end of file
+9 −11
Original line number Diff line number Diff line
@@ -629,19 +629,17 @@ public abstract class AuthBiometricView extends LinearLayout {

        final String negativeText;
        if (isDeviceCredentialAllowed()) {
            final LockPatternUtils lpu = new LockPatternUtils(mContext);
            switch (lpu.getKeyguardStoredPasswordQuality(mUserId)) {
                case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
                    negativeText = getResources().getString(R.string.biometric_dialog_use_pattern);
                    break;
                case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
                case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:

            final @Utils.CredentialType int credentialType =
                    Utils.getCredentialType(mContext, mUserId);
            switch(credentialType) {
                case Utils.CREDENTIAL_PIN:
                    negativeText = getResources().getString(R.string.biometric_dialog_use_pin);
                    break;
                case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
                case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
                case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
                case DevicePolicyManager.PASSWORD_QUALITY_MANAGED:
                case Utils.CREDENTIAL_PATTERN:
                    negativeText = getResources().getString(R.string.biometric_dialog_use_pattern);
                    break;
                case Utils.CREDENTIAL_PASSWORD:
                    negativeText = getResources().getString(R.string.biometric_dialog_use_password);
                    break;
                default:
+16 −2
Original line number Diff line number Diff line
@@ -307,8 +307,22 @@ public class AuthContainerView extends LinearLayout
     */
    private void addCredentialView(boolean animatePanel, boolean animateContents) {
        final LayoutInflater factory = LayoutInflater.from(mContext);
        final int credentialType = Utils.getCredentialType(mContext, mConfig.mUserId);
        switch (credentialType) {
            case Utils.CREDENTIAL_PATTERN:
                mCredentialView = (AuthCredentialView) factory.inflate(
                R.layout.auth_credential_view, null, false);
                        R.layout.auth_credential_pattern_view, null, false);
                break;
            case Utils.CREDENTIAL_PIN:
            case Utils.CREDENTIAL_PASSWORD:
                mCredentialView = (AuthCredentialView) factory.inflate(
                        R.layout.auth_credential_password_view, null, false);
                break;
            default:
                throw new IllegalStateException("Unknown credential type: " + credentialType);
        }

        mCredentialView.setContainerView(this);
        mCredentialView.setUser(mConfig.mUserId);
        mCredentialView.setCallback(mCredentialCallback);
        mCredentialView.setBiometricPromptBundle(mConfig.mBiometricPromptBundle);
Loading