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

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

Merge "Add a templated customized view API on Biometric Prompt." into main

parents e7d11bbe e9e9573f
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -18680,6 +18680,7 @@ package android.hardware.biometrics {
    method @RequiresPermission(android.Manifest.permission.USE_BIOMETRIC) public void authenticate(@NonNull android.hardware.biometrics.BiometricPrompt.CryptoObject, @NonNull android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull android.hardware.biometrics.BiometricPrompt.AuthenticationCallback);
    method @RequiresPermission(android.Manifest.permission.USE_BIOMETRIC) public void authenticate(@NonNull android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull android.hardware.biometrics.BiometricPrompt.AuthenticationCallback);
    method @Nullable public int getAllowedAuthenticators();
    method @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") @Nullable public android.hardware.biometrics.PromptContentView getContentView();
    method @Nullable public CharSequence getDescription();
    method @Nullable public CharSequence getNegativeButtonText();
    method @Nullable public CharSequence getSubtitle();
@@ -18727,6 +18728,7 @@ package android.hardware.biometrics {
    method @NonNull public android.hardware.biometrics.BiometricPrompt build();
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setAllowedAuthenticators(int);
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setConfirmationRequired(boolean);
    method @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setContentView(@NonNull android.hardware.biometrics.PromptContentView);
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setDescription(@NonNull CharSequence);
    method @Deprecated @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setDeviceCredentialAllowed(boolean);
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setNegativeButton(@NonNull CharSequence, @NonNull java.util.concurrent.Executor, @NonNull android.content.DialogInterface.OnClickListener);
@@ -18750,6 +18752,43 @@ package android.hardware.biometrics {
    method @Nullable public java.security.Signature getSignature();
  }
  @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public interface PromptContentListItem {
  }
  @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public final class PromptContentListItemBulletedText implements android.os.Parcelable android.hardware.biometrics.PromptContentListItem {
    ctor public PromptContentListItemBulletedText(@NonNull CharSequence);
    method public int describeContents();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.biometrics.PromptContentListItemBulletedText> CREATOR;
  }
  @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public final class PromptContentListItemPlainText implements android.os.Parcelable android.hardware.biometrics.PromptContentListItem {
    ctor public PromptContentListItemPlainText(@NonNull CharSequence);
    method public int describeContents();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.biometrics.PromptContentListItemPlainText> CREATOR;
  }
  @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public interface PromptContentView {
  }
  @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public final class PromptVerticalListContentView implements android.os.Parcelable android.hardware.biometrics.PromptContentView {
    method public int describeContents();
    method @Nullable public CharSequence getDescription();
    method @NonNull public java.util.List<android.hardware.biometrics.PromptContentListItem> getListItems();
    method public static int getMaxEachItemCharacterNumber();
    method public static int getMaxItemCount();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.biometrics.PromptVerticalListContentView> CREATOR;
  }
  public static final class PromptVerticalListContentView.Builder {
    ctor public PromptVerticalListContentView.Builder();
    method @NonNull public android.hardware.biometrics.PromptVerticalListContentView.Builder addListItem(@NonNull android.hardware.biometrics.PromptContentListItem);
    method @NonNull public android.hardware.biometrics.PromptVerticalListContentView build();
    method @NonNull public android.hardware.biometrics.PromptVerticalListContentView.Builder setDescription(@NonNull CharSequence);
  }
}
package android.hardware.camera2 {
+37 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;
import static android.hardware.biometrics.BiometricManager.Authenticators;
import static android.hardware.biometrics.Flags.FLAG_ADD_KEY_AGREEMENT_CRYPTO_OBJECT;
import static android.hardware.biometrics.Flags.FLAG_GET_OP_ID_CRYPTO_OBJECT;
import static android.hardware.biometrics.Flags.FLAG_CUSTOM_BIOMETRIC_PROMPT;

import android.annotation.CallbackExecutor;
import android.annotation.FlaggedApi;
@@ -208,6 +209,12 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan

        /**
         * Optional: Sets a description that will be shown on the prompt.
         *
         * <p> Note that the description set by {@link Builder#setDescription(CharSequence)} will be
         * overridden by {@link Builder#setContentView(PromptContentView)}. The view provided to
         * {@link Builder#setContentView(PromptContentView)} will be used if both methods are
         * called.
         *
         * @param description The description to display.
         * @return This builder.
         */
@@ -217,6 +224,24 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
            return this;
        }

        /**
         * Optional: Sets application customized content view that will be shown on the prompt.
         *
         * <p> Note that the description set by {@link Builder#setDescription(CharSequence)} will be
         * overridden by {@link Builder#setContentView(PromptContentView)}. The view provided to
         * {@link Builder#setContentView(PromptContentView)} will be used if both methods are
         * called.
         *
         * @param view The customized view information.
         * @return This builder.re
         */
        @FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
        @NonNull
        public BiometricPrompt.Builder setContentView(@NonNull PromptContentView view) {
            mPromptInfo.setContentView(view);
            return this;
        }

        /**
         * @param service
         * @return This builder.
@@ -697,6 +722,18 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
        return mPromptInfo.getDescription();
    }

    /**
     * Gets the content view for the prompt, as set by
     * {@link Builder#setContentView(PromptContentView)}.
     *
     * @return The content view for the prompt, or null if the prompt has no content view.
     */
    @FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
    @Nullable
    public PromptContentView getContentView() {
        return mPromptInfo.getContentView();
    }

    /**
     * Gets the negative button text for the prompt, as set by
     * {@link Builder#setNegativeButton(CharSequence, Executor, DialogInterface.OnClickListener)}.
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.
 */

package android.hardware.biometrics;

import static android.hardware.biometrics.Flags.FLAG_CUSTOM_BIOMETRIC_PROMPT;

import android.annotation.FlaggedApi;

/**
 * A list item shown on {@link PromptVerticalListContentView}.
 */
@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
public interface PromptContentListItem {
}
+81 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.
 */

package android.hardware.biometrics;

import static android.hardware.biometrics.Flags.FLAG_CUSTOM_BIOMETRIC_PROMPT;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * A list item with bulleted text shown on {@link PromptVerticalListContentView}.
 */
@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
public final class PromptContentListItemBulletedText implements PromptContentListItemParcelable {
    private final CharSequence mText;

    /**
     * A list item with bulleted text shown on {@link PromptVerticalListContentView}.
     *
     * @param text The text of this list item.
     */
    public PromptContentListItemBulletedText(@NonNull CharSequence text) {
        mText = text;
    }

    /**
     * @hide
     */
    @NonNull
    public CharSequence getText() {
        return mText;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int describeContents() {
        return 0;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeCharSequence(mText);
    }

    /**
     * @see Parcelable.Creator
     */
    @NonNull
    public static final Creator<PromptContentListItemBulletedText> CREATOR = new Creator<>() {
        @Override
        public PromptContentListItemBulletedText createFromParcel(Parcel in) {
            return new PromptContentListItemBulletedText(in.readCharSequence());
        }

        @Override
        public PromptContentListItemBulletedText[] newArray(int size) {
            return new PromptContentListItemBulletedText[size];
        }
    };
}
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.
 */

package android.hardware.biometrics;

import static android.hardware.biometrics.Flags.FLAG_CUSTOM_BIOMETRIC_PROMPT;

import android.annotation.FlaggedApi;
import android.os.Parcelable;

/**
 * A parcelable {@link PromptContentListItem}.
 */
@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
sealed interface PromptContentListItemParcelable extends PromptContentListItem, Parcelable
        permits PromptContentListItemPlainText, PromptContentListItemBulletedText {
}
Loading