Updated Fingerprint enrollment logging
Test: Verified regular fingerprint enrollment correctly logged
enrollment.
Test: Verified that the find fingerprint sensor activity no longer
falsely reports a failed enrollment.
Bug: 175316123
Fingerprint enrollment shows a find sensor screen which makes a call to
FingerprintManager.enroll(), the purpose is to get the user to locate
the sensor. The consequence was that logging built into the framework
was incorrectly logging a failed enrollment after cancellation.
Change-Id: I4777613fe521f04cc97c471e0a1e85e5809d7f06
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
index 234666f..dc0928a 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
@@ -109,6 +109,7 @@
FingerprintEnrollEnrolling.TAG_SIDECAR);
if (mSidecar == null) {
mSidecar = new FingerprintEnrollSidecar();
+ mSidecar.logMetrics(false);
getSupportFragmentManager().beginTransaction()
.add(mSidecar, FingerprintEnrollEnrolling.TAG_SIDECAR)
.commitAllowingStateLoss();
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollSidecar.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollSidecar.java
index cbd9d4d..73540c9 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollSidecar.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollSidecar.java
@@ -19,7 +19,6 @@
import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.hardware.fingerprint.FingerprintManager;
-import android.os.UserHandle;
import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricEnrollSidecar;
@@ -30,6 +29,7 @@
public class FingerprintEnrollSidecar extends BiometricEnrollSidecar {
private FingerprintManager mFingerprintManager;
+ private boolean mShouldLogMetrics = true;
@Override
public void onAttach(Activity activity) {
@@ -40,7 +40,18 @@
@Override
protected void startEnrollment() {
super.startEnrollment();
- mFingerprintManager.enroll(mToken, mEnrollmentCancel, mUserId, mEnrollmentCallback);
+ mFingerprintManager.enroll(mToken, mEnrollmentCancel, mUserId, mEnrollmentCallback,
+ mShouldLogMetrics);
+ }
+
+ /**
+ * Sets the flag mShouldLogMetrics which controls whether or not
+ * logging of enrollment successes/failures will be recorded for
+ * this particular instance of enrollment. This is primarily used by
+ * the find sensor activity so that false negatives are not reported.
+ */
+ public void logMetrics(boolean shouldLogMetrics) {
+ mShouldLogMetrics = shouldLogMetrics;
}
private FingerprintManager.EnrollmentCallback mEnrollmentCallback
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
index 47edb40..41a5598 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
@@ -20,6 +20,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import android.content.Intent;
@@ -95,7 +96,8 @@
any(byte[].class),
any(CancellationSignal.class),
anyInt(),
- callbackCaptor.capture());
+ callbackCaptor.capture(),
+ eq(true));
return callbackCaptor.getValue();
}
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java
index 465e735..f2ced9c 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java
@@ -21,6 +21,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.robolectric.RuntimeEnvironment.application;
@@ -30,7 +31,6 @@
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintManager.EnrollmentCallback;
import android.os.CancellationSignal;
-import android.widget.Button;
import com.android.settings.R;
import com.android.settings.biometrics.BiometricEnrollBase;
@@ -152,7 +152,8 @@
any(byte[].class),
any(CancellationSignal.class),
anyInt(),
- callbackCaptor.capture());
+ callbackCaptor.capture(),
+ eq(false));
return callbackCaptor.getValue();
}