[Activity embedding] Fix unexpected finished 2nd layer problem

If Settings is started on an existing task, the existing SplitPairRule
may cause an unexpected app finish while navigating back from the
2nd layer page.

This change resets SplitPairRule in onCreate().

Bug: 247080168
Test: make RunSettingsRoboTests ROBOTEST_FILTER=SettingsHomepageActivityTest
      manual
      1. Settings app -> 'Connexted device'.
      2. Launch Settings app again from Settings icon in quick Settings.
      3. Start a 3rd layer from 'Network & internet'
      4. Click back and see if the 2nd lay shows.
Change-Id: I262327cc49c3a4434a183eb00ac57f47fa598f70
This commit is contained in:
Arc Wang
2022-10-25 15:55:59 +08:00
parent c972af0ca7
commit 31eec49217
2 changed files with 31 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Toolbar;
import androidx.annotation.VisibleForTesting;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
@@ -223,10 +224,23 @@ public class SettingsHomepageActivity extends FragmentActivity implements
if (shouldLaunchDeepLinkIntentToRight()) {
launchDeepLinkIntentToRight();
}
// Settings app may be launched on an existing task. Reset SplitPairRule of SubSettings here
// to prevent SplitPairRule of an existing task applied on a new started Settings app.
if (ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)
&& (getIntent().getFlags() & Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0) {
initSplitPairRules();
}
updateHomepagePaddings();
updateSplitLayout();
}
@VisibleForTesting
void initSplitPairRules() {
new ActivityEmbeddingRulesController(getApplicationContext()).initRules();
}
@Override
protected void onStart() {
((SettingsApplication) getApplication()).setHomeActivity(this);