Propagate extras when switching between choose lock activities

bug: 71715828
Test: Manually tested, added robolectric test
Change-Id: Ide18c94f52fe896aee0636ef702cd808b7d88638
This commit is contained in:
Ajay Nadathur
2018-01-10 11:37:23 -08:00
parent 9798ae86bf
commit b14b996dbf
2 changed files with 13 additions and 11 deletions

View File

@@ -72,31 +72,31 @@ public class ChooseLockTypeDialogFragment extends InstrumentedDialogFragment
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
// Copy the original extras into the new intent
copyBooleanExtra(activityIntent, intent,
ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
copyBooleanExtra(activityIntent, intent,
ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, false);
if (activityIntent.hasExtra(
ChooseLockGenericFragment.EXTRA_CHOOSE_LOCK_GENERIC_EXTRAS)) {
intent.putExtras(activityIntent.getBundleExtra(
ChooseLockGenericFragment.EXTRA_CHOOSE_LOCK_GENERIC_EXTRAS));
}
intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, selectedLockType.defaultQuality);
// Propagate the fingerprint challenge
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE,
activityIntent.getBooleanExtra(
ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false));
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE,
activityIntent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0));
// The user is already given the choice of the what screen lock to set up. No need to
// show this button again.
intent.putExtra(ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, false);
WizardManagerHelper.copyWizardManagerExtras(activityIntent, intent);
activity.startActivity(intent);
activity.finish();
}
}
private static void copyBooleanExtra(Intent from, Intent to, String name,
boolean defaultValue) {
to.putExtra(name, from.getBooleanExtra(name, defaultValue));
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

View File

@@ -137,6 +137,8 @@ public class SetupChooseLockPasswordTest {
ShadowActivity shadowActivity = shadowOf(activity);
final Intent nextStartedActivity = shadowActivity.getNextStartedActivity();
assertThat(nextStartedActivity).isNotNull();
assertThat(nextStartedActivity.getBooleanExtra(
ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, false)).isTrue();
assertThat(nextStartedActivity.getStringExtra("foo")).named("Foo extra")
.isEqualTo("bar");
}