From 329979c9e6cecbcec470ec6f3ac41da82ca58d3f Mon Sep 17 00:00:00 2001 From: Steven Ross Date: Wed, 28 Sep 2011 11:42:56 -0400 Subject: [PATCH] calling back SetupFaceLock to clean up temporary gallery This is done when the backup lock is complete or canceled. If successful, the permanent gallery is replaced with the new one. If canceled, the temporary gallery is deleted Also deletes the main gallery if the lock type is changed from facial recognition Change-Id: Id1ce804dec6b71b6410af53c050ad265c4cad5b0 --- .../internal/widget/LockPatternUtils.java | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index 81e7c34709a3d..3795a7c430b3c 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -23,6 +23,7 @@ import com.google.android.collect.Lists; import android.app.admin.DevicePolicyManager; import android.content.ContentResolver; import android.content.Context; +import android.content.Intent; import android.os.FileObserver; import android.os.IBinder; import android.os.RemoteException; @@ -125,6 +126,8 @@ public class LockPatternUtils { private static FileObserver sPasswordObserver; + private static boolean mLastAttemptWasBiometric = false; + private static class PasswordFileObserver extends FileObserver { public PasswordFileObserver(String path, int mask) { super(path, mask); @@ -371,7 +374,8 @@ public class LockPatternUtils { /** * Clear any lock pattern or password. */ - public void clearLock() { + public void clearLock(boolean isFallback) { + if(!isFallback) deleteGallery(); saveLockPassword(null, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); setLockPatternEnabled(false); saveLockPattern(null); @@ -389,6 +393,13 @@ public class LockPatternUtils { setLong(DISABLE_LOCKSCREEN_KEY, disable ? 1 : 0); } + /** + * Sets whether the last lockscreen setup attempt was biometric + */ + public static void setLastAttemptWasBiometric(boolean val) { + mLastAttemptWasBiometric = val; + } + /** * Determine if LockScreen can be disabled. This is used, for example, to tell if we should * show LockScreen or go straight to the home screen. @@ -407,6 +418,41 @@ public class LockPatternUtils { this.saveLockPattern(pattern, false); } + /** + * Calls back SetupFaceLock to save the temporary gallery file if this is the backup lock. + * This doesn't have to verify that biometric is enabled because it's only called in that case + */ + void moveTempGallery() { + Intent intent = new Intent().setClassName("com.android.facelock", + "com.android.facelock.SetupFaceLock"); + intent.putExtra("moveTempGallery", true); + mContext.startActivity(intent); + } + + /** + * Calls back SetupFaceLock to delete the temporary gallery file if this is the backup lock. + */ + public void deleteTempGallery() { + //if(mLastAttemptWasBiometric) { + Intent intent = new Intent().setClassName("com.android.facelock", + "com.android.facelock.SetupFaceLock"); + intent.putExtra("deleteTempGallery", true); + mContext.startActivity(intent); + //} + } + + /** + * Calls back SetupFaceLock to delete the gallery file when the lock type is changed + */ + void deleteGallery() { + if(isBiometricEnabled()) { + Intent intent = new Intent().setClassName("com.android.facelock", + "com.android.facelock.SetupFaceLock"); + intent.putExtra("deleteGallery", true); + mContext.startActivity(intent); + } + } + /** * Save a lock pattern. * @param pattern The new pattern to save. @@ -431,11 +477,13 @@ public class LockPatternUtils { keyStore.password(patternToString(pattern)); setBoolean(PATTERN_EVER_CHOSEN_KEY, true); if (!isFallback) { + deleteGallery(); setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); } else { setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK); setLong(PASSWORD_TYPE_ALTERNATE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); + moveTempGallery(); } dpm.setActivePasswordState(DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, pattern .size(), 0, 0, 0, 0, 0, 0); @@ -547,10 +595,12 @@ public class LockPatternUtils { int computedQuality = computePasswordQuality(password); if (!isFallback) { + deleteGallery(); setLong(PASSWORD_TYPE_KEY, Math.max(quality, computedQuality)); } else { setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK); setLong(PASSWORD_TYPE_ALTERNATE_KEY, Math.max(quality, computedQuality)); + moveTempGallery(); } if (computedQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) { int letters = 0;