Merge "[Settings] Adds an intent extra when setup wizard start the WallpaperSuggestionActivity"
diff --git a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
index e9e12e8..a5cc414 100644
--- a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
+++ b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
@@ -26,8 +26,10 @@
import com.android.settings.display.WallpaperPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.Indexable;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.search.SearchIndexableRaw;
+
+import com.google.android.setupcompat.util.WizardManagerHelper;
import java.util.ArrayList;
import java.util.List;
@@ -37,10 +39,15 @@
private static final String WALLPAPER_FLAVOR_EXTRA = "com.android.launcher3.WALLPAPER_FLAVOR";
private static final String WALLPAPER_FOCUS = "focus_wallpaper";
+ private static final String WALLPAPER_ONLY = "wallpaper_only";
@Override
protected void addExtras(Intent intent) {
- intent.putExtra(WALLPAPER_FLAVOR_EXTRA, WALLPAPER_FOCUS);
+ if (WizardManagerHelper.isAnySetupWizard(intent)) {
+ intent.putExtra(WALLPAPER_FLAVOR_EXTRA, WALLPAPER_ONLY);
+ } else {
+ intent.putExtra(WALLPAPER_FLAVOR_EXTRA, WALLPAPER_FOCUS);
+ }
}
@VisibleForTesting
diff --git a/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java
index 54a41a3..73f12c2 100644
--- a/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java
@@ -22,15 +22,20 @@
import android.app.Application;
import android.app.WallpaperManager;
+import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Resources;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;
@@ -48,6 +53,10 @@
@Mock
private Resources mResources;
+ private static final String PACKAGE_WALLPAPER_ACTIVITY =
+ "com.android.settings.wallpaper.WallpaperSuggestionActivity";
+ private static final String WALLPAPER_FLAVOR = "com.android.launcher3.WALLPAPER_FLAVOR";
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -90,6 +99,34 @@
.isTrue();
}
+ @Test
+ public void addExtras_intentFromSetupWizard_extrasHasWallpaperOnly() {
+ WallpaperSuggestionActivity activity =
+ Robolectric.buildActivity(WallpaperSuggestionActivity.class, new Intent(
+ Intent.ACTION_MAIN).setComponent(
+ new ComponentName(RuntimeEnvironment.application,
+ PACKAGE_WALLPAPER_ACTIVITY)).putExtra(
+ WizardManagerHelper.EXTRA_IS_FIRST_RUN, true).putExtra(
+ WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).setup().get();
+ Intent intent = Shadows.shadowOf(activity).getNextStartedActivity();
+
+ assertThat(intent).isNotNull();
+ assertThat(intent.getStringExtra(WALLPAPER_FLAVOR)).isEqualTo("wallpaper_only");
+ }
+
+ @Test
+ public void addExtras_intentNotFromSetupWizard_extrasHasFocusWallpaper() {
+ WallpaperSuggestionActivity activity = Robolectric.buildActivity(
+ WallpaperSuggestionActivity.class, new Intent(Intent.ACTION_MAIN).setComponent(
+ new ComponentName(RuntimeEnvironment.application,
+ PACKAGE_WALLPAPER_ACTIVITY))).setup().get();
+ Intent intent = Shadows.shadowOf(activity).getNextStartedActivity();
+
+ assertThat(intent).isNotNull();
+ assertThat(intent.getStringExtra(WALLPAPER_FLAVOR)).isEqualTo("focus_wallpaper");
+ }
+
+
@Implements(WallpaperManager.class)
public static class ShadowWallpaperManager extends
org.robolectric.shadows.ShadowWallpaperManager {