diff options
author | Ido Ofir <iofir@google.com> | 2017-04-28 11:57:29 -0700 |
---|---|---|
committer | Ido Ofir <iofir@google.com> | 2017-04-28 13:47:08 -0700 |
commit | 364d9cd8b8274709e46414b1d1bf6d91ec97160c (patch) | |
tree | 6beba10533ed2b644861f2651aa7948cd4f0f90e /library | |
parent | d43413dfcf15f21b07dc8f550b764a072a91843c (diff) | |
download | setupwizard-364d9cd8b8274709e46414b1d1bf6d91ec97160c.tar.gz |
Fix an issue with deferred setup wizard flag not being copied to new
intents. Also adds a new helper function to check said flag.
Test: added robolectric tests
Change-Id: I261dd01b81700ef27f7ae07580d53ef40531a596
Diffstat (limited to 'library')
-rw-r--r-- | library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java | 16 | ||||
-rw-r--r-- | library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java | 11 |
2 files changed, 27 insertions, 0 deletions
diff --git a/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java b/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java index f25d646..a93694c 100644 --- a/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java +++ b/library/main/src/com/android/setupwizardlib/util/WizardManagerHelper.java @@ -43,6 +43,8 @@ public class WizardManagerHelper { private static final String EXTRA_RESULT_CODE = "com.android.setupwizard.ResultCode"; @VisibleForTesting static final String EXTRA_IS_FIRST_RUN = "firstRun"; + @VisibleForTesting + static final String EXTRA_IS_DEFERRED_SETUP = "deferredSetup"; public static final String EXTRA_THEME = "theme"; public static final String EXTRA_USE_IMMERSIVE_MODE = "useImmersiveMode"; @@ -141,6 +143,8 @@ public class WizardManagerHelper { dstIntent.putExtra(EXTRA_THEME, srcIntent.getStringExtra(EXTRA_THEME)); dstIntent.putExtra(EXTRA_IS_FIRST_RUN, srcIntent.getBooleanExtra(EXTRA_IS_FIRST_RUN, false)); + dstIntent.putExtra(EXTRA_IS_DEFERRED_SETUP, + srcIntent.getBooleanExtra(EXTRA_IS_DEFERRED_SETUP, false)); dstIntent.putExtra(EXTRA_SCRIPT_URI, srcIntent.getStringExtra(EXTRA_SCRIPT_URI)); dstIntent.putExtra(EXTRA_ACTION_ID, srcIntent.getStringExtra(EXTRA_ACTION_ID)); } @@ -197,6 +201,18 @@ public class WizardManagerHelper { } /** + * Checks whether an intent is running in the deferred setup wizard flow. + * + * @param originalIntent The original intent that was used to start the step, usually via + * {@link android.app.Activity#getIntent()}. + * @return true if the intent passed in was running in deferred setup wizard. + */ + public static boolean isDeferredSetupWizard(Intent originalIntent) { + return originalIntent != null + && originalIntent.getBooleanExtra(EXTRA_IS_DEFERRED_SETUP, false); + } + + /** * Checks the intent whether the extra indicates that the light theme should be used or not. If * the theme is not specified in the intent, or the theme specified is unknown, the value def * will be returned. diff --git a/library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java b/library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java index 00de17e..4c460c8 100644 --- a/library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java +++ b/library/test/robotest/src/com/android/setupwizardlib/util/WizardManagerHelperTest.java @@ -80,6 +80,14 @@ public class WizardManagerHelperTest { } @Test + public void testIsDeferredSetupTrue() { + final Intent intent = new Intent(); + intent.putExtra("deferredSetup", true); + assertTrue("Is deferred setup wizard should be true", + WizardManagerHelper.isDeferredSetupWizard(intent)); + } + + @Test public void testIsSetupWizardFalse() { final Intent intent = new Intent(); intent.putExtra("firstRun", false); @@ -257,6 +265,7 @@ public class WizardManagerHelperTest { .putExtra(WizardManagerHelper.EXTRA_THEME, "test_theme") .putExtra(WizardManagerHelper.EXTRA_WIZARD_BUNDLE, wizardBundle) .putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true) + .putExtra(WizardManagerHelper.EXTRA_IS_DEFERRED_SETUP, true) // Script URI and Action ID are kept for backwards compatibility .putExtra(WizardManagerHelper.EXTRA_SCRIPT_URI, "test_script_uri") .putExtra(WizardManagerHelper.EXTRA_ACTION_ID, "test_action_id"); @@ -273,6 +282,8 @@ public class WizardManagerHelperTest { assertTrue("EXTRA_IS_FIRST_RUN should be copied", intent.getBooleanExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, false)); + assertTrue("EXTRA_IS_DEFERRED_SETUP should be copied", + intent.getBooleanExtra(WizardManagerHelper.EXTRA_IS_DEFERRED_SETUP, false)); // Script URI and Action ID are replaced by Wizard Bundle in M, but are kept for backwards // compatibility |