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

@@ -58,7 +58,6 @@ import androidx.preference.PreferenceManager;
import com.android.internal.util.ArrayUtils;
import com.android.settings.Settings.WifiSettingsActivity;
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
import com.android.settings.activityembedding.SplitStateObserver;
import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.core.OnActivityResultListener;
import com.android.settings.core.SettingsBaseActivity;
@@ -248,16 +247,21 @@ public class SettingsActivity extends SettingsBaseActivity
@Override
protected void onCreate(Bundle savedState) {
super.onCreate(savedState);
Log.d(LOG_TAG, "Starting onCreate");
long startTime = System.currentTimeMillis();
// Should happen before any call to getIntent()
getMetaData();
final Intent intent = getIntent();
registerSplitStateObserverForTwoPaneDeepLink();
if (shouldShowTwoPaneDeepLink(intent)) {
launchHomepageForTwoPaneDeepLink(intent);
finishAndRemoveTask();
super.onCreate(savedState);
return;
}
super.onCreate(savedState);
Log.d(LOG_TAG, "Starting onCreate");
long startTime = System.currentTimeMillis();
final FeatureFactory factory = FeatureFactory.getFactory(this);
mDashboardFeatureProvider = factory.getDashboardFeatureProvider(this);
@@ -362,30 +366,6 @@ public class SettingsActivity extends SettingsBaseActivity
}
}
private void registerSplitStateObserverForTwoPaneDeepLink() {
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)) {
return;
}
final SplitStateObserver splitStateObserver = new SplitStateObserver(this /* activity*/,
true /* listenOnce */,
splitInfos -> {
if (!splitInfos.isEmpty() || !SettingsActivity.this.isTaskRoot()) {
// It's already in 2-pane or in a non-empty task, there is no need to go
// 2-pane deep link flow.
return;
}
if (shouldShowTwoPaneDeepLink(getIntent())) {
launchHomepageForTwoPaneDeepLink(getIntent());
finishAndRemoveTask();
return;
}
}
);
getLifecycle().addObserver(splitStateObserver);
}
private boolean isSubSettings(Intent intent) {
return this instanceof SubSettings ||
intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);
@@ -435,6 +415,15 @@ public class SettingsActivity extends SettingsBaseActivity
}
private boolean shouldShowTwoPaneDeepLink(Intent intent) {
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)) {
return false;
}
// If the activity is not the task root, it should not start trampoline for deep links.
if (!isTaskRoot()) {
return false;
}
// Only starts trampoline for deep links. Should return false for all the cases that
// Settings app starts SettingsActivity or SubSetting by itself.
if (intent.getAction() == null) {