Improve work profile unification flow
When unifying work profile challenge, keep the device lock as long as it will still meet password requirement after unification. If not, prompt the user to set a new device lock and only unify work challenge after a compliant device lock is set. Bug: 148630506 Fix: 149682344 Test: make RunSettingsRoboTests ROBOTEST_FILTER='ChooseLockGenericTest|ChooseLockPasswordTest|ChooseLockPatternTest|LockUnificationPreferenceControllerTest' Change-Id: I99cde2650902927f6a4cc7c0cc7c6016e0dc283f
This commit is contained in:
@@ -35,12 +35,14 @@ import static org.robolectric.Shadows.shadowOf;
|
||||
import android.app.Activity;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings.Global;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.internal.widget.LockscreenCredential;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.biometrics.BiometricEnrollBase;
|
||||
import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
|
||||
@@ -312,6 +314,56 @@ public class ChooseLockGenericTest {
|
||||
.isEqualTo("app name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnifyProfile_IntentPassedToChooseLockPassword() {
|
||||
final Bundle arguments = new Bundle();
|
||||
arguments.putInt(ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_ID, 11);
|
||||
arguments.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_CREDENTIAL,
|
||||
LockscreenCredential.createNone());
|
||||
mFragment.setArguments(arguments);
|
||||
|
||||
Intent intent = new Intent().putExtra(
|
||||
LockPatternUtils.PASSWORD_TYPE_KEY,
|
||||
DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
|
||||
initActivity(intent);
|
||||
|
||||
mFragment.updatePreferencesOrFinish(false /* isRecreatingActivity */);
|
||||
|
||||
Intent nextIntent = shadowOf(mActivity).getNextStartedActivity();
|
||||
assertThat(nextIntent).isNotNull();
|
||||
assertThat(nextIntent.getComponent().getClassName()).isEqualTo(
|
||||
ChooseLockPassword.class.getName());
|
||||
assertThat(nextIntent.getIntExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_ID, 0)).isEqualTo(11);
|
||||
assertThat((LockscreenCredential) nextIntent.getParcelableExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_CREDENTIAL)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnifyProfile_IntentPassedToChooseLockPattern() {
|
||||
final Bundle arguments = new Bundle();
|
||||
arguments.putInt(ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_ID, 13);
|
||||
arguments.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_CREDENTIAL,
|
||||
LockscreenCredential.createNone());
|
||||
mFragment.setArguments(arguments);
|
||||
|
||||
Intent intent = new Intent().putExtra(
|
||||
LockPatternUtils.PASSWORD_TYPE_KEY,
|
||||
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
|
||||
initActivity(intent);
|
||||
|
||||
mFragment.updatePreferencesOrFinish(false /* isRecreatingActivity */);
|
||||
|
||||
Intent nextIntent = shadowOf(mActivity).getNextStartedActivity();
|
||||
assertThat(nextIntent).isNotNull();
|
||||
assertThat(nextIntent.getComponent().getClassName()).isEqualTo(
|
||||
ChooseLockPattern.class.getName());
|
||||
assertThat(nextIntent.getIntExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_ID, 0)).isEqualTo(13);
|
||||
assertThat((LockscreenCredential) nextIntent.getParcelableExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_CREDENTIAL)).isNotNull();
|
||||
}
|
||||
|
||||
private void initActivity(@Nullable Intent intent) {
|
||||
if (intent == null) {
|
||||
intent = new Intent();
|
||||
|
@@ -147,6 +147,21 @@ public class ChooseLockPasswordTest {
|
||||
assertThat(intent.hasExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void intentBuilder_setProfileToUnify_shouldAddExtras() {
|
||||
Intent intent = new IntentBuilder(application)
|
||||
.setProfileToUnify(23, LockscreenCredential.createNone())
|
||||
.build();
|
||||
|
||||
assertThat(intent.getIntExtra(ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_ID, 0))
|
||||
.named("EXTRA_KEY_UNIFICATION_PROFILE_ID")
|
||||
.isEqualTo(23);
|
||||
assertThat((LockscreenCredential) intent.getParcelableExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_CREDENTIAL))
|
||||
.named("EXTRA_KEY_UNIFICATION_PROFILE_CREDENTIAL")
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void processAndValidatePasswordRequirements_noMinPasswordComplexity() {
|
||||
mShadowDpm.setPasswordQuality(PASSWORD_QUALITY_ALPHABETIC);
|
||||
|
@@ -92,6 +92,21 @@ public class ChooseLockPatternTest {
|
||||
.isEqualTo(123);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void intentBuilder_setProfileToUnify_shouldAddExtras() {
|
||||
Intent intent = new IntentBuilder(application)
|
||||
.setProfileToUnify(23, LockscreenCredential.createNone())
|
||||
.build();
|
||||
|
||||
assertThat(intent.getIntExtra(ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_ID, 0))
|
||||
.named("EXTRA_KEY_UNIFICATION_PROFILE_ID")
|
||||
.isEqualTo(23);
|
||||
assertThat((LockscreenCredential) intent.getParcelableExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_CREDENTIAL))
|
||||
.named("EXTRA_KEY_UNIFICATION_PROFILE_CREDENTIAL")
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Config(qualifiers = "sw400dp")
|
||||
@Test
|
||||
public void fingerprintExtraSet_shouldDisplayFingerprintIcon() {
|
||||
|
Reference in New Issue
Block a user