Do Not Report Activities that are Finishing

...in TaskFragment

There may be a delay between when an activity is marked
to finish and when the WM hierarchy actually removes the
activity from the TaskFragment. In between this delay,
the TaskFragmentInfo will change because the runningActivityCount
will change, triggering an onTaskFragmentInfoChanged.
This callback is unncessary because there will be another
callback soon once the activity is removed from the hierarchy.

Bug: b/205901017
Test: atest CtsWindowManagerJetpackTestCases:ActivityEmbeddingLaunchTests
Change-Id: I64e08acc2a745f6f242996e99240fe4a8f0dea97
Merged-In: Id773ac3f0afea198ad4f8b4594d7a4cf0ad98ea8
This commit is contained in:
Shivam Agrawal
2021-11-16 11:59:38 -08:00
parent 7a696c99da
commit 32e0508252
2 changed files with 7 additions and 8 deletions

View File

@@ -103,7 +103,7 @@ class TaskFragmentContainer {
ActivityThread activityThread = ActivityThread.currentActivityThread();
for (IBinder token : mInfo.getActivities()) {
Activity activity = activityThread.getActivity(token);
if (activity != null && !allActivities.contains(activity)) {
if (activity != null && !activity.isFinishing() && !allActivities.contains(activity)) {
allActivities.add(activity);
}
}

View File

@@ -2171,14 +2171,13 @@ class TaskFragment extends WindowContainer<WindowContainer> {
TaskFragmentInfo getTaskFragmentInfo() {
List<IBinder> childActivities = new ArrayList<>();
for (int i = 0; i < getChildCount(); i++) {
WindowContainer wc = getChildAt(i);
if (mTaskFragmentOrganizerUid != INVALID_UID
&& wc.asActivityRecord() != null
&& wc.asActivityRecord().info.processName.equals(
mTaskFragmentOrganizerProcessName)
&& wc.asActivityRecord().getUid() == mTaskFragmentOrganizerUid) {
final WindowContainer wc = getChildAt(i);
final ActivityRecord ar = wc.asActivityRecord();
if (mTaskFragmentOrganizerUid != INVALID_UID && ar != null
&& ar.info.processName.equals(mTaskFragmentOrganizerProcessName)
&& ar.getUid() == mTaskFragmentOrganizerUid && !ar.finishing) {
// Only includes Activities that belong to the organizer process for security.
childActivities.add(wc.asActivityRecord().appToken);
childActivities.add(ar.appToken);
}
}
final Point positionInParent = new Point();