diff options
8 files changed, 73 insertions, 14 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 90ba7ce0c812..a0d416523dbf 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -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; } /** diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 6326f2e6b2bb..0491c732db81 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -8164,6 +8164,13 @@ public final class Settings { 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. * * @hide diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java index 655070722c9a..fafd8333f236 100644 --- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java +++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java @@ -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() { diff --git a/services/core/java/com/android/server/biometrics/AuthenticationClient.java b/services/core/java/com/android/server/biometrics/AuthenticationClient.java index f7278d2601c3..b2c5c053528e 100644 --- a/services/core/java/com/android/server/biometrics/AuthenticationClient.java +++ b/services/core/java/com/android/server/biometrics/AuthenticationClient.java @@ -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(); diff --git a/services/core/java/com/android/server/biometrics/BiometricService.java b/services/core/java/com/android/server/biometrics/BiometricService.java index 153133a6c669..4c59e608398c 100644 --- a/services/core/java/com/android/server/biometrics/BiometricService.java +++ b/services/core/java/com/android/server/biometrics/BiometricService.java @@ -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)); } } diff --git a/services/core/java/com/android/server/biometrics/ClientMonitor.java b/services/core/java/com/android/server/biometrics/ClientMonitor.java index 87b9eaaa9cbb..006558080ef0 100644 --- a/services/core/java/com/android/server/biometrics/ClientMonitor.java +++ b/services/core/java/com/android/server/biometrics/ClientMonitor.java @@ -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()); diff --git a/services/core/java/com/android/server/biometrics/LoggableMonitor.java b/services/core/java/com/android/server/biometrics/LoggableMonitor.java index b0577cd79ac4..9c040884772c 100644 --- a/services/core/java/com/android/server/biometrics/LoggableMonitor.java +++ b/services/core/java/com/android/server/biometrics/LoggableMonitor.java @@ -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) { diff --git a/services/core/java/com/android/server/biometrics/Utils.java b/services/core/java/com/android/server/biometrics/Utils.java new file mode 100644 index 000000000000..5544bede92f2 --- /dev/null +++ b/services/core/java/com/android/server/biometrics/Utils.java @@ -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; + } +} |