diff options
author | Danielle Millett <dmillett@google.com> | 2011-10-03 17:38:47 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-10-03 17:38:47 -0700 |
commit | fee5cb54af9c86c045f1cb5d129c2cc395fe56db (patch) | |
tree | db9bff6fc382303a8fdf385267b76e10ab887b5d /core/java/com | |
parent | 7d657e5cfacec1f0be845c86dd4336e7efde5ede (diff) | |
parent | 58396984ef49080d5550919130fc0d869ccf840b (diff) | |
download | frameworks_base-fee5cb54af9c86c045f1cb5d129c2cc395fe56db.zip frameworks_base-fee5cb54af9c86c045f1cb5d129c2cc395fe56db.tar.gz frameworks_base-fee5cb54af9c86c045f1cb5d129c2cc395fe56db.tar.bz2 |
Merge "Reworked biometric weak check functions"
Diffstat (limited to 'core/java/com')
-rw-r--r-- | core/java/com/android/internal/widget/LockPatternUtils.java | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index 4a38775..a793abb 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -24,11 +24,15 @@ import android.app.admin.DevicePolicyManager; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; +import android.hardware.Camera; +import android.hardware.Camera.CameraInfo; import android.os.FileObserver; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; +import android.os.SystemProperties; import android.os.storage.IMountService; import android.provider.Settings; import android.security.KeyStore; @@ -434,7 +438,7 @@ public class LockPatternUtils { * Calls back SetupFaceLock to delete the gallery file when the lock type is changed */ void deleteGallery() { - if(isBiometricEnabled()) { + if(usingBiometricWeak()) { Intent intent = new Intent().setClassName("com.android.facelock", "com.android.facelock.SetupFaceLock"); intent.putExtra("deleteGallery", true); @@ -677,6 +681,9 @@ public class LockPatternUtils { return quality; } + /** + * @return true if the lockscreen method is set to biometric weak + */ public boolean usingBiometricWeak() { int quality = (int) getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); @@ -810,7 +817,7 @@ public class LockPatternUtils { || backupMode == DevicePolicyManager.PASSWORD_QUALITY_COMPLEX; return savedPasswordExists() && (passwordEnabled || - (isBiometricEnabled() && backupEnabled)); + (usingBiometricWeak() && backupEnabled)); } /** @@ -824,16 +831,36 @@ public class LockPatternUtils { return getBoolean(Settings.Secure.LOCK_PATTERN_ENABLED) && (getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING || - (isBiometricEnabled() && backupEnabled)); + (usingBiometricWeak() && backupEnabled)); } /** - * @return Whether biometric weak lock is enabled. + * @return Whether biometric weak lock is installed and that the front facing camera exists */ - public boolean isBiometricEnabled() { - // TODO: check if it's installed - return getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) - == DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK; + public boolean isBiometricWeakInstalled() { + // Check that the system flag was set + if (!SystemProperties.getBoolean("ro.lockscreen.facelock_enabled", false)) { + return false; + } + + // Check that it's installed + PackageManager pm = mContext.getPackageManager(); + try { + pm.getPackageInfo("com.android.facelock", PackageManager.GET_ACTIVITIES); + } catch (PackageManager.NameNotFoundException e) { + return false; + } + + // Check that the camera is enabled + if (!pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) { + return false; + } + if (getDevicePolicyManager().getCameraDisabled(null)) { + return false; + } + + + return true; } /** |