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

Commit 0dfdd607 authored by Yuncheol Heo's avatar Yuncheol Heo Committed by Android (Google) Code Review
Browse files

Merge "Allow getTasks to filter tasks by displayId." into tm-qpr-dev

parents a97e6db8 5c8fd0dd
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.app;

import static android.view.Display.INVALID_DISPLAY;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -369,7 +371,8 @@ public class ActivityTaskManager {
     * @hide
     */
    public List<ActivityManager.RunningTaskInfo> getTasks(int maxNum) {
        return getTasks(maxNum, false /* filterForVisibleRecents */);
        return getTasks(maxNum, false /* filterForVisibleRecents */, false /* keepIntentExtra */,
                INVALID_DISPLAY);
    }

    /**
@@ -378,7 +381,8 @@ public class ActivityTaskManager {
     */
    public List<ActivityManager.RunningTaskInfo> getTasks(
            int maxNum, boolean filterOnlyVisibleRecents) {
        return getTasks(maxNum, filterOnlyVisibleRecents, false /* keepIntentExtra */);
        return getTasks(maxNum, filterOnlyVisibleRecents, false /* keepIntentExtra */,
                INVALID_DISPLAY);
    }

    /**
@@ -388,8 +392,20 @@ public class ActivityTaskManager {
     */
    public List<ActivityManager.RunningTaskInfo> getTasks(
            int maxNum, boolean filterOnlyVisibleRecents, boolean keepIntentExtra) {
        return getTasks(maxNum, filterOnlyVisibleRecents, keepIntentExtra, INVALID_DISPLAY);
    }

    /**
     * @return List of running tasks that can be filtered by visibility and displayId in recents
     * and keep intent extra.
     * @param displayId the target display id, or {@link INVALID_DISPLAY} not to filter by displayId
     * @hide
     */
    public List<ActivityManager.RunningTaskInfo> getTasks(
            int maxNum, boolean filterOnlyVisibleRecents, boolean keepIntentExtra, int displayId) {
        try {
            return getService().getTasks(maxNum, filterOnlyVisibleRecents, keepIntentExtra);
            return getService().getTasks(maxNum, filterOnlyVisibleRecents, keepIntentExtra,
                    displayId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+1 −1
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ interface IActivityTaskManager {
    boolean removeTask(int taskId);
    void removeAllVisibleRecentTasks();
    List<ActivityManager.RunningTaskInfo> getTasks(int maxNum, boolean filterOnlyVisibleRecents,
            boolean keepIntentExtra);
            boolean keepIntentExtra, int displayId);
    void moveTaskToFront(in IApplicationThread app, in String callingPackage, int task,
            int flags, in Bundle options);
    ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags,
+4 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.app;

import static android.view.Display.INVALID_DISPLAY;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager.RunningTaskInfo;
@@ -93,7 +95,8 @@ final class GameTaskInfoProvider {
            runningTaskInfos = mActivityTaskManager.getTasks(
                    /* maxNum= */ Integer.MAX_VALUE,
                    /* filterOnlyVisibleRecents= */ false,
                    /* keepIntentExtra= */ false);
                    /* keepIntentExtra= */ false,
                    INVALID_DISPLAY);
        } catch (RemoteException ex) {
            Slog.w(TAG, "Failed to fetch running tasks");
            return null;
+12 −3
Original line number Diff line number Diff line
@@ -2311,16 +2311,25 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
     * @return a list of {@link ActivityManager.RunningTaskInfo} with up to {@code maxNum} items
     */
    public List<ActivityManager.RunningTaskInfo> getTasks(int maxNum) {
        return getTasks(maxNum, false /* filterForVisibleRecents */, false /* keepIntentExtra */);
        return getTasks(maxNum, false /* filterForVisibleRecents */, false /* keepIntentExtra */,
                INVALID_DISPLAY);
    }

    /**
     * @param filterOnlyVisibleRecents whether to filter the tasks based on whether they would ever
     *                                 be visible in the recent task list in systemui
     */
    @Override
    public List<ActivityManager.RunningTaskInfo> getTasks(int maxNum,
            boolean filterOnlyVisibleRecents, boolean keepIntentExtra) {
        return getTasks(maxNum, filterOnlyVisibleRecents, keepIntentExtra, INVALID_DISPLAY);
    }

    /**
     * @param displayId the target display id, or {@link INVALID_DISPLAY} not to filter by displayId
     */
    @Override
    public List<ActivityManager.RunningTaskInfo> getTasks(int maxNum,
            boolean filterOnlyVisibleRecents, boolean keepIntentExtra, int displayId) {
        final int callingUid = Binder.getCallingUid();
        final int callingPid = Binder.getCallingPid();

@@ -2342,7 +2351,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            final boolean allowed = isGetTasksAllowed("getTasks", callingPid, callingUid);
            flags |= (allowed ? RunningTasks.FLAG_ALLOWED : 0);
            mRootWindowContainer.getRunningTasks(
                    maxNum, list, flags, callingUid, callingProfileIds);
                    maxNum, list, flags, callingUid, callingProfileIds, displayId);
        }

        return list;
+10 −3
Original line number Diff line number Diff line
@@ -3345,9 +3345,16 @@ class RootWindowContainer extends WindowContainer<DisplayContent>

    @VisibleForTesting
    void getRunningTasks(int maxNum, List<ActivityManager.RunningTaskInfo> list,
            int flags, int callingUid, ArraySet<Integer> profileIds) {
        mTaskSupervisor.getRunningTasks().getTasks(maxNum, list, flags, this, callingUid,
                profileIds);
            int flags, int callingUid, ArraySet<Integer> profileIds, int displayId) {
        WindowContainer root = this;
        if (displayId != INVALID_DISPLAY) {
            root = getDisplayContent(displayId);
            if (root == null) {
                return;
            }
        }
        mTaskSupervisor.getRunningTasks().getTasks(maxNum, list, flags, mService.getRecentTasks(),
                root, callingUid, profileIds);
    }

    void startPowerModeLaunchIfNeeded(boolean forceSend, ActivityRecord targetActivity) {
Loading