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

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

Revert "Add some new modality-specific APIs in BiometricManager."

Revert submission 32295314-fm_to_bm

Reason for revert:b/406937567#comment7
Bug: 406937567

Reverted changes: /q/submissionid:32295314-fm_to_bm

Change-Id: I7c9a506362b74bfe9f876b1191f3f8da4c93cd4c
parent 02adb885
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -4925,20 +4925,6 @@ package android.hardware {
package android.hardware.biometrics {
  @FlaggedApi("android.hardware.biometrics.move_fm_api_to_bm") public final class BiometricEnrollmentStatus implements android.os.Parcelable {
    method public int describeContents();
    method @IntRange(from=0) public int getEnrollCount();
    method public int getModality();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.biometrics.BiometricEnrollmentStatus> CREATOR;
  }
  public class BiometricManager {
    method @FlaggedApi("android.hardware.biometrics.move_fm_api_to_bm") @NonNull @RequiresPermission(android.Manifest.permission.SET_BIOMETRIC_DIALOG_ADVANCED) public java.util.Set<android.hardware.biometrics.BiometricEnrollmentStatus> getEnrollmentStatus();
    field @FlaggedApi("android.hardware.biometrics.move_fm_api_to_bm") @RequiresPermission(android.Manifest.permission.SET_BIOMETRIC_DIALOG_ADVANCED) public static final int TYPE_FACE = 8; // 0x8
    field @FlaggedApi("android.hardware.biometrics.move_fm_api_to_bm") @RequiresPermission(android.Manifest.permission.SET_BIOMETRIC_DIALOG_ADVANCED) public static final int TYPE_FINGERPRINT = 2; // 0x2
  }
  public static interface BiometricManager.Authenticators {
    field @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static final int BIOMETRIC_CONVENIENCE = 4095; // 0xfff
    field @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static final int EMPTY_SET = 0; // 0x0
+0 −19
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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;

// @hide
parcelable BiometricEnrollmentStatus;
+0 −108
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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 android.annotation.FlaggedApi;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * This class contains enrollment information. It keeps track of the modality type (e.g.
 * fingerprint, face) and the number of times the biometric has been enrolled.
 *
 * @hide
 */
@SystemApi
@FlaggedApi(Flags.FLAG_MOVE_FM_API_TO_BM)
public final class BiometricEnrollmentStatus implements Parcelable {
    @BiometricManager.BiometricModality
    private final int mModality;
    private final int mEnrollCount;

    /**
     * @hide
     */
    public BiometricEnrollmentStatus(
            @BiometricManager.BiometricModality int modality, int enrollCount) {
        mModality = modality;
        mEnrollCount = enrollCount;
    }

    /**
     * Returns the modality associated with this enrollment status.
     *
     * @return The int value representing the biometric sensor type, e.g.
     * {@link BiometricManager#TYPE_FACE} or
     * {@link BiometricManager#TYPE_FINGERPRINT}.
     */
    @BiometricManager.BiometricModality
    public int getModality() {
        return mModality;
    }

    /**
     * Returns the number of enrolled biometric for the associated modality.
     *
     * @return The number of enrolled biometric.
     */
    @IntRange(from = 0)
    public int getEnrollCount() {
        return mEnrollCount;
    }

    private BiometricEnrollmentStatus(Parcel in) {
        this(in.readInt(), in.readInt());
    }

    @NonNull
    public static final Creator<BiometricEnrollmentStatus> CREATOR = new Creator<>() {
        @Override
        public BiometricEnrollmentStatus createFromParcel(Parcel in) {
            return new BiometricEnrollmentStatus(in);
        }

        @Override
        public BiometricEnrollmentStatus[] newArray(int size) {
            return new BiometricEnrollmentStatus[size];
        }
    };

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mModality);
        dest.writeInt(mEnrollCount);
    }

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

    @Override
    public String toString() {
        String modality = "";
        if (mModality == BiometricManager.TYPE_FINGERPRINT) {
            modality = "Fingerprint";
        } else if (mModality == BiometricManager.TYPE_FACE) {
            modality = "Face";
        }
        return "Modality: " + modality + ", Enrolled Count: " + mEnrollCount;
    }
}
+2 −65
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.hardware.biometrics;

import static android.Manifest.permission.SET_BIOMETRIC_DIALOG_ADVANCED;
import static android.Manifest.permission.TEST_BIOMETRIC;
import static android.Manifest.permission.USE_BIOMETRIC;
import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;
@@ -46,9 +45,7 @@ import com.android.internal.util.FrameworkStatsLog;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * A class that contains biometric utilities. For authentication, see {@link BiometricPrompt}.
@@ -145,37 +142,6 @@ public class BiometricManager {
    @Retention(RetentionPolicy.SOURCE)
    public @interface BiometricError {}

    /**
     * Constant representing fingerprint.
     * @hide
     */
    @SystemApi
    @FlaggedApi(Flags.FLAG_MOVE_FM_API_TO_BM)
    @RequiresPermission(SET_BIOMETRIC_DIALOG_ADVANCED)
    public static final int TYPE_FINGERPRINT = BiometricAuthenticator.TYPE_FINGERPRINT;

    /**
     * Constant representing face.
     * @hide
     */
    @SystemApi
    @FlaggedApi(Flags.FLAG_MOVE_FM_API_TO_BM)
    @RequiresPermission(SET_BIOMETRIC_DIALOG_ADVANCED)
    public static final int TYPE_FACE = BiometricAuthenticator.TYPE_FACE;

    /**
     * An {@link IntDef} representing the biometric modalities.
     * @hide
     */
    @IntDef(flag = true, value = {
            TYPE_FINGERPRINT,
            TYPE_FACE
    })
    @Retention(RetentionPolicy.SOURCE)
    @interface BiometricModality {
    }


    /**
     * Types of authenticators, defined at a level of granularity supported by
     * {@link BiometricManager} and {@link BiometricPrompt}.
@@ -440,6 +406,8 @@ public class BiometricManager {

    /**
     * @hide
     * @param context
     * @param service
     */
    public BiometricManager(@NonNull Context context, @NonNull IAuthService service) {
        mContext = context;
@@ -598,37 +566,6 @@ public class BiometricManager {
        return new Strings(mContext, mService, authenticators);
    }

    /**
     * Return the current biometrics enrollment status set.
     *
     * <p>Returning more than one status indicates that the device supports multiple biometric
     * modalities (e.g., fingerprint, face, iris). Each {@link BiometricEnrollmentStatus} object
     * within the returned collection provides detailed information about the enrollment state for a
     * particular modality.
     *
     * <p>This method is intended for system apps, such as settings or device setup, which require
     * detailed enrollment information to show or hide features or to encourage users to enroll
     * in a specific modality. Applications should instead use
     * {@link BiometricManager#canAuthenticate(int)} to check the enrollment status and use the
     * enroll intent, when needed to allow users to enroll. That ensures that users are presented
     * with a consistent set of options across all of their apps and can be redirected to a
     * single system-managed settings surface.</p>
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(SET_BIOMETRIC_DIALOG_ADVANCED)
    @FlaggedApi(Flags.FLAG_MOVE_FM_API_TO_BM)
    @NonNull
    public Set<BiometricEnrollmentStatus> getEnrollmentStatus() {
        try {
            return new HashSet<BiometricEnrollmentStatus>(
                    mService.getEnrollmentStatus(mContext.getOpPackageName()));
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @hide
     * @param userId
+0 −4
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.hardware.biometrics.IBiometricServiceReceiver;
import android.hardware.biometrics.IInvalidationCallback;
import android.hardware.biometrics.ITestSession;
import android.hardware.biometrics.ITestSessionCallback;
import android.hardware.biometrics.BiometricEnrollmentStatus;
import android.hardware.biometrics.PromptInfo;
import android.hardware.biometrics.SensorPropertiesInternal;

@@ -65,9 +64,6 @@ interface IAuthService {
    // Checks if any biometrics are enrolled.
    boolean hasEnrolledBiometrics(int userId, String opPackageName);

    // Return the current biometrics enrollment status.
    List<BiometricEnrollmentStatus> getEnrollmentStatus(String opPackageName);

    // Register callback for when keyguard biometric eligibility changes.
    void registerEnabledOnKeyguardCallback(IBiometricEnabledOnKeyguardCallback callback);

Loading