Merge changes from topic "face-logging" into qt-dev

* changes:
  Populate debug value for biometric atoms
  Adding debug value to Biometric atoms.
This commit is contained in:
Kevin Chyn
2019-04-12 00:14:36 +00:00
committed by Android (Google) Code Review
8 changed files with 73 additions and 14 deletions

View File

@@ -3122,6 +3122,8 @@ message BiometricAcquired {
optional int32 acquire_info = 6;
// Vendor-specific acquire info. Valid only if acquire_info == ACQUIRED_VENDOR.
optional int32 acquire_info_vendor = 7;
// Dictates if this message should trigger additional debugging.
optional bool debug = 8;
}
/**
@@ -3158,6 +3160,8 @@ message BiometricAuthenticated {
// AUTHENTICATED. for setRequireConfirmation(true), this is from PENDING_CONFIRMATION to
// CONFIRMED.
optional int64 latency_millis = 7;
// Dictates if this message should trigger additional debugging.
optional bool debug = 8;
}
/**
@@ -3183,6 +3187,8 @@ message BiometricErrorOccurred {
// Vendor-specific error info. Valid only if acquire_info == ACQUIRED_VENDOR. These are defined
// by the vendor and not specified by the HIDL interface.
optional int32 error_info_vendor = 7;
// Dictates if this message should trigger additional debugging.
optional bool debug = 8;
}
/**
@@ -3195,6 +3201,8 @@ message BiometricSystemHealthIssueDetected {
optional android.hardware.biometrics.ModalityEnum modality = 1;
// Type of issue detected.
optional android.hardware.biometrics.IssueEnum issue = 2;
// Dictates if this message should trigger additional debugging.
optional bool debug = 3;
}
/**

View File

@@ -8163,6 +8163,13 @@ public final class Settings {
private static final Validator FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION_VALIDATOR =
BOOLEAN_VALIDATOR;
/**
* Whether or not debugging is enabled.
* @hide
*/
public static final String BIOMETRIC_DEBUG_ENABLED =
"biometric_debug_enabled";
/**
* Whether the assist gesture should be enabled.
*

View File

@@ -708,7 +708,8 @@ public class SettingsBackupTest {
Settings.Secure.FLASHLIGHT_ENABLED,
Settings.Secure.CROSS_PROFILE_CALENDAR_ENABLED,
Settings.Secure.LOCATION_ACCESS_CHECK_INTERVAL_MILLIS,
Settings.Secure.LOCATION_ACCESS_CHECK_DELAY_MILLIS);
Settings.Secure.LOCATION_ACCESS_CHECK_DELAY_MILLIS,
Settings.Secure.BIOMETRIC_DEBUG_ENABLED);
@Test
public void systemSettingsBackedUpOrBlacklisted() {

View File

@@ -120,8 +120,8 @@ public abstract class AuthenticationClient extends ClientMonitor {
@Override
public boolean onAuthenticated(BiometricAuthenticator.Identifier identifier,
boolean authenticated, ArrayList<Byte> token) {
super.logOnAuthenticated(authenticated, mRequireConfirmation, getTargetUserId(),
isBiometricPrompt());
super.logOnAuthenticated(getContext(), authenticated, mRequireConfirmation,
getTargetUserId(), isBiometricPrompt());
final BiometricServiceBase.ServiceListener listener = getListener();

View File

@@ -1054,7 +1054,8 @@ public class BiometricService extends SystemService {
BiometricsProtoEnums.CLIENT_BIOMETRIC_PROMPT,
mCurrentAuthSession.mRequireConfirmation,
StatsLog.BIOMETRIC_AUTHENTICATED__STATE__CONFIRMED,
latency);
latency,
Utils.isDebugEnabled(getContext(), mCurrentAuthSession.mUserId));
} else {
int error = reason == BiometricPrompt.DISMISSED_REASON_NEGATIVE
? BiometricConstants.BIOMETRIC_ERROR_NEGATIVE_BUTTON
@@ -1077,7 +1078,8 @@ public class BiometricService extends SystemService {
BiometricsProtoEnums.ACTION_AUTHENTICATE,
BiometricsProtoEnums.CLIENT_BIOMETRIC_PROMPT,
error,
0 /* vendorCode */);
0 /* vendorCode */,
Utils.isDebugEnabled(getContext(), mCurrentAuthSession.mUserId));
}
}

View File

@@ -157,7 +157,7 @@ public abstract class ClientMonitor extends LoggableMonitor implements IBinder.D
* @return true if client should be removed
*/
public boolean onAcquired(int acquiredInfo, int vendorCode) {
super.logOnAcquired(acquiredInfo, vendorCode, getTargetUserId());
super.logOnAcquired(mContext, acquiredInfo, vendorCode, getTargetUserId());
if (DEBUG) Slog.v(getLogTag(), "Acquired: " + acquiredInfo + " " + vendorCode);
try {
if (mListener != null) {
@@ -182,7 +182,7 @@ public abstract class ClientMonitor extends LoggableMonitor implements IBinder.D
* @return true if client should be removed
*/
public boolean onError(long deviceId, int error, int vendorCode) {
super.logOnError(error, vendorCode, getTargetUserId());
super.logOnError(mContext, error, vendorCode, getTargetUserId());
try {
if (mListener != null) {
mListener.onError(deviceId, error, vendorCode, getCookie());

View File

@@ -16,6 +16,7 @@
package com.android.server.biometrics;
import android.content.Context;
import android.hardware.biometrics.BiometricConstants;
import android.hardware.biometrics.BiometricsProtoEnums;
import android.hardware.face.FaceManager;
@@ -61,7 +62,8 @@ public abstract class LoggableMonitor {
return BiometricsProtoEnums.CLIENT_UNKNOWN;
}
protected final void logOnAcquired(int acquiredInfo, int vendorCode, int targetUserId) {
protected final void logOnAcquired(Context context, int acquiredInfo, int vendorCode,
int targetUserId) {
if (statsModality() == BiometricsProtoEnums.MODALITY_FACE) {
if (acquiredInfo == FaceManager.FACE_ACQUIRED_START) {
mFirstAcquireTimeMs = System.currentTimeMillis();
@@ -87,10 +89,11 @@ public abstract class LoggableMonitor {
statsAction(),
statsClient(),
acquiredInfo,
0 /* vendorCode */); // Don't log vendorCode for now
0 /* vendorCode */, // Don't log vendorCode for now
Utils.isDebugEnabled(context, targetUserId));
}
protected final void logOnError(int error, int vendorCode, int targetUserId) {
protected final void logOnError(Context context, int error, int vendorCode, int targetUserId) {
if (DEBUG) {
Slog.v(TAG, "Error! Modality: " + statsModality()
+ ", User: " + targetUserId
@@ -107,11 +110,12 @@ public abstract class LoggableMonitor {
statsAction(),
statsClient(),
error,
vendorCode);
vendorCode,
Utils.isDebugEnabled(context, targetUserId));
}
protected final void logOnAuthenticated(boolean authenticated, boolean requireConfirmation,
int targetUserId, boolean isBiometricPrompt) {
protected final void logOnAuthenticated(Context context, boolean authenticated,
boolean requireConfirmation, int targetUserId, boolean isBiometricPrompt) {
int authState = StatsLog.BIOMETRIC_AUTHENTICATED__STATE__UNKNOWN;
if (!authenticated) {
authState = StatsLog.BIOMETRIC_AUTHENTICATED__STATE__REJECTED;
@@ -148,7 +152,8 @@ public abstract class LoggableMonitor {
statsClient(),
requireConfirmation,
authState,
latency);
latency,
Utils.isDebugEnabled(context, targetUserId));
}
protected final void logOnEnrolled(int targetUserId, long latency, boolean enrollSuccessful) {

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2019 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.server.biometrics;
import android.content.Context;
import android.os.Build;
import android.provider.Settings;
public class Utils {
public static boolean isDebugEnabled(Context context, int targetUserId) {
if (!(Build.IS_ENG || Build.IS_USERDEBUG)) {
return false;
}
if (Settings.Secure.getIntForUser(context.getContentResolver(),
Settings.Secure.BIOMETRIC_DEBUG_ENABLED, 0,
targetUserId) == 0) {
return false;
}
return true;
}
}