Merge "Don't send split info callback before activity is created" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7bc9ba3bc5
@@ -777,22 +777,14 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCallbackIfNecessary() {
|
|
||||||
updateCallbackIfNecessary(true /* deferCallbackUntilAllActivitiesCreated */);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies listeners about changes to split states if necessary.
|
* Notifies listeners about changes to split states if necessary.
|
||||||
*
|
|
||||||
* @param deferCallbackUntilAllActivitiesCreated boolean to indicate whether the split info
|
|
||||||
* callback should be deferred until all the
|
|
||||||
* organized activities have been created.
|
|
||||||
*/
|
*/
|
||||||
private void updateCallbackIfNecessary(boolean deferCallbackUntilAllActivitiesCreated) {
|
private void updateCallbackIfNecessary() {
|
||||||
if (mEmbeddingCallback == null) {
|
if (mEmbeddingCallback == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (deferCallbackUntilAllActivitiesCreated && !allActivitiesCreated()) {
|
if (!allActivitiesCreated()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<SplitInfo> currentSplitStates = getActiveSplitStates();
|
List<SplitInfo> currentSplitStates = getActiveSplitStates();
|
||||||
@@ -848,9 +840,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
|||||||
for (int i = mTaskContainers.size() - 1; i >= 0; i--) {
|
for (int i = mTaskContainers.size() - 1; i >= 0; i--) {
|
||||||
final List<TaskFragmentContainer> containers = mTaskContainers.valueAt(i).mContainers;
|
final List<TaskFragmentContainer> containers = mTaskContainers.valueAt(i).mContainers;
|
||||||
for (TaskFragmentContainer container : containers) {
|
for (TaskFragmentContainer container : containers) {
|
||||||
if (container.getInfo() == null
|
if (!container.taskInfoActivityCountMatchesCreated()) {
|
||||||
|| container.getInfo().getActivities().size()
|
|
||||||
!= container.collectActivities().size()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1035,11 +1025,8 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
|||||||
&& container.getTaskFragmentToken().equals(initialTaskFragmentToken)) {
|
&& container.getTaskFragmentToken().equals(initialTaskFragmentToken)) {
|
||||||
// The onTaskFragmentInfoChanged callback containing this activity has not
|
// The onTaskFragmentInfoChanged callback containing this activity has not
|
||||||
// reached the client yet, so add the activity to the pending appeared
|
// reached the client yet, so add the activity to the pending appeared
|
||||||
// activities and send a split info callback to the client before
|
// activities.
|
||||||
// {@link Activity#onCreate} is called.
|
|
||||||
container.addPendingAppearedActivity(activity);
|
container.addPendingAppearedActivity(activity);
|
||||||
updateCallbackIfNecessary(
|
|
||||||
false /* deferCallbackUntilAllActivitiesCreated */);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,6 +145,18 @@ class TaskFragmentContainer {
|
|||||||
return allActivities;
|
return allActivities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the count of activities from the same process in task fragment info corresponds to
|
||||||
|
* the ones created and available on the client side.
|
||||||
|
*/
|
||||||
|
boolean taskInfoActivityCountMatchesCreated() {
|
||||||
|
if (mInfo == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return mPendingAppearedActivities.isEmpty()
|
||||||
|
&& mInfo.getActivities().size() == collectActivities().size();
|
||||||
|
}
|
||||||
|
|
||||||
ActivityStack toActivityStack() {
|
ActivityStack toActivityStack() {
|
||||||
return new ActivityStack(collectActivities(), isEmpty());
|
return new ActivityStack(collectActivities(), isEmpty());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user