Loading Android.mk +2 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,8 @@ LOCAL_SRC_FILES += \ core/java/com/android/internal/appwidget/IAppWidgetService.aidl \ core/java/com/android/internal/appwidget/IAppWidgetHost.aidl \ core/java/com/android/internal/backup/IBackupTransport.aidl \ core/java/com/android/internal/policy/IFaceLockCallback.aidl \ core/java/com/android/internal/policy/IFaceLockInterface.aidl \ core/java/com/android/internal/os/IDropBoxManagerService.aidl \ core/java/com/android/internal/os/IResultReceiver.aidl \ core/java/com/android/internal/statusbar/IStatusBar.aidl \ Loading core/java/com/android/internal/policy/IFaceLockCallback.aidl 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.policy; import android.os.IBinder; /** {@hide} */ oneway interface IFaceLockCallback { void unlock(); void cancel(); void sleepDevice(); } core/java/com/android/internal/policy/IFaceLockInterface.aidl 0 → 100644 +26 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.policy; import android.os.IBinder; import com.android.internal.policy.IFaceLockCallback; /** {@hide} */ interface IFaceLockInterface { void startUi(IBinder containingWindowToken, int x, int y, int width, int height); void stopUi(); void registerCallback(IFaceLockCallback cb); } core/java/com/android/internal/widget/LockPatternUtils.java +65 −4 Original line number Diff line number Diff line Loading @@ -106,8 +106,11 @@ public class LockPatternUtils { private final static String LOCKOUT_ATTEMPT_DEADLINE = "lockscreen.lockoutattemptdeadline"; private final static String PATTERN_EVER_CHOSEN_KEY = "lockscreen.patterneverchosen"; public final static String PASSWORD_TYPE_KEY = "lockscreen.password_type"; public static final String PASSWORD_TYPE_ALTERNATE_KEY = "lockscreen.password_type_alternate"; private final static String LOCK_PASSWORD_SALT_KEY = "lockscreen.password_salt"; private final static String DISABLE_LOCKSCREEN_KEY = "lockscreen.disabled"; public final static String LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK = "lockscreen.biometric_weak_fallback"; private final static String PASSWORD_HISTORY_KEY = "lockscreen.passwordhistory"; Loading Loading @@ -373,6 +376,7 @@ public class LockPatternUtils { setLockPatternEnabled(false); saveLockPattern(null); setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); setLong(PASSWORD_TYPE_ALTERNATE_KEY, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED); } /** Loading Loading @@ -400,6 +404,15 @@ public class LockPatternUtils { * @param pattern The new pattern to save. */ public void saveLockPattern(List<LockPatternView.Cell> pattern) { this.saveLockPattern(pattern, false); } /** * Save a lock pattern. * @param pattern The new pattern to save. * @param isFallback Specifies if this is a fallback to biometric weak */ public void saveLockPattern(List<LockPatternView.Cell> pattern, boolean isFallback) { // Compute the hash final byte[] hash = LockPatternUtils.patternToHash(pattern); try { Loading @@ -417,7 +430,13 @@ public class LockPatternUtils { if (pattern != null) { keyStore.password(patternToString(pattern)); setBoolean(PATTERN_EVER_CHOSEN_KEY, true); if (!isFallback) { 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); } dpm.setActivePasswordState(DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, pattern .size(), 0, 0, 0, 0, 0, 0); } else { Loading Loading @@ -493,6 +512,18 @@ public class LockPatternUtils { * @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} */ public void saveLockPassword(String password, int quality) { this.saveLockPassword(password, quality, false); } /** * Save a lock password. Does not ensure that the password is as good * as the requested mode, but will adjust the mode to be as good as the * pattern. * @param password The password to save * @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} * @param isFallback Specifies if this is a fallback to biometric weak */ public void saveLockPassword(String password, int quality, boolean isFallback) { // Compute the hash final byte[] hash = passwordToHash(password); try { Loading @@ -515,7 +546,12 @@ public class LockPatternUtils { keyStore.password(password); int computedQuality = computePasswordQuality(password); if (!isFallback) { 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)); } if (computedQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) { int letters = 0; int uppercase = 0; Loading Loading @@ -590,7 +626,22 @@ public class LockPatternUtils { * @return stored password quality */ public int getKeyguardStoredPasswordQuality() { return (int) getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); int quality = (int) getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); // If the user has chosen to use weak biometric sensor, then return the backup locking // method and treat biometric as a special case. if (quality == DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK) { quality = (int) getLong(PASSWORD_TYPE_ALTERNATE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); } return quality; } public boolean usingBiometricWeak() { int quality = (int) getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); return quality == DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK; } /** Loading Loading @@ -725,6 +776,15 @@ public class LockPatternUtils { == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING; } /** * @return Whether biometric weak lock is enabled. */ public boolean isBiometricEnabled() { // TODO: check if it's installed return getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) == DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK; } /** * Set whether the lock pattern is enabled. */ Loading Loading @@ -863,7 +923,8 @@ public class LockPatternUtils { || mode == DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC || mode == DevicePolicyManager.PASSWORD_QUALITY_COMPLEX; final boolean secure = isPattern && isLockPatternEnabled() && savedPatternExists() || isPassword && savedPasswordExists(); || isPassword && savedPasswordExists() || usingBiometricWeak() && isBiometricEnabled(); return secure; } Loading policy/src/com/android/internal/policy/impl/KeyguardViewBase.java +9 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,15 @@ public abstract class KeyguardViewBase extends FrameLayout { */ abstract public void cleanUp(); /** * These were added to support FaceLock because the KeyguardViewManager needs to tell the * LockPatternKeyguardView when to bind and and unbind with FaceLock service. Although * implemented in LockPatternKeyguardView, these are not implemented in anything else * derived from KeyguardViewBase */ abstract public void bindToFaceLock(); abstract public void stopAndUnbindFromFaceLock(); @Override public boolean dispatchKeyEvent(KeyEvent event) { if (shouldEventKeepScreenOnWhileKeyguardShowing(event)) { Loading Loading
Android.mk +2 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,8 @@ LOCAL_SRC_FILES += \ core/java/com/android/internal/appwidget/IAppWidgetService.aidl \ core/java/com/android/internal/appwidget/IAppWidgetHost.aidl \ core/java/com/android/internal/backup/IBackupTransport.aidl \ core/java/com/android/internal/policy/IFaceLockCallback.aidl \ core/java/com/android/internal/policy/IFaceLockInterface.aidl \ core/java/com/android/internal/os/IDropBoxManagerService.aidl \ core/java/com/android/internal/os/IResultReceiver.aidl \ core/java/com/android/internal/statusbar/IStatusBar.aidl \ Loading
core/java/com/android/internal/policy/IFaceLockCallback.aidl 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.policy; import android.os.IBinder; /** {@hide} */ oneway interface IFaceLockCallback { void unlock(); void cancel(); void sleepDevice(); }
core/java/com/android/internal/policy/IFaceLockInterface.aidl 0 → 100644 +26 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.policy; import android.os.IBinder; import com.android.internal.policy.IFaceLockCallback; /** {@hide} */ interface IFaceLockInterface { void startUi(IBinder containingWindowToken, int x, int y, int width, int height); void stopUi(); void registerCallback(IFaceLockCallback cb); }
core/java/com/android/internal/widget/LockPatternUtils.java +65 −4 Original line number Diff line number Diff line Loading @@ -106,8 +106,11 @@ public class LockPatternUtils { private final static String LOCKOUT_ATTEMPT_DEADLINE = "lockscreen.lockoutattemptdeadline"; private final static String PATTERN_EVER_CHOSEN_KEY = "lockscreen.patterneverchosen"; public final static String PASSWORD_TYPE_KEY = "lockscreen.password_type"; public static final String PASSWORD_TYPE_ALTERNATE_KEY = "lockscreen.password_type_alternate"; private final static String LOCK_PASSWORD_SALT_KEY = "lockscreen.password_salt"; private final static String DISABLE_LOCKSCREEN_KEY = "lockscreen.disabled"; public final static String LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK = "lockscreen.biometric_weak_fallback"; private final static String PASSWORD_HISTORY_KEY = "lockscreen.passwordhistory"; Loading Loading @@ -373,6 +376,7 @@ public class LockPatternUtils { setLockPatternEnabled(false); saveLockPattern(null); setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); setLong(PASSWORD_TYPE_ALTERNATE_KEY, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED); } /** Loading Loading @@ -400,6 +404,15 @@ public class LockPatternUtils { * @param pattern The new pattern to save. */ public void saveLockPattern(List<LockPatternView.Cell> pattern) { this.saveLockPattern(pattern, false); } /** * Save a lock pattern. * @param pattern The new pattern to save. * @param isFallback Specifies if this is a fallback to biometric weak */ public void saveLockPattern(List<LockPatternView.Cell> pattern, boolean isFallback) { // Compute the hash final byte[] hash = LockPatternUtils.patternToHash(pattern); try { Loading @@ -417,7 +430,13 @@ public class LockPatternUtils { if (pattern != null) { keyStore.password(patternToString(pattern)); setBoolean(PATTERN_EVER_CHOSEN_KEY, true); if (!isFallback) { 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); } dpm.setActivePasswordState(DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, pattern .size(), 0, 0, 0, 0, 0, 0); } else { Loading Loading @@ -493,6 +512,18 @@ public class LockPatternUtils { * @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} */ public void saveLockPassword(String password, int quality) { this.saveLockPassword(password, quality, false); } /** * Save a lock password. Does not ensure that the password is as good * as the requested mode, but will adjust the mode to be as good as the * pattern. * @param password The password to save * @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} * @param isFallback Specifies if this is a fallback to biometric weak */ public void saveLockPassword(String password, int quality, boolean isFallback) { // Compute the hash final byte[] hash = passwordToHash(password); try { Loading @@ -515,7 +546,12 @@ public class LockPatternUtils { keyStore.password(password); int computedQuality = computePasswordQuality(password); if (!isFallback) { 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)); } if (computedQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) { int letters = 0; int uppercase = 0; Loading Loading @@ -590,7 +626,22 @@ public class LockPatternUtils { * @return stored password quality */ public int getKeyguardStoredPasswordQuality() { return (int) getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); int quality = (int) getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); // If the user has chosen to use weak biometric sensor, then return the backup locking // method and treat biometric as a special case. if (quality == DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK) { quality = (int) getLong(PASSWORD_TYPE_ALTERNATE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); } return quality; } public boolean usingBiometricWeak() { int quality = (int) getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); return quality == DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK; } /** Loading Loading @@ -725,6 +776,15 @@ public class LockPatternUtils { == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING; } /** * @return Whether biometric weak lock is enabled. */ public boolean isBiometricEnabled() { // TODO: check if it's installed return getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) == DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK; } /** * Set whether the lock pattern is enabled. */ Loading Loading @@ -863,7 +923,8 @@ public class LockPatternUtils { || mode == DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC || mode == DevicePolicyManager.PASSWORD_QUALITY_COMPLEX; final boolean secure = isPattern && isLockPatternEnabled() && savedPatternExists() || isPassword && savedPasswordExists(); || isPassword && savedPasswordExists() || usingBiometricWeak() && isBiometricEnabled(); return secure; } Loading
policy/src/com/android/internal/policy/impl/KeyguardViewBase.java +9 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,15 @@ public abstract class KeyguardViewBase extends FrameLayout { */ abstract public void cleanUp(); /** * These were added to support FaceLock because the KeyguardViewManager needs to tell the * LockPatternKeyguardView when to bind and and unbind with FaceLock service. Although * implemented in LockPatternKeyguardView, these are not implemented in anything else * derived from KeyguardViewBase */ abstract public void bindToFaceLock(); abstract public void stopAndUnbindFromFaceLock(); @Override public boolean dispatchKeyEvent(KeyEvent event) { if (shouldEventKeepScreenOnWhileKeyguardShowing(event)) { Loading