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

Commit 4dde6487 authored by Vinit Nayak's avatar Vinit Nayak Committed by Automerger Merge Worker
Browse files

Merge "Add API to get multiple running tasks for split" into sc-v2-dev am: 3a91691e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16482617

Change-Id: I368b4025726bda6b2315dd2a4d6205311eef4189
parents f5fd9f2a 3a91691e
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ import java.util.function.Consumer;
public class ActivityManagerWrapper {

    private static final String TAG = "ActivityManagerWrapper";

    private static final int NUM_RECENT_ACTIVITIES_REQUEST = 3;
    private static final ActivityManagerWrapper sInstance = new ActivityManagerWrapper();

    // Should match the values in PhoneWindowManager
@@ -112,6 +112,22 @@ public class ActivityManagerWrapper {
        return tasks.get(0);
    }

    /**
     * We ask for {@link #NUM_RECENT_ACTIVITIES_REQUEST} activities because when in split screen,
     * we'll get back 2 activities for each split app and one for launcher. Launcher might be more
     * "recently" used than one of the split apps so if we only request 2 tasks, then we might miss
     * out on one of the split apps
     *
     * @return an array of up to {@link #NUM_RECENT_ACTIVITIES_REQUEST} running tasks
     *         filtering only for tasks that can be visible in the recent tasks list.
     */
    public ActivityManager.RunningTaskInfo[] getRunningTasks(boolean filterOnlyVisibleRecents) {
        // Note: The set of running tasks from the system is ordered by recency
        List<ActivityManager.RunningTaskInfo> tasks =
                mAtm.getTasks(NUM_RECENT_ACTIVITIES_REQUEST, filterOnlyVisibleRecents);
        return tasks.toArray(new RunningTaskInfo[tasks.size()]);
    }

    /**
     * @return a list of the recents tasks.
     */