summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Ross <stross@google.com> 2011-09-28 11:42:56 -0400
committer Steven Ross <stross@google.com> 2011-09-29 16:00:59 -0400
commit329979c9e6cecbcec470ec6f3ac41da82ca58d3f (patch)
treef6666cf770c270ac29db70ecc246193ae329f5e7
parent29af07443607b21c943c9adc0ffb34331135ad3e (diff)
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
-rw-r--r--core/java/com/android/internal/widget/LockPatternUtils.java52
1 files changed, 51 insertions, 1 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index 81e7c34709a3..3795a7c430b3 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);
@@ -390,6 +394,13 @@ public class LockPatternUtils {
}
/**
+ * 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.
*
@@ -408,6 +419,41 @@ public class LockPatternUtils {
}
/**
+ * 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.
* @param isFallback Specifies if this is a fallback to biometric weak
@@ -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;