From 6f9f3a459419db410504642b4d7e1466ce0592e8 Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Mon, 5 Jun 2023 15:50:54 -0700 Subject: [PATCH] Fixes nav stack issue. By marking the Intent that's being sent to WPP as "launched from settings", the code in CustomizationPickerActivity can correctly conclude that the multi-pane wrapper does not need to be applied to the intent, preventing the odd "disordering" of the back stack in the bug. Fix: 284809020 Test: manually verified, on a large screen device with a multi-pane settings configuration, that going to Display > Lock screen > Shortcuts and then swiping back off the left edge of the display correctly exits settings instead of revealing an incorrect screen like it did in the bug. Test: also manually verified that the long-press on the home screena and on the lock screen paths both open the right tab in WPP in settings correctly. Change-Id: Iac2b4e9fa5bab91b6a5251f1c51b4d21a0824f00 --- .../display/CustomizableLockScreenUtils.java | 15 ++++++++++++++- ...nQuickAffordancesPreferenceControllerTest.java | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/display/CustomizableLockScreenUtils.java b/src/com/android/settings/display/CustomizableLockScreenUtils.java index d945652e880..23444364c6a 100644 --- a/src/com/android/settings/display/CustomizableLockScreenUtils.java +++ b/src/com/android/settings/display/CustomizableLockScreenUtils.java @@ -60,6 +60,12 @@ public final class CustomizableLockScreenUtils { @VisibleForTesting static final String AFFORDANCE_NAME = "affordance_name"; + @VisibleForTesting + static final String WALLPAPER_LAUNCH_SOURCE = "com.android.wallpaper.LAUNCH_SOURCE"; + @VisibleForTesting + static final String LAUNCH_SOURCE_SETTINGS = "app_launched_settings"; + + private CustomizableLockScreenUtils() {} /** @@ -163,7 +169,14 @@ public final class CustomizableLockScreenUtils { * activity. */ public static Intent newIntent() { - return new Intent(Intent.ACTION_SET_WALLPAPER); + final Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER); + // By adding the launch source here, we tell our destination (in this case, the wallpaper + // picker app) that it's been launched from within settings. That way, if we are in a + // multi-pane configuration (for example, for large screens), the wallpaper picker app can + // safely skip redirecting to the multi-pane version of its activity, as it's already opened + // within a multi-pane configuration context. + intent.putExtra(WALLPAPER_LAUNCH_SOURCE, LAUNCH_SOURCE_SETTINGS); + return intent; } private static boolean isWallpaperPickerInstalled(Context context) { diff --git a/tests/robotests/src/com/android/settings/display/CustomizableLockScreenQuickAffordancesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/CustomizableLockScreenQuickAffordancesPreferenceControllerTest.java index e92dbe6cb5e..bf316e9d9bc 100644 --- a/tests/robotests/src/com/android/settings/display/CustomizableLockScreenQuickAffordancesPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/display/CustomizableLockScreenQuickAffordancesPreferenceControllerTest.java @@ -114,6 +114,9 @@ public class CustomizableLockScreenQuickAffordancesPreferenceControllerTest { assertThat(intentCaptor.getValue().getPackage()).isEqualTo( mContext.getString(R.string.config_wallpaper_picker_package)); assertThat(intentCaptor.getValue().getAction()).isEqualTo(Intent.ACTION_SET_WALLPAPER); + assertThat(intentCaptor.getValue().getStringExtra( + CustomizableLockScreenUtils.WALLPAPER_LAUNCH_SOURCE)).isEqualTo( + CustomizableLockScreenUtils.LAUNCH_SOURCE_SETTINGS); assertThat(intentCaptor.getValue().getStringExtra("destination")) .isEqualTo("quick_affordances"); }