Do not send split info update when TaskFragmentContainer

...in a split has no activities

If a TaskFragmentContainer in a SplitContainer has no
activities, then that means that either the entire split
is going to be removed or the empty TaskFragmentContainer
is about to get a running activity. This CL prevents a
split info update from sent in this case because the info
will soon be stale by another update.

Bug: b/204193051
Test: atest CtsWindowManagerJetpackTestCases:ActivityEmbeddingLaunchTests
Change-Id: I4b6f684b8d8e9a9b3fefd54b399d8a7d83c6cfb0
This commit is contained in:
Shivam Agrawal
2021-10-29 11:36:49 -07:00
parent 9c906fbc94
commit 5cb70ee9d4

View File

@@ -497,7 +497,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
return; return;
} }
List<SplitInfo> currentSplitStates = getActiveSplitStates(); List<SplitInfo> currentSplitStates = getActiveSplitStates();
if (mLastReportedSplitStates.equals(currentSplitStates)) { if (currentSplitStates == null || mLastReportedSplitStates.equals(currentSplitStates)) {
return; return;
} }
mLastReportedSplitStates.clear(); mLastReportedSplitStates.clear();
@@ -506,15 +506,19 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
} }
/** /**
* Returns a list of descriptors for currently active split states. * @return a list of descriptors for currently active split states. If the value returned is
* null, that indicates that the active split states are in an intermediate state and should
* not be reported.
*/ */
@Nullable
private List<SplitInfo> getActiveSplitStates() { private List<SplitInfo> getActiveSplitStates() {
List<SplitInfo> splitStates = new ArrayList<>(); List<SplitInfo> splitStates = new ArrayList<>();
for (SplitContainer container : mSplitContainers) { for (SplitContainer container : mSplitContainers) {
if (container.getPrimaryContainer().isEmpty() if (container.getPrimaryContainer().isEmpty()
|| container.getSecondaryContainer().isEmpty()) { || container.getSecondaryContainer().isEmpty()) {
// Skipping containers that do not have any activities to report. // We are in an intermediate state because either the split container is about to be
continue; // removed or the primary or secondary container are about to receive an activity.
return null;
} }
ActivityStack primaryContainer = container.getPrimaryContainer().toActivityStack(); ActivityStack primaryContainer = container.getPrimaryContainer().toActivityStack();
ActivityStack secondaryContainer = container.getSecondaryContainer().toActivityStack(); ActivityStack secondaryContainer = container.getSecondaryContainer().toActivityStack();