Loading core/java/android/hardware/biometrics/BiometricPrompt.java +36 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,18 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan * @hide */ public static final String KEY_DESCRIPTION = "description"; /** * @hide */ public static final String KEY_DEVICE_CREDENTIAL_TITLE = "device_credential_title"; /** * @hide */ public static final String KEY_DEVICE_CREDENTIAL_SUBTITLE = "device_credential_subtitle"; /** * @hide */ public static final String KEY_DEVICE_CREDENTIAL_DESCRIPTION = "device_credential_description"; /** * @hide */ Loading Loading @@ -220,6 +232,30 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan return this; } /** * Sets an optional title, subtitle, and/or description that will override other text when * the user is authenticating with PIN/pattern/password. Currently for internal use only. * @return This builder. * @hide */ @RequiresPermission(USE_BIOMETRIC_INTERNAL) @NonNull public Builder setTextForDeviceCredential( @Nullable CharSequence title, @Nullable CharSequence subtitle, @Nullable CharSequence description) { if (title != null) { mBundle.putCharSequence(KEY_DEVICE_CREDENTIAL_TITLE, title); } if (subtitle != null) { mBundle.putCharSequence(KEY_DEVICE_CREDENTIAL_SUBTITLE, subtitle); } if (description != null) { mBundle.putCharSequence(KEY_DEVICE_CREDENTIAL_DESCRIPTION, description); } return this; } /** * Required: Sets the text, executor, and click listener for the negative button on the * prompt. This is typically a cancel button, but may be also used to show an alternative Loading packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java +35 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.biometrics; import android.annotation.NonNull; import android.content.Context; import android.graphics.drawable.Drawable; import android.hardware.biometrics.BiometricPrompt; Loading @@ -33,6 +34,8 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.Nullable; import com.android.internal.widget.LockPatternUtils; import com.android.systemui.Interpolators; import com.android.systemui.R; Loading Loading @@ -126,18 +129,18 @@ public abstract class AuthCredentialView extends LinearLayout { mHandler.postDelayed(mClearErrorRunnable, ERROR_DURATION_MS); } private void setTextOrHide(TextView view, String string) { if (TextUtils.isEmpty(string)) { private void setTextOrHide(TextView view, CharSequence text) { if (TextUtils.isEmpty(text)) { view.setVisibility(View.GONE); } else { view.setText(string); view.setText(text); } Utils.notifyAccessibilityContentChanged(mAccessibilityManager, this); } private void setText(TextView view, String string) { view.setText(string); private void setText(TextView view, CharSequence text) { view.setText(text); } void setEffectiveUserId(int effectiveUserId) { Loading Loading @@ -173,11 +176,9 @@ public abstract class AuthCredentialView extends LinearLayout { protected void onAttachedToWindow() { super.onAttachedToWindow(); setText(mTitleView, mBiometricPromptBundle.getString(BiometricPrompt.KEY_TITLE)); setTextOrHide(mSubtitleView, mBiometricPromptBundle.getString(BiometricPrompt.KEY_SUBTITLE)); setTextOrHide(mDescriptionView, mBiometricPromptBundle.getString(BiometricPrompt.KEY_DESCRIPTION)); setText(mTitleView, getTitle(mBiometricPromptBundle)); setTextOrHide(mSubtitleView, getSubtitle(mBiometricPromptBundle)); setTextOrHide(mDescriptionView, getDescription(mBiometricPromptBundle)); final boolean isManagedProfile = Utils.isManagedProfile(mContext, mEffectiveUserId); final Drawable image; Loading Loading @@ -279,4 +280,28 @@ public abstract class AuthCredentialView extends LinearLayout { } } } @Nullable private static CharSequence getTitle(@NonNull Bundle bundle) { final CharSequence credentialTitle = bundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_TITLE); return credentialTitle != null ? credentialTitle : bundle.getCharSequence(BiometricPrompt.KEY_TITLE); } @Nullable private static CharSequence getSubtitle(@NonNull Bundle bundle) { final CharSequence credentialSubtitle = bundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_SUBTITLE); return credentialSubtitle != null ? credentialSubtitle : bundle.getCharSequence(BiometricPrompt.KEY_SUBTITLE); } @Nullable private static CharSequence getDescription(@NonNull Bundle bundle) { final CharSequence credentialDescription = bundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_DESCRIPTION); return credentialDescription != null ? credentialDescription : bundle.getCharSequence(BiometricPrompt.KEY_DESCRIPTION); } } services/core/java/com/android/server/biometrics/AuthService.java +6 −1 Original line number Diff line number Diff line Loading @@ -153,7 +153,12 @@ public class AuthService extends SystemService { // Only allow internal clients to enable non-public options. if (bundle.getBoolean(BiometricPrompt.EXTRA_DISALLOW_BIOMETRICS_IF_POLICY_EXISTS) || bundle.getBoolean(BiometricPrompt.KEY_USE_DEFAULT_TITLE, false)) { || bundle.getBoolean(BiometricPrompt.KEY_USE_DEFAULT_TITLE, false) || bundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_TITLE) != null || bundle.getCharSequence( BiometricPrompt.KEY_DEVICE_CREDENTIAL_SUBTITLE) != null || bundle.getCharSequence( BiometricPrompt.KEY_DEVICE_CREDENTIAL_DESCRIPTION) != null) { checkInternalPermission(); } Loading Loading
core/java/android/hardware/biometrics/BiometricPrompt.java +36 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,18 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan * @hide */ public static final String KEY_DESCRIPTION = "description"; /** * @hide */ public static final String KEY_DEVICE_CREDENTIAL_TITLE = "device_credential_title"; /** * @hide */ public static final String KEY_DEVICE_CREDENTIAL_SUBTITLE = "device_credential_subtitle"; /** * @hide */ public static final String KEY_DEVICE_CREDENTIAL_DESCRIPTION = "device_credential_description"; /** * @hide */ Loading Loading @@ -220,6 +232,30 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan return this; } /** * Sets an optional title, subtitle, and/or description that will override other text when * the user is authenticating with PIN/pattern/password. Currently for internal use only. * @return This builder. * @hide */ @RequiresPermission(USE_BIOMETRIC_INTERNAL) @NonNull public Builder setTextForDeviceCredential( @Nullable CharSequence title, @Nullable CharSequence subtitle, @Nullable CharSequence description) { if (title != null) { mBundle.putCharSequence(KEY_DEVICE_CREDENTIAL_TITLE, title); } if (subtitle != null) { mBundle.putCharSequence(KEY_DEVICE_CREDENTIAL_SUBTITLE, subtitle); } if (description != null) { mBundle.putCharSequence(KEY_DEVICE_CREDENTIAL_DESCRIPTION, description); } return this; } /** * Required: Sets the text, executor, and click listener for the negative button on the * prompt. This is typically a cancel button, but may be also used to show an alternative Loading
packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java +35 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.biometrics; import android.annotation.NonNull; import android.content.Context; import android.graphics.drawable.Drawable; import android.hardware.biometrics.BiometricPrompt; Loading @@ -33,6 +34,8 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.Nullable; import com.android.internal.widget.LockPatternUtils; import com.android.systemui.Interpolators; import com.android.systemui.R; Loading Loading @@ -126,18 +129,18 @@ public abstract class AuthCredentialView extends LinearLayout { mHandler.postDelayed(mClearErrorRunnable, ERROR_DURATION_MS); } private void setTextOrHide(TextView view, String string) { if (TextUtils.isEmpty(string)) { private void setTextOrHide(TextView view, CharSequence text) { if (TextUtils.isEmpty(text)) { view.setVisibility(View.GONE); } else { view.setText(string); view.setText(text); } Utils.notifyAccessibilityContentChanged(mAccessibilityManager, this); } private void setText(TextView view, String string) { view.setText(string); private void setText(TextView view, CharSequence text) { view.setText(text); } void setEffectiveUserId(int effectiveUserId) { Loading Loading @@ -173,11 +176,9 @@ public abstract class AuthCredentialView extends LinearLayout { protected void onAttachedToWindow() { super.onAttachedToWindow(); setText(mTitleView, mBiometricPromptBundle.getString(BiometricPrompt.KEY_TITLE)); setTextOrHide(mSubtitleView, mBiometricPromptBundle.getString(BiometricPrompt.KEY_SUBTITLE)); setTextOrHide(mDescriptionView, mBiometricPromptBundle.getString(BiometricPrompt.KEY_DESCRIPTION)); setText(mTitleView, getTitle(mBiometricPromptBundle)); setTextOrHide(mSubtitleView, getSubtitle(mBiometricPromptBundle)); setTextOrHide(mDescriptionView, getDescription(mBiometricPromptBundle)); final boolean isManagedProfile = Utils.isManagedProfile(mContext, mEffectiveUserId); final Drawable image; Loading Loading @@ -279,4 +280,28 @@ public abstract class AuthCredentialView extends LinearLayout { } } } @Nullable private static CharSequence getTitle(@NonNull Bundle bundle) { final CharSequence credentialTitle = bundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_TITLE); return credentialTitle != null ? credentialTitle : bundle.getCharSequence(BiometricPrompt.KEY_TITLE); } @Nullable private static CharSequence getSubtitle(@NonNull Bundle bundle) { final CharSequence credentialSubtitle = bundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_SUBTITLE); return credentialSubtitle != null ? credentialSubtitle : bundle.getCharSequence(BiometricPrompt.KEY_SUBTITLE); } @Nullable private static CharSequence getDescription(@NonNull Bundle bundle) { final CharSequence credentialDescription = bundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_DESCRIPTION); return credentialDescription != null ? credentialDescription : bundle.getCharSequence(BiometricPrompt.KEY_DESCRIPTION); } }
services/core/java/com/android/server/biometrics/AuthService.java +6 −1 Original line number Diff line number Diff line Loading @@ -153,7 +153,12 @@ public class AuthService extends SystemService { // Only allow internal clients to enable non-public options. if (bundle.getBoolean(BiometricPrompt.EXTRA_DISALLOW_BIOMETRICS_IF_POLICY_EXISTS) || bundle.getBoolean(BiometricPrompt.KEY_USE_DEFAULT_TITLE, false)) { || bundle.getBoolean(BiometricPrompt.KEY_USE_DEFAULT_TITLE, false) || bundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_TITLE) != null || bundle.getCharSequence( BiometricPrompt.KEY_DEVICE_CREDENTIAL_SUBTITLE) != null || bundle.getCharSequence( BiometricPrompt.KEY_DEVICE_CREDENTIAL_DESCRIPTION) != null) { checkInternalPermission(); } Loading