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

Commit 8066d8ec authored by Shaquille Johnson's avatar Shaquille Johnson Committed by Automerger Merge Worker
Browse files

Merge "biometric: Add nullable to api for crypto" into main am: 6fff31bf

parents 37b59a00 6fff31bf
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -18375,12 +18375,12 @@ package android.hardware.biometrics {
    ctor @Deprecated public BiometricPrompt.CryptoObject(@NonNull android.security.identity.IdentityCredential);
    ctor public BiometricPrompt.CryptoObject(@NonNull android.security.identity.PresentationSession);
    ctor @FlaggedApi("android.hardware.biometrics.add_key_agreement_crypto_object") public BiometricPrompt.CryptoObject(@NonNull javax.crypto.KeyAgreement);
    method public javax.crypto.Cipher getCipher();
    method @Nullable public javax.crypto.Cipher getCipher();
    method @Deprecated @Nullable public android.security.identity.IdentityCredential getIdentityCredential();
    method @FlaggedApi("android.hardware.biometrics.add_key_agreement_crypto_object") @Nullable public javax.crypto.KeyAgreement getKeyAgreement();
    method public javax.crypto.Mac getMac();
    method @Nullable public javax.crypto.Mac getMac();
    method @Nullable public android.security.identity.PresentationSession getPresentationSession();
    method public java.security.Signature getSignature();
    method @Nullable public java.security.Signature getSignature();
  }
}
+3 −3
Original line number Diff line number Diff line
@@ -792,7 +792,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
         * Get {@link Signature} object.
         * @return {@link Signature} object or null if this doesn't contain one.
         */
        public Signature getSignature() {
        public @Nullable Signature getSignature() {
            return super.getSignature();
        }

@@ -800,7 +800,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
         * Get {@link Cipher} object.
         * @return {@link Cipher} object or null if this doesn't contain one.
         */
        public Cipher getCipher() {
        public @Nullable Cipher getCipher() {
            return super.getCipher();
        }

@@ -808,7 +808,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
         * Get {@link Mac} object.
         * @return {@link Mac} object or null if this doesn't contain one.
         */
        public Mac getMac() {
        public @Nullable Mac getMac() {
            return super.getMac();
        }

+36 −8
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.hardware.biometrics.Flags.FLAG_ADD_KEY_AGREEMENT_CRYPTO_OB

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.security.identity.IdentityCredential;
import android.security.identity.PresentationSession;
import android.security.keystore2.AndroidKeyStoreProvider;
@@ -33,20 +34,35 @@ import javax.crypto.Mac;
/**
 * A wrapper class for the crypto objects supported by BiometricPrompt and FingerprintManager.
 * Currently the framework supports {@link Signature}, {@link Cipher}, {@link Mac},
 * {@link IdentityCredential}, and {@link PresentationSession} objects.
 * {@link KeyAgreement}, {@link IdentityCredential}, and {@link PresentationSession} objects.
 * @hide
 */
public class CryptoObject {
    private final Object mCrypto;

    /**
     * Create from a {@link Signature} object.
     *
     * @param signature a {@link Signature} object.
     */
    public CryptoObject(@NonNull Signature signature) {
        mCrypto = signature;
    }

    /**
     * Create from a {@link Cipher} object.
     *
     * @param cipher a {@link Cipher} object.
     */
    public CryptoObject(@NonNull Cipher cipher) {
        mCrypto = cipher;
    }

    /**
     * Create from a {@link Mac} object.
     *
     * @param mac a {@link Mac} object.
     */
    public CryptoObject(@NonNull Mac mac) {
        mCrypto = mac;
    }
@@ -62,10 +78,20 @@ public class CryptoObject {
        mCrypto = credential;
    }

    /**
     * Create from a {@link PresentationSession} object.
     *
     * @param session a {@link PresentationSession} object.
     */
    public CryptoObject(@NonNull PresentationSession session) {
        mCrypto = session;
    }

    /**
     * Create from a {@link KeyAgreement} object.
     *
     * @param keyAgreement a {@link KeyAgreement} object.
     */
    @FlaggedApi(FLAG_ADD_KEY_AGREEMENT_CRYPTO_OBJECT)
    public CryptoObject(@NonNull KeyAgreement keyAgreement) {
        mCrypto = keyAgreement;
@@ -75,7 +101,7 @@ public class CryptoObject {
     * Get {@link Signature} object.
     * @return {@link Signature} object or null if this doesn't contain one.
     */
    public Signature getSignature() {
    public @Nullable Signature getSignature() {
        return mCrypto instanceof Signature ? (Signature) mCrypto : null;
    }

@@ -83,7 +109,7 @@ public class CryptoObject {
     * Get {@link Cipher} object.
     * @return {@link Cipher} object or null if this doesn't contain one.
     */
    public Cipher getCipher() {
    public @Nullable Cipher getCipher() {
        return mCrypto instanceof Cipher ? (Cipher) mCrypto : null;
    }

@@ -91,7 +117,7 @@ public class CryptoObject {
     * Get {@link Mac} object.
     * @return {@link Mac} object or null if this doesn't contain one.
     */
    public Mac getMac() {
    public @Nullable Mac getMac() {
        return mCrypto instanceof Mac ? (Mac) mCrypto : null;
    }

@@ -101,7 +127,7 @@ public class CryptoObject {
     * @deprecated Use {@link PresentationSession} instead of {@link IdentityCredential}.
     */
    @Deprecated
    public IdentityCredential getIdentityCredential() {
    public @Nullable IdentityCredential getIdentityCredential() {
        return mCrypto instanceof IdentityCredential ? (IdentityCredential) mCrypto : null;
    }

@@ -109,16 +135,18 @@ public class CryptoObject {
     * Get {@link PresentationSession} object.
     * @return {@link PresentationSession} object or null if this doesn't contain one.
     */
    public PresentationSession getPresentationSession() {
    public @Nullable PresentationSession getPresentationSession() {
        return mCrypto instanceof PresentationSession ? (PresentationSession) mCrypto : null;
    }

    /**
     * Get {@link KeyAgreement} object.
     * Get {@link KeyAgreement} object. A key-agreement protocol is a protocol whereby
     * two or more parties can agree on a shared secret using public key cryptography.
     *
     * @return {@link KeyAgreement} object or null if this doesn't contain one.
     */
    @FlaggedApi(FLAG_ADD_KEY_AGREEMENT_CRYPTO_OBJECT)
    public KeyAgreement getKeyAgreement() {
    public @Nullable KeyAgreement getKeyAgreement() {
        return mCrypto instanceof KeyAgreement ? (KeyAgreement) mCrypto : null;
    }