Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 389ef0bb authored by Ming-Shin Lu's avatar Ming-Shin Lu
Browse files

Fix no cross-profile thumbnail animation

As the task of the launching activity requests attaching cross-profile
thumbnail animation but in Transication#onTransitionReady didn't be
promoted into change list, so it ends up no-op since attaching thumbnail
for cross-task requires the animating target is the task.

Fix the issue by
1) Add {FLAG_CROSS_PROFILE_OWNER_THUMBNAIL,
   FLAG_CROSS_PROFILE_WORK_THUMBNAIL} in TransitionInfo.Change for shell
   to know which thumbnail icon should load, according to the userId of
   launching activity.
2) Remove isTask and add 1)'s change flag check in
   attachCrossProfileThumbnailAnimation to make the thumbnail animation
   can be played and attached on the activity-level.

Fix: 239798040
Test: as issue steps
 1) Use Gmail app
 2) Tap the account icon
 3) Select "Switch to personal profile" (or "Switch to work profile")
 4) Expect the dimmed background thumbnail icon with
    task opening transition are animated in parallel
Change-Id: I90eecf4e8ba104c7234a39d1b2638295820d2ac7
parent 58507e26
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -119,6 +119,12 @@ public final class TransitionInfo implements Parcelable {
    /** The container is going to show IME on its task after the transition. */
    public static final int FLAG_WILL_IME_SHOWN = 1 << 11;

    /** The container attaches owner profile thumbnail for cross profile animation. */
    public static final int FLAG_CROSS_PROFILE_OWNER_THUMBNAIL = 1 << 12;

    /** The container attaches work profile thumbnail for cross profile animation. */
    public static final int FLAG_CROSS_PROFILE_WORK_THUMBNAIL = 1 << 13;

    /** @hide */
    @IntDef(prefix = { "FLAG_" }, value = {
            FLAG_NONE,
@@ -508,6 +514,11 @@ public final class TransitionInfo implements Parcelable {
            return mFlags;
        }

        /** Whether the given change flags has included in this change. */
        public boolean hasFlags(@ChangeFlags int flags) {
            return (mFlags & flags) != 0;
        }

        /**
         * @return the bounds of the container before the change. It may be empty if the container
         * is coming into existence.
+10 −4
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ import static android.view.WindowManager.TRANSIT_RELAUNCH;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.view.WindowManager.transitTypeToString;
import static android.window.TransitionInfo.FLAG_CROSS_PROFILE_OWNER_THUMBNAIL;
import static android.window.TransitionInfo.FLAG_CROSS_PROFILE_WORK_THUMBNAIL;
import static android.window.TransitionInfo.FLAG_DISPLAY_HAS_ALERT_WINDOWS;
import static android.window.TransitionInfo.FLAG_IS_DISPLAY;
import static android.window.TransitionInfo.FLAG_IS_VOICE_INTERACTION;
@@ -903,11 +905,10 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
    private void attachThumbnail(@NonNull ArrayList<Animator> animations,
            @NonNull Runnable finishCallback, TransitionInfo.Change change,
            TransitionInfo.AnimationOptions options, float cornerRadius) {
        final boolean isTask = change.getTaskInfo() != null;
        final boolean isOpen = Transitions.isOpeningType(change.getMode());
        final boolean isClose = Transitions.isClosingType(change.getMode());
        if (isOpen) {
            if (options.getType() == ANIM_OPEN_CROSS_PROFILE_APPS && isTask) {
            if (options.getType() == ANIM_OPEN_CROSS_PROFILE_APPS) {
                attachCrossProfileThumbnailAnimation(animations, finishCallback, change,
                        cornerRadius);
            } else if (options.getType() == ANIM_THUMBNAIL_SCALE_UP) {
@@ -922,8 +923,13 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
            @NonNull Runnable finishCallback, TransitionInfo.Change change, float cornerRadius) {
        final Rect bounds = change.getEndAbsBounds();
        // Show the right drawable depending on the user we're transitioning to.
        final Drawable thumbnailDrawable = change.getTaskInfo().userId == mCurrentUserId
                ? mContext.getDrawable(R.drawable.ic_account_circle) : mEnterpriseThumbnailDrawable;
        final Drawable thumbnailDrawable = change.hasFlags(FLAG_CROSS_PROFILE_OWNER_THUMBNAIL)
                        ? mContext.getDrawable(R.drawable.ic_account_circle)
                        : change.hasFlags(FLAG_CROSS_PROFILE_WORK_THUMBNAIL)
                                ? mEnterpriseThumbnailDrawable : null;
        if (thumbnailDrawable == null) {
            return;
        }
        final HardwareBuffer thumbnail = mTransitionAnimation.createCrossProfileAppsThumbnail(
                thumbnailDrawable, bounds);
        if (thumbnail == null) {
+14 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.wm;

import static android.app.ActivityOptions.ANIM_OPEN_CROSS_PROFILE_APPS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
@@ -817,6 +818,19 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
                transaction);
        if (mOverrideOptions != null) {
            info.setAnimationOptions(mOverrideOptions);
            if (mOverrideOptions.getType() == ANIM_OPEN_CROSS_PROFILE_APPS) {
                for (int i = 0; i < mTargets.size(); ++i) {
                    final TransitionInfo.Change c = info.getChanges().get(i);
                    final ActivityRecord ar = mTargets.get(i).asActivityRecord();
                    if (ar == null || c.getMode() != TRANSIT_OPEN) continue;
                    int flags = c.getFlags();
                    flags |= ar.mUserId == ar.mWmService.mCurrentUserId
                            ? TransitionInfo.FLAG_CROSS_PROFILE_OWNER_THUMBNAIL
                            : TransitionInfo.FLAG_CROSS_PROFILE_WORK_THUMBNAIL;
                    c.setFlags(flags);
                    break;
                }
            }
        }

        // TODO(b/188669821): Move to animation impl in shell.