Fix a regression from miss detect cross-task target.

Regression from I9aff6399020df9012ba807a1b834c74ee07a7c50 in Task_SWTICH
The type of window container can also be ActivityRecord.
Also by passing transition targets instead of participants to
BNC#onTransactionReady, BNC can by-pass empty transition.

Bug: 274997067
Test: manual verify back-to-home/task/activity(includes TaskFragment)
animation work properly.

Change-Id: I5d88672e7700b543ae90619c3ed8012c849fdd86
This commit is contained in:
wilsonshih
2023-03-31 02:38:14 +00:00
parent f3f8e10b3b
commit d0dd340387
3 changed files with 22 additions and 8 deletions

View File

@@ -883,6 +883,12 @@
"group": "WM_SHOW_TRANSACTIONS",
"at": "com\/android\/server\/wm\/WindowSurfaceController.java"
},
"-1258739769": {
"message": "onTransactionReady, opening: %s, closing: %s, animating: %s, match: %b",
"level": "DEBUG",
"group": "WM_DEBUG_BACK_PREVIEW",
"at": "com\/android\/server\/wm\/BackNavigationController.java"
},
"-1257821162": {
"message": "OUT SURFACE %s: copied",
"level": "INFO",

View File

@@ -585,14 +585,14 @@ class BackNavigationController {
* The closing target should only exist in close list, but the opening target can be either in
* open or close list.
*/
void onTransactionReady(Transition transition) {
void onTransactionReady(Transition transition, ArrayList<Transition.ChangeInfo> targets) {
if (!isMonitoringTransition()) {
return;
}
final ArraySet<WindowContainer> targets = transition.mParticipants;
for (int i = targets.size() - 1; i >= 0; --i) {
final WindowContainer wc = targets.valueAt(i);
if (wc.asActivityRecord() == null && wc.asTask() == null) {
final WindowContainer wc = targets.get(i).mContainer;
if (wc.asActivityRecord() == null && wc.asTask() == null
&& wc.asTaskFragment() == null) {
continue;
}
// WC can be visible due to setLaunchBehind
@@ -605,6 +605,9 @@ class BackNavigationController {
final boolean matchAnimationTargets = isWaitBackTransition()
&& (transition.mType == TRANSIT_CLOSE || transition.mType == TRANSIT_TO_BACK)
&& mAnimationHandler.containsBackAnimationTargets(mTmpOpenApps, mTmpCloseApps);
ProtoLog.d(WM_DEBUG_BACK_PREVIEW,
"onTransactionReady, opening: %s, closing: %s, animating: %s, match: %b",
mTmpOpenApps, mTmpCloseApps, mAnimationHandler, matchAnimationTargets);
if (!matchAnimationTargets) {
mNavigationMonitor.onTransitionReadyWhileNavigate(mTmpOpenApps, mTmpCloseApps);
} else {
@@ -829,10 +832,16 @@ class BackNavigationController {
if (!mComposed) {
return false;
}
// WC must be ActivityRecord in legacy transition, but it also can be Task or
// TaskFragment when using Shell transition.
// Open target: Can be Task or ActivityRecord or TaskFragment
// Close target: Limit to the top activity for now, to reduce the chance of misjudgment.
final WindowContainer target = open ? mOpenAdaptor.mTarget : mCloseAdaptor.mTarget;
if (mSwitchType == TASK_SWITCH) {
return wc == target
|| (wc.asTask() != null && wc.hasChild(target));
|| (wc.asTask() != null && wc.hasChild(target))
|| (wc.asActivityRecord() != null && target.hasChild(wc));
} else if (mSwitchType == ACTIVITY_SWITCH) {
return wc == target || (wc.asTaskFragment() != null && wc.hasChild(target));
}

View File

@@ -1199,13 +1199,12 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
if (primaryDisplay.isKeyguardLocked()) {
mFlags |= TRANSIT_FLAG_KEYGUARD_LOCKED;
}
// Check whether the participants were animated from back navigation.
mController.mAtm.mBackNavigationController.onTransactionReady(this);
collectOrderChanges();
// Resolve the animating targets from the participants.
mTargets = calculateTargets(mParticipants, mChanges);
// Check whether the participants were animated from back navigation.
mController.mAtm.mBackNavigationController.onTransactionReady(this, mTargets);
final TransitionInfo info = calculateTransitionInfo(mType, mFlags, mTargets, transaction);
info.setDebugId(mSyncId);