From 7569bb18815437a2f656fc7ff4d57274c5055477 Mon Sep 17 00:00:00 2001 From: Charles He Date: Thu, 11 May 2017 19:51:46 +0100 Subject: [PATCH] Properly remove fingerprints when removing device lock. When strong auth (PIN, password, or pattern) is removed from a user, fingerprints enrolled for that user should also be removed. Then, if the user has a work profile guarded by a unified work challenge, the work profile's fingerprints should also be removed. Previously, when removing the fingerprints of the current user, ChooseLockGeneric checked the finger id of the onRemovalSucceeded() and onRemovalError() callbacks, and assumed the removal had completed when the id was 0. Only after this would it initiate the removal of work profile fingerprints, if any. However, the finger id is actually non-zero even for the user's last fingerprint. This means the work profile fingerprints (under unified challenge) were never removed. Another more visible symptom was that when the user removed the device lock by choosing "None" or "Swipe" in ChooseLockGeneric, the activity failed to exit, since finish() is called only at the end of the removal flow which was not executed. In this CL, we check the number of remaining fingerprints instead of relying on the finger id, thus allowing the removal flow to complete and the activity to finish(). Bug: 37938345 Test: manual, both with and without work profile Test: make SettingsRoboTests Change-Id: Ic04fd01177ad6d4a061023a4b6889af585f8f2b7 --- src/com/android/settings/ChooseLockGeneric.java | 13 +++++++------ .../fingerprint/FingerprintRemoveSidecar.java | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java index 546b11ef51f..49784f68130 100644 --- a/src/com/android/settings/ChooseLockGeneric.java +++ b/src/com/android/settings/ChooseLockGeneric.java @@ -722,15 +722,16 @@ public class ChooseLockGeneric extends SettingsActivity { @Override public void onRemovalError(Fingerprint fp, int errMsgId, CharSequence errString) { - Log.v(TAG, "Fingerprint removed: " + fp.getFingerId()); - if (fp.getFingerId() == 0) { - removeManagedProfileFingerprintsAndFinishIfNecessary(userId); - } + Log.e(TAG, String.format( + "Can't remove fingerprint %d in group %d. Reason: %s", + fp.getFingerId(), fp.getGroupId(), errString)); + // TODO: need to proceed with the removal of managed profile + // fingerprints and finish() gracefully. } @Override - public void onRemovalSucceeded(Fingerprint fingerprint) { - if (fingerprint.getFingerId() == 0) { + public void onRemovalSucceeded(Fingerprint fp, int remaining) { + if (remaining == 0) { removeManagedProfileFingerprintsAndFinishIfNecessary(userId); } } diff --git a/src/com/android/settings/fingerprint/FingerprintRemoveSidecar.java b/src/com/android/settings/fingerprint/FingerprintRemoveSidecar.java index eda4c82da52..462d09ee9e1 100644 --- a/src/com/android/settings/fingerprint/FingerprintRemoveSidecar.java +++ b/src/com/android/settings/fingerprint/FingerprintRemoveSidecar.java @@ -53,7 +53,7 @@ public class FingerprintRemoveSidecar extends InstrumentedPreferenceFragment { private FingerprintManager.RemovalCallback mRemoveCallback = new FingerprintManager.RemovalCallback() { @Override - public void onRemovalSucceeded(Fingerprint fingerprint) { + public void onRemovalSucceeded(Fingerprint fingerprint, int remaining) { if (mListener != null) { mListener.onRemovalSucceeded(fingerprint); } else {