Skip to content

Commit 329979c

Browse files
author
Steven Ross
committed
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
1 parent 29af074 commit 329979c

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

core/java/com/android/internal/widget/LockPatternUtils.java

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import android.app.admin.DevicePolicyManager;
2424
import android.content.ContentResolver;
2525
import android.content.Context;
26+
import android.content.Intent;
2627
import android.os.FileObserver;
2728
import android.os.IBinder;
2829
import android.os.RemoteException;
@@ -125,6 +126,8 @@ public class LockPatternUtils {
125126

126127
private static FileObserver sPasswordObserver;
127128

129+
private static boolean mLastAttemptWasBiometric = false;
130+
128131
private static class PasswordFileObserver extends FileObserver {
129132
public PasswordFileObserver(String path, int mask) {
130133
super(path, mask);
@@ -371,7 +374,8 @@ public int getActivePasswordQuality() {
371374
/**
372375
* Clear any lock pattern or password.
373376
*/
374-
public void clearLock() {
377+
public void clearLock(boolean isFallback) {
378+
if(!isFallback) deleteGallery();
375379
saveLockPassword(null, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
376380
setLockPatternEnabled(false);
377381
saveLockPattern(null);
@@ -389,6 +393,13 @@ public void setLockScreenDisabled(boolean disable) {
389393
setLong(DISABLE_LOCKSCREEN_KEY, disable ? 1 : 0);
390394
}
391395

396+
/**
397+
* Sets whether the last lockscreen setup attempt was biometric
398+
*/
399+
public static void setLastAttemptWasBiometric(boolean val) {
400+
mLastAttemptWasBiometric = val;
401+
}
402+
392403
/**
393404
* Determine if LockScreen can be disabled. This is used, for example, to tell if we should
394405
* show LockScreen or go straight to the home screen.
@@ -407,6 +418,41 @@ public void saveLockPattern(List<LockPatternView.Cell> pattern) {
407418
this.saveLockPattern(pattern, false);
408419
}
409420

421+
/**
422+
* Calls back SetupFaceLock to save the temporary gallery file if this is the backup lock.
423+
* This doesn't have to verify that biometric is enabled because it's only called in that case
424+
*/
425+
void moveTempGallery() {
426+
Intent intent = new Intent().setClassName("com.android.facelock",
427+
"com.android.facelock.SetupFaceLock");
428+
intent.putExtra("moveTempGallery", true);
429+
mContext.startActivity(intent);
430+
}
431+
432+
/**
433+
* Calls back SetupFaceLock to delete the temporary gallery file if this is the backup lock.
434+
*/
435+
public void deleteTempGallery() {
436+
//if(mLastAttemptWasBiometric) {
437+
Intent intent = new Intent().setClassName("com.android.facelock",
438+
"com.android.facelock.SetupFaceLock");
439+
intent.putExtra("deleteTempGallery", true);
440+
mContext.startActivity(intent);
441+
//}
442+
}
443+
444+
/**
445+
* Calls back SetupFaceLock to delete the gallery file when the lock type is changed
446+
*/
447+
void deleteGallery() {
448+
if(isBiometricEnabled()) {
449+
Intent intent = new Intent().setClassName("com.android.facelock",
450+
"com.android.facelock.SetupFaceLock");
451+
intent.putExtra("deleteGallery", true);
452+
mContext.startActivity(intent);
453+
}
454+
}
455+
410456
/**
411457
* Save a lock pattern.
412458
* @param pattern The new pattern to save.
@@ -431,11 +477,13 @@ public void saveLockPattern(List<LockPatternView.Cell> pattern, boolean isFallba
431477
keyStore.password(patternToString(pattern));
432478
setBoolean(PATTERN_EVER_CHOSEN_KEY, true);
433479
if (!isFallback) {
480+
deleteGallery();
434481
setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
435482
} else {
436483
setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK);
437484
setLong(PASSWORD_TYPE_ALTERNATE_KEY,
438485
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
486+
moveTempGallery();
439487
}
440488
dpm.setActivePasswordState(DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, pattern
441489
.size(), 0, 0, 0, 0, 0, 0);
@@ -547,10 +595,12 @@ public void saveLockPassword(String password, int quality, boolean isFallback) {
547595

548596
int computedQuality = computePasswordQuality(password);
549597
if (!isFallback) {
598+
deleteGallery();
550599
setLong(PASSWORD_TYPE_KEY, Math.max(quality, computedQuality));
551600
} else {
552601
setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK);
553602
setLong(PASSWORD_TYPE_ALTERNATE_KEY, Math.max(quality, computedQuality));
603+
moveTempGallery();
554604
}
555605
if (computedQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
556606
int letters = 0;

0 commit comments

Comments
 (0)