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

Commit 03cde6c3 authored by Hao Dong's avatar Hao Dong Committed by Android (Google) Code Review
Browse files

Merge "Add an API setLogoDescription() for bp." into main

parents 4eac1b08 6232cc58
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -18847,6 +18847,7 @@ package android.hardware.biometrics {
    method @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") @Nullable public android.hardware.biometrics.PromptContentView getContentView();
    method @Nullable public CharSequence getDescription();
    method @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") @Nullable @RequiresPermission(android.Manifest.permission.SET_BIOMETRIC_DIALOG_LOGO) public android.graphics.Bitmap getLogoBitmap();
    method @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") @Nullable @RequiresPermission(android.Manifest.permission.SET_BIOMETRIC_DIALOG_LOGO) public String getLogoDescription();
    method @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") @DrawableRes @RequiresPermission(android.Manifest.permission.SET_BIOMETRIC_DIALOG_LOGO) public int getLogoRes();
    method @Nullable public CharSequence getNegativeButtonText();
    method @Nullable public CharSequence getSubtitle();
@@ -18898,6 +18899,7 @@ package android.hardware.biometrics {
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setDescription(@NonNull CharSequence);
    method @Deprecated @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setDeviceCredentialAllowed(boolean);
    method @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") @NonNull @RequiresPermission(android.Manifest.permission.SET_BIOMETRIC_DIALOG_LOGO) public android.hardware.biometrics.BiometricPrompt.Builder setLogoBitmap(@NonNull android.graphics.Bitmap);
    method @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") @NonNull @RequiresPermission(android.Manifest.permission.SET_BIOMETRIC_DIALOG_LOGO) public android.hardware.biometrics.BiometricPrompt.Builder setLogoDescription(@NonNull String);
    method @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") @NonNull @RequiresPermission(android.Manifest.permission.SET_BIOMETRIC_DIALOG_LOGO) public android.hardware.biometrics.BiometricPrompt.Builder setLogoRes(@DrawableRes int);
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setNegativeButton(@NonNull CharSequence, @NonNull java.util.concurrent.Executor, @NonNull android.content.DialogInterface.OnClickListener);
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setSubtitle(@NonNull CharSequence);
+33 −1
Original line number Diff line number Diff line
@@ -200,6 +200,25 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
            return this;
        }

        /**
         * Optional: Sets logo description text that will be shown on the prompt.
         *
         * <p> Note that using this method is not recommended in most scenarios because the calling
         * application's name will be used by default. Setting the logo description is intended for
         * large bundled applications that perform a wide range of functions and need to show
         * distinct description for each function.
         *
         * @param logoDescription The logo description text that will be shown on the prompt.
         * @return This builder.
         */
        @FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
        @RequiresPermission(SET_BIOMETRIC_DIALOG_LOGO)
        @NonNull
        public BiometricPrompt.Builder setLogoDescription(@NonNull String logoDescription) {
            mPromptInfo.setLogoDescription(logoDescription);
            return this;
        }


        /**
         * Required: Sets the title that will be shown on the prompt.
@@ -743,7 +762,20 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
        return mPromptInfo.getLogoBitmap();
    }


    /**
     * Gets the logo description for the prompt, as set by
     * {@link Builder#setDescription(CharSequence)}.
     * Currently for system applications use only.
     *
     * @return The logo description of the prompt, or null if the prompt has no logo description
     * set.
     */
    @FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
    @RequiresPermission(SET_BIOMETRIC_DIALOG_LOGO)
    @Nullable
    public String getLogoDescription() {
        return mPromptInfo.getLogoDescription();
    }

    /**
     * Gets the title for the prompt, as set by {@link Builder#setTitle(CharSequence)}.
+13 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ public class PromptInfo implements Parcelable {

    @DrawableRes private int mLogoRes = -1;
    @Nullable private Bitmap mLogoBitmap;
    @Nullable private String mLogoDescription;
    @NonNull private CharSequence mTitle;
    private boolean mUseDefaultTitle;
    @Nullable private CharSequence mSubtitle;
@@ -62,6 +63,7 @@ public class PromptInfo implements Parcelable {
    PromptInfo(Parcel in) {
        mLogoRes = in.readInt();
        mLogoBitmap = in.readTypedObject(Bitmap.CREATOR);
        mLogoDescription = in.readString();
        mTitle = in.readCharSequence();
        mUseDefaultTitle = in.readBoolean();
        mSubtitle = in.readCharSequence();
@@ -106,6 +108,7 @@ public class PromptInfo implements Parcelable {
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mLogoRes);
        dest.writeTypedObject(mLogoBitmap, 0);
        dest.writeString(mLogoDescription);
        dest.writeCharSequence(mTitle);
        dest.writeBoolean(mUseDefaultTitle);
        dest.writeCharSequence(mSubtitle);
@@ -173,6 +176,8 @@ public class PromptInfo implements Parcelable {
            return true;
        } else if (mLogoBitmap != null) {
            return true;
        } else if (mLogoDescription != null) {
            return true;
        }
        return false;
    }
@@ -189,6 +194,10 @@ public class PromptInfo implements Parcelable {
        checkOnlyOneLogoSet();
    }

    public void setLogoDescription(@NonNull String logoDescription) {
        mLogoDescription = logoDescription;
    }

    public void setTitle(CharSequence title) {
        mTitle = title;
    }
@@ -282,6 +291,10 @@ public class PromptInfo implements Parcelable {
        return mLogoBitmap;
    }

    public String getLogoDescription() {
        return mLogoDescription;
    }

    public CharSequence getTitle() {
        return mTitle;
    }
+2 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ internal fun Collection<SensorPropertiesInternal?>.extractAuthenticatorTypes():
internal fun promptInfo(
    logoRes: Int = -1,
    logoBitmap: Bitmap? = null,
    logoDescription: String? = null,
    title: String = "title",
    subtitle: String = "sub",
    description: String = "desc",
@@ -132,6 +133,7 @@ internal fun promptInfo(
    val info = PromptInfo()
    info.logoRes = logoRes
    info.logoBitmap = logoBitmap
    info.logoDescription = logoDescription
    info.title = title
    info.subtitle = subtitle
    info.description = description
+10 −0
Original line number Diff line number Diff line
@@ -13,6 +13,16 @@ android:layout_height="match_parent">
        android:scaleType="fitXY"
        android:visibility="gone" />

    <TextView
        android:id="@+id/logo_description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="@integer/biometric_dialog_text_gravity"
        android:singleLine="true"
        android:marqueeRepeatLimit="1"
        android:ellipsize="marquee"
        android:visibility="gone"/>

    <ImageView
        android:id="@+id/background"
        android:layout_width="0dp"
Loading