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

Commit 1f6275fd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Switch some recent tasks calls from IATM to ATM"

parents 902555e0 071e95e8
Loading
Loading
Loading
Loading
+6 −14
Original line number Diff line number Diff line
@@ -1854,16 +1854,12 @@ public class ActivityManager {
     * the recent tasks.
     */
    @Deprecated
    public List<RecentTaskInfo> getRecentTasks(int maxNum, int flags)
            throws SecurityException {
        try {
    public List<RecentTaskInfo> getRecentTasks(int maxNum, int flags) throws SecurityException {
        if (maxNum < 0) {
            throw new IllegalArgumentException("The requested number of tasks should be >= 0");
        }
            return getTaskService().getRecentTasks(maxNum, flags, mContext.getUserId()).getList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        return ActivityTaskManager.getInstance().getRecentTasks(
                maxNum, flags, mContext.getUserId());
    }

    /**
@@ -2084,11 +2080,7 @@ public class ActivityManager {
    @Deprecated
    public List<RunningTaskInfo> getRunningTasks(int maxNum)
            throws SecurityException {
        try {
            return getTaskService().getTasks(maxNum);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        return ActivityTaskManager.getInstance().getTasks(maxNum);
    }

    /**
+107 −2
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
@@ -35,6 +34,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.DisplayMetrics;
import android.util.Singleton;
import android.view.RemoteAnimationDefinition;

import java.util.List;

@@ -147,7 +147,20 @@ public class ActivityTaskManager {

    private static int sMaxRecentTasks = -1;

    ActivityTaskManager(Context context, Handler handler) {
    private static final Singleton<ActivityTaskManager> sInstance =
            new Singleton<ActivityTaskManager>() {
                @Override
                protected ActivityTaskManager create() {
                    return new ActivityTaskManager();
                }
            };

    private ActivityTaskManager() {
    }

    /** @hide */
    public static ActivityTaskManager getInstance() {
        return sInstance.get();
    }

    /** @hide */
@@ -443,6 +456,98 @@ public class ActivityTaskManager {
                com.android.internal.R.integer.config_pictureInPictureMaxNumberOfActions);
    }

    /**
     * @return List of running tasks.
     * @hide
     */
    public List<ActivityManager.RunningTaskInfo> getTasks(int maxNum) {
        return getTasks(maxNum, false /* filterForVisibleRecents */);
    }

    /**
     * @return List of running tasks that can be filtered by visibility in recents.
     * @hide
     */
    public List<ActivityManager.RunningTaskInfo> getTasks(
            int maxNum, boolean filterOnlyVisibleRecents) {
        try {
            return getService().getTasks(maxNum, filterOnlyVisibleRecents);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @return List of recent tasks.
     * @hide
     */
    public List<ActivityManager.RecentTaskInfo> getRecentTasks(
            int maxNum, int flags, int userId) {
        try {
            return getService().getRecentTasks(maxNum, flags, userId).getList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** @hide */
    public void registerTaskStackListener(TaskStackListener listener) {
        try {
            getService().registerTaskStackListener(listener);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** @hide */
    public void unregisterTaskStackListener(TaskStackListener listener) {
        try {
            getService().unregisterTaskStackListener(listener);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** @hide */
    public Rect getTaskBounds(int taskId) {
        try {
            return getService().getTaskBounds(taskId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Registers remote animations for a display.
     * @hide
     */
    public void registerRemoteAnimationsForDisplay(
            int displayId, RemoteAnimationDefinition definition) {
        try {
            getService().registerRemoteAnimationsForDisplay(displayId, definition);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** @hide */
    public boolean isInLockTaskMode() {
        try {
            return getService().isInLockTaskMode();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** @hide */
    public boolean removeTask(int taskId) {
        try {
            return getService().removeTask(taskId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Information you can retrieve about a root task in the system.
     * @hide
+10 −3
Original line number Diff line number Diff line
@@ -83,6 +83,15 @@ import java.util.List;
 *
 * {@hide}
 */
// TODO(b/174040395): Make this interface private to ActivityTaskManager.java and have external
// caller go through that call instead. This would help us better separate and control the API
// surface exposed.
// TODO(b/174041144): Move callback methods from Activity (Things that take param 'IBinder token')
// to a separate interface that is only available to the Activity.
// TODO(b/174041603): Create a builder interface for things like startActivityXXX(...) to reduce
// interface duplication.
// TODO(b/174040691): Clean-up/remove all obsolete or unused interfaces like things that should be
// going through task organizer now.
interface IActivityTaskManager {
    int startActivity(in IApplicationThread caller, in String callingPackage,
            in String callingFeatureId, in Intent intent, in String resolvedType,
@@ -154,9 +163,7 @@ interface IActivityTaskManager {
    void setFocusedTask(int taskId);
    boolean removeTask(int taskId);
    void removeAllVisibleRecentTasks();
    List<ActivityManager.RunningTaskInfo> getTasks(int maxNum);
    List<ActivityManager.RunningTaskInfo> getFilteredTasks(int maxNum,
            boolean filterOnlyVisibleRecents);
    List<ActivityManager.RunningTaskInfo> getTasks(int maxNum, boolean filterOnlyVisibleRecents);
    boolean shouldUpRecreateTask(in IBinder token, in String destAffinity);
    boolean navigateUpTo(in IBinder token, in Intent target, int resultCode,
            in Intent resultData);
+1 −2
Original line number Diff line number Diff line
@@ -284,8 +284,7 @@ public final class SystemServiceRegistry {
                new CachedServiceFetcher<ActivityTaskManager>() {
            @Override
            public ActivityTaskManager createService(ContextImpl ctx) {
                return new ActivityTaskManager(
                        ctx.getOuterContext(), ctx.mMainThread.getHandler());
                return ActivityTaskManager.getInstance();
            }});

        registerService(Context.URI_GRANTS_SERVICE, UriGrantsManager.class,
+16 −23
Original line number Diff line number Diff line
@@ -18,12 +18,10 @@ package com.android.wm.shell.draganddrop;

import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.ClipDescription.EXTRA_ACTIVITY_OPTIONS;
import static android.content.ClipDescription.EXTRA_PENDING_INTENT;
import static android.content.ClipDescription.MIMETYPE_APPLICATION_ACTIVITY;
import static android.content.ClipDescription.MIMETYPE_APPLICATION_SHORTCUT;
import static android.content.ClipDescription.MIMETYPE_APPLICATION_TASK;
import static android.content.Intent.EXTRA_PACKAGE_NAME;
@@ -78,7 +76,7 @@ public class DragAndDropPolicy {
    private static final String TAG = DragAndDropPolicy.class.getSimpleName();

    private final Context mContext;
    private final IActivityTaskManager mIActivityTaskManager;
    private final ActivityTaskManager mActivityTaskManager;
    private final Starter mStarter;
    private final SplitScreen mSplitScreen;
    private final ArrayList<DragAndDropPolicy.Target> mTargets = new ArrayList<>();
@@ -86,15 +84,15 @@ public class DragAndDropPolicy {
    private DragSession mSession;

    public DragAndDropPolicy(Context context, SplitScreen splitScreen) {
        this(context, ActivityTaskManager.getService(), splitScreen,
        this(context, ActivityTaskManager.getInstance(), splitScreen,
                new DefaultStarter(context, splitScreen));
    }

    @VisibleForTesting
    DragAndDropPolicy(Context context, IActivityTaskManager activityTaskManager,
    DragAndDropPolicy(Context context, ActivityTaskManager activityTaskManager,
            SplitScreen splitScreen, Starter starter) {
        mContext = context;
        mIActivityTaskManager = activityTaskManager;
        mActivityTaskManager = activityTaskManager;
        mSplitScreen = splitScreen;
        mStarter = starter;
    }
@@ -103,7 +101,7 @@ public class DragAndDropPolicy {
     * Starts a new drag session with the given initial drag data.
     */
    void start(DisplayLayout displayLayout, ClipData data) {
        mSession = new DragSession(mContext, mIActivityTaskManager, displayLayout, data);
        mSession = new DragSession(mContext, mActivityTaskManager, displayLayout, data);
        // TODO(b/169894807): Also update the session data with task stack changes
        mSession.update();
    }
@@ -271,7 +269,7 @@ public class DragAndDropPolicy {
     */
    private static class DragSession {
        private final Context mContext;
        private final IActivityTaskManager mIActivityTaskManager;
        private final ActivityTaskManager mActivityTaskManager;
        private final ClipData mInitialDragData;

        final DisplayLayout displayLayout;
@@ -285,10 +283,10 @@ public class DragAndDropPolicy {
        boolean dragItemSupportsSplitscreen;
        boolean isPhone;

        DragSession(Context context, IActivityTaskManager activityTaskManager,
        DragSession(Context context, ActivityTaskManager activityTaskManager,
                DisplayLayout dispLayout, ClipData data) {
            mContext = context;
            mIActivityTaskManager = activityTaskManager;
            mActivityTaskManager = activityTaskManager;
            mInitialDragData = data;
            displayLayout = dispLayout;
        }
@@ -298,10 +296,8 @@ public class DragAndDropPolicy {
         */
        void update() {

            try {
            List<ActivityManager.RunningTaskInfo> tasks =
                        mIActivityTaskManager.getFilteredTasks(1,
                                false /* filterOnlyVisibleRecents */);
                    mActivityTaskManager.getTasks(1, false /* filterOnlyVisibleRecents */);
            if (!tasks.isEmpty()) {
                final ActivityManager.RunningTaskInfo task = tasks.get(0);
                runningTaskWinMode = task.getWindowingMode();
@@ -309,9 +305,6 @@ public class DragAndDropPolicy {
                runningTaskId = task.taskId;
                runningTaskIsResizeable = task.isResizeable;
            }
            } catch (RemoteException e) {
                // Fall through
            }

            final ActivityInfo info = mInitialDragData.getItemAt(0).getActivityInfo();
            dragItemSupportsSplitscreen = info == null
Loading