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

Commit 99b91f95 authored by Chris Li's avatar Chris Li Committed by Android (Google) Code Review
Browse files

Merge "Override all open/close animation for organized app" into sc-v2-dev

parents e25bce2d f738fadd
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -16,9 +16,13 @@

package androidx.window.extensions.embedding;

import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CHANGE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;

import android.util.Log;
import android.view.RemoteAnimationAdapter;
@@ -45,8 +49,12 @@ class TaskFragmentAnimationController {
        final RemoteAnimationDefinition definition = new RemoteAnimationDefinition();
        final RemoteAnimationAdapter animationAdapter =
                new RemoteAnimationAdapter(mRemoteRunner, 0, 0, true /* changeNeedsSnapshot */);
        definition.addRemoteAnimation(TRANSIT_OLD_ACTIVITY_OPEN, animationAdapter);
        definition.addRemoteAnimation(TRANSIT_OLD_TASK_FRAGMENT_OPEN, animationAdapter);
        definition.addRemoteAnimation(TRANSIT_OLD_TASK_OPEN, animationAdapter);
        definition.addRemoteAnimation(TRANSIT_OLD_ACTIVITY_CLOSE, animationAdapter);
        definition.addRemoteAnimation(TRANSIT_OLD_TASK_FRAGMENT_CLOSE, animationAdapter);
        definition.addRemoteAnimation(TRANSIT_OLD_TASK_CLOSE, animationAdapter);
        definition.addRemoteAnimation(TRANSIT_OLD_TASK_FRAGMENT_CHANGE, animationAdapter);
        mOrganizer.registerRemoteAnimations(definition);
    }
+8 −0
Original line number Diff line number Diff line
@@ -17,9 +17,13 @@
package androidx.window.extensions.embedding;

import static android.view.RemoteAnimationTarget.MODE_CLOSING;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CHANGE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;

import android.animation.Animator;
import android.animation.ValueAnimator;
@@ -155,9 +159,13 @@ class TaskFragmentAnimationRunner extends IRemoteAnimationRunner.Stub {
            @WindowManager.TransitionOldType int transit,
            @NonNull RemoteAnimationTarget[] targets) {
        switch (transit) {
            case TRANSIT_OLD_ACTIVITY_OPEN:
            case TRANSIT_OLD_TASK_FRAGMENT_OPEN:
            case TRANSIT_OLD_TASK_OPEN:
                return createOpenAnimationAdapters(targets);
            case TRANSIT_OLD_ACTIVITY_CLOSE:
            case TRANSIT_OLD_TASK_FRAGMENT_CLOSE:
            case TRANSIT_OLD_TASK_CLOSE:
                return createCloseAnimationAdapters(targets);
            case TRANSIT_OLD_TASK_FRAGMENT_CHANGE:
                return createChangeAnimationAdapters(targets);
+6 −12
Original line number Diff line number Diff line
@@ -65,7 +65,10 @@ import static com.android.server.wm.ActivityTaskManagerInternal.APP_TRANSITION_S
import static com.android.server.wm.ActivityTaskManagerInternal.APP_TRANSITION_SPLASH_SCREEN;
import static com.android.server.wm.ActivityTaskManagerInternal.APP_TRANSITION_WINDOWS_DRAWN;
import static com.android.server.wm.AppTransition.isNormalTransit;
import static com.android.server.wm.NonAppWindowAnimationAdapter.shouldAttachNavBarToApp;
import static com.android.server.wm.NonAppWindowAnimationAdapter.shouldStartNonAppWindowAnimationsForKeyguardExit;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.WallpaperAnimationAdapter.shouldStartWallpaperAnimation;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
@@ -529,18 +532,9 @@ public class AppTransitionController {
        // Having {@code transit} of those types doesn't mean it will contain non-app windows, but
        // non-app windows will only be included with those transition types. And we don't currently
        // have any use case of those for TaskFragment transition.
        // @see NonAppWindowAnimationAdapter#startNonAppWindowAnimations
        if (transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY
                || transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER
                || transit == TRANSIT_OLD_TASK_OPEN || transit == TRANSIT_OLD_TASK_TO_FRONT
                || transit == TRANSIT_OLD_WALLPAPER_CLOSE) {
            return true;
        }

        // Check if the wallpaper is going to participate in the transition. We don't want to have
        // the client to animate the wallpaper windows.
        // @see WallpaperAnimationAdapter#startWallpaperAnimations
        return mDisplayContent.mWallpaperController.isWallpaperVisible();
        return shouldStartNonAppWindowAnimationsForKeyguardExit(transit)
                || shouldAttachNavBarToApp(mService, mDisplayContent, transit)
                || shouldStartWallpaperAnimation(mDisplayContent);
    }

    /**
+20 −13
Original line number Diff line number Diff line
@@ -69,25 +69,32 @@ class NonAppWindowAnimationAdapter implements AnimationAdapter {
            long durationHint, long statusBarTransitionDelay,
            ArrayList<NonAppWindowAnimationAdapter> adaptersOut) {
        final ArrayList<RemoteAnimationTarget> targets = new ArrayList<>();
        if (transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY
                || transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER) {
        if (shouldStartNonAppWindowAnimationsForKeyguardExit(transit)) {
            startNonAppWindowAnimationsForKeyguardExit(
                    service, durationHint, statusBarTransitionDelay, targets, adaptersOut);
        } else if (transit == TRANSIT_OLD_TASK_OPEN || transit == TRANSIT_OLD_TASK_TO_FRONT
                || transit == TRANSIT_OLD_WALLPAPER_CLOSE) {
            final boolean shouldAttachNavBarToApp =
                    displayContent.getDisplayPolicy().shouldAttachNavBarToAppDuringTransition()
                            && service.getRecentsAnimationController() == null
                            && displayContent.getFadeRotationAnimationController() == null;
            if (shouldAttachNavBarToApp) {
        } else if (shouldAttachNavBarToApp(service, displayContent, transit)) {
            startNavigationBarWindowAnimation(
                    displayContent, durationHint, statusBarTransitionDelay, targets,
                    adaptersOut);
        }
        }
        return targets.toArray(new RemoteAnimationTarget[targets.size()]);
    }

    static boolean shouldStartNonAppWindowAnimationsForKeyguardExit(
            @WindowManager.TransitionOldType int transit) {
        return transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY
                || transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER;
    }

    static boolean shouldAttachNavBarToApp(WindowManagerService service,
            DisplayContent displayContent, @WindowManager.TransitionOldType int transit) {
        return (transit == TRANSIT_OLD_TASK_OPEN || transit == TRANSIT_OLD_TASK_TO_FRONT
                || transit == TRANSIT_OLD_WALLPAPER_CLOSE)
                && displayContent.getDisplayPolicy().shouldAttachNavBarToAppDuringTransition()
                && service.getRecentsAnimationController() == null
                && displayContent.getFadeRotationAnimationController() == null;
    }

    /**
     * Creates and starts remote animations for all the visible non app windows.
     *
+5 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ class WallpaperAnimationAdapter implements AnimationAdapter {
            long durationHint, long statusBarTransitionDelay,
            Consumer<WallpaperAnimationAdapter> animationCanceledRunnable,
            ArrayList<WallpaperAnimationAdapter> adaptersOut) {
        if (!displayContent.mWallpaperController.isWallpaperVisible()) {
        if (!shouldStartWallpaperAnimation(displayContent)) {
            ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS,
                    "\tWallpaper of display=%s is not visible", displayContent);
            return new RemoteAnimationTarget[0];
@@ -87,6 +87,10 @@ class WallpaperAnimationAdapter implements AnimationAdapter {
        return targets.toArray(new RemoteAnimationTarget[targets.size()]);
    }

    static boolean shouldStartWallpaperAnimation(DisplayContent displayContent) {
        return displayContent.mWallpaperController.isWallpaperVisible();
    }

    /**
     * Create a remote animation target for this animation adapter.
     */