Merge "Fix 2579923: Make changing lock screen method more discoverable." into froyo
This commit is contained in:
@@ -491,8 +491,7 @@
|
|||||||
android:theme="@android:style/Theme.NoTitleBar">
|
android:theme="@android:style/Theme.NoTitleBar">
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="ChooseLockGeneric"
|
<activity android:name="ChooseLockGeneric">
|
||||||
android:theme="@android:style/Theme.NoDisplay">
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.app.action.SET_NEW_PASSWORD" />
|
<action android:name="android.app.action.SET_NEW_PASSWORD" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
@@ -500,12 +499,14 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="ChooseLockPattern"
|
<activity android:name="ChooseLockPattern"
|
||||||
android:label="@string/lockpattern_change_lock_pattern_label">
|
android:label="@string/lockpattern_change_lock_pattern_label"
|
||||||
|
android:exported="false">
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="ChooseLockPassword"
|
<activity android:name="ChooseLockPassword"
|
||||||
android:label="@string/lockpattern_change_lock_pin_label"
|
android:label="@string/lockpattern_change_lock_pin_label"
|
||||||
android:theme="@android:style/Theme.NoTitleBar">
|
android:theme="@android:style/Theme.NoTitleBar"
|
||||||
|
android:exported="false">
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="ChooseLockPatternTutorial"
|
<activity android:name="ChooseLockPatternTutorial"
|
||||||
|
@@ -514,6 +514,8 @@
|
|||||||
<!-- Menu item on Select time zone screen -->
|
<!-- Menu item on Select time zone screen -->
|
||||||
<string name="zone_list_menu_sort_by_timezone">Sort by time zone</string>
|
<string name="zone_list_menu_sort_by_timezone">Sort by time zone</string>
|
||||||
|
|
||||||
|
<!-- Security Settings --><skip />
|
||||||
|
|
||||||
<!-- Main Settings screen setting option title for the item to take you the security and location screen -->
|
<!-- Main Settings screen setting option title for the item to take you the security and location screen -->
|
||||||
<string name="security_settings_title">Location & security</string>
|
<string name="security_settings_title">Location & security</string>
|
||||||
<!-- Location & security settings screen title -->
|
<!-- Location & security settings screen title -->
|
||||||
@@ -525,23 +527,49 @@
|
|||||||
<!-- In the security screen, the header title for settings related to Passwords-->
|
<!-- In the security screen, the header title for settings related to Passwords-->
|
||||||
<string name="security_passwords_title">Passwords</string>
|
<string name="security_passwords_title">Passwords</string>
|
||||||
|
|
||||||
|
<!-- Unlock Picker Settings --><skip />
|
||||||
|
|
||||||
<!-- Unlock settings --><skip />
|
<!-- Security Picker --><skip />
|
||||||
|
<!-- Title for security picker to choose the unlock method: None/Pattern/PIN/Password -->
|
||||||
|
<string name="lock_settings_picker_title">Screen unlock security</string>
|
||||||
|
|
||||||
<!-- Title for preference that will guide the user through creating an unlock pattern -->
|
<!-- Main Security lock settings --><skip />
|
||||||
<string name="unlock_set_unlock_pattern_title">Set unlock pattern</string>
|
<!-- Title for PreferenceScreen to launch picker for security method when there is none -->
|
||||||
|
<string name="unlock_set_unlock_launch_picker_title">Set up screen lock</string>
|
||||||
|
|
||||||
|
<!-- Summary for PreferenceScreen to launch picker for security method when there is none -->
|
||||||
|
<string name="unlock_set_unlock_launch_picker_summary">Lock screen with a pattern, PIN, or password</string>
|
||||||
|
|
||||||
|
<!-- Title for PreferenceScreen to change security method: None/Pattern/PIN/Password -->
|
||||||
|
<string name="unlock_set_unlock_launch_picker_change_title">Change screen lock</string>
|
||||||
|
|
||||||
|
<!-- Summary for PreferenceScreen to changeecurity method: None/Pattern/PIN/Password -->
|
||||||
|
<string name="unlock_set_unlock_launch_picker_change_summary">Change or disable pattern, PIN, or password security</string>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Title for preference that disables unlock security -->
|
||||||
|
<string name="unlock_set_unlock_none_title">None</string>
|
||||||
|
<!-- Summary for preference that disables unlock security -->
|
||||||
|
<string name="unlock_set_unlock_none_summary">Disable screen unlock security</string>
|
||||||
|
|
||||||
|
<!-- Title for preference that guides the user through creating an unlock pattern -->
|
||||||
|
<string name="unlock_set_unlock_pattern_title">Pattern</string>
|
||||||
<!-- Summary for preference that guides the user through creating an unlock pattern -->
|
<!-- Summary for preference that guides the user through creating an unlock pattern -->
|
||||||
<string name="unlock_set_unlock_pattern_summary">Must draw pattern to unlock screen</string>
|
<string name="unlock_set_unlock_pattern_summary">Draw pattern to unlock screen</string>
|
||||||
|
|
||||||
<!-- Title for preference that guides the user through creating an unlock PIN (Personal Identification Number) -->
|
<!-- Title for preference that guides the user through creating an unlock PIN (Personal Identification Number) -->
|
||||||
<string name="unlock_set_unlock_pin_title">Set unlock PIN</string>
|
<string name="unlock_set_unlock_pin_title">PIN</string>
|
||||||
<!-- Summary for preference that guides the user through creating an unlock PIN (Personal Identification Number) -->
|
<!-- Summary for preference that guides the user through creating an unlock PIN (Personal Identification Number) -->
|
||||||
<string name="unlock_set_unlock_pin_summary">Must use a numeric PIN to unlock screen</string>
|
<string name="unlock_set_unlock_pin_summary">Enter a numeric PIN to unlock screen</string>
|
||||||
|
|
||||||
<!-- Title for preference that guides the user through creating an unlock password -->
|
<!-- Title for preference that guides the user through creating an unlock password -->
|
||||||
<string name="unlock_set_unlock_password_title">Set unlock password</string>
|
<string name="unlock_set_unlock_password_title">Password</string>
|
||||||
<!-- Title for preference that guides the user through creating an unlock password -->
|
<!-- Title for preference that guides the user through creating an unlock password -->
|
||||||
<string name="unlock_set_unlock_password_summary">Must use a password to unlock screen</string>
|
<string name="unlock_set_unlock_password_summary">Enter a password to unlock screen</string>
|
||||||
|
|
||||||
|
<!-- Summary for preference that has been disabled by DevicePolicyAdmin -->
|
||||||
|
<string name="unlock_set_unlock_disabled_summary">Disable by device policy</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Title for option to turn of password/pin/pattern unlock. -->
|
<!-- Title for option to turn of password/pin/pattern unlock. -->
|
||||||
<string name="unlock_disable_lock_title">Turn off screen lock</string>
|
<string name="unlock_disable_lock_title">Turn off screen lock</string>
|
||||||
|
@@ -21,21 +21,9 @@
|
|||||||
android:title="@string/lock_settings_title">
|
android:title="@string/lock_settings_title">
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="unlock_set_pattern"
|
android:key="unlock_set_or_change"
|
||||||
android:title="@string/unlock_set_unlock_pattern_title"
|
android:title="@string/unlock_set_unlock_launch_picker_title"
|
||||||
android:summary="@string/unlock_set_unlock_pattern_summary"
|
android:summary="@string/unlock_set_unlock_launch_picker_summary"
|
||||||
android:persistent="false"/>
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="unlock_set_pin"
|
|
||||||
android:title="@string/unlock_set_unlock_pin_title"
|
|
||||||
android:summary="@string/unlock_set_unlock_pin_summary"
|
|
||||||
android:persistent="false"/>
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="unlock_set_password"
|
|
||||||
android:title="@string/unlock_set_unlock_password_title"
|
|
||||||
android:summary="@string/unlock_set_unlock_password_summary"
|
|
||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
@@ -21,14 +21,9 @@
|
|||||||
android:title="@string/lock_settings_title">
|
android:title="@string/lock_settings_title">
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="unlock_method_disable"
|
android:key="unlock_set_or_change"
|
||||||
android:title="@string/unlock_disable_lock_title"
|
android:title="@string/unlock_set_unlock_launch_picker_change_title"
|
||||||
android:summary="@string/unlock_disable_lock_password_summary"
|
android:summary="@string/unlock_set_unlock_launch_picker_change_summary"
|
||||||
android:persistent="false"/>
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="unlock_method_change_current"
|
|
||||||
android:title="@string/unlock_change_lock_password_title"
|
|
||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
@@ -21,14 +21,9 @@
|
|||||||
android:title="@string/lock_settings_title">
|
android:title="@string/lock_settings_title">
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="unlock_method_disable"
|
android:key="unlock_set_or_change"
|
||||||
android:title="@string/unlock_disable_lock_title"
|
android:title="@string/unlock_set_unlock_launch_picker_change_title"
|
||||||
android:summary="@string/unlock_disable_lock_pattern_summary"
|
android:summary="@string/unlock_set_unlock_launch_picker_change_summary"
|
||||||
android:persistent="false"/>
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="unlock_method_change_current"
|
|
||||||
android:title="@string/unlock_change_lock_pattern_title"
|
|
||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
49
res/xml/security_settings_picker.xml
Normal file
49
res/xml/security_settings_picker.xml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2008 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">
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="security_picker_category"
|
||||||
|
android:title="@string/lock_settings_picker_title">
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="unlock_set_none"
|
||||||
|
android:title="@string/unlock_set_unlock_none_title"
|
||||||
|
android:summary="@string/unlock_set_unlock_none_summary"
|
||||||
|
android:persistent="false"/>
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="unlock_set_pattern"
|
||||||
|
android:title="@string/unlock_set_unlock_pattern_title"
|
||||||
|
android:summary="@string/unlock_set_unlock_pattern_summary"
|
||||||
|
android:persistent="false"/>
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="unlock_set_pin"
|
||||||
|
android:title="@string/unlock_set_unlock_pin_title"
|
||||||
|
android:summary="@string/unlock_set_unlock_pin_summary"
|
||||||
|
android:persistent="false"/>
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="unlock_set_password"
|
||||||
|
android:title="@string/unlock_set_unlock_password_title"
|
||||||
|
android:summary="@string/unlock_set_unlock_password_summary"
|
||||||
|
android:persistent="false"/>
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
@@ -21,14 +21,9 @@
|
|||||||
android:title="@string/lock_settings_title">
|
android:title="@string/lock_settings_title">
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="unlock_method_disable"
|
android:key="unlock_set_or_change"
|
||||||
android:title="@string/unlock_disable_lock_title"
|
android:title="@string/unlock_set_unlock_launch_picker_change_title"
|
||||||
android:summary="@string/unlock_disable_lock_pin_summary"
|
android:summary="@string/unlock_set_unlock_launch_picker_change_summary"
|
||||||
android:persistent="false"/>
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="unlock_method_change_current"
|
|
||||||
android:title="@string/unlock_change_lock_pin_title"
|
|
||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
@@ -18,52 +18,180 @@ package com.android.settings;
|
|||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceActivity;
|
||||||
|
import android.preference.PreferenceCategory;
|
||||||
|
import android.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
public class ChooseLockGeneric extends PreferenceActivity {
|
||||||
|
private static final int MIN_PASSWORD_LENGTH = 4;
|
||||||
|
private static final String KEY_UNLOCK_SET_NONE = "unlock_set_none";
|
||||||
|
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_PATTERN = "unlock_set_pattern";
|
||||||
|
private static final int CONFIRM_EXISTING_REQUEST = 100;
|
||||||
|
private static final String PASSWORD_CONFIRMED = "password_confirmed";
|
||||||
|
private static final String CONFIRM_CREDENTIALS = "confirm_credentials";
|
||||||
|
|
||||||
public class ChooseLockGeneric extends Activity {
|
|
||||||
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
|
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
|
||||||
DevicePolicyManager mDPM;
|
private DevicePolicyManager mDPM;
|
||||||
|
private boolean mPasswordConfirmed = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
|
mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
|
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
|
||||||
|
|
||||||
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
|
if (savedInstanceState != null) {
|
||||||
|
mPasswordConfirmed = savedInstanceState.getBoolean(PASSWORD_CONFIRMED);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mPasswordConfirmed) {
|
||||||
|
ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this);
|
||||||
|
if (!helper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST)) {
|
||||||
|
mPasswordConfirmed = true; // no password set, so no need to confirm
|
||||||
|
updatePreferencesOrFinish();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updatePreferencesOrFinish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
|
||||||
|
Preference preference) {
|
||||||
|
final String key = preference.getKey();
|
||||||
|
boolean handled = true;
|
||||||
|
if (KEY_UNLOCK_SET_NONE.equals(key)) {
|
||||||
|
updateUnlockMethodAndFinish(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
|
||||||
|
} else if (KEY_UNLOCK_SET_PATTERN.equals(key)) {
|
||||||
|
updateUnlockMethodAndFinish(DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
|
||||||
|
} else if (KEY_UNLOCK_SET_PIN.equals(key)) {
|
||||||
|
updateUnlockMethodAndFinish(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
|
||||||
|
} else if (KEY_UNLOCK_SET_PASSWORD.equals(key)) {
|
||||||
|
updateUnlockMethodAndFinish(DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC);
|
||||||
|
} else {
|
||||||
|
handled = false;
|
||||||
|
}
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == RESULT_OK) {
|
||||||
|
mPasswordConfirmed = true;
|
||||||
|
updatePreferencesOrFinish();
|
||||||
|
} else {
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
// Saved so we don't force user to re-enter their password if configuration changes
|
||||||
|
outState.putBoolean(PASSWORD_CONFIRMED, mPasswordConfirmed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePreferencesOrFinish() {
|
||||||
int quality = getIntent().getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, -1);
|
int quality = getIntent().getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, -1);
|
||||||
if (quality == -1) {
|
if (quality == -1) {
|
||||||
quality = lockPatternUtils.getKeyguardStoredPasswordQuality();
|
// If caller didn't specify password quality, show the UI and allow the user to choose.
|
||||||
|
quality = mChooseLockSettingsHelper.utils().getKeyguardStoredPasswordQuality();
|
||||||
|
final PreferenceScreen prefScreen = getPreferenceScreen();
|
||||||
|
if (prefScreen != null) {
|
||||||
|
prefScreen.removeAll();
|
||||||
|
}
|
||||||
|
addPreferencesFromResource(R.xml.security_settings_picker);
|
||||||
|
disableUnusablePreferences(mDPM.getPasswordQuality(null));
|
||||||
|
} else {
|
||||||
|
updateUnlockMethodAndFinish(quality);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Disables preferences that are less secure than required quality.
|
||||||
|
*
|
||||||
|
* @param quality the requested quality.
|
||||||
|
*/
|
||||||
|
private void disableUnusablePreferences(final int quality) {
|
||||||
|
final Preference picker = getPreferenceScreen().findPreference("security_picker_category");
|
||||||
|
final PreferenceCategory cat = (PreferenceCategory) picker;
|
||||||
|
final int preferenceCount = cat.getPreferenceCount();
|
||||||
|
for (int i = 0; i < preferenceCount; i++) {
|
||||||
|
Preference pref = cat.getPreference(i);
|
||||||
|
if (pref instanceof PreferenceScreen) {
|
||||||
|
final String key = ((PreferenceScreen) pref).getKey();
|
||||||
|
boolean enabled = true;
|
||||||
|
if (KEY_UNLOCK_SET_NONE.equals(key)) {
|
||||||
|
enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
|
||||||
|
} else if (KEY_UNLOCK_SET_PATTERN.equals(key)) {
|
||||||
|
enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
|
||||||
|
} else if (KEY_UNLOCK_SET_PIN.equals(key)) {
|
||||||
|
enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_NUMERIC;
|
||||||
|
} else if (KEY_UNLOCK_SET_PASSWORD.equals(key)) {
|
||||||
|
enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC;
|
||||||
|
}
|
||||||
|
if (!enabled) {
|
||||||
|
pref.setSummary(R.string.unlock_set_unlock_disabled_summary);
|
||||||
|
pref.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invokes an activity to change the user's pattern, password or PIN based on given quality
|
||||||
|
* and minimum quality specified by DevicePolicyManager. If quality is
|
||||||
|
* {@link DevicePolicyManager#PASSWORD_QUALITY_UNSPECIFIED}, password is cleared.
|
||||||
|
*
|
||||||
|
* @param quality the desired quality. Ignored if DevicePolicyManager requires more security.
|
||||||
|
*/
|
||||||
|
void updateUnlockMethodAndFinish(int quality) {
|
||||||
|
// Sanity check. We should never get here without confirming user's existing password first.
|
||||||
|
if (!mPasswordConfirmed) {
|
||||||
|
throw new IllegalStateException("Tried to update password without confirming first");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare minimum allowed password quality and launch appropriate security setting method
|
||||||
int minQuality = mDPM.getPasswordQuality(null);
|
int minQuality = mDPM.getPasswordQuality(null);
|
||||||
if (quality < minQuality) {
|
if (quality < minQuality) {
|
||||||
quality = minQuality;
|
quality = minQuality;
|
||||||
}
|
}
|
||||||
if (quality >= DevicePolicyManager.PASSWORD_QUALITY_NUMERIC) {
|
if (quality >= DevicePolicyManager.PASSWORD_QUALITY_NUMERIC) {
|
||||||
int minLength = mDPM.getPasswordMinimumLength(null);
|
int minLength = mDPM.getPasswordMinimumLength(null);
|
||||||
if (minLength < 4) {
|
if (minLength < MIN_PASSWORD_LENGTH) {
|
||||||
minLength = 4;
|
minLength = MIN_PASSWORD_LENGTH;
|
||||||
}
|
}
|
||||||
final int maxLength = mDPM.getPasswordMaximumLength(quality);
|
final int maxLength = mDPM.getPasswordMaximumLength(quality);
|
||||||
Intent intent = new Intent().setClass(this, ChooseLockPassword.class);
|
Intent intent = new Intent().setClass(this, ChooseLockPassword.class);
|
||||||
intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, quality);
|
intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, quality);
|
||||||
intent.putExtra(ChooseLockPassword.PASSWORD_MIN_KEY, minLength);
|
intent.putExtra(ChooseLockPassword.PASSWORD_MIN_KEY, minLength);
|
||||||
intent.putExtra(ChooseLockPassword.PASSWORD_MAX_KEY, maxLength);
|
intent.putExtra(ChooseLockPassword.PASSWORD_MAX_KEY, maxLength);
|
||||||
|
intent.putExtra(CONFIRM_CREDENTIALS, false);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else {
|
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
|
||||||
boolean showTutorial = !lockPatternUtils.isPatternEverChosen();
|
boolean showTutorial = !mChooseLockSettingsHelper.utils().isPatternEverChosen();
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setClass(this, showTutorial
|
intent.setClass(this, showTutorial
|
||||||
? ChooseLockPatternTutorial.class
|
? ChooseLockPatternTutorial.class
|
||||||
: ChooseLockPattern.class);
|
: ChooseLockPattern.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||||
intent.putExtra("key_lock_method", "pattern");
|
intent.putExtra("key_lock_method", "pattern");
|
||||||
|
intent.putExtra(CONFIRM_CREDENTIALS, false);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
|
||||||
|
mChooseLockSettingsHelper.utils().clearLock();
|
||||||
|
setResult(RESULT_OK);
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
@@ -104,6 +104,8 @@ public class ChooseLockPassword extends Activity implements OnClickListener, OnE
|
|||||||
mRequestedQuality = getIntent().getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, mRequestedQuality);
|
mRequestedQuality = getIntent().getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, mRequestedQuality);
|
||||||
mPasswordMinLength = getIntent().getIntExtra(PASSWORD_MIN_KEY, mPasswordMinLength);
|
mPasswordMinLength = getIntent().getIntExtra(PASSWORD_MIN_KEY, mPasswordMinLength);
|
||||||
mPasswordMaxLength = getIntent().getIntExtra(PASSWORD_MAX_KEY, mPasswordMaxLength);
|
mPasswordMaxLength = getIntent().getIntExtra(PASSWORD_MAX_KEY, mPasswordMaxLength);
|
||||||
|
|
||||||
|
final boolean confirmCredentials = getIntent().getBooleanExtra("confirm_credentials", true);
|
||||||
int minMode = mLockPatternUtils.getRequestedPasswordQuality();
|
int minMode = mLockPatternUtils.getRequestedPasswordQuality();
|
||||||
if (mRequestedQuality < minMode) {
|
if (mRequestedQuality < minMode) {
|
||||||
mRequestedQuality = minMode;
|
mRequestedQuality = minMode;
|
||||||
@@ -116,7 +118,9 @@ public class ChooseLockPassword extends Activity implements OnClickListener, OnE
|
|||||||
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
|
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
updateStage(Stage.Introduction);
|
updateStage(Stage.Introduction);
|
||||||
mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST);
|
if (confirmCredentials) {
|
||||||
|
mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -280,11 +280,19 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
|
|||||||
R.id.topLayout);
|
R.id.topLayout);
|
||||||
topLayout.setDefaultTouchRecepient(mLockPatternView);
|
topLayout.setDefaultTouchRecepient(mLockPatternView);
|
||||||
|
|
||||||
|
final boolean confirmCredentials = getIntent().getBooleanExtra("confirm_credentials", true);
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
// first launch. As a security measure, we're in NeedToConfirm mode until we know
|
if (confirmCredentials) {
|
||||||
// there isn't an existing password or the user confirms their password.
|
// first launch. As a security measure, we're in NeedToConfirm mode until we know
|
||||||
updateStage(Stage.NeedToConfirm);
|
// there isn't an existing password or the user confirms their password.
|
||||||
if (!mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST)) {
|
updateStage(Stage.NeedToConfirm);
|
||||||
|
boolean launchedConfirmationActivity =
|
||||||
|
mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST);
|
||||||
|
if (!launchedConfirmationActivity) {
|
||||||
|
updateStage(Stage.Introduction);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
updateStage(Stage.Introduction);
|
updateStage(Stage.Introduction);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -25,7 +25,6 @@ import android.view.View;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
public class ChooseLockPatternExample extends Activity implements View.OnClickListener {
|
public class ChooseLockPatternExample extends Activity implements View.OnClickListener {
|
||||||
private static final int REQUESTCODE_CHOOSE = 1;
|
|
||||||
private static final long START_DELAY = 1000;
|
private static final long START_DELAY = 1000;
|
||||||
protected static final String TAG = "Settings";
|
protected static final String TAG = "Settings";
|
||||||
private View mNextButton;
|
private View mNextButton;
|
||||||
@@ -66,14 +65,8 @@ public class ChooseLockPatternExample extends Activity implements View.OnClickLi
|
|||||||
} else if (v == mNextButton) {
|
} else if (v == mNextButton) {
|
||||||
stopAnimation(mAnimation);
|
stopAnimation(mAnimation);
|
||||||
Intent intent = new Intent(this, ChooseLockPattern.class);
|
Intent intent = new Intent(this, ChooseLockPattern.class);
|
||||||
startActivityForResult(intent, REQUESTCODE_CHOOSE);
|
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||||
}
|
startActivity(intent);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
if (requestCode == REQUESTCODE_CHOOSE && resultCode == ChooseLockPattern.RESULT_FINISHED) {
|
|
||||||
setResult(resultCode);
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,8 +24,6 @@ import android.os.Bundle;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
public class ChooseLockPatternTutorial extends Activity implements View.OnClickListener {
|
public class ChooseLockPatternTutorial extends Activity implements View.OnClickListener {
|
||||||
private static final int REQUESTCODE_EXAMPLE = 1;
|
|
||||||
|
|
||||||
private View mNextButton;
|
private View mNextButton;
|
||||||
private View mSkipButton;
|
private View mSkipButton;
|
||||||
|
|
||||||
@@ -35,8 +33,8 @@ public class ChooseLockPatternTutorial extends Activity implements View.OnClickL
|
|||||||
// Don't show the tutorial if the user has seen it before.
|
// Don't show the tutorial if the user has seen it before.
|
||||||
LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
|
LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
|
||||||
if (savedInstanceState == null && lockPatternUtils.isPatternEverChosen()) {
|
if (savedInstanceState == null && lockPatternUtils.isPatternEverChosen()) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent(this, ChooseLockPattern.class);
|
||||||
intent.setClass(this, ChooseLockPattern.class);
|
intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
@@ -58,18 +56,11 @@ public class ChooseLockPatternTutorial extends Activity implements View.OnClickL
|
|||||||
setResult(ChooseLockPattern.RESULT_FINISHED);
|
setResult(ChooseLockPattern.RESULT_FINISHED);
|
||||||
finish();
|
finish();
|
||||||
} else if (v == mNextButton) {
|
} else if (v == mNextButton) {
|
||||||
startActivityForResult(new Intent(this, ChooseLockPatternExample.class),
|
Intent intent = new Intent(this, ChooseLockPatternExample.class);
|
||||||
REQUESTCODE_EXAMPLE);
|
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||||
}
|
startActivity(intent);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
if (requestCode == REQUESTCODE_EXAMPLE && resultCode == ChooseLockPattern.RESULT_FINISHED) {
|
|
||||||
setResult(resultCode);
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,25 +56,15 @@ import com.android.internal.widget.LockPatternUtils;
|
|||||||
* Gesture lock pattern settings.
|
* Gesture lock pattern settings.
|
||||||
*/
|
*/
|
||||||
public class SecuritySettings extends PreferenceActivity {
|
public class SecuritySettings extends PreferenceActivity {
|
||||||
|
private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
|
||||||
|
|
||||||
private static final String KEY_UNLOCK_SET_PASSWORD = "unlock_set_password";
|
|
||||||
private static final String KEY_UNLOCK_SET_PIN = "unlock_set_pin";
|
|
||||||
private static final String KEY_UNLOCK_SET_PATTERN = "unlock_set_pattern";
|
|
||||||
private static final String KEY_UNLOCK_METHOD_CHANGE_CURRENT = "unlock_method_change_current";
|
|
||||||
private static final String KEY_UNLOCK_METHOD_DISABLE = "unlock_method_disable";
|
|
||||||
// Lock Settings
|
// Lock Settings
|
||||||
private static final String PACKAGE = "com.android.settings";
|
private static final String PACKAGE = "com.android.settings";
|
||||||
private static final String LOCK_PATTERN_TUTORIAL = PACKAGE + ".ChooseLockPatternTutorial";
|
|
||||||
private static final String ICC_LOCK_SETTINGS = PACKAGE + ".IccLockSettings";
|
private static final String ICC_LOCK_SETTINGS = PACKAGE + ".IccLockSettings";
|
||||||
private static final String CHOOSE_LOCK_PATTERN = PACKAGE + ".ChooseLockPattern";
|
|
||||||
private static final String CHOOSE_LOCK_PIN = PACKAGE + ".ChooseLockPassword";
|
|
||||||
|
|
||||||
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_TACTILE_FEEDBACK_ENABLED = "unlock_tactile_feedback";
|
private static final String KEY_TACTILE_FEEDBACK_ENABLED = "unlock_tactile_feedback";
|
||||||
private static final String KEY_UNLOCK_METHOD = "unlock_method";
|
|
||||||
private static final int UPDATE_PASSWORD_REQUEST = 56;
|
|
||||||
private static final int CONFIRM_EXISTING_REQUEST = 57;
|
|
||||||
|
|
||||||
private CheckBoxPreference mVisiblePattern;
|
private CheckBoxPreference mVisiblePattern;
|
||||||
private CheckBoxPreference mTactileFeedback;
|
private CheckBoxPreference mTactileFeedback;
|
||||||
@@ -82,14 +72,10 @@ public class SecuritySettings extends PreferenceActivity {
|
|||||||
private CheckBoxPreference mShowPassword;
|
private CheckBoxPreference mShowPassword;
|
||||||
|
|
||||||
// Location Settings
|
// Location Settings
|
||||||
private static final String LOCATION_CATEGORY = "location_category";
|
|
||||||
private static final String LOCATION_NETWORK = "location_network";
|
private static final String LOCATION_NETWORK = "location_network";
|
||||||
private static final String LOCATION_GPS = "location_gps";
|
private static final String LOCATION_GPS = "location_gps";
|
||||||
private static final String ASSISTED_GPS = "assisted_gps";
|
private static final String ASSISTED_GPS = "assisted_gps";
|
||||||
|
private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
|
||||||
// Default password lengths if device policy isn't in effect. Ignored otherwise.
|
|
||||||
private static final int PASSWORD_MIN_LENGTH = 4;
|
|
||||||
private static final int PASSWORD_MAX_LENGTH = 16;
|
|
||||||
|
|
||||||
// Credential storage
|
// Credential storage
|
||||||
private CredentialStorage mCredentialStorage = new CredentialStorage();
|
private CredentialStorage mCredentialStorage = new CredentialStorage();
|
||||||
@@ -106,8 +92,6 @@ public class SecuritySettings extends PreferenceActivity {
|
|||||||
private ContentQueryMap mContentQueryMap;
|
private ContentQueryMap mContentQueryMap;
|
||||||
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
|
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
|
||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
private PreferenceScreen mDisableUnlock;
|
|
||||||
private PreferenceScreen mChangeCurrent;
|
|
||||||
private final class SettingsObserver implements Observer {
|
private final class SettingsObserver implements Observer {
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
updateToggles();
|
updateToggles();
|
||||||
@@ -169,11 +153,8 @@ public class SecuritySettings extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable current pattern. Should be common to all unlock preference screens.
|
// set or change current. Should be common to all unlock preference screens
|
||||||
mDisableUnlock = (PreferenceScreen) pm.findPreference(KEY_UNLOCK_METHOD_DISABLE);
|
// mSetOrChange = (PreferenceScreen) pm.findPreference(KEY_UNLOCK_SET_OR_CHANGE);
|
||||||
|
|
||||||
// change current. Should be common to all unlock preference screens
|
|
||||||
mChangeCurrent = (PreferenceScreen) pm.findPreference(KEY_UNLOCK_METHOD_CHANGE_CURRENT);
|
|
||||||
|
|
||||||
// visible pattern
|
// visible pattern
|
||||||
mVisiblePattern = (CheckBoxPreference) pm.findPreference(KEY_VISIBLE_PATTERN);
|
mVisiblePattern = (CheckBoxPreference) pm.findPreference(KEY_VISIBLE_PATTERN);
|
||||||
@@ -181,7 +162,6 @@ public class SecuritySettings extends PreferenceActivity {
|
|||||||
// tactile feedback. Should be common to all unlock preference screens.
|
// tactile feedback. Should be common to all unlock preference screens.
|
||||||
mTactileFeedback = (CheckBoxPreference) pm.findPreference(KEY_TACTILE_FEEDBACK_ENABLED);
|
mTactileFeedback = (CheckBoxPreference) pm.findPreference(KEY_TACTILE_FEEDBACK_ENABLED);
|
||||||
|
|
||||||
|
|
||||||
int activePhoneType = TelephonyManager.getDefault().getPhoneType();
|
int activePhoneType = TelephonyManager.getDefault().getPhoneType();
|
||||||
|
|
||||||
// do not display SIM lock for CDMA phone
|
// do not display SIM lock for CDMA phone
|
||||||
@@ -232,46 +212,6 @@ public class SecuritySettings extends PreferenceActivity {
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleUpdateUnlockMethod(String value) {
|
|
||||||
// NULL means update the current password/pattern/pin
|
|
||||||
if (value == null) {
|
|
||||||
int mode = mLockPatternUtils.getKeyguardStoredPasswordQuality();
|
|
||||||
if (DevicePolicyManager.PASSWORD_QUALITY_SOMETHING == mode) {
|
|
||||||
value = "pattern";
|
|
||||||
} else if (DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC == mode
|
|
||||||
|| DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC == mode) {
|
|
||||||
value = "password";
|
|
||||||
} else if (DevicePolicyManager.PASSWORD_QUALITY_NUMERIC == mode) {
|
|
||||||
value = "pin";
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("Unknown password mode: " + value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("none".equals(value)) {
|
|
||||||
if (mDPM.getPasswordQuality(null) == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
|
|
||||||
mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int reqMode;
|
|
||||||
if ("password".equals(value)) {
|
|
||||||
reqMode = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC;
|
|
||||||
} else if ( "pin".equals(value)) {
|
|
||||||
reqMode = DevicePolicyManager.PASSWORD_QUALITY_NUMERIC;
|
|
||||||
} else {
|
|
||||||
reqMode = DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
|
|
||||||
}
|
|
||||||
int minMode = mDPM.getPasswordQuality(null);
|
|
||||||
if (reqMode < minMode) {
|
|
||||||
reqMode = minMode;
|
|
||||||
}
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setClass(this, ChooseLockGeneric.class);
|
|
||||||
intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, reqMode);
|
|
||||||
startActivityForResult(intent, UPDATE_PASSWORD_REQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -296,16 +236,9 @@ public class SecuritySettings extends PreferenceActivity {
|
|||||||
final String key = preference.getKey();
|
final String key = preference.getKey();
|
||||||
|
|
||||||
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
|
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
|
||||||
if (KEY_UNLOCK_SET_PATTERN.equals(key)) {
|
if (KEY_UNLOCK_SET_OR_CHANGE.equals(key)) {
|
||||||
handleUpdateUnlockMethod("pattern");
|
Intent intent = new Intent(this, ChooseLockGeneric.class);
|
||||||
} else if (KEY_UNLOCK_SET_PIN.equals(key)) {
|
startActivityForResult(intent, SET_OR_CHANGE_LOCK_METHOD_REQUEST);
|
||||||
handleUpdateUnlockMethod("pin");
|
|
||||||
} else if (KEY_UNLOCK_SET_PASSWORD.equals(key)) {
|
|
||||||
handleUpdateUnlockMethod("password");
|
|
||||||
} else if (KEY_UNLOCK_METHOD_DISABLE.equals(key)) {
|
|
||||||
handleUpdateUnlockMethod("none");
|
|
||||||
} else if (KEY_UNLOCK_METHOD_CHANGE_CURRENT.equals(key)) {
|
|
||||||
handleUpdateUnlockMethod(null);
|
|
||||||
} else if (KEY_LOCK_ENABLED.equals(key)) {
|
} else if (KEY_LOCK_ENABLED.equals(key)) {
|
||||||
lockPatternUtils.setLockPatternEnabled(isToggled(preference));
|
lockPatternUtils.setLockPatternEnabled(isToggled(preference));
|
||||||
} else if (KEY_VISIBLE_PATTERN.equals(key)) {
|
} else if (KEY_VISIBLE_PATTERN.equals(key)) {
|
||||||
@@ -360,13 +293,6 @@ public class SecuritySettings extends PreferenceActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
final boolean resultOk = resultCode == Activity.RESULT_OK;
|
|
||||||
|
|
||||||
LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
|
|
||||||
if ((requestCode == CONFIRM_EXISTING_REQUEST) && resultOk) {
|
|
||||||
lockPatternUtils.clearLock();
|
|
||||||
}
|
|
||||||
createPreferenceHierarchy();
|
createPreferenceHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user