[Large screen] Make slice deep linking to Settings show in 2-pane

- add a standalone home activity for slice deep link.
- add EXTRA_IS_FROM_SLICE to control the slice deep link flow.
- Intent#parseUri fails if the intent data schema is set.
  Add EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_DATA to relay the
  data schema.

Bug: 201397123
Test: manual, robotest
      1.  Say 'Enable NFC'/'Enable Bluetooth'to Google assistant.
      2.  Click the the NFC/BT Slice.
Change-Id: Ia3216956328c32b2109cb2d70ad1105327661f26
This commit is contained in:
Arc Wang
2021-09-28 20:39:15 +08:00
committed by Jason Chiu
parent 929e577e1b
commit a63e9c625d
6 changed files with 126 additions and 28 deletions

View File

@@ -61,9 +61,15 @@ 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 =
"settings_large_screen_deep_link_intent_data";
// An alias class name of SettingsHomepageActivity.
public static final String ALIAS_DEEP_LINK = "com.android.settings.DeepLinkHomepageActivity";
@@ -232,10 +238,13 @@ public class SettingsHomepageActivity extends FragmentActivity implements
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,
new ComponentName(Utils.SETTINGS_PACKAGE_NAME, ALIAS_DEEP_LINK),
getDeepLinkComponent(),
targetComponentName,
targetIntent.getAction(),
true /* finishPrimaryWithSecondary */,
@@ -249,6 +258,10 @@ public class SettingsHomepageActivity extends FragmentActivity implements
startActivity(targetIntent);
}
protected ComponentName getDeepLinkComponent() {
return new ComponentName(Utils.SETTINGS_PACKAGE_NAME, ALIAS_DEEP_LINK);
}
private String getHighlightMenuKey() {
final Intent intent = getIntent();
if (intent != null && TextUtils.equals(intent.getAction(),