Start deep link page synchronously in SettingsActivity

- Use a synchronous API to make SettingsActivity start deep link intent
  in onCreate
- Change SettingsHomepageActivity from an alias to a real activity
- Clean up redundant codes

Fix: 206585572
Test: Manual, robotest build pass
Change-Id: Idf42c026f593bb5801a13cae250d1523030b7092
This commit is contained in:
Jason Chiu
2021-11-16 18:20:19 +08:00
parent 943d68127c
commit a3b21cf017
11 changed files with 82 additions and 246 deletions

View File

@@ -44,7 +44,6 @@ import com.android.settings.R;
import com.android.settings.Settings;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsApplication;
import com.android.settings.Utils;
import com.android.settings.accounts.AvatarViewMixin;
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
@@ -72,9 +71,6 @@ public class SettingsHomepageActivity extends FragmentActivity implements
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";
private static final int DEFAULT_HIGHLIGHT_MENU_KEY = R.string.menu_key_network;
private static final long HOMEPAGE_LOADING_TIMEOUT_MS = 300;
@@ -91,12 +87,12 @@ public class SettingsHomepageActivity extends FragmentActivity implements
}
/**
* Try to register a {@link HomepageLoadedListener}. If homepage is already loaded, the
* listener will not be notified.
* Try to add a {@link HomepageLoadedListener}. If homepage is already loaded, the listener
* will not be notified.
*
* @return Whether the listener should be registered.
* @return Whether the listener is added.
*/
public boolean registerHomepageLoadedListenerIfNeeded(HomepageLoadedListener listener) {
public boolean addHomepageLoadedListener(HomepageLoadedListener listener) {
if (mHomepageView == null) {
return false;
} else {
@@ -245,6 +241,13 @@ public class SettingsHomepageActivity extends FragmentActivity implements
return;
}
if (!(this instanceof DeepLinkHomepageActivity
|| this instanceof SliceDeepLinkHomepageActivity)) {
Log.e(TAG, "Not a deep link component");
finish();
return;
}
final String intentUriString = intent.getStringExtra(
EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI);
if (TextUtils.isEmpty(intentUriString)) {
@@ -287,7 +290,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
// Set 2-pane pair rule for the deep link page.
ActivityEmbeddingRulesController.registerTwoPanePairRule(this,
getDeepLinkComponent(),
new ComponentName(getApplicationContext(), getClass()),
targetComponentName,
targetIntent.getAction(),
true /* finishPrimaryWithSecondary */,
@@ -303,10 +306,6 @@ 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(),