Request legacy app transition when moveActivityToFront

Before, when there is no ActivityEmbedding, the transition is requested
later when the previous top Activity is paused to resume the Task top,
which works ok. But when there is ActivityEmbedding, the organizer may
request WCT that trigger visibility update before a transition is
requested, which cause a flicker.

When startActivity with FLAG_ACTIVITY_REORDER_TO_FRONT to bring an
existing activity to the front, we should call prepareAppTransition
early to make sure the following activity visibility change is tracked.

Fix: 255701223
Test: verify with FLAG_ACTIVITY_REORDER_TO_FRONT app
Change-Id: I65d4ffd1c17d6817c073122447e620a2fbb514a1
This commit is contained in:
Chris Li
2022-11-23 21:50:21 +08:00
parent 4013b5600d
commit 851685c401
2 changed files with 15 additions and 0 deletions

View File

@@ -55,7 +55,9 @@ import static android.content.pm.ActivityInfo.launchModeToString;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.Process.INVALID_UID;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_START_ACTIVITY_IN_TASK_FRAGMENT;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_CONFIGURATION;
@@ -2398,6 +2400,11 @@ class ActivityStarter {
if (actuallyMoved) {
// Only record if the activity actually moved.
mMovedToTopActivity = act;
if (mNoAnimation) {
act.mDisplayContent.prepareAppTransition(TRANSIT_NONE);
} else {
act.mDisplayContent.prepareAppTransition(TRANSIT_TO_FRONT);
}
}
act.updateOptionsLocked(mOptions);
deliverNewIntent(act, intentGrants);

View File

@@ -2605,6 +2605,14 @@ class TaskFragment extends WindowContainer<WindowContainer> {
return false;
}
@Override
boolean canCustomizeAppTransition() {
// This is only called when the app transition is going to be played by system server. In
// this case, we should allow custom app transition for fullscreen embedded TaskFragment
// just like Activity.
return isEmbedded() && matchParentBounds();
}
/** Clear {@link #mLastPausedActivity} for all {@link TaskFragment} children */
void clearLastPausedActivity() {
forAllTaskFragments(taskFragment -> taskFragment.mLastPausedActivity = null);