Fix 2385283: Add DevicePolicyManager calls to LockScreen.
This commit is contained in:
@@ -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 {
|
||||
|
@@ -25,15 +25,15 @@ import android.view.View;
|
||||
|
||||
public class ChooseLockPatternTutorial extends Activity implements View.OnClickListener {
|
||||
private static final int REQUESTCODE_EXAMPLE = 1;
|
||||
|
||||
|
||||
private View mNextButton;
|
||||
private View mSkipButton;
|
||||
|
||||
|
||||
@Override
|
||||
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");
|
||||
@@ -43,7 +43,7 @@ public class ChooseLockPatternTutorial extends Activity implements View.OnClickL
|
||||
initViews();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initViews() {
|
||||
setContentView(R.layout.choose_lock_pattern_tutorial);
|
||||
mNextButton = findViewById(R.id.next_button);
|
||||
@@ -70,6 +70,6 @@ public class ChooseLockPatternTutorial extends Activity implements View.OnClickL
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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() {
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
@@ -94,7 +94,7 @@ public class ConfirmLockPattern extends Activity {
|
||||
final LinearLayoutWithDefaultTouchRecepient topLayout
|
||||
= (LinearLayoutWithDefaultTouchRecepient) findViewById(
|
||||
R.id.topLayout);
|
||||
topLayout.setDefaultTouchRecepient(mLockPatternView);
|
||||
topLayout.setDefaultTouchRecepient(mLockPatternView);
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
@@ -161,7 +161,7 @@ public class ConfirmLockPattern extends Activity {
|
||||
} else {
|
||||
mFooterTextView.setText(R.string.lockpattern_need_to_unlock_footer);
|
||||
}
|
||||
|
||||
|
||||
mLockPatternView.setEnabled(true);
|
||||
mLockPatternView.enableInput();
|
||||
break;
|
||||
@@ -176,7 +176,7 @@ public class ConfirmLockPattern extends Activity {
|
||||
} else {
|
||||
mFooterTextView.setText(R.string.lockpattern_need_to_unlock_wrong_footer);
|
||||
}
|
||||
|
||||
|
||||
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
|
||||
mLockPatternView.setEnabled(true);
|
||||
mLockPatternView.enableInput();
|
||||
|
@@ -53,7 +53,7 @@ public class MasterClear extends Activity {
|
||||
private View mFinalView;
|
||||
private Button mFinalButton;
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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
|
||||
* state (rebooting in the process).
|
||||
@@ -65,7 +65,7 @@ public class MasterClear extends Activity {
|
||||
return;
|
||||
}
|
||||
|
||||
ICheckinService service =
|
||||
ICheckinService service =
|
||||
ICheckinService.Stub.asInterface(ServiceManager.getService("checkin"));
|
||||
if (service != null) {
|
||||
try {
|
||||
@@ -159,7 +159,7 @@ public class MasterClear extends Activity {
|
||||
* click in order to initiate a confirmation sequence. This method is
|
||||
* called from various other points in the code to reset the activity to
|
||||
* this base state.
|
||||
*
|
||||
*
|
||||
* <p>Reinflating views from resources is expensive and prevents us from
|
||||
* 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
|
||||
@@ -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();
|
||||
}
|
||||
|
@@ -147,7 +147,7 @@ public class MediaFormat extends Activity {
|
||||
* click in order to initiate a confirmation sequence. This method is
|
||||
* called from various other points in the code to reset the activity to
|
||||
* this base state.
|
||||
*
|
||||
*
|
||||
* <p>Reinflating views from resources is expensive and prevents us from
|
||||
* 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
|
||||
@@ -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();
|
||||
}
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user