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

Commit 2de0d19c authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Notify recents animation state for CommandQueue" into main

parents 5d730304 67b7cd18
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -34,4 +34,10 @@ public interface RecentTasks {
    default void getRecentTasks(int maxNum, int flags, int userId, Executor callbackExecutor,
    default void getRecentTasks(int maxNum, int flags, int userId, Executor callbackExecutor,
            Consumer<List<GroupedRecentTaskInfo>> callback) {
            Consumer<List<GroupedRecentTaskInfo>> callback) {
    }
    }

    /**
     * Adds the listener to be notified of whether the recent task animation is running.
     */
    default void addAnimationStateListener(Executor listenerExecutor, Consumer<Boolean> listener) {
    }
}
}
+15 −0
Original line number Original line Diff line number Diff line
@@ -428,6 +428,21 @@ public class RecentTasksController implements TaskStackListenerCallback,
                executor.execute(() -> callback.accept(tasks));
                executor.execute(() -> callback.accept(tasks));
            });
            });
        }
        }

        @Override
        public void addAnimationStateListener(Executor executor, Consumer<Boolean> listener) {
            mMainExecutor.execute(() -> {
                if (mTransitionHandler == null) {
                    return;
                }
                mTransitionHandler.addTransitionStateListener(new RecentsTransitionStateListener() {
                    @Override
                    public void onAnimationStateChanged(boolean running) {
                        executor.execute(() -> listener.accept(running));
                    }
                });
            });
        }
    }
    }




+12 −0
Original line number Original line Diff line number Diff line
@@ -76,6 +76,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
    private final RecentTasksController mRecentTasksController;
    private final RecentTasksController mRecentTasksController;
    private IApplicationThread mAnimApp = null;
    private IApplicationThread mAnimApp = null;
    private final ArrayList<RecentsController> mControllers = new ArrayList<>();
    private final ArrayList<RecentsController> mControllers = new ArrayList<>();
    private final ArrayList<RecentsTransitionStateListener> mStateListeners = new ArrayList<>();


    /**
    /**
     * List of other handlers which might need to mix recents with other things. These are checked
     * List of other handlers which might need to mix recents with other things. These are checked
@@ -106,6 +107,11 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
        mMixers.remove(mixer);
        mMixers.remove(mixer);
    }
    }


    /** Adds the callback for receiving the state change of transition. */
    public void addTransitionStateListener(RecentsTransitionStateListener listener) {
        mStateListeners.add(listener);
    }

    @VisibleForTesting
    @VisibleForTesting
    public IBinder startRecentsTransition(PendingIntent intent, Intent fillIn, Bundle options,
    public IBinder startRecentsTransition(PendingIntent intent, Intent fillIn, Bundle options,
            IApplicationThread appThread, IRecentsAnimationRunner listener) {
            IApplicationThread appThread, IRecentsAnimationRunner listener) {
@@ -389,6 +395,9 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
            mTransition = null;
            mTransition = null;
            mPendingPauseSnapshotsForCancel = null;
            mPendingPauseSnapshotsForCancel = null;
            mControllers.remove(this);
            mControllers.remove(this);
            for (int i = 0; i < mStateListeners.size(); i++) {
                mStateListeners.get(i).onAnimationStateChanged(false);
            }
        }
        }


        boolean start(TransitionInfo info, SurfaceControl.Transaction t,
        boolean start(TransitionInfo info, SurfaceControl.Transaction t,
@@ -528,6 +537,9 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
                        apps.toArray(new RemoteAnimationTarget[apps.size()]),
                        apps.toArray(new RemoteAnimationTarget[apps.size()]),
                        wallpapers.toArray(new RemoteAnimationTarget[wallpapers.size()]),
                        wallpapers.toArray(new RemoteAnimationTarget[wallpapers.size()]),
                        new Rect(0, 0, 0, 0), new Rect(), b);
                        new Rect(0, 0, 0, 0), new Rect(), b);
                for (int i = 0; i < mStateListeners.size(); i++) {
                    mStateListeners.get(i).onAnimationStateChanged(true);
                }
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Slog.e(TAG, "Error starting recents animation", e);
                Slog.e(TAG, "Error starting recents animation", e);
                cancel("onAnimationStart() failed");
                cancel("onAnimationStart() failed");
+25 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.recents;

/** The listener for the events from {@link RecentsTransitionHandler}. */
public interface RecentsTransitionStateListener {

    /** Notifies whether the recents animation is running. */
    default void onAnimationStateChanged(boolean running) {
    }
}
+11 −0
Original line number Original line Diff line number Diff line
@@ -61,6 +61,7 @@ import com.android.wm.shell.onehanded.OneHandedEventCallback;
import com.android.wm.shell.onehanded.OneHandedTransitionCallback;
import com.android.wm.shell.onehanded.OneHandedTransitionCallback;
import com.android.wm.shell.onehanded.OneHandedUiEventLogger;
import com.android.wm.shell.onehanded.OneHandedUiEventLogger;
import com.android.wm.shell.pip.Pip;
import com.android.wm.shell.pip.Pip;
import com.android.wm.shell.recents.RecentTasks;
import com.android.wm.shell.splitscreen.SplitScreen;
import com.android.wm.shell.splitscreen.SplitScreen;
import com.android.wm.shell.sysui.ShellInterface;
import com.android.wm.shell.sysui.ShellInterface;


@@ -109,6 +110,7 @@ public final class WMShell implements
    private final Optional<SplitScreen> mSplitScreenOptional;
    private final Optional<SplitScreen> mSplitScreenOptional;
    private final Optional<OneHanded> mOneHandedOptional;
    private final Optional<OneHanded> mOneHandedOptional;
    private final Optional<DesktopMode> mDesktopModeOptional;
    private final Optional<DesktopMode> mDesktopModeOptional;
    private final Optional<RecentTasks> mRecentTasksOptional;


    private final CommandQueue mCommandQueue;
    private final CommandQueue mCommandQueue;
    private final ConfigurationController mConfigurationController;
    private final ConfigurationController mConfigurationController;
@@ -172,6 +174,7 @@ public final class WMShell implements
            Optional<SplitScreen> splitScreenOptional,
            Optional<SplitScreen> splitScreenOptional,
            Optional<OneHanded> oneHandedOptional,
            Optional<OneHanded> oneHandedOptional,
            Optional<DesktopMode> desktopMode,
            Optional<DesktopMode> desktopMode,
            Optional<RecentTasks> recentTasks,
            CommandQueue commandQueue,
            CommandQueue commandQueue,
            ConfigurationController configurationController,
            ConfigurationController configurationController,
            KeyguardStateController keyguardStateController,
            KeyguardStateController keyguardStateController,
@@ -195,6 +198,7 @@ public final class WMShell implements
        mSplitScreenOptional = splitScreenOptional;
        mSplitScreenOptional = splitScreenOptional;
        mOneHandedOptional = oneHandedOptional;
        mOneHandedOptional = oneHandedOptional;
        mDesktopModeOptional = desktopMode;
        mDesktopModeOptional = desktopMode;
        mRecentTasksOptional = recentTasks;
        mWakefulnessLifecycle = wakefulnessLifecycle;
        mWakefulnessLifecycle = wakefulnessLifecycle;
        mUserTracker = userTracker;
        mUserTracker = userTracker;
        mDisplayTracker = displayTracker;
        mDisplayTracker = displayTracker;
@@ -220,6 +224,7 @@ public final class WMShell implements
        mSplitScreenOptional.ifPresent(this::initSplitScreen);
        mSplitScreenOptional.ifPresent(this::initSplitScreen);
        mOneHandedOptional.ifPresent(this::initOneHanded);
        mOneHandedOptional.ifPresent(this::initOneHanded);
        mDesktopModeOptional.ifPresent(this::initDesktopMode);
        mDesktopModeOptional.ifPresent(this::initDesktopMode);
        mRecentTasksOptional.ifPresent(this::initRecentTasks);


        mNoteTaskInitializer.initialize();
        mNoteTaskInitializer.initialize();
    }
    }
@@ -351,6 +356,12 @@ public final class WMShell implements
                }, mSysUiMainExecutor);
                }, mSysUiMainExecutor);
    }
    }


    @VisibleForTesting
    void initRecentTasks(RecentTasks recentTasks) {
        recentTasks.addAnimationStateListener(mSysUiMainExecutor,
                mCommandQueue::onRecentsAnimationStateChanged);
    }

    @Override
    @Override
    public boolean isDumpCritical() {
    public boolean isDumpCritical() {
        // Dump can't be critical because the shell has to dump on the main thread for
        // Dump can't be critical because the shell has to dump on the main thread for
Loading