Merge "Reworked biometric weak check functions"
This commit is contained in:
committed by
Android (Google) Code Review
commit
fee5cb54af
@@ -24,11 +24,15 @@ import android.app.admin.DevicePolicyManager;
|
|||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
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.FileObserver;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.os.storage.IMountService;
|
import android.os.storage.IMountService;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.security.KeyStore;
|
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
|
* Calls back SetupFaceLock to delete the gallery file when the lock type is changed
|
||||||
*/
|
*/
|
||||||
void deleteGallery() {
|
void deleteGallery() {
|
||||||
if(isBiometricEnabled()) {
|
if(usingBiometricWeak()) {
|
||||||
Intent intent = new Intent().setClassName("com.android.facelock",
|
Intent intent = new Intent().setClassName("com.android.facelock",
|
||||||
"com.android.facelock.SetupFaceLock");
|
"com.android.facelock.SetupFaceLock");
|
||||||
intent.putExtra("deleteGallery", true);
|
intent.putExtra("deleteGallery", true);
|
||||||
@@ -677,6 +681,9 @@ public class LockPatternUtils {
|
|||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the lockscreen method is set to biometric weak
|
||||||
|
*/
|
||||||
public boolean usingBiometricWeak() {
|
public boolean usingBiometricWeak() {
|
||||||
int quality =
|
int quality =
|
||||||
(int) getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
|
(int) getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
|
||||||
@@ -810,7 +817,7 @@ public class LockPatternUtils {
|
|||||||
|| backupMode == DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;
|
|| backupMode == DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;
|
||||||
|
|
||||||
return savedPasswordExists() && (passwordEnabled ||
|
return savedPasswordExists() && (passwordEnabled ||
|
||||||
(isBiometricEnabled() && backupEnabled));
|
(usingBiometricWeak() && backupEnabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -824,16 +831,36 @@ public class LockPatternUtils {
|
|||||||
return getBoolean(Settings.Secure.LOCK_PATTERN_ENABLED)
|
return getBoolean(Settings.Secure.LOCK_PATTERN_ENABLED)
|
||||||
&& (getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING)
|
&& (getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING)
|
||||||
== 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() {
|
public boolean isBiometricWeakInstalled() {
|
||||||
// TODO: check if it's installed
|
// Check that the system flag was set
|
||||||
return getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING)
|
if (!SystemProperties.getBoolean("ro.lockscreen.facelock_enabled", false)) {
|
||||||
== DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -531,7 +531,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
|
|||||||
((KeyguardScreen) mUnlockScreen).onResume();
|
((KeyguardScreen) mUnlockScreen).onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLockPatternUtils.usingBiometricWeak()) {
|
if (mLockPatternUtils.usingBiometricWeak() &&
|
||||||
|
mLockPatternUtils.isBiometricWeakInstalled()) {
|
||||||
mHandler.sendEmptyMessage(MSG_SHOW_FACELOCK_AREA_VIEW);
|
mHandler.sendEmptyMessage(MSG_SHOW_FACELOCK_AREA_VIEW);
|
||||||
} else {
|
} else {
|
||||||
mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW);
|
mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW);
|
||||||
@@ -1014,7 +1015,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
|
|||||||
|
|
||||||
// Binds to FaceLock service, but does not tell it to start
|
// Binds to FaceLock service, but does not tell it to start
|
||||||
public void bindToFaceLock() {
|
public void bindToFaceLock() {
|
||||||
if (mLockPatternUtils.usingBiometricWeak()) {
|
if (mLockPatternUtils.usingBiometricWeak() &&
|
||||||
|
mLockPatternUtils.isBiometricWeakInstalled()) {
|
||||||
if (!mBoundToFaceLockService) {
|
if (!mBoundToFaceLockService) {
|
||||||
if (DEBUG) Log.d(TAG, "before bind to FaceLock service");
|
if (DEBUG) Log.d(TAG, "before bind to FaceLock service");
|
||||||
mContext.bindService(new Intent(IFaceLockInterface.class.getName()),
|
mContext.bindService(new Intent(IFaceLockInterface.class.getName()),
|
||||||
@@ -1030,7 +1032,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
|
|||||||
|
|
||||||
// Tells FaceLock to stop and then unbinds from the FaceLock service
|
// Tells FaceLock to stop and then unbinds from the FaceLock service
|
||||||
public void stopAndUnbindFromFaceLock() {
|
public void stopAndUnbindFromFaceLock() {
|
||||||
if (mLockPatternUtils.usingBiometricWeak()) {
|
if (mLockPatternUtils.usingBiometricWeak() &&
|
||||||
|
mLockPatternUtils.isBiometricWeakInstalled()) {
|
||||||
stopFaceLock();
|
stopFaceLock();
|
||||||
|
|
||||||
if (mBoundToFaceLockService) {
|
if (mBoundToFaceLockService) {
|
||||||
@@ -1079,7 +1082,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
|
|||||||
// Tells the FaceLock service to start displaying its UI and perform recognition
|
// Tells the FaceLock service to start displaying its UI and perform recognition
|
||||||
public void startFaceLock(IBinder windowToken, int x, int y, int h, int w)
|
public void startFaceLock(IBinder windowToken, int x, int y, int h, int w)
|
||||||
{
|
{
|
||||||
if (mLockPatternUtils.usingBiometricWeak()) {
|
if (mLockPatternUtils.usingBiometricWeak() &&
|
||||||
|
mLockPatternUtils.isBiometricWeakInstalled()) {
|
||||||
synchronized (mFaceLockServiceRunningLock) {
|
synchronized (mFaceLockServiceRunningLock) {
|
||||||
if (!mFaceLockServiceRunning) {
|
if (!mFaceLockServiceRunning) {
|
||||||
if (DEBUG) Log.d(TAG, "Starting FaceLock");
|
if (DEBUG) Log.d(TAG, "Starting FaceLock");
|
||||||
@@ -1099,7 +1103,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
|
|||||||
// Tells the FaceLock service to stop displaying its UI and stop recognition
|
// Tells the FaceLock service to stop displaying its UI and stop recognition
|
||||||
public void stopFaceLock()
|
public void stopFaceLock()
|
||||||
{
|
{
|
||||||
if (mLockPatternUtils.usingBiometricWeak()) {
|
if (mLockPatternUtils.usingBiometricWeak() &&
|
||||||
|
mLockPatternUtils.isBiometricWeakInstalled()) {
|
||||||
// Note that attempting to stop FaceLock when it's not running is not an issue.
|
// Note that attempting to stop FaceLock when it's not running is not an issue.
|
||||||
// FaceLock can return, which stops it and then we try to stop it when the
|
// FaceLock can return, which stops it and then we try to stop it when the
|
||||||
// screen is turned off. That's why we check.
|
// screen is turned off. That's why we check.
|
||||||
|
|||||||
Reference in New Issue
Block a user