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

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

Merge "Fix res not found in PromptInfo." into main

parents 3d5c109e b0885022
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -200,7 +200,10 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
                throw new IllegalStateException(
                        "Exclusively one of logo resource or logo bitmap can be set");
            }
            mPromptInfo.setLogo(logoRes, convertDrawableToBitmap(mContext.getDrawable(logoRes)));
            if (logoRes != 0) {
                mPromptInfo.setLogo(logoRes,
                        convertDrawableToBitmap(mContext.getDrawable(logoRes)));
            }
            return this;
        }

@@ -219,11 +222,11 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
        @RequiresPermission(SET_BIOMETRIC_DIALOG_ADVANCED)
        @NonNull
        public BiometricPrompt.Builder setLogoBitmap(@NonNull Bitmap logoBitmap) {
            if (mPromptInfo.getLogoRes() != -1) {
            if (mPromptInfo.getLogoRes() != 0) {
                throw new IllegalStateException(
                        "Exclusively one of logo resource or logo bitmap can be set");
            }
            mPromptInfo.setLogo(-1, logoBitmap);
            mPromptInfo.setLogo(0, logoBitmap);
            return this;
        }

@@ -832,7 +835,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
     * Gets the drawable resource of the logo for the prompt, as set by
     * {@link Builder#setLogoRes(int)}. Currently for system applications use only.
     *
     * @return The drawable resource of the logo, or -1 if the prompt has no logo resource set.
     * @return The drawable resource of the logo, or 0 if the prompt has no logo resource set.
     */
    @FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
    @RequiresPermission(SET_BIOMETRIC_DIALOG_ADVANCED)
+4 −4
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import java.util.List;
 */
public class PromptInfo implements Parcelable {

    @DrawableRes private int mLogoRes = -1;
    @DrawableRes private int mLogoRes;
    @Nullable private Bitmap mLogoBitmap;
    @Nullable private String mLogoDescription;
    @NonNull private CharSequence mTitle;
@@ -187,7 +187,7 @@ public class PromptInfo implements Parcelable {
     * this permission.
     */
    public boolean requiresAdvancedPermission() {
        if (mLogoRes != -1) {
        if (mLogoRes != 0) {
            return true;
        } else if (mLogoBitmap != null) {
            return true;
@@ -221,7 +221,7 @@ public class PromptInfo implements Parcelable {
    /**
     * Sets logo res and bitmap
     *
     * @param logoRes    The logo res set by the app; Or -1 if the app sets bitmap directly.
     * @param logoRes    The logo res set by the app; Or 0 if the app sets bitmap directly.
     * @param logoBitmap The bitmap from logoRes if the app sets logoRes; Or the bitmap set by the
     *                   app directly.
     */
@@ -351,7 +351,7 @@ public class PromptInfo implements Parcelable {
    public Bitmap getLogoBitmap() {
        // If mLogoRes has been set, return null since mLogoBitmap is from the res, but not from
        // the app directly.
        return mLogoRes == -1 ? mLogoBitmap : null;
        return mLogoRes == 0 ? mLogoBitmap : null;
    }

    public String getLogoDescription() {
+3 −4
Original line number Diff line number Diff line
@@ -1559,7 +1559,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa
        subtitle: String? = "s",
        description: String? = null,
        contentView: PromptContentView? = null,
        logoRes: Int = -1,
        logoRes: Int = 0,
        logoBitmap: Bitmap? = null,
        logoDescription: String? = null,
        packageName: String = OP_PACKAGE_NAME,
@@ -1599,8 +1599,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa
            descriptionFromApp = description,
            contentViewFromApp = contentView,
            logoResFromApp = logoRes,
            logoBitmapFromApp =
                if (logoRes != -1) logoDrawableFromAppRes.toBitmap() else logoBitmap,
            logoBitmapFromApp = if (logoRes != 0) logoDrawableFromAppRes.toBitmap() else logoBitmap,
            logoDescriptionFromApp = logoDescription,
            packageName = packageName,
        )
@@ -1787,7 +1786,7 @@ private fun PromptSelectorInteractor.initializePrompt(
    subtitleFromApp: String? = "s",
    descriptionFromApp: String? = null,
    contentViewFromApp: PromptContentView? = null,
    logoResFromApp: Int = -1,
    logoResFromApp: Int = 0,
    logoBitmapFromApp: Bitmap? = null,
    logoDescriptionFromApp: String? = null,
    packageName: String = OP_PACKAGE_NAME,