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

Commit 411e8fa8 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Add shell recents interface"

parents 6d480a94 20e3e4e2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ filegroup {
    path: "src",
}

// Sources that have no dependencies that can be used directly downstream of this library
filegroup {
    name: "wm_shell_util-sources",
    srcs: [
@@ -46,6 +47,7 @@ filegroup {
    path: "src",
}

// Aidls which can be used directly downstream of this library
filegroup {
    name: "wm_shell-aidls",
    srcs: [
+7 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.wm.shell.hidedisplaycutout.HideDisplayCutoutController;
import com.android.wm.shell.legacysplitscreen.LegacySplitScreenController;
import com.android.wm.shell.onehanded.OneHandedController;
import com.android.wm.shell.pip.Pip;
import com.android.wm.shell.recents.RecentTasksController;
import com.android.wm.shell.splitscreen.SplitScreenController;

import java.io.PrintWriter;
@@ -43,6 +44,7 @@ public final class ShellCommandHandlerImpl {
    private final Optional<OneHandedController> mOneHandedOptional;
    private final Optional<HideDisplayCutoutController> mHideDisplayCutout;
    private final Optional<AppPairsController> mAppPairsOptional;
    private final Optional<RecentTasksController> mRecentTasks;
    private final ShellTaskOrganizer mShellTaskOrganizer;
    private final ShellExecutor mMainExecutor;
    private final HandlerImpl mImpl = new HandlerImpl();
@@ -55,8 +57,10 @@ public final class ShellCommandHandlerImpl {
            Optional<OneHandedController> oneHandedOptional,
            Optional<HideDisplayCutoutController> hideDisplayCutout,
            Optional<AppPairsController> appPairsOptional,
            Optional<RecentTasksController> recentTasks,
            ShellExecutor mainExecutor) {
        mShellTaskOrganizer = shellTaskOrganizer;
        mRecentTasks = recentTasks;
        mLegacySplitScreenOptional = legacySplitScreenOptional;
        mSplitScreenOptional = splitScreenOptional;
        mPipOptional = pipOptional;
@@ -85,6 +89,9 @@ public final class ShellCommandHandlerImpl {
        pw.println();
        pw.println();
        mSplitScreenOptional.ifPresent(splitScreen -> splitScreen.dump(pw, ""));
        pw.println();
        pw.println();
        mRecentTasks.ifPresent(recentTasks -> recentTasks.dump(pw, ""));
    }


+5 −4
Original line number Diff line number Diff line
@@ -29,8 +29,8 @@ import com.android.wm.shell.draganddrop.DragAndDropController;
import com.android.wm.shell.freeform.FreeformTaskListener;
import com.android.wm.shell.fullscreen.FullscreenTaskListener;
import com.android.wm.shell.fullscreen.FullscreenUnfoldController;
import com.android.wm.shell.legacysplitscreen.LegacySplitScreenController;
import com.android.wm.shell.pip.phone.PipTouchHandler;
import com.android.wm.shell.recents.RecentTasksController;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.startingsurface.StartingWindowController;
import com.android.wm.shell.transition.Transitions;
@@ -49,7 +49,6 @@ public class ShellInitImpl {
    private final DragAndDropController mDragAndDropController;
    private final ShellTaskOrganizer mShellTaskOrganizer;
    private final Optional<BubbleController> mBubblesOptional;
    private final Optional<LegacySplitScreenController> mLegacySplitScreenOptional;
    private final Optional<SplitScreenController> mSplitScreenOptional;
    private final Optional<AppPairsController> mAppPairsOptional;
    private final Optional<PipTouchHandler> mPipTouchHandlerOptional;
@@ -59,6 +58,7 @@ public class ShellInitImpl {
    private final ShellExecutor mMainExecutor;
    private final Transitions mTransitions;
    private final StartingWindowController mStartingWindow;
    private final Optional<RecentTasksController> mRecentTasks;

    private final InitImpl mImpl = new InitImpl();

@@ -69,13 +69,13 @@ public class ShellInitImpl {
            DragAndDropController dragAndDropController,
            ShellTaskOrganizer shellTaskOrganizer,
            Optional<BubbleController> bubblesOptional,
            Optional<LegacySplitScreenController> legacySplitScreenOptional,
            Optional<SplitScreenController> splitScreenOptional,
            Optional<AppPairsController> appPairsOptional,
            Optional<PipTouchHandler> pipTouchHandlerOptional,
            FullscreenTaskListener fullscreenTaskListener,
            Optional<FullscreenUnfoldController> fullscreenUnfoldTransitionController,
            Optional<Optional<FreeformTaskListener>> freeformTaskListenerOptional,
            Optional<RecentTasksController> recentTasks,
            Transitions transitions,
            StartingWindowController startingWindow,
            ShellExecutor mainExecutor) {
@@ -85,13 +85,13 @@ public class ShellInitImpl {
        mDragAndDropController = dragAndDropController;
        mShellTaskOrganizer = shellTaskOrganizer;
        mBubblesOptional = bubblesOptional;
        mLegacySplitScreenOptional = legacySplitScreenOptional;
        mSplitScreenOptional = splitScreenOptional;
        mAppPairsOptional = appPairsOptional;
        mFullscreenTaskListener = fullscreenTaskListener;
        mPipTouchHandlerOptional = pipTouchHandlerOptional;
        mFullscreenUnfoldController = fullscreenUnfoldTransitionController;
        mFreeformTaskListenerOptional = freeformTaskListenerOptional.flatMap(f -> f);
        mRecentTasks = recentTasks;
        mTransitions = transitions;
        mMainExecutor = mainExecutor;
        mStartingWindow = startingWindow;
@@ -135,6 +135,7 @@ public class ShellInitImpl {
                        f, ShellTaskOrganizer.TASK_LISTENER_TYPE_FREEFORM));

        mFullscreenUnfoldController.ifPresent(FullscreenUnfoldController::init);
        mRecentTasks.ifPresent(RecentTasksController::init);
    }

    @ExternalThread
+26 −3
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.FrameworkStatsLog;
import com.android.wm.shell.common.ScreenshotUtils;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.recents.RecentTasksController;
import com.android.wm.shell.sizecompatui.SizeCompatUIController;
import com.android.wm.shell.startingsurface.StartingWindowController;

@@ -59,6 +60,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;

/**
@@ -150,20 +152,34 @@ public class ShellTaskOrganizer extends TaskOrganizer implements
    @Nullable
    private final SizeCompatUIController mSizeCompatUI;

    @Nullable
    private final Optional<RecentTasksController> mRecentTasks;

    public ShellTaskOrganizer(ShellExecutor mainExecutor, Context context) {
        this(null /* taskOrganizerController */, mainExecutor, context, null /* sizeCompatUI */);
        this(null /* taskOrganizerController */, mainExecutor, context, null /* sizeCompatUI */,
                Optional.empty() /* recentTasksController */);
    }

    public ShellTaskOrganizer(ShellExecutor mainExecutor, Context context, @Nullable
            SizeCompatUIController sizeCompatUI) {
        this(null /* taskOrganizerController */, mainExecutor, context, sizeCompatUI);
        this(null /* taskOrganizerController */, mainExecutor, context, sizeCompatUI,
                Optional.empty() /* recentTasksController */);
    }

    public ShellTaskOrganizer(ShellExecutor mainExecutor, Context context, @Nullable
            SizeCompatUIController sizeCompatUI,
            Optional<RecentTasksController> recentTasks) {
        this(null /* taskOrganizerController */, mainExecutor, context, sizeCompatUI,
                recentTasks);
    }

    @VisibleForTesting
    ShellTaskOrganizer(ITaskOrganizerController taskOrganizerController, ShellExecutor mainExecutor,
            Context context, @Nullable SizeCompatUIController sizeCompatUI) {
            Context context, @Nullable SizeCompatUIController sizeCompatUI,
            Optional<RecentTasksController> recentTasks) {
        super(taskOrganizerController, mainExecutor);
        mSizeCompatUI = sizeCompatUI;
        mRecentTasks = recentTasks;
        if (sizeCompatUI != null) {
            sizeCompatUI.setSizeCompatUICallback(this);
        }
@@ -401,6 +417,11 @@ public class ShellTaskOrganizer extends TaskOrganizer implements
                // Notify the size compat UI if the listener or task info changed.
                notifySizeCompatUI(taskInfo, newListener);
            }
            if (data.getTaskInfo().getWindowingMode() != taskInfo.getWindowingMode()) {
                // Notify the recent tasks when a task changes windowing modes
                mRecentTasks.ifPresent(recentTasks ->
                        recentTasks.onTaskWindowingModeChanged(taskInfo));
            }
        }
    }

@@ -428,6 +449,8 @@ public class ShellTaskOrganizer extends TaskOrganizer implements
            notifyLocusVisibilityIfNeeded(taskInfo);
            // Pass null for listener to remove the size compat UI on this task if there is any.
            notifySizeCompatUI(taskInfo, null /* taskListener */);
            // Notify the recent tasks that a task has been removed
            mRecentTasks.ifPresent(recentTasks -> recentTasks.onTaskRemoved(taskInfo));
        }
    }

+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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;

import com.android.wm.shell.recents.IRecentTasksListener;
import com.android.wm.shell.util.GroupedRecentTaskInfo;

/**
 * Interface that is exposed to remote callers to fetch recent tasks.
 */
interface IRecentTasks {

    /**
     * Registers a recent tasks listener.
     */
    oneway void registerRecentTasksListener(in IRecentTasksListener listener) = 1;

    /**
     * Unregisters a recent tasks listener.
     */
    oneway void unregisterRecentTasksListener(in IRecentTasksListener listener) = 2;

    /**
     * Gets the set of recent tasks.
     */
    GroupedRecentTaskInfo[] getRecentTasks(int maxNum, int flags, int userId) = 3;
}
Loading