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

View File

@@ -25,15 +25,15 @@ 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 static final int REQUESTCODE_EXAMPLE = 1;
private View mNextButton; private View mNextButton;
private View mSkipButton; private View mSkipButton;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// 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(getContentResolver()); LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
if (savedInstanceState == null && lockPatternUtils.isPatternEverChosen()) { if (savedInstanceState == null && lockPatternUtils.isPatternEverChosen()) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.ChooseLockPattern"); intent.setClassName("com.android.settings", "com.android.settings.ChooseLockPattern");
@@ -43,7 +43,7 @@ public class ChooseLockPatternTutorial extends Activity implements View.OnClickL
initViews(); initViews();
} }
} }
private void initViews() { private void initViews() {
setContentView(R.layout.choose_lock_pattern_tutorial); setContentView(R.layout.choose_lock_pattern_tutorial);
mNextButton = findViewById(R.id.next_button); mNextButton = findViewById(R.id.next_button);
@@ -70,6 +70,6 @@ public class ChooseLockPatternTutorial extends Activity implements View.OnClickL
finish(); finish();
} }
} }
} }

View File

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

View File

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

View File

@@ -80,7 +80,7 @@ public class ConfirmLockPattern extends Activity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mLockPatternUtils = new LockPatternUtils(getContentResolver()); mLockPatternUtils = new LockPatternUtils(this);
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.confirm_lock_pattern); setContentView(R.layout.confirm_lock_pattern);
@@ -94,7 +94,7 @@ public class ConfirmLockPattern extends Activity {
final LinearLayoutWithDefaultTouchRecepient topLayout final LinearLayoutWithDefaultTouchRecepient topLayout
= (LinearLayoutWithDefaultTouchRecepient) findViewById( = (LinearLayoutWithDefaultTouchRecepient) findViewById(
R.id.topLayout); R.id.topLayout);
topLayout.setDefaultTouchRecepient(mLockPatternView); topLayout.setDefaultTouchRecepient(mLockPatternView);
Intent intent = getIntent(); Intent intent = getIntent();
if (intent != null) { if (intent != null) {
@@ -161,7 +161,7 @@ public class ConfirmLockPattern extends Activity {
} else { } else {
mFooterTextView.setText(R.string.lockpattern_need_to_unlock_footer); mFooterTextView.setText(R.string.lockpattern_need_to_unlock_footer);
} }
mLockPatternView.setEnabled(true); mLockPatternView.setEnabled(true);
mLockPatternView.enableInput(); mLockPatternView.enableInput();
break; break;
@@ -176,7 +176,7 @@ public class ConfirmLockPattern extends Activity {
} else { } else {
mFooterTextView.setText(R.string.lockpattern_need_to_unlock_wrong_footer); mFooterTextView.setText(R.string.lockpattern_need_to_unlock_wrong_footer);
} }
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong); mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
mLockPatternView.setEnabled(true); mLockPatternView.setEnabled(true);
mLockPatternView.enableInput(); mLockPatternView.enableInput();

View File

@@ -53,7 +53,7 @@ public class MasterClear extends Activity {
private View mFinalView; private View mFinalView;
private Button mFinalButton; private Button mFinalButton;
/** /**
* The user has gone through the multiple confirmation, so now we go ahead * The user has gone through the multiple confirmation, so now we go ahead
* and invoke the Checkin Service to reset the device to its factory-default * and invoke the Checkin Service to reset the device to its factory-default
* state (rebooting in the process). * state (rebooting in the process).
@@ -65,7 +65,7 @@ public class MasterClear extends Activity {
return; return;
} }
ICheckinService service = ICheckinService service =
ICheckinService.Stub.asInterface(ServiceManager.getService("checkin")); ICheckinService.Stub.asInterface(ServiceManager.getService("checkin"));
if (service != null) { if (service != null) {
try { try {
@@ -159,7 +159,7 @@ public class MasterClear extends Activity {
* click in order to initiate a confirmation sequence. This method is * click in order to initiate a confirmation sequence. This method is
* called from various other points in the code to reset the activity to * called from various other points in the code to reset the activity to
* this base state. * this base state.
* *
* <p>Reinflating views from resources is expensive and prevents us from * <p>Reinflating views from resources is expensive and prevents us from
* caching widget pointers, so we use a single-inflate pattern: we lazy- * caching widget pointers, so we use a single-inflate pattern: we lazy-
* inflate each view, caching all of the widget pointers we'll need at the * inflate each view, caching all of the widget pointers we'll need at the
@@ -184,7 +184,7 @@ public class MasterClear extends Activity {
mInitialView = null; mInitialView = null;
mFinalView = null; mFinalView = null;
mInflater = LayoutInflater.from(this); mInflater = LayoutInflater.from(this);
mLockUtils = new LockPatternUtils(getContentResolver()); mLockUtils = new LockPatternUtils(this);
establishInitialState(); establishInitialState();
} }

View File

@@ -147,7 +147,7 @@ public class MediaFormat extends Activity {
* click in order to initiate a confirmation sequence. This method is * click in order to initiate a confirmation sequence. This method is
* called from various other points in the code to reset the activity to * called from various other points in the code to reset the activity to
* this base state. * this base state.
* *
* <p>Reinflating views from resources is expensive and prevents us from * <p>Reinflating views from resources is expensive and prevents us from
* caching widget pointers, so we use a single-inflate pattern: we lazy- * caching widget pointers, so we use a single-inflate pattern: we lazy-
* inflate each view, caching all of the widget pointers we'll need at the * inflate each view, caching all of the widget pointers we'll need at the
@@ -172,7 +172,7 @@ public class MediaFormat extends Activity {
mInitialView = null; mInitialView = null;
mFinalView = null; mFinalView = null;
mInflater = LayoutInflater.from(this); mInflater = LayoutInflater.from(this);
mLockUtils = new LockPatternUtils(getContentResolver()); mLockUtils = new LockPatternUtils(this);
establishInitialState(); establishInitialState();
} }

View File

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