Update Work Challenge check to take userId

Change-Id: I239bca2dc55066c717d74487105646df22768d93
This commit is contained in:
Clara Bayarri
2015-12-18 16:40:18 +00:00
parent 8c9521f27c
commit b8a22e42d4
5 changed files with 25 additions and 13 deletions

View File

@@ -486,6 +486,7 @@ public class ChooseLockGeneric extends SettingsActivity {
if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
mChooseLockSettingsHelper.utils().clearLock(mUserId);
mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId);
mLockPatternUtils.setSeparateProfileChallengeEnabled(mUserId, false);
removeAllFingerprintTemplatesAndFinish();
getActivity().setResult(Activity.RESULT_OK);
} else {

View File

@@ -670,12 +670,11 @@ public class ChooseLockPassword extends SettingsActivity {
private String mChosenPassword;
private String mCurrentPassword;
private int mRequestedQuality;
private int mUserId;
public void start(LockPatternUtils utils, boolean required,
boolean hasChallenge, long challenge,
String chosenPassword, String currentPassword, int requestedQuality, int userId) {
prepare(utils, required, hasChallenge, challenge);
prepare(utils, required, hasChallenge, challenge, userId);
mChosenPassword = chosenPassword;
mCurrentPassword = currentPassword;

View File

@@ -671,12 +671,11 @@ public class ChooseLockPattern extends SettingsActivity {
private List<LockPatternView.Cell> mChosenPattern;
private String mCurrentPattern;
private boolean mLockVirgin;
private int mUserId;
public void start(LockPatternUtils utils, boolean credentialRequired,
boolean hasChallenge, long challenge,
List<LockPatternView.Cell> chosenPattern, String currentPattern, int userId) {
prepare(utils, credentialRequired, hasChallenge, challenge);
prepare(utils, credentialRequired, hasChallenge, challenge, userId);
mCurrentPattern = currentPattern;
mChosenPattern = chosenPattern;

View File

@@ -20,7 +20,6 @@ import android.app.Fragment;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.UserHandle;
import com.android.internal.widget.LockPatternUtils;
@@ -38,6 +37,7 @@ abstract class SaveChosenLockWorkerBase extends Fragment {
protected boolean mHasChallenge;
protected long mChallenge;
protected boolean mWasSecureBefore;
protected int mUserId;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -57,12 +57,15 @@ abstract class SaveChosenLockWorkerBase extends Fragment {
}
protected void prepare(LockPatternUtils utils, boolean credentialRequired,
boolean hasChallenge, long challenge) {
boolean hasChallenge, long challenge, int userId) {
mUtils = utils;
mUserId = userId;
mHasChallenge = hasChallenge;
mChallenge = challenge;
mWasSecureBefore = mUtils.isSecure(UserHandle.myUserId());
// This will be a no-op for non managed profiles.
mUtils.setSeparateProfileChallengeEnabled(mUserId, true);
mWasSecureBefore = mUtils.isSecure(mUserId);
mUtils.setCredentialRequiredToDecrypt(credentialRequired);

View File

@@ -223,7 +223,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
mProfileChallengeUserId = profile.id;
}
}
if (LockPatternUtils.isSeparateWorkChallengeEnabled()) {
if (mLockPatternUtils.isSeparateProfileChallengeAllowed(mProfileChallengeUserId)) {
addPreferencesFromResource(R.xml.security_settings_profile);
}
}
@@ -776,11 +776,21 @@ public class SecuritySettings extends SettingsPreferenceFragment
result.add(sir);
final UserManager um = UserManager.get(context);
boolean hasChildProfile = um.getProfiles(UserHandle.myUserId()).size() > 1;
if (hasChildProfile && LockPatternUtils.isSeparateWorkChallengeEnabled()) {
sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.security_settings_profile;
result.add(sir);
List<UserInfo> profiles = um.getProfiles(UserHandle.myUserId());
int numProfiles = profiles.size();
if (numProfiles > 1) {
int profileUserId = -1;
for (int i = 0; i < numProfiles; ++i) {
UserInfo profile = profiles.get(i);
if (profile.id != UserHandle.myUserId()) {
profileUserId = profile.id;
}
}
if (lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)) {
sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.security_settings_profile;
result.add(sir);
}
}
if (um.isAdminUser()) {