Fix 2385283: Add DevicePolicyManager calls to LockScreen.

This commit is contained in:
Jim Miller
2010-01-20 13:37:14 -08:00
parent feff652132
commit 47d380f1e6
8 changed files with 48 additions and 39 deletions

View File

@@ -78,10 +78,16 @@ public class ChooseLockPassword extends Activity implements OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLockPatternUtils = new LockPatternUtils(getContentResolver());
mRequestedMode = getIntent().getIntExtra("password_mode", mRequestedMode);
mPasswordMinLength = getIntent().getIntExtra("password_min_length", mPasswordMinLength);
mPasswordMaxLength = getIntent().getIntExtra("password_max_length", mPasswordMaxLength);
mLockPatternUtils = new LockPatternUtils(this);
if (mLockPatternUtils.isDevicePolicyActive()) {
mRequestedMode = mLockPatternUtils.getRequestedPasswordMode();
mPasswordMinLength = mLockPatternUtils.getRequestedMinimumPasswordLength();
} else {
mRequestedMode = getIntent().getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY,
mRequestedMode);
mPasswordMinLength = getIntent().getIntExtra(PASSWORD_MIN_KEY, mPasswordMinLength);
}
mPasswordMaxLength = getIntent().getIntExtra(PASSWORD_MAX_KEY, mPasswordMaxLength);
initViews();
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
if (savedInstanceState == null) {
@@ -91,19 +97,22 @@ public class ChooseLockPassword extends Activity implements OnClickListener {
}
private void initViews() {
if (LockPatternUtils.MODE_PIN == mRequestedMode
|| LockPatternUtils.MODE_PASSWORD == mRequestedMode) {
setContentView(R.layout.choose_lock_pin);
// TODO: alphanumeric layout
// setContentView(R.layout.choose_lock_password);
for (int i = 0; i < digitIds.length; i++) {
Button button = (Button) findViewById(digitIds[i]);
button.setOnClickListener(this);
button.setText(Integer.toString(i));
}
findViewById(R.id.ok).setOnClickListener(this);
findViewById(R.id.cancel).setOnClickListener(this);
switch(mRequestedMode) {
case LockPatternUtils.MODE_PIN:
case LockPatternUtils.MODE_PASSWORD:
case LockPatternUtils.MODE_PATTERN:
setContentView(R.layout.choose_lock_pin);
// TODO: alphanumeric layout
// setContentView(R.layout.choose_lock_password);
for (int i = 0; i < digitIds.length; i++) {
Button button = (Button) findViewById(digitIds[i]);
button.setOnClickListener(this);
button.setText(Integer.toString(i));
}
break;
}
findViewById(R.id.ok).setOnClickListener(this);
findViewById(R.id.cancel).setOnClickListener(this);
findViewById(R.id.backspace).setOnClickListener(this);
mPasswordTextView = (TextView) findViewById(R.id.pinDisplay);
mHeaderText = (TextView) findViewById(R.id.headerText);
@@ -179,8 +188,6 @@ public class ChooseLockPassword extends Activity implements OnClickListener {
// TODO: move these to LockPatternUtils
mLockPatternUtils.setLockPatternEnabled(false);
mLockPatternUtils.saveLockPattern(null);
mLockPatternUtils.saveLockPassword(pin);
finish();
} else {

View File

@@ -33,7 +33,7 @@ public class ChooseLockPatternTutorial extends Activity implements View.OnClickL
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Don't show the tutorial if the user has seen it before.
LockPatternUtils lockPatternUtils = new LockPatternUtils(getContentResolver());
LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
if (savedInstanceState == null && lockPatternUtils.isPatternEverChosen()) {
Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.ChooseLockPattern");

View File

@@ -27,7 +27,7 @@ public class ChooseLockSettingsHelper {
public ChooseLockSettingsHelper(Activity activity) {
mActivity = activity;
mLockPatternUtils = new LockPatternUtils(activity.getContentResolver());
mLockPatternUtils = new LockPatternUtils(activity);
}
public LockPatternUtils utils() {

View File

@@ -39,7 +39,7 @@ public class ConfirmLockPassword extends Activity implements OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLockPatternUtils = new LockPatternUtils(getContentResolver());
mLockPatternUtils = new LockPatternUtils(this);
initViews();
}

View File

@@ -80,7 +80,7 @@ public class ConfirmLockPattern extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLockPatternUtils = new LockPatternUtils(getContentResolver());
mLockPatternUtils = new LockPatternUtils(this);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.confirm_lock_pattern);

View File

@@ -184,7 +184,7 @@ public class MasterClear extends Activity {
mInitialView = null;
mFinalView = null;
mInflater = LayoutInflater.from(this);
mLockUtils = new LockPatternUtils(getContentResolver());
mLockUtils = new LockPatternUtils(this);
establishInitialState();
}

View File

@@ -172,7 +172,7 @@ public class MediaFormat extends Activity {
mInitialView = null;
mFinalView = null;
mInflater = LayoutInflater.from(this);
mLockUtils = new LockPatternUtils(getContentResolver());
mLockUtils = new LockPatternUtils(this);
establishInitialState();
}

View File

@@ -89,6 +89,10 @@ public class SecuritySettings extends PreferenceActivity {
private static final String LOCATION_GPS = "location_gps";
private static final String ASSISTED_GPS = "assisted_gps";
// 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
private CredentialStorage mCredentialStorage = new CredentialStorage();
@@ -217,14 +221,12 @@ public class SecuritySettings extends PreferenceActivity {
if ("none".equals(value)) {
mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST);
} else if ("password".equals(value) || "pin".equals(value)) {
final int minLength = 4; // TODO: get from policy store.
final int maxLength = 16;
final int mode = "password".equals(value)
? LockPatternUtils.MODE_PASSWORD : LockPatternUtils.MODE_PIN;
Intent intent = new Intent().setClassName(PACKAGE, CHOOSE_LOCK_PIN);
intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, mode);
intent.putExtra(ChooseLockPassword.PASSWORD_MIN_KEY, minLength);
intent.putExtra(ChooseLockPassword.PASSWORD_MAX_KEY, maxLength);
intent.putExtra(ChooseLockPassword.PASSWORD_MIN_KEY, PASSWORD_MIN_LENGTH);
intent.putExtra(ChooseLockPassword.PASSWORD_MAX_KEY, PASSWORD_MAX_LENGTH);
startActivityForResult(intent, UPDATE_PASSWORD_REQUEST);
} else if ("pattern".equals(value)) {
boolean showTutorial = !lockPatternUtils.isPatternEverChosen();