Read and cache features when user switches
Bug: 163830899 Test: Verified feature is stored to secure setting. 1. Flashed flame device to QDA release build 2. Verified require_attention was being reported as 1 3. Flashed to most recent change, verified require_attention setting was upated to 0. Change-Id: I0187e27b641edf0836fa187530cb2a193082fe5d
This commit is contained in:
committed by
Joshua Mccloskey
parent
056630f142
commit
1cae475b47
@@ -25,12 +25,14 @@ import android.app.UserSwitchObserver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.hardware.biometrics.BiometricConstants;
|
import android.hardware.biometrics.BiometricConstants;
|
||||||
|
import android.hardware.biometrics.BiometricFaceConstants;
|
||||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||||
import android.hardware.biometrics.face.V1_0.IBiometricsFace;
|
import android.hardware.biometrics.face.V1_0.IBiometricsFace;
|
||||||
import android.hardware.biometrics.face.V1_0.IBiometricsFaceClientCallback;
|
import android.hardware.biometrics.face.V1_0.IBiometricsFaceClientCallback;
|
||||||
import android.hardware.face.Face;
|
import android.hardware.face.Face;
|
||||||
import android.hardware.face.FaceSensorProperties;
|
import android.hardware.face.FaceSensorProperties;
|
||||||
import android.hardware.face.IFaceServiceReceiver;
|
import android.hardware.face.IFaceServiceReceiver;
|
||||||
|
import android.os.Binder;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -109,6 +111,9 @@ class Face10 implements IHwBinder.DeathRecipient {
|
|||||||
@Override
|
@Override
|
||||||
public void onUserSwitching(int newUserId) {
|
public void onUserSwitching(int newUserId) {
|
||||||
scheduleInternalCleanup(newUserId);
|
scheduleInternalCleanup(newUserId);
|
||||||
|
scheduleGetFeature(new Binder(), newUserId,
|
||||||
|
BiometricFaceConstants.FEATURE_REQUIRE_ATTENTION,
|
||||||
|
null, mContext.getOpPackageName());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -360,6 +365,9 @@ class Face10 implements IHwBinder.DeathRecipient {
|
|||||||
if (halId != 0) {
|
if (halId != 0) {
|
||||||
scheduleLoadAuthenticatorIds();
|
scheduleLoadAuthenticatorIds();
|
||||||
scheduleInternalCleanup(ActivityManager.getCurrentUser());
|
scheduleInternalCleanup(ActivityManager.getCurrentUser());
|
||||||
|
scheduleGetFeature(new Binder(), ActivityManager.getCurrentUser(),
|
||||||
|
BiometricFaceConstants.FEATURE_REQUIRE_ATTENTION,
|
||||||
|
null, mContext.getOpPackageName());
|
||||||
} else {
|
} else {
|
||||||
Slog.e(TAG, "Unable to set callback");
|
Slog.e(TAG, "Unable to set callback");
|
||||||
mDaemon = null;
|
mDaemon = null;
|
||||||
@@ -450,7 +458,7 @@ class Face10 implements IHwBinder.DeathRecipient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void scheduleGetFeature(@NonNull IBinder token, int userId, int feature,
|
void scheduleGetFeature(@NonNull IBinder token, int userId, int feature,
|
||||||
@NonNull IFaceServiceReceiver receiver, @NonNull String opPackageName) {
|
@Nullable ClientMonitorCallbackConverter listener, @NonNull String opPackageName) {
|
||||||
mHandler.post(() -> {
|
mHandler.post(() -> {
|
||||||
final List<Face> faces = getEnrolledFaces(userId);
|
final List<Face> faces = getEnrolledFaces(userId);
|
||||||
if (faces.isEmpty()) {
|
if (faces.isEmpty()) {
|
||||||
@@ -461,10 +469,22 @@ class Face10 implements IHwBinder.DeathRecipient {
|
|||||||
scheduleUpdateActiveUserWithoutHandler(userId);
|
scheduleUpdateActiveUserWithoutHandler(userId);
|
||||||
|
|
||||||
final int faceId = faces.get(0).getBiometricId();
|
final int faceId = faces.get(0).getBiometricId();
|
||||||
final FaceGetFeatureClient client = new FaceGetFeatureClient(mContext,
|
final FaceGetFeatureClient client = new FaceGetFeatureClient(mContext, mLazyDaemon,
|
||||||
mLazyDaemon, token, new ClientMonitorCallbackConverter(receiver), userId,
|
token, listener, userId, opPackageName, mSensorId, feature, faceId);
|
||||||
opPackageName, mSensorId, feature, faceId);
|
mScheduler.scheduleClientMonitor(client, new ClientMonitor.Callback() {
|
||||||
mScheduler.scheduleClientMonitor(client);
|
@Override
|
||||||
|
public void onClientFinished(
|
||||||
|
@NonNull ClientMonitor<?> clientMonitor, boolean success) {
|
||||||
|
if (success && feature == BiometricFaceConstants.FEATURE_REQUIRE_ATTENTION) {
|
||||||
|
final int settingsValue = client.getValue() ? 1 : 0;
|
||||||
|
Slog.d(TAG, "Updating attention value for user: " + userId
|
||||||
|
+ " to value: " + settingsValue);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.FACE_UNLOCK_ATTENTION_REQUIRED,
|
||||||
|
settingsValue, userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.server.biometrics.sensors.face;
|
package com.android.server.biometrics.sensors.face;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||||
import android.hardware.biometrics.face.V1_0.IBiometricsFace;
|
import android.hardware.biometrics.face.V1_0.IBiometricsFace;
|
||||||
@@ -39,9 +40,10 @@ public class FaceGetFeatureClient extends ClientMonitor<IBiometricsFace> {
|
|||||||
|
|
||||||
private final int mFeature;
|
private final int mFeature;
|
||||||
private final int mFaceId;
|
private final int mFaceId;
|
||||||
|
private boolean mValue;
|
||||||
|
|
||||||
FaceGetFeatureClient(@NonNull Context context, @NonNull LazyDaemon<IBiometricsFace> lazyDaemon,
|
FaceGetFeatureClient(@NonNull Context context, @NonNull LazyDaemon<IBiometricsFace> lazyDaemon,
|
||||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener, int userId,
|
@NonNull IBinder token, @Nullable ClientMonitorCallbackConverter listener, int userId,
|
||||||
@NonNull String owner, int sensorId, int feature, int faceId) {
|
@NonNull String owner, int sensorId, int feature, int faceId) {
|
||||||
super(context, lazyDaemon, token, listener, userId, owner, 0 /* cookie */, sensorId,
|
super(context, lazyDaemon, token, listener, userId, owner, 0 /* cookie */, sensorId,
|
||||||
BiometricsProtoEnums.MODALITY_UNKNOWN, BiometricsProtoEnums.ACTION_UNKNOWN,
|
BiometricsProtoEnums.MODALITY_UNKNOWN, BiometricsProtoEnums.ACTION_UNKNOWN,
|
||||||
@@ -54,7 +56,9 @@ public class FaceGetFeatureClient extends ClientMonitor<IBiometricsFace> {
|
|||||||
@Override
|
@Override
|
||||||
public void unableToStart() {
|
public void unableToStart() {
|
||||||
try {
|
try {
|
||||||
getListener().onFeatureGet(false /* success */, mFeature, false /* value */);
|
if (getListener() != null) {
|
||||||
|
getListener().onFeatureGet(false /* success */, mFeature, false /* value */);
|
||||||
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.e(TAG, "Unable to send error", e);
|
Slog.e(TAG, "Unable to send error", e);
|
||||||
}
|
}
|
||||||
@@ -70,11 +74,18 @@ public class FaceGetFeatureClient extends ClientMonitor<IBiometricsFace> {
|
|||||||
protected void startHalOperation() {
|
protected void startHalOperation() {
|
||||||
try {
|
try {
|
||||||
final OptionalBool result = getFreshDaemon().getFeature(mFeature, mFaceId);
|
final OptionalBool result = getFreshDaemon().getFeature(mFeature, mFaceId);
|
||||||
getListener().onFeatureGet(result.status == Status.OK, mFeature, result.value);
|
mValue = result.value;
|
||||||
|
if (getListener() != null) {
|
||||||
|
getListener().onFeatureGet(result.status == Status.OK, mFeature, mValue);
|
||||||
|
}
|
||||||
mCallback.onClientFinished(this, true /* success */);
|
mCallback.onClientFinished(this, true /* success */);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.e(TAG, "Unable to getFeature", e);
|
Slog.e(TAG, "Unable to getFeature", e);
|
||||||
mCallback.onClientFinished(this, false /* success */);
|
mCallback.onClientFinished(this, false /* success */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean getValue() {
|
||||||
|
return mValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ import android.hardware.biometrics.BiometricsProtoEnums;
|
|||||||
import android.hardware.biometrics.IBiometricSensorReceiver;
|
import android.hardware.biometrics.IBiometricSensorReceiver;
|
||||||
import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
|
import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
|
||||||
import android.hardware.face.Face;
|
import android.hardware.face.Face;
|
||||||
|
import android.hardware.face.FaceSensorProperties;
|
||||||
import android.hardware.face.IFaceService;
|
import android.hardware.face.IFaceService;
|
||||||
import android.hardware.face.IFaceServiceReceiver;
|
import android.hardware.face.IFaceServiceReceiver;
|
||||||
import android.hardware.face.FaceSensorProperties;
|
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.NativeHandle;
|
import android.os.NativeHandle;
|
||||||
@@ -303,7 +303,8 @@ public class FaceService extends SystemService {
|
|||||||
public void getFeature(final IBinder token, int userId, int feature,
|
public void getFeature(final IBinder token, int userId, int feature,
|
||||||
IFaceServiceReceiver receiver, final String opPackageName) {
|
IFaceServiceReceiver receiver, final String opPackageName) {
|
||||||
Utils.checkPermission(getContext(), MANAGE_BIOMETRIC);
|
Utils.checkPermission(getContext(), MANAGE_BIOMETRIC);
|
||||||
mFace10.scheduleGetFeature(token, userId, feature, receiver, opPackageName);
|
mFace10.scheduleGetFeature(token, userId, feature,
|
||||||
|
new ClientMonitorCallbackConverter(receiver), opPackageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
|
|||||||
Reference in New Issue
Block a user