Purge biometric weak from internal code

Bug: 18931518
Change-Id: I5da41908b1d6895a69f981e139f2d268327fafcd
This commit is contained in:
Adrian Roos
2015-01-07 20:51:57 +01:00
parent 6a3ccd176f
commit f788718f21
10 changed files with 40 additions and 297 deletions

View File

@@ -718,13 +718,6 @@
<!-- Security Settings --><skip /> <!-- Security Settings --><skip />
<!-- Security settings screen when using face unlock, setting option name to start an activity that allows the user to improve accuracy by adding additional enrollment faces -->
<string name="biometric_weak_improve_matching_title">Improve face matching</string>
<!-- On the security settings screen when using face unlock. This checkbox is used to toggle whether liveliness detection is required. If it is checked the user must blink during unlock to prove it's not a photo -->
<string name="biometric_weak_liveliness_title">Liveness check</string>
<!-- On the security settings screen when using face unlock. The summary of the liveliness checkbox -->
<string name="biometric_weak_liveliness_summary" msgid="7980026533493781616">Require eye blink while unlocking</string>
<!-- Security settings screen, setting option name to change screen timeout --> <!-- Security settings screen, setting option name to change screen timeout -->
<string name="lock_after_timeout">Automatically lock</string> <string name="lock_after_timeout">Automatically lock</string>
<!-- Security settings screen, setting option summary to change screen timeout --> <!-- Security settings screen, setting option summary to change screen timeout -->
@@ -938,11 +931,6 @@
<!-- Summary for preference that disables unlock security [CHAR LIMIT=45]--> <!-- Summary for preference that disables unlock security [CHAR LIMIT=45]-->
<string name="unlock_set_unlock_none_summary">No security</string> <string name="unlock_set_unlock_none_summary">No security</string>
<!-- Title for preference that guides the user through a weak biometric lock [CHAR LIMIT=22] -->
<string name="unlock_set_unlock_biometric_weak_title">Face Unlock</string>
<!-- Summary for preference that disables unlock security [CHAR LIMIT=45]-->
<string name="unlock_set_unlock_biometric_weak_summary">Low security, experimental</string>
<!-- Title for preference that guides the user through creating an unlock pattern [CHAR LIMIT=22]--> <!-- Title for preference that guides the user through creating an unlock pattern [CHAR LIMIT=22]-->
<string name="unlock_set_unlock_pattern_title">Pattern</string> <string name="unlock_set_unlock_pattern_title">Pattern</string>
<!-- Summary for preference that guides the user through creating an unlock pattern [CHAR LIMIT=45] --> <!-- Summary for preference that guides the user through creating an unlock pattern [CHAR LIMIT=45] -->
@@ -968,8 +956,6 @@
<string name="unlock_set_unlock_mode_off">None</string> <string name="unlock_set_unlock_mode_off">None</string>
<!-- Summary for "Configure lockscreen" when security is disabled [CHAR LIMIT=45] --> <!-- Summary for "Configure lockscreen" when security is disabled [CHAR LIMIT=45] -->
<string name="unlock_set_unlock_mode_none">Swipe</string> <string name="unlock_set_unlock_mode_none">Swipe</string>
<!-- Summary for "Configure lockscreen" when security biometric weak is enabled [CHAR LIMIT=45] -->
<string name="unlock_set_unlock_mode_biometric_weak">Face Unlock</string>
<!-- Summary for "Configure lockscreen" when security pattern is enabled [CHAR LIMIT=45] --> <!-- Summary for "Configure lockscreen" when security pattern is enabled [CHAR LIMIT=45] -->
<string name="unlock_set_unlock_mode_pattern">Pattern</string> <string name="unlock_set_unlock_mode_pattern">Pattern</string>
<!-- Summary for "Configure lockscreen" when security PIN is enabled [CHAR LIMIT=45] --> <!-- Summary for "Configure lockscreen" when security PIN is enabled [CHAR LIMIT=45] -->

View File

@@ -1,63 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 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.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/security_settings_title">
<PreferenceCategory
android:key="security_category"
android:title="@string/lock_settings_title">
<PreferenceScreen
android:key="unlock_set_or_change"
android:title="@string/unlock_set_unlock_launch_picker_title"
android:summary="@string/unlock_set_unlock_mode_biometric_weak"
android:persistent="false"/>
<PreferenceScreen
android:key="biometric_weak_improve_matching"
android:title="@string/biometric_weak_improve_matching_title"/>
<SwitchPreference
android:key="biometric_weak_liveliness"
android:title="@string/biometric_weak_liveliness_title"
android:summary="@string/biometric_weak_liveliness_summary"/>
<SwitchPreference
android:key="visiblepattern"
android:title="@string/lockpattern_settings_enable_visible_pattern_title"/>
<ListPreference
android:key="lock_after_timeout"
android:title="@string/lock_after_timeout"
android:summary="@string/lock_after_timeout_summary"
android:entries="@array/lock_after_timeout_entries"
android:entryValues="@array/lock_after_timeout_values"
android:persistent="false"/>
<SwitchPreference
android:key="power_button_instantly_locks"
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
<PreferenceScreen
android:key="owner_info_settings"
android:fragment="com.android.settings.OwnerInfoSettings"
android:title="@string/owner_info_settings_title"
android:summary="@string/owner_info_settings_summary"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -28,11 +28,6 @@
android:title="@string/unlock_set_unlock_none_title" android:title="@string/unlock_set_unlock_none_title"
android:persistent="false"/> android:persistent="false"/>
<PreferenceScreen
android:key="unlock_set_biometric_weak"
android:title="@string/unlock_set_unlock_biometric_weak_title"
android:persistent="false"/>
<PreferenceScreen <PreferenceScreen
android:key="unlock_set_pattern" android:key="unlock_set_pattern"
android:title="@string/unlock_set_unlock_pattern_title" android:title="@string/unlock_set_unlock_pattern_title"

View File

@@ -76,12 +76,10 @@ public class ChooseLockGeneric extends SettingsActivity {
private static final String KEY_UNLOCK_BACKUP_INFO = "unlock_backup_info"; private static final String KEY_UNLOCK_BACKUP_INFO = "unlock_backup_info";
private static final String KEY_UNLOCK_SET_OFF = "unlock_set_off"; private static final String KEY_UNLOCK_SET_OFF = "unlock_set_off";
private static final String KEY_UNLOCK_SET_NONE = "unlock_set_none"; private static final String KEY_UNLOCK_SET_NONE = "unlock_set_none";
private static final String KEY_UNLOCK_SET_BIOMETRIC_WEAK = "unlock_set_biometric_weak";
private static final String KEY_UNLOCK_SET_PIN = "unlock_set_pin"; private static final String KEY_UNLOCK_SET_PIN = "unlock_set_pin";
private static final String KEY_UNLOCK_SET_PASSWORD = "unlock_set_password"; private static final String KEY_UNLOCK_SET_PASSWORD = "unlock_set_password";
private static final String KEY_UNLOCK_SET_PATTERN = "unlock_set_pattern"; private static final String KEY_UNLOCK_SET_PATTERN = "unlock_set_pattern";
private static final int CONFIRM_EXISTING_REQUEST = 100; private static final int CONFIRM_EXISTING_REQUEST = 100;
private static final int FALLBACK_REQUEST = 101;
private static final int ENABLE_ENCRYPTION_REQUEST = 102; private static final int ENABLE_ENCRYPTION_REQUEST = 102;
private static final String PASSWORD_CONFIRMED = "password_confirmed"; private static final String PASSWORD_CONFIRMED = "password_confirmed";
@@ -194,21 +192,6 @@ public class ChooseLockGeneric extends SettingsActivity {
} }
} }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = super.onCreateView(inflater, container, savedInstanceState);
final boolean onlyShowFallback = getActivity().getIntent()
.getBooleanExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false);
if (onlyShowFallback) {
View header = v.inflate(getActivity(),
R.layout.weak_biometric_fallback_header, null);
((ListView) v.findViewById(android.R.id.list)).addHeaderView(header, null, false);
}
return v;
}
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
@@ -216,10 +199,6 @@ public class ChooseLockGeneric extends SettingsActivity {
if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == Activity.RESULT_OK) { if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == Activity.RESULT_OK) {
mPasswordConfirmed = true; mPasswordConfirmed = true;
updatePreferencesOrFinish(); updatePreferencesOrFinish();
} else if (requestCode == FALLBACK_REQUEST) {
mChooseLockSettingsHelper.utils().deleteTempGallery();
getActivity().setResult(resultCode);
finish();
} else if (requestCode == ENABLE_ENCRYPTION_REQUEST } else if (requestCode == ENABLE_ENCRYPTION_REQUEST
&& resultCode == Activity.RESULT_OK) { && resultCode == Activity.RESULT_OK) {
mRequirePassword = data.getBooleanExtra( mRequirePassword = data.getBooleanExtra(
@@ -248,22 +227,21 @@ public class ChooseLockGeneric extends SettingsActivity {
if (quality == -1) { if (quality == -1) {
// If caller didn't specify password quality, show UI and allow the user to choose. // If caller didn't specify password quality, show UI and allow the user to choose.
quality = intent.getIntExtra(MINIMUM_QUALITY_KEY, -1); quality = intent.getIntExtra(MINIMUM_QUALITY_KEY, -1);
MutableBoolean allowBiometric = new MutableBoolean(false); quality = upgradeQuality(quality);
quality = upgradeQuality(quality, allowBiometric);
final PreferenceScreen prefScreen = getPreferenceScreen(); final PreferenceScreen prefScreen = getPreferenceScreen();
if (prefScreen != null) { if (prefScreen != null) {
prefScreen.removeAll(); prefScreen.removeAll();
} }
addPreferencesFromResource(R.xml.security_settings_picker); addPreferencesFromResource(R.xml.security_settings_picker);
disableUnusablePreferences(quality, allowBiometric); disableUnusablePreferences(quality);
updatePreferenceSummaryIfNeeded(); updatePreferenceSummaryIfNeeded();
} else { } else {
updateUnlockMethodAndFinish(quality, false); updateUnlockMethodAndFinish(quality, false);
} }
} }
/** increases the quality if necessary, and returns whether biometric is allowed */ /** increases the quality if necessary */
private int upgradeQuality(int quality, MutableBoolean allowBiometric) { private int upgradeQuality(int quality) {
quality = upgradeQualityForDPM(quality); quality = upgradeQualityForDPM(quality);
quality = upgradeQualityForKeyStore(quality); quality = upgradeQualityForKeyStore(quality);
return quality; return quality;
@@ -292,28 +270,21 @@ public class ChooseLockGeneric extends SettingsActivity {
* implementation is in disableUnusablePreferenceImpl. * implementation is in disableUnusablePreferenceImpl.
* *
* @param quality the requested quality. * @param quality the requested quality.
* @param allowBiometric whether to allow biometic screen lock.
*/ */
protected void disableUnusablePreferences(final int quality, protected void disableUnusablePreferences(final int quality) {
MutableBoolean allowBiometric) { disableUnusablePreferencesImpl(quality, false /* hideDisabled */);
disableUnusablePreferencesImpl(quality, allowBiometric, false /* hideDisabled */);
} }
/*** /***
* Disables preferences that are less secure than required quality. * Disables preferences that are less secure than required quality.
* *
* @param quality the requested quality. * @param quality the requested quality.
* @param allowBiometric whether to allow biometic screen lock.
* @param hideDisabled whether to hide disable screen lock options. * @param hideDisabled whether to hide disable screen lock options.
*/ */
protected void disableUnusablePreferencesImpl(final int quality, protected void disableUnusablePreferencesImpl(final int quality,
MutableBoolean allowBiometric, boolean hideDisabled) { boolean hideDisabled) {
final PreferenceScreen entries = getPreferenceScreen(); final PreferenceScreen entries = getPreferenceScreen();
final Intent intent = getActivity().getIntent(); final Intent intent = getActivity().getIntent();
final boolean onlyShowFallback = intent.getBooleanExtra(
LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false);
final boolean weakBiometricAvailable =
mChooseLockSettingsHelper.utils().isBiometricWeakInstalled();
// if there are multiple users, disable "None" setting // if there are multiple users, disable "None" setting
UserManager mUm = (UserManager) getSystemService(Context.USER_SERVICE); UserManager mUm = (UserManager) getSystemService(Context.USER_SERVICE);
@@ -331,10 +302,6 @@ public class ChooseLockGeneric extends SettingsActivity {
visible = singleUser; // don't show when there's more than 1 user visible = singleUser; // don't show when there's more than 1 user
} else if (KEY_UNLOCK_SET_NONE.equals(key)) { } else if (KEY_UNLOCK_SET_NONE.equals(key)) {
enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
} else if (KEY_UNLOCK_SET_BIOMETRIC_WEAK.equals(key)) {
enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK ||
allowBiometric.value;
visible = weakBiometricAvailable; // If not available, then don't show it.
} else if (KEY_UNLOCK_SET_PATTERN.equals(key)) { } else if (KEY_UNLOCK_SET_PATTERN.equals(key)) {
enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING; enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
} else if (KEY_UNLOCK_SET_PIN.equals(key)) { } else if (KEY_UNLOCK_SET_PIN.equals(key)) {
@@ -345,7 +312,7 @@ public class ChooseLockGeneric extends SettingsActivity {
if (hideDisabled) { if (hideDisabled) {
visible = visible && enabled; visible = visible && enabled;
} }
if (!visible || (onlyShowFallback && !allowedForFallback(key))) { if (!visible) {
entries.removePreference(pref); entries.removePreference(pref);
} else if (!enabled) { } else if (!enabled) {
pref.setSummary(R.string.unlock_set_unlock_disabled_summary); pref.setSummary(R.string.unlock_set_unlock_disabled_summary);
@@ -381,46 +348,16 @@ public class ChooseLockGeneric extends SettingsActivity {
} }
} }
/**
* Check whether the key is allowed for fallback (e.g. bio sensor). Returns true if it's
* supported as a backup.
*
* @param key
* @return true if allowed
*/
private boolean allowedForFallback(String key) {
return KEY_UNLOCK_BACKUP_INFO.equals(key) ||
KEY_UNLOCK_SET_PATTERN.equals(key) || KEY_UNLOCK_SET_PIN.equals(key);
}
private Intent getBiometricSensorIntent() {
Intent fallBackIntent = new Intent().setClass(getActivity(),
ChooseLockGeneric.InternalActivity.class);
fallBackIntent.putExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, true);
fallBackIntent.putExtra(CONFIRM_CREDENTIALS, false);
fallBackIntent.putExtra(EXTRA_SHOW_FRAGMENT_TITLE,
R.string.backup_lock_settings_picker_title);
boolean showTutorial = ALWAY_SHOW_TUTORIAL ||
!mChooseLockSettingsHelper.utils().isBiometricWeakEverChosen();
Intent intent = new Intent();
intent.setClassName("com.android.facelock", "com.android.facelock.SetupIntro");
intent.putExtra("showTutorial", showTutorial);
PendingIntent pending = PendingIntent.getActivity(getActivity(), 0, fallBackIntent, 0);
intent.putExtra("PendingIntent", pending);
return intent;
}
protected Intent getLockPasswordIntent(Context context, int quality, protected Intent getLockPasswordIntent(Context context, int quality,
final boolean isFallback, int minLength, final int maxLength, int minLength, final int maxLength,
boolean requirePasswordToDecrypt, boolean confirmCredentials) { boolean requirePasswordToDecrypt, boolean confirmCredentials) {
return ChooseLockPassword.createIntent(context, quality, isFallback, minLength, return ChooseLockPassword.createIntent(context, quality, minLength,
maxLength, requirePasswordToDecrypt, confirmCredentials); maxLength, requirePasswordToDecrypt, confirmCredentials);
} }
protected Intent getLockPatternIntent(Context context, final boolean isFallback, protected Intent getLockPatternIntent(Context context, final boolean requirePassword,
final boolean requirePassword, final boolean confirmCredentials) { final boolean confirmCredentials) {
return ChooseLockPattern.createIntent(context, isFallback, requirePassword, return ChooseLockPattern.createIntent(context, requirePassword,
confirmCredentials); confirmCredentials);
} }
@@ -444,10 +381,7 @@ public class ChooseLockGeneric extends SettingsActivity {
throw new IllegalStateException("Tried to update password without confirming it"); throw new IllegalStateException("Tried to update password without confirming it");
} }
final boolean isFallback = getActivity().getIntent() quality = upgradeQuality(quality);
.getBooleanExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false);
quality = upgradeQuality(quality, null);
final Context context = getActivity(); final Context context = getActivity();
if (quality >= DevicePolicyManager.PASSWORD_QUALITY_NUMERIC) { if (quality >= DevicePolicyManager.PASSWORD_QUALITY_NUMERIC) {
@@ -456,33 +390,19 @@ public class ChooseLockGeneric extends SettingsActivity {
minLength = MIN_PASSWORD_LENGTH; minLength = MIN_PASSWORD_LENGTH;
} }
final int maxLength = mDPM.getPasswordMaximumLength(quality); final int maxLength = mDPM.getPasswordMaximumLength(quality);
Intent intent = getLockPasswordIntent(context, quality, isFallback, minLength, Intent intent = getLockPasswordIntent(context, quality, minLength,
maxLength, mRequirePassword, /* confirm credentials */false); maxLength, mRequirePassword, /* confirm credentials */false);
if (isFallback) {
startActivityForResult(intent, FALLBACK_REQUEST);
return;
} else {
mFinishPending = true;
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(intent);
}
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
Intent intent = getLockPatternIntent(context, isFallback, mRequirePassword,
/* confirm credentials */false);
if (isFallback) {
startActivityForResult(intent, FALLBACK_REQUEST);
return;
} else {
mFinishPending = true;
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(intent);
}
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK) {
Intent intent = getBiometricSensorIntent();
mFinishPending = true; mFinishPending = true;
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(intent);
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
Intent intent = getLockPatternIntent(context, mRequirePassword,
/* confirm credentials */false);
mFinishPending = true;
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(intent); startActivity(intent);
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) { } else if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
mChooseLockSettingsHelper.utils().clearLock(false); mChooseLockSettingsHelper.utils().clearLock();
mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled); mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled);
getActivity().setResult(Activity.RESULT_OK); getActivity().setResult(Activity.RESULT_OK);
finish(); finish();
@@ -526,9 +446,6 @@ public class ChooseLockGeneric extends SettingsActivity {
} else if (KEY_UNLOCK_SET_NONE.equals(unlockMethod)) { } else if (KEY_UNLOCK_SET_NONE.equals(unlockMethod)) {
updateUnlockMethodAndFinish( updateUnlockMethodAndFinish(
DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED, false /* disabled */ ); DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED, false /* disabled */ );
} else if (KEY_UNLOCK_SET_BIOMETRIC_WEAK.equals(unlockMethod)) {
maybeEnableEncryption(
DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK, false);
} else if (KEY_UNLOCK_SET_PATTERN.equals(unlockMethod)) { } else if (KEY_UNLOCK_SET_PATTERN.equals(unlockMethod)) {
maybeEnableEncryption( maybeEnableEncryption(
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, false); DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, false);

View File

@@ -63,7 +63,7 @@ public class ChooseLockPassword extends SettingsActivity {
return modIntent; return modIntent;
} }
public static Intent createIntent(Context context, int quality, final boolean isFallback, public static Intent createIntent(Context context, int quality,
int minLength, final int maxLength, boolean requirePasswordToDecrypt, int minLength, final int maxLength, boolean requirePasswordToDecrypt,
boolean confirmCredentials) { boolean confirmCredentials) {
Intent intent = new Intent().setClass(context, ChooseLockPassword.class); Intent intent = new Intent().setClass(context, ChooseLockPassword.class);
@@ -71,7 +71,6 @@ public class ChooseLockPassword extends SettingsActivity {
intent.putExtra(PASSWORD_MIN_KEY, minLength); intent.putExtra(PASSWORD_MIN_KEY, minLength);
intent.putExtra(PASSWORD_MAX_KEY, maxLength); intent.putExtra(PASSWORD_MAX_KEY, maxLength);
intent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, confirmCredentials); intent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, confirmCredentials);
intent.putExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, isFallback);
intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, requirePasswordToDecrypt); intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, requirePasswordToDecrypt);
return intent; return intent;
} }
@@ -431,14 +430,12 @@ public class ChooseLockPassword extends SettingsActivity {
} }
} else if (mUiStage == Stage.NeedToConfirm) { } else if (mUiStage == Stage.NeedToConfirm) {
if (mFirstPin.equals(pin)) { if (mFirstPin.equals(pin)) {
final boolean isFallback = getActivity().getIntent().getBooleanExtra(
LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false);
boolean wasSecureBefore = mLockPatternUtils.isSecure(); boolean wasSecureBefore = mLockPatternUtils.isSecure();
mLockPatternUtils.clearLock(isFallback); mLockPatternUtils.clearLock();
final boolean required = getActivity().getIntent().getBooleanExtra( final boolean required = getActivity().getIntent().getBooleanExtra(
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true); EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
mLockPatternUtils.setCredentialRequiredToDecrypt(required); mLockPatternUtils.setCredentialRequiredToDecrypt(required);
mLockPatternUtils.saveLockPassword(pin, mRequestedQuality, isFallback); mLockPatternUtils.saveLockPassword(pin, mRequestedQuality);
getActivity().setResult(RESULT_FINISHED); getActivity().setResult(RESULT_FINISHED);
getActivity().finish(); getActivity().finish();
mDone = true; mDone = true;

View File

@@ -69,12 +69,11 @@ public class ChooseLockPattern extends SettingsActivity {
return modIntent; return modIntent;
} }
public static Intent createIntent(Context context, final boolean isFallback, public static Intent createIntent(Context context,
boolean requirePassword, boolean confirmCredentials) { boolean requirePassword, boolean confirmCredentials) {
Intent intent = new Intent(context, ChooseLockPattern.class); Intent intent = new Intent(context, ChooseLockPattern.class);
intent.putExtra("key_lock_method", "pattern"); intent.putExtra("key_lock_method", "pattern");
intent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, confirmCredentials); intent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, confirmCredentials);
intent.putExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, isFallback);
intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, requirePassword); intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, requirePassword);
return intent; return intent;
} }
@@ -563,16 +562,13 @@ public class ChooseLockPattern extends SettingsActivity {
LockPatternUtils utils = mChooseLockSettingsHelper.utils(); LockPatternUtils utils = mChooseLockSettingsHelper.utils();
final boolean lockVirgin = !utils.isPatternEverChosen(); final boolean lockVirgin = !utils.isPatternEverChosen();
final boolean isFallback = getActivity().getIntent()
.getBooleanExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false);
boolean wasSecureBefore = utils.isSecure(); boolean wasSecureBefore = utils.isSecure();
final boolean required = getActivity().getIntent().getBooleanExtra( final boolean required = getActivity().getIntent().getBooleanExtra(
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true); EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
utils.setCredentialRequiredToDecrypt(required); utils.setCredentialRequiredToDecrypt(required);
utils.setLockPatternEnabled(true); utils.setLockPatternEnabled(true);
utils.saveLockPattern(mChosenPattern, isFallback); utils.saveLockPattern(mChosenPattern);
if (lockVirgin) { if (lockVirgin) {
utils.setVisiblePatternEnabled(true); utils.setVisiblePatternEnabled(true);

View File

@@ -72,9 +72,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
// Lock Settings // Lock Settings
private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change"; private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
private static final String KEY_BIOMETRIC_WEAK_IMPROVE_MATCHING =
"biometric_weak_improve_matching";
private static final String KEY_BIOMETRIC_WEAK_LIVELINESS = "biometric_weak_liveliness";
private static final String KEY_LOCK_ENABLED = "lockenabled"; private static final String KEY_LOCK_ENABLED = "lockenabled";
private static final String KEY_VISIBLE_PATTERN = "visiblepattern"; private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
private static final String KEY_SECURITY_CATEGORY = "security_category"; private static final String KEY_SECURITY_CATEGORY = "security_category";
@@ -85,8 +82,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
private static final String KEY_MANAGE_TRUST_AGENTS = "manage_trust_agents"; private static final String KEY_MANAGE_TRUST_AGENTS = "manage_trust_agents";
private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123; private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
private static final int CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_IMPROVE_REQUEST = 124;
private static final int CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_LIVELINESS_OFF = 125;
private static final int CHANGE_TRUST_AGENT_SETTINGS = 126; private static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
// Misc Settings // Misc Settings
@@ -104,7 +99,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
// These switch preferences need special handling since they're not all stored in Settings. // These switch preferences need special handling since they're not all stored in Settings.
private static final String SWITCH_PREFERENCE_KEYS[] = { KEY_LOCK_AFTER_TIMEOUT, private static final String SWITCH_PREFERENCE_KEYS[] = { KEY_LOCK_AFTER_TIMEOUT,
KEY_LOCK_ENABLED, KEY_VISIBLE_PATTERN, KEY_BIOMETRIC_WEAK_LIVELINESS, KEY_LOCK_ENABLED, KEY_VISIBLE_PATTERN,
KEY_POWER_INSTANTLY_LOCKS, KEY_SHOW_PASSWORD, KEY_TOGGLE_INSTALL_APPLICATIONS }; KEY_POWER_INSTANTLY_LOCKS, KEY_SHOW_PASSWORD, KEY_TOGGLE_INSTALL_APPLICATIONS };
// Only allow one trust agent on the platform. // Only allow one trust agent on the platform.
@@ -117,7 +112,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
private LockPatternUtils mLockPatternUtils; private LockPatternUtils mLockPatternUtils;
private ListPreference mLockAfter; private ListPreference mLockAfter;
private SwitchPreference mBiometricWeakLiveliness;
private SwitchPreference mVisiblePattern; private SwitchPreference mVisiblePattern;
private SwitchPreference mShowPassword; private SwitchPreference mShowPassword;
@@ -165,9 +159,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
} else { } else {
resid = R.xml.security_settings_chooser; resid = R.xml.security_settings_chooser;
} }
} else if (lockPatternUtils.usingBiometricWeak() &&
lockPatternUtils.isBiometricWeakInstalled()) {
resid = R.xml.security_settings_biometric_weak;
} else { } else {
switch (lockPatternUtils.getKeyguardStoredPasswordQuality()) { switch (lockPatternUtils.getKeyguardStoredPasswordQuality()) {
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
@@ -265,10 +256,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
updateLockAfterPreferenceSummary(); updateLockAfterPreferenceSummary();
} }
// biometric weak liveliness
mBiometricWeakLiveliness =
(SwitchPreference) root.findPreference(KEY_BIOMETRIC_WEAK_LIVELINESS);
// visible pattern // visible pattern
mVisiblePattern = (SwitchPreference) root.findPreference(KEY_VISIBLE_PATTERN); mVisiblePattern = (SwitchPreference) root.findPreference(KEY_VISIBLE_PATTERN);
@@ -284,15 +271,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
trustAgentPreference.getTitle())); trustAgentPreference.getTitle()));
} }
// don't display visible pattern if biometric and backup is not pattern
if (resid == R.xml.security_settings_biometric_weak &&
mLockPatternUtils.getKeyguardStoredPasswordQuality() !=
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
if (securityCategory != null && mVisiblePattern != null) {
securityCategory.removePreference(root.findPreference(KEY_VISIBLE_PATTERN));
}
}
// Append the rest of the settings // Append the rest of the settings
addPreferencesFromResource(R.xml.security_settings_misc); addPreferencesFromResource(R.xml.security_settings_misc);
@@ -562,10 +540,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
createPreferenceHierarchy(); createPreferenceHierarchy();
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils(); final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
if (mBiometricWeakLiveliness != null) {
mBiometricWeakLiveliness.setChecked(
lockPatternUtils.isBiometricWeakLivelinessEnabled());
}
if (mVisiblePattern != null) { if (mVisiblePattern != null) {
mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled()); mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled());
} }
@@ -589,17 +563,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
if (KEY_UNLOCK_SET_OR_CHANGE.equals(key)) { if (KEY_UNLOCK_SET_OR_CHANGE.equals(key)) {
startFragment(this, "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment", startFragment(this, "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment",
R.string.lock_settings_picker_title, SET_OR_CHANGE_LOCK_METHOD_REQUEST, null); R.string.lock_settings_picker_title, SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
} else if (KEY_BIOMETRIC_WEAK_IMPROVE_MATCHING.equals(key)) {
ChooseLockSettingsHelper helper =
new ChooseLockSettingsHelper(this.getActivity(), this);
if (!helper.launchConfirmationActivity(
CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_IMPROVE_REQUEST, null, null)) {
// If this returns false, it means no password confirmation is required, so
// go ahead and start improve.
// Note: currently a backup is required for biometric_weak so this code path
// can't be reached, but is here in case things change in the future
startBiometricWeakImprove();
}
} else if (KEY_TRUST_AGENT.equals(key)) { } else if (KEY_TRUST_AGENT.equals(key)) {
ChooseLockSettingsHelper helper = ChooseLockSettingsHelper helper =
new ChooseLockSettingsHelper(this.getActivity(), this); new ChooseLockSettingsHelper(this.getActivity(), this);
@@ -623,19 +586,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_IMPROVE_REQUEST && if (requestCode == CHANGE_TRUST_AGENT_SETTINGS && resultCode == Activity.RESULT_OK) {
resultCode == Activity.RESULT_OK) {
startBiometricWeakImprove();
return;
} else if (requestCode == CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_LIVELINESS_OFF &&
resultCode == Activity.RESULT_OK) {
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
lockPatternUtils.setBiometricWeakLivelinessEnabled(false);
// Setting the mBiometricWeakLiveliness checked value to false is handled when onResume
// is called by grabbing the value from lockPatternUtils. We can't set it here
// because mBiometricWeakLiveliness could be null
return;
} else if (requestCode == CHANGE_TRUST_AGENT_SETTINGS && resultCode == Activity.RESULT_OK) {
if (mTrustAgentClickIntent != null) { if (mTrustAgentClickIntent != null) {
startActivity(mTrustAgentClickIntent); startActivity(mTrustAgentClickIntent);
mTrustAgentClickIntent = null; mTrustAgentClickIntent = null;
@@ -663,26 +614,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
lockPatternUtils.setLockPatternEnabled((Boolean) value); lockPatternUtils.setLockPatternEnabled((Boolean) value);
} else if (KEY_VISIBLE_PATTERN.equals(key)) { } else if (KEY_VISIBLE_PATTERN.equals(key)) {
lockPatternUtils.setVisiblePatternEnabled((Boolean) value); lockPatternUtils.setVisiblePatternEnabled((Boolean) value);
} else if (KEY_BIOMETRIC_WEAK_LIVELINESS.equals(key)) {
if ((Boolean) value) {
lockPatternUtils.setBiometricWeakLivelinessEnabled(true);
} else {
// In this case the user has just unchecked the checkbox, but this action requires
// them to confirm their password. We need to re-check the checkbox until
// they've confirmed their password
mBiometricWeakLiveliness.setChecked(true);
ChooseLockSettingsHelper helper =
new ChooseLockSettingsHelper(this.getActivity(), this);
if (!helper.launchConfirmationActivity(
CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_LIVELINESS_OFF, null, null)) {
// If this returns false, it means no password confirmation is required, so
// go ahead and uncheck it here.
// Note: currently a backup is required for biometric_weak so this code path
// can't be reached, but is here in case things change in the future
lockPatternUtils.setBiometricWeakLivelinessEnabled(false);
mBiometricWeakLiveliness.setChecked(false);
}
}
} else if (KEY_POWER_INSTANTLY_LOCKS.equals(key)) { } else if (KEY_POWER_INSTANTLY_LOCKS.equals(key)) {
mLockPatternUtils.setPowerButtonInstantlyLocks((Boolean) value); mLockPatternUtils.setPowerButtonInstantlyLocks((Boolean) value);
} else if (KEY_SHOW_PASSWORD.equals(key)) { } else if (KEY_SHOW_PASSWORD.equals(key)) {
@@ -706,12 +637,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
return R.string.help_url_security; return R.string.help_url_security;
} }
public void startBiometricWeakImprove(){
Intent intent = new Intent();
intent.setClassName("com.android.facelock", "com.android.facelock.AddToSetup");
startActivity(intent);
}
/** /**
* For Search. Please keep it in sync when updating "createPreferenceHierarchy()" * For Search. Please keep it in sync when updating "createPreferenceHierarchy()"
*/ */
@@ -832,13 +757,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
// Add options for lock/unlock screen // Add options for lock/unlock screen
int resId = getResIdForLockUnlockScreen(context, lockPatternUtils); int resId = getResIdForLockUnlockScreen(context, lockPatternUtils);
// don't display visible pattern if biometric and backup is not pattern
if (resId == R.xml.security_settings_biometric_weak &&
lockPatternUtils.getKeyguardStoredPasswordQuality() !=
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
keys.add(KEY_VISIBLE_PATTERN);
}
// Do not display SIM lock for devices without an Icc card // Do not display SIM lock for devices without an Icc card
TelephonyManager tm = TelephonyManager.getDefault(); TelephonyManager tm = TelephonyManager.getDefault();
if (!mIsPrimary || !tm.hasIccCard()) { if (!mIsPrimary || !tm.hasIccCard()) {

View File

@@ -99,11 +99,9 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric
* screen lock options here. * screen lock options here.
* *
* @param quality the requested quality. * @param quality the requested quality.
* @param allowBiometric whether to allow biometic screen lock
*/ */
@Override @Override
protected void disableUnusablePreferences(final int quality, protected void disableUnusablePreferences(final int quality) {
MutableBoolean allowBiometric) {
// At this part of the flow, the user has already indicated they want to add a pin, // At this part of the flow, the user has already indicated they want to add a pin,
// pattern or password, so don't show "None" or "Slide". We disable them here and set // pattern or password, so don't show "None" or "Slide". We disable them here and set
// the HIDE_DISABLED flag to true to hide them. This only happens for setup wizard. // the HIDE_DISABLED flag to true to hide them. This only happens for setup wizard.
@@ -111,24 +109,23 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric
// installed with a policy we need to honor. // installed with a policy we need to honor.
final int newQuality = Math.max(quality, final int newQuality = Math.max(quality,
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
super.disableUnusablePreferencesImpl(newQuality, allowBiometric, super.disableUnusablePreferencesImpl(newQuality, true /* hideDisabled */);
true /* hideDisabled */);
} }
@Override @Override
protected Intent getLockPasswordIntent(Context context, int quality, boolean isFallback, protected Intent getLockPasswordIntent(Context context, int quality,
int minLength, int maxLength, boolean requirePasswordToDecrypt, int minLength, int maxLength, boolean requirePasswordToDecrypt,
boolean confirmCredentials) { boolean confirmCredentials) {
final Intent intent = SetupChooseLockPassword.createIntent(context, quality, final Intent intent = SetupChooseLockPassword.createIntent(context, quality,
isFallback, minLength, maxLength, requirePasswordToDecrypt, confirmCredentials); minLength, maxLength, requirePasswordToDecrypt, confirmCredentials);
SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent); SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent);
return intent; return intent;
} }
@Override @Override
protected Intent getLockPatternIntent(Context context, boolean isFallback, protected Intent getLockPatternIntent(Context context,
boolean requirePassword, boolean confirmCredentials) { boolean requirePassword, boolean confirmCredentials) {
final Intent intent = SetupChooseLockPattern.createIntent(context, isFallback, final Intent intent = SetupChooseLockPattern.createIntent(context,
requirePassword, confirmCredentials); requirePassword, confirmCredentials);
SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent); SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent);
return intent; return intent;

View File

@@ -38,10 +38,10 @@ import android.view.WindowInsets;
public class SetupChooseLockPassword extends ChooseLockPassword public class SetupChooseLockPassword extends ChooseLockPassword
implements SetupWizardNavBar.NavigationBarListener { implements SetupWizardNavBar.NavigationBarListener {
public static Intent createIntent(Context context, int quality, final boolean isFallback, public static Intent createIntent(Context context, int quality,
int minLength, final int maxLength, boolean requirePasswordToDecrypt, int minLength, final int maxLength, boolean requirePasswordToDecrypt,
boolean confirmCredentials) { boolean confirmCredentials) {
Intent intent = ChooseLockPassword.createIntent(context, quality, isFallback, minLength, Intent intent = ChooseLockPassword.createIntent(context, quality, minLength,
maxLength, requirePasswordToDecrypt, confirmCredentials); maxLength, requirePasswordToDecrypt, confirmCredentials);
intent.setClass(context, SetupChooseLockPassword.class); intent.setClass(context, SetupChooseLockPassword.class);
intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false); intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false);

View File

@@ -38,9 +38,9 @@ import android.widget.Button;
public class SetupChooseLockPattern extends ChooseLockPattern public class SetupChooseLockPattern extends ChooseLockPattern
implements SetupWizardNavBar.NavigationBarListener { implements SetupWizardNavBar.NavigationBarListener {
public static Intent createIntent(Context context, final boolean isFallback, public static Intent createIntent(Context context,
boolean requirePassword, boolean confirmCredentials) { boolean requirePassword, boolean confirmCredentials) {
Intent intent = ChooseLockPattern.createIntent(context, isFallback, requirePassword, Intent intent = ChooseLockPattern.createIntent(context, requirePassword,
confirmCredentials); confirmCredentials);
intent.setClass(context, SetupChooseLockPattern.class); intent.setClass(context, SetupChooseLockPattern.class);
return intent; return intent;