Fix 2385283: Add DevicePolicyManager calls to LockScreen.
This commit is contained in:
@@ -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,8 +97,10 @@ 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:
|
||||||
|
case LockPatternUtils.MODE_PASSWORD:
|
||||||
|
case LockPatternUtils.MODE_PATTERN:
|
||||||
setContentView(R.layout.choose_lock_pin);
|
setContentView(R.layout.choose_lock_pin);
|
||||||
// TODO: alphanumeric layout
|
// TODO: alphanumeric layout
|
||||||
// setContentView(R.layout.choose_lock_password);
|
// setContentView(R.layout.choose_lock_password);
|
||||||
@@ -101,9 +109,10 @@ public class ChooseLockPassword extends Activity implements OnClickListener {
|
|||||||
button.setOnClickListener(this);
|
button.setOnClickListener(this);
|
||||||
button.setText(Integer.toString(i));
|
button.setText(Integer.toString(i));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
findViewById(R.id.ok).setOnClickListener(this);
|
findViewById(R.id.ok).setOnClickListener(this);
|
||||||
findViewById(R.id.cancel).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 {
|
||||||
|
@@ -33,7 +33,7 @@ public class ChooseLockPatternTutorial extends Activity implements View.OnClickL
|
|||||||
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");
|
||||||
|
@@ -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() {
|
||||||
|
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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);
|
||||||
|
@@ -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();
|
||||||
}
|
}
|
||||||
|
@@ -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();
|
||||||
}
|
}
|
||||||
|
@@ -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();
|
||||||
|
Reference in New Issue
Block a user