[Large screen] Check if it's in 2-pane before 2-pane deep link flow

The callback of SplitStateObserver.SplitStateListener can have one
or more active splits when there is already 2-pane in Activity stack.

This change prevent unnecessary 2-pane deep link flow if the Activity
is already in 2-pane activity stack.

This solution does not work if the Activity was started in a new task.
(e.g., Intent.FLAG_ACTIVITY_NEW_TASK, launchMode singleTask).

Bug: 201379454
Bug: 201620626
Bug: 204398432
Bug: 204397936
Bug: 197609195
Bug: 197609197
Bug: 204501179
Bug: 204959335
Bug: 204845334
Test: manual
      1. Settings -> Apps > Default apps > Opening links.
      2. Click back button should back to Default apps page.
Change-Id: I04aaceed47a8f2754a4e17c53b49252f61e0a1d1
This commit is contained in:
Arc Wang
2021-11-01 19:07:43 +08:00
parent 02ccb048bf
commit e80b74de3a
3 changed files with 108 additions and 19 deletions

View File

@@ -63,10 +63,6 @@ public class SettingsHomepageActivity extends FragmentActivity implements
private static final String TAG = "SettingsHomepageActivity";
// Additional extra of Settings#ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK.
// Put true value to the intent when startActivity for a deep link intent from this Activity.
public static final String EXTRA_IS_FROM_SETTINGS_HOMEPAGE = "is_from_settings_homepage";
// Additional extra of Settings#ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK.
// Set & get Uri of the Intent separately to prevent failure of Intent#ParseUri.
public static final String EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_DATA =
@@ -268,11 +264,11 @@ public class SettingsHomepageActivity extends FragmentActivity implements
// Sender of intent may want to send intent extra data to the destination of targetIntent.
targetIntent.replaceExtras(intent);
targetIntent.putExtra(EXTRA_IS_FROM_SETTINGS_HOMEPAGE, true);
targetIntent.putExtra(SettingsActivity.EXTRA_IS_FROM_SLICE, false);
targetIntent.setData(intent.getParcelableExtra(
SettingsHomepageActivity.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_DATA));
// Set 2-pane pair rule for the deep link page.
ActivityEmbeddingRulesController.registerTwoPanePairRule(this,
getDeepLinkComponent(),