The added files in this CL are mostly copied from SystemUI. Enabling the flag SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS with this CL, the udfps enrollment icons and progress bar are shown in settings. Turn this flag on via adb: adb shell setprop sys.fflag.override.settings_show_udfps_enroll_in_settings true There are some known issues that will be fixed in the following CLs, including: - When the finger is down on the screen and the lighting circle on the sensor is shown, the fingerprint icon is not hidden. - When rotating the screen, fingerprint location is not right. - Currently the scale factor is hard coded for pixel 7 pro, we should update the scale factor based on the device, etc. Test: manually tested on device Bug: 260617060 Change-Id: I5aede070eb1de9eb3b5e1400d6e51a8523079852
127 lines
4.6 KiB
Java
127 lines
4.6 KiB
Java
/*
|
|
* Copyright (C) 2022 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 com.android.settings.biometrics.fingerprint;
|
|
|
|
import android.content.Context;
|
|
import android.hardware.fingerprint.Fingerprint;
|
|
import android.hardware.fingerprint.FingerprintManager;
|
|
import android.os.CancellationSignal;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import com.android.settings.Utils;
|
|
import com.android.settings.safetycenter.BiometricsSafetySource;
|
|
|
|
/**
|
|
* Responsible for making {@link FingerprintManager#enroll} and {@link FingerprintManager#remove}
|
|
* calls and thus updating the fingerprint setting.
|
|
*/
|
|
public class FingerprintUpdater {
|
|
|
|
private final Context mContext;
|
|
private final FingerprintManager mFingerprintManager;
|
|
|
|
public FingerprintUpdater(Context context) {
|
|
mContext = context;
|
|
mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
|
|
}
|
|
|
|
public FingerprintUpdater(Context context, FingerprintManager fingerprintManager) {
|
|
mContext = context;
|
|
mFingerprintManager = fingerprintManager;
|
|
}
|
|
|
|
/** Wrapper around the {@link FingerprintManager#enroll} method. */
|
|
public void enroll(byte [] hardwareAuthToken, CancellationSignal cancel, int userId,
|
|
FingerprintManager.EnrollmentCallback callback,
|
|
@FingerprintManager.EnrollReason int enrollReason) {
|
|
mFingerprintManager.enroll(hardwareAuthToken, cancel, userId,
|
|
new NotifyingEnrollmentCallback(mContext, callback), enrollReason);
|
|
}
|
|
|
|
/** Wrapper around the {@link FingerprintManager#remove} method. */
|
|
public void remove(Fingerprint fp, int userId, FingerprintManager.RemovalCallback callback) {
|
|
mFingerprintManager.remove(fp, userId, new NotifyingRemovalCallback(mContext, callback));
|
|
}
|
|
|
|
/**
|
|
* Decorator of the {@link FingerprintManager.EnrollmentCallback} class that notifies other
|
|
* interested parties that a fingerprint setting has changed.
|
|
*/
|
|
private static class NotifyingEnrollmentCallback
|
|
extends FingerprintManager.EnrollmentCallback {
|
|
|
|
private final Context mContext;
|
|
private final FingerprintManager.EnrollmentCallback mCallback;
|
|
|
|
NotifyingEnrollmentCallback(Context context,
|
|
FingerprintManager.EnrollmentCallback callback) {
|
|
mContext = context;
|
|
mCallback = callback;
|
|
}
|
|
|
|
@Override
|
|
public void onEnrollmentError(int errMsgId, CharSequence errString) {
|
|
mCallback.onEnrollmentError(errMsgId, errString);
|
|
}
|
|
|
|
@Override
|
|
public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
|
|
mCallback.onEnrollmentHelp(helpMsgId, helpString);
|
|
}
|
|
|
|
@Override
|
|
public void onEnrollmentProgress(int remaining) {
|
|
mCallback.onEnrollmentProgress(remaining);
|
|
if (remaining == 0) {
|
|
BiometricsSafetySource.onBiometricsChanged(mContext); // biometrics data changed
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onAcquired(boolean isAcquiredGood) {
|
|
mCallback.onAcquired(isAcquiredGood);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Decorator of the {@link FingerprintManager.RemovalCallback} class that notifies other
|
|
* interested parties that a fingerprint setting has changed.
|
|
*/
|
|
private static class NotifyingRemovalCallback extends FingerprintManager.RemovalCallback {
|
|
|
|
private final Context mContext;
|
|
private final FingerprintManager.RemovalCallback mCallback;
|
|
|
|
NotifyingRemovalCallback(Context context, FingerprintManager.RemovalCallback callback) {
|
|
mContext = context;
|
|
mCallback = callback;
|
|
}
|
|
|
|
@Override
|
|
public void onRemovalError(Fingerprint fp, int errMsgId, CharSequence errString) {
|
|
mCallback.onRemovalError(fp, errMsgId, errString);
|
|
}
|
|
|
|
@Override
|
|
public void onRemovalSucceeded(@Nullable Fingerprint fp, int remaining) {
|
|
mCallback.onRemovalSucceeded(fp, remaining);
|
|
BiometricsSafetySource.onBiometricsChanged(mContext); // biometrics data changed
|
|
}
|
|
}
|
|
}
|