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) { if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
mChooseLockSettingsHelper.utils().clearLock(mUserId); mChooseLockSettingsHelper.utils().clearLock(mUserId);
mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId); mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId);
mLockPatternUtils.setSeparateProfileChallengeEnabled(mUserId, false);
removeAllFingerprintTemplatesAndFinish(); removeAllFingerprintTemplatesAndFinish();
getActivity().setResult(Activity.RESULT_OK); getActivity().setResult(Activity.RESULT_OK);
} else { } else {

View File

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

View File

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

View File

@@ -20,7 +20,6 @@ import android.app.Fragment;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.UserHandle;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
@@ -38,6 +37,7 @@ abstract class SaveChosenLockWorkerBase extends Fragment {
protected boolean mHasChallenge; protected boolean mHasChallenge;
protected long mChallenge; protected long mChallenge;
protected boolean mWasSecureBefore; protected boolean mWasSecureBefore;
protected int mUserId;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@@ -57,12 +57,15 @@ abstract class SaveChosenLockWorkerBase extends Fragment {
} }
protected void prepare(LockPatternUtils utils, boolean credentialRequired, protected void prepare(LockPatternUtils utils, boolean credentialRequired,
boolean hasChallenge, long challenge) { boolean hasChallenge, long challenge, int userId) {
mUtils = utils; mUtils = utils;
mUserId = userId;
mHasChallenge = hasChallenge; mHasChallenge = hasChallenge;
mChallenge = challenge; 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); mUtils.setCredentialRequiredToDecrypt(credentialRequired);

View File

@@ -223,7 +223,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
mProfileChallengeUserId = profile.id; mProfileChallengeUserId = profile.id;
} }
} }
if (LockPatternUtils.isSeparateWorkChallengeEnabled()) { if (mLockPatternUtils.isSeparateProfileChallengeAllowed(mProfileChallengeUserId)) {
addPreferencesFromResource(R.xml.security_settings_profile); addPreferencesFromResource(R.xml.security_settings_profile);
} }
} }
@@ -776,12 +776,22 @@ public class SecuritySettings extends SettingsPreferenceFragment
result.add(sir); result.add(sir);
final UserManager um = UserManager.get(context); final UserManager um = UserManager.get(context);
boolean hasChildProfile = um.getProfiles(UserHandle.myUserId()).size() > 1; List<UserInfo> profiles = um.getProfiles(UserHandle.myUserId());
if (hasChildProfile && LockPatternUtils.isSeparateWorkChallengeEnabled()) { 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 = new SearchIndexableResource(context);
sir.xmlResId = R.xml.security_settings_profile; sir.xmlResId = R.xml.security_settings_profile;
result.add(sir); result.add(sir);
} }
}
if (um.isAdminUser()) { if (um.isAdminUser()) {
DevicePolicyManager dpm = (DevicePolicyManager) DevicePolicyManager dpm = (DevicePolicyManager)