[Settings] Adds an intent extra when setup wizard start the WallpaperSuggestionActivity
before: https://hsv.googleplex.com/4812887816142848 changed: https://hsv.googleplex.com/5670376870772736 Bug: b/139653958 Test: manual Change-Id: I54de39059f7215d25f37c0d88d92e03bc5a076d4
This commit is contained in:
@@ -26,8 +26,10 @@ import androidx.annotation.VisibleForTesting;
|
||||
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 @@ public class WallpaperSuggestionActivity extends StyleSuggestionActivityBase imp
|
||||
|
||||
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
|
||||
|
@@ -22,15 +22,20 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
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 @@ public class WallpaperSuggestionActivityTest {
|
||||
@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 @@ public class WallpaperSuggestionActivityTest {
|
||||
.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 {
|
||||
|
Reference in New Issue
Block a user