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

Commit f3741120 authored by Tony Huang's avatar Tony Huang
Browse files

Make sure launcher side can animate divider

Fix divider target should pass to remote animation runner and add
mIsDividerRemoteAnimating flag to eusure launcher side controlling
the divider surface and shell side do not controll until remote
animation finished.

Bug: 202914644
Test: manual
Test: pass existing tests
Merged-In: I6411a609268274355a38c72fcb5d628b76b2340c
Change-Id: I6411a609268274355a38c72fcb5d628b76b2340c
parent f1ecb267
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -352,7 +352,7 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
    }
    }


    RemoteAnimationTarget[] onGoingToRecentsLegacy(boolean cancel, RemoteAnimationTarget[] apps) {
    RemoteAnimationTarget[] onGoingToRecentsLegacy(boolean cancel, RemoteAnimationTarget[] apps) {
        if (!isSplitScreenVisible()) return null;
        if (apps.length < 2) return null;
        final SurfaceControl.Builder builder = new SurfaceControl.Builder(new SurfaceSession())
        final SurfaceControl.Builder builder = new SurfaceControl.Builder(new SurfaceSession())
                .setContainerLayer()
                .setContainerLayer()
                .setName("RecentsAnimationSplitTasks")
                .setName("RecentsAnimationSplitTasks")
+21 −6
Original line number Original line Diff line number Diff line
@@ -157,6 +157,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
    private boolean mExitSplitScreenOnHide;
    private boolean mExitSplitScreenOnHide;
    private boolean mKeyguardOccluded;
    private boolean mKeyguardOccluded;
    private boolean mDeviceSleep;
    private boolean mDeviceSleep;
    private boolean mIsDividerRemoteAnimating;


    @StageType
    @StageType
    private int mDismissTop = NO_DISMISS;
    private int mDismissTop = NO_DISMISS;
@@ -363,6 +364,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
    void startTasksWithLegacyTransition(int mainTaskId, @Nullable Bundle mainOptions,
    void startTasksWithLegacyTransition(int mainTaskId, @Nullable Bundle mainOptions,
            int sideTaskId, @Nullable Bundle sideOptions, @SplitPosition int sidePosition,
            int sideTaskId, @Nullable Bundle sideOptions, @SplitPosition int sidePosition,
            float splitRatio, RemoteAnimationAdapter adapter) {
            float splitRatio, RemoteAnimationAdapter adapter) {
        // Init divider first to make divider leash for remote animation target.
        setDividerVisibility(true /* visible */);
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        // Need to add another wrapper here in shell so that we can inject the divider bar
        // Need to add another wrapper here in shell so that we can inject the divider bar
        // and also manage the process elevation via setRunningRemote
        // and also manage the process elevation via setRunningRemote
@@ -373,12 +376,23 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                    RemoteAnimationTarget[] wallpapers,
                    RemoteAnimationTarget[] wallpapers,
                    RemoteAnimationTarget[] nonApps,
                    RemoteAnimationTarget[] nonApps,
                    final IRemoteAnimationFinishedCallback finishedCallback) {
                    final IRemoteAnimationFinishedCallback finishedCallback) {
                mIsDividerRemoteAnimating = true;
                RemoteAnimationTarget[] augmentedNonApps =
                RemoteAnimationTarget[] augmentedNonApps =
                        new RemoteAnimationTarget[nonApps.length + 1];
                        new RemoteAnimationTarget[nonApps.length + 1];
                for (int i = 0; i < nonApps.length; ++i) {
                for (int i = 0; i < nonApps.length; ++i) {
                    augmentedNonApps[i] = nonApps[i];
                    augmentedNonApps[i] = nonApps[i];
                }
                }
                augmentedNonApps[augmentedNonApps.length - 1] = getDividerBarLegacyTarget();
                augmentedNonApps[augmentedNonApps.length - 1] = getDividerBarLegacyTarget();

                IRemoteAnimationFinishedCallback wrapCallback =
                        new IRemoteAnimationFinishedCallback.Stub() {
                            @Override
                            public void onAnimationFinished() throws RemoteException {
                                mIsDividerRemoteAnimating = false;
                                mSyncQueue.runInSync(t -> applyDividerVisibility(t));
                                finishedCallback.onAnimationFinished();
                            }
                        };
                try {
                try {
                    try {
                    try {
                        ActivityTaskManager.getService().setRunningRemoteTransitionDelegate(
                        ActivityTaskManager.getService().setRunningRemoteTransitionDelegate(
@@ -387,8 +401,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                        Slog.e(TAG, "Unable to boost animation thread. This should only happen"
                        Slog.e(TAG, "Unable to boost animation thread. This should only happen"
                                + " during unit tests");
                                + " during unit tests");
                    }
                    }
                    adapter.getRunner().onAnimationStart(transit, apps, wallpapers, nonApps,
                    adapter.getRunner().onAnimationStart(transit, apps, wallpapers,
                            finishedCallback);
                            augmentedNonApps, wrapCallback);
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    Slog.e(TAG, "Error starting remote animation", e);
                    Slog.e(TAG, "Error starting remote animation", e);
                }
                }
@@ -396,6 +410,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,


            @Override
            @Override
            public void onAnimationCancelled() {
            public void onAnimationCancelled() {
                mIsDividerRemoteAnimating = false;
                try {
                try {
                    adapter.getRunner().onAnimationCancelled();
                    adapter.getRunner().onAnimationCancelled();
                } catch (RemoteException e) {
                } catch (RemoteException e) {
@@ -812,7 +827,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
    }
    }


    private void setDividerVisibility(boolean visible) {
    private void setDividerVisibility(boolean visible) {
        if (mDividerVisible == visible) return;
        if (mIsDividerRemoteAnimating || mDividerVisible == visible) return;
        mDividerVisible = visible;
        mDividerVisible = visible;
        if (visible) {
        if (visible) {
            mSplitLayout.init();
            mSplitLayout.init();
@@ -860,10 +875,10 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
    }
    }


    private void applyDividerVisibility(SurfaceControl.Transaction t) {
    private void applyDividerVisibility(SurfaceControl.Transaction t) {
        if  (mIsDividerRemoteAnimating) return;

        final SurfaceControl dividerLeash = mSplitLayout.getDividerLeash();
        final SurfaceControl dividerLeash = mSplitLayout.getDividerLeash();
        if (dividerLeash == null) {
        if (dividerLeash == null) return;
            return;
        }


        if (mDividerVisible) {
        if (mDividerVisible) {
            t.show(dividerLeash)
            t.show(dividerLeash)