DO NOT MERGE: Fix DPM.ACTION_SET_NEW_PASSWORD

This is a cherry-pick of ag/1640561.

1. Context.getActivityToken is not available in n mr2, passed the token
   from the activity to the controller instead.

2. Haven't pick the tests from master to mr2 branch because robotest
   is not set up in mr2 branch.

Fix: 32959373

Change-Id: I2f73d01ab11e91b337beb90c05bbcb857dfd40dc
This commit is contained in:
Tony Mak
2016-12-12 02:29:55 +00:00
parent c04f8b9ecd
commit 8a2f28a629
6 changed files with 199 additions and 60 deletions

View File

@@ -186,22 +186,15 @@ public class ChooseLockGeneric extends SettingsActivity {
ENCRYPT_REQUESTED_DISABLED);
}
int targetUser = Utils.getSecureTargetUser(
// a) If this is started from other user, use that user id.
// b) If this is started from the same user, read the extra if this is launched
// from Settings app itself.
// c) Otherwise, use UserHandle.myUserId().
mUserId = Utils.getSecureTargetUser(
getActivity().getActivityToken(),
UserManager.get(getActivity()),
null,
getArguments(),
getActivity().getIntent().getExtras()).getIdentifier();
if (ACTION_SET_NEW_PARENT_PROFILE_PASSWORD.equals(chooseLockAction)
|| !mLockPatternUtils.isSeparateProfileChallengeAllowed(targetUser)) {
// Always use parent if explicitely requested or if profile challenge is not
// supported
Bundle arguments = getArguments();
mUserId = Utils.getUserIdFromBundle(getContext(), arguments != null ? arguments
: getActivity().getIntent().getExtras());
} else {
mUserId = targetUser;
}
if (ACTION_SET_NEW_PASSWORD.equals(chooseLockAction)
&& Utils.isManagedProfile(UserManager.get(getActivity()), mUserId)
&& mLockPatternUtils.isSeparateProfileChallengeEnabled(mUserId)) {
@@ -256,6 +249,8 @@ public class ChooseLockGeneric extends SettingsActivity {
} else if (KEY_SKIP_FINGERPRINT.equals(key)) {
Intent chooseLockGenericIntent = new Intent(getActivity(), ChooseLockGeneric.class);
chooseLockGenericIntent.setAction(getIntent().getAction());
// Forward the target user id to ChooseLockGeneric.
chooseLockGenericIntent.putExtra(Intent.EXTRA_USER_ID, mUserId);
chooseLockGenericIntent.putExtra(PASSWORD_CONFIRMED, mPasswordConfirmed);
startActivityForResult(chooseLockGenericIntent, SKIP_FINGERPRINT_REQUEST);
return true;
@@ -343,6 +338,8 @@ public class ChooseLockGeneric extends SettingsActivity {
if (data != null) {
intent.putExtras(data.getExtras());
}
// Forward the target user id to fingerprint setup page.
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
startActivity(intent);
finish();
} else if (requestCode == SKIP_FINGERPRINT_REQUEST) {