From 5406db9d6eff187a81a2061220a7cc34e399483a Mon Sep 17 00:00:00 2001 From: George Lin Date: Wed, 18 Sep 2024 14:23:32 +0000 Subject: [PATCH] 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 --- .../wallpaper/WallpaperSuggestionActivity.java | 13 +++++++------ .../wallpaper/WallpaperSuggestionActivityTest.java | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java index 14ef4833588..00bd0f23cdc 100644 --- a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java +++ b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java @@ -41,19 +41,20 @@ public class WallpaperSuggestionActivity extends StyleSuggestionActivityBase imp private static final String WALLPAPER_FOCUS = "focus_wallpaper"; private static final String WALLPAPER_ONLY = "wallpaper_only"; private static final String LAUNCHED_SUW = "app_launched_suw"; - - private String mWallpaperLaunchExtra; + private static final String LAUNCH_SOURCE_SETTINGS_SEARCH = "app_launched_settings_search"; @Override protected void addExtras(Intent intent) { + String wallpaperLaunchExtra = + getResources().getString(R.string.config_wallpaper_picker_launch_extra);; if (WizardManagerHelper.isAnySetupWizard(intent)) { intent.putExtra(WALLPAPER_FLAVOR_EXTRA, WALLPAPER_ONLY); - - mWallpaperLaunchExtra = - getResources().getString(R.string.config_wallpaper_picker_launch_extra); - intent.putExtra(mWallpaperLaunchExtra, LAUNCHED_SUW); + intent.putExtra(wallpaperLaunchExtra, LAUNCHED_SUW); } 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(wallpaperLaunchExtra, LAUNCH_SOURCE_SETTINGS_SEARCH); } } diff --git a/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java index 3f6d785463d..230b443f296 100644 --- a/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java +++ b/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java @@ -118,7 +118,7 @@ public class WallpaperSuggestionActivityTest { } @Test - public void addExtras_intentNotFromSetupWizard_extrasHasFocusWallpaper() { + public void addExtras_intentNotFromSetupWizard_extrasHasFocusWallpaperAndLaunchedSettingsSearch() { WallpaperSuggestionActivity activity = Robolectric.buildActivity( WallpaperSuggestionActivity.class, new Intent(Intent.ACTION_MAIN).setComponent( new ComponentName(RuntimeEnvironment.application, @@ -127,6 +127,8 @@ public class WallpaperSuggestionActivityTest { assertThat(intent).isNotNull(); assertThat(intent.getStringExtra(WALLPAPER_FLAVOR)).isEqualTo("focus_wallpaper"); + assertThat(intent.getStringExtra(WALLPAPER_LAUNCH_SOURCE)) + .isEqualTo("app_launched_settings_search"); }