Adding launch source info in the wallpaper picker intent (1/3)

When launching Wallpaper & Style from the settings search, we should
also append the launch source information to the intent.

The major purpose if for logging. So that we know then entrypoint of the
Wallpaper & Style app.

Test: Manually tested that the intent contains the extra we need
Bug: 368052505
Flag: EXEMPT bugfix
Change-Id: I9af663dad7cb79bfe74431e6a61cd34393e60dbd
This commit is contained in:
George Lin
2024-09-18 14:23:32 +00:00
parent 133fcf3dc5
commit 5406db9d6e
2 changed files with 10 additions and 7 deletions

View File

@@ -41,19 +41,20 @@ public class WallpaperSuggestionActivity extends StyleSuggestionActivityBase imp
private static final String WALLPAPER_FOCUS = "focus_wallpaper"; private static final String WALLPAPER_FOCUS = "focus_wallpaper";
private static final String WALLPAPER_ONLY = "wallpaper_only"; private static final String WALLPAPER_ONLY = "wallpaper_only";
private static final String LAUNCHED_SUW = "app_launched_suw"; private static final String LAUNCHED_SUW = "app_launched_suw";
private static final String LAUNCH_SOURCE_SETTINGS_SEARCH = "app_launched_settings_search";
private String mWallpaperLaunchExtra;
@Override @Override
protected void addExtras(Intent intent) { protected void addExtras(Intent intent) {
String wallpaperLaunchExtra =
getResources().getString(R.string.config_wallpaper_picker_launch_extra);;
if (WizardManagerHelper.isAnySetupWizard(intent)) { if (WizardManagerHelper.isAnySetupWizard(intent)) {
intent.putExtra(WALLPAPER_FLAVOR_EXTRA, WALLPAPER_ONLY); intent.putExtra(WALLPAPER_FLAVOR_EXTRA, WALLPAPER_ONLY);
intent.putExtra(wallpaperLaunchExtra, LAUNCHED_SUW);
mWallpaperLaunchExtra =
getResources().getString(R.string.config_wallpaper_picker_launch_extra);
intent.putExtra(mWallpaperLaunchExtra, LAUNCHED_SUW);
} else { } else {
// This is the case when user enter the wallpaper picker from the search result entry
// on the Settings app
intent.putExtra(WALLPAPER_FLAVOR_EXTRA, WALLPAPER_FOCUS); intent.putExtra(WALLPAPER_FLAVOR_EXTRA, WALLPAPER_FOCUS);
intent.putExtra(wallpaperLaunchExtra, LAUNCH_SOURCE_SETTINGS_SEARCH);
} }
} }

View File

@@ -118,7 +118,7 @@ public class WallpaperSuggestionActivityTest {
} }
@Test @Test
public void addExtras_intentNotFromSetupWizard_extrasHasFocusWallpaper() { public void addExtras_intentNotFromSetupWizard_extrasHasFocusWallpaperAndLaunchedSettingsSearch() {
WallpaperSuggestionActivity activity = Robolectric.buildActivity( WallpaperSuggestionActivity activity = Robolectric.buildActivity(
WallpaperSuggestionActivity.class, new Intent(Intent.ACTION_MAIN).setComponent( WallpaperSuggestionActivity.class, new Intent(Intent.ACTION_MAIN).setComponent(
new ComponentName(RuntimeEnvironment.application, new ComponentName(RuntimeEnvironment.application,
@@ -127,6 +127,8 @@ public class WallpaperSuggestionActivityTest {
assertThat(intent).isNotNull(); assertThat(intent).isNotNull();
assertThat(intent.getStringExtra(WALLPAPER_FLAVOR)).isEqualTo("focus_wallpaper"); assertThat(intent.getStringExtra(WALLPAPER_FLAVOR)).isEqualTo("focus_wallpaper");
assertThat(intent.getStringExtra(WALLPAPER_LAUNCH_SOURCE))
.isEqualTo("app_launched_settings_search");
} }