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

Commit ed0c8a7b authored by Bartosz Chomiński's avatar Bartosz Chomiński Committed by Android (Google) Code Review
Browse files

Merge "Add API to check whether app may use the window repositioning APIs" into main

parents 0f8b0250 2b031a7d
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -4822,6 +4822,7 @@ package android.app {
    method public boolean isLowRamDevice();
    method public boolean isLowRamDevice();
    method @Deprecated public static boolean isRunningInTestHarness();
    method @Deprecated public static boolean isRunningInTestHarness();
    method public static boolean isRunningInUserTestHarness();
    method public static boolean isRunningInUserTestHarness();
    method @FlaggedApi("com.android.window.flags.enable_window_repositioning_api") public boolean isTaskMoveAllowedOnDisplay(int);
    method public static boolean isUserAMonkey();
    method public static boolean isUserAMonkey();
    method @RequiresPermission(android.Manifest.permission.KILL_BACKGROUND_PROCESSES) public void killBackgroundProcesses(String);
    method @RequiresPermission(android.Manifest.permission.KILL_BACKGROUND_PROCESSES) public void killBackgroundProcesses(String);
    method @RequiresPermission(android.Manifest.permission.REORDER_TASKS) public void moveTaskToFront(int, int);
    method @RequiresPermission(android.Manifest.permission.REORDER_TASKS) public void moveTaskToFront(int, int);
+24 −0
Original line number Original line Diff line number Diff line
@@ -3184,6 +3184,30 @@ public class ActivityManager {
        return false;
        return false;
    }
    }


    /**
     * Checks if a task opened on the display with the given ID can be repositioned on screen using
     * the {@link android.app.ActivityManager.AppTask#moveTaskTo} method.
     * <p>
     * This method does not guarantee that a subsequent call to reposition a task on the given
     * display will succeed. Instead, it indicates whether the given display's windowing mode
     * configuration allows for handling repositioning requests.
     * <p>
     * Apps without the {@link android.Manifest.permission#REPOSITION_SELF_WINDOWS} permission are
     * not allowed to move tasks and this method will always return {@code false} for such apps.
     *
     * @param displayId Target display ID
     * @return Whether the windowing mode active on display with given ID allows task repositioning
     */
    @FlaggedApi(com.android.window.flags.Flags.FLAG_ENABLE_WINDOW_REPOSITIONING_API)
    @SuppressLint("RequiresPermission")
    public boolean isTaskMoveAllowedOnDisplay(int displayId) {
        try {
            return getTaskService().isTaskMoveAllowedOnDisplay(displayId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
    /**
     * Information you can retrieve about a particular Service that is
     * Information you can retrieve about a particular Service that is
     * currently running in the system.
     * currently running in the system.
+1 −0
Original line number Original line Diff line number Diff line
@@ -138,6 +138,7 @@ interface IActivityTaskManager {


    boolean isActivityStartAllowedOnDisplay(int displayId, in Intent intent, in String resolvedType,
    boolean isActivityStartAllowedOnDisplay(int displayId, in Intent intent, in String resolvedType,
            int userId);
            int userId);
    boolean isTaskMoveAllowedOnDisplay(int displayId);


    void unhandledBack();
    void unhandledBack();


+3 −0
Original line number Original line Diff line number Diff line
@@ -548,6 +548,9 @@ public final class WindowContainerTransaction implements Parcelable {
     *
     *
     * <p>Initially after each boot-up no window containers can contain self-movable tasks.
     * <p>Initially after each boot-up no window containers can contain self-movable tasks.
     *
     *
     * <p>The container must be either a TaskDisplayArea or a root Task for this setting to have
     * effect.
     *
     * @param container The window container whose ability to contain self-movable tasks is set on.
     * @param container The window container whose ability to contain self-movable tasks is set on.
     * @param isTaskMoveAllowed {@code true} to allow containing self-movable tasks, {@code
     * @param isTaskMoveAllowed {@code true} to allow containing self-movable tasks, {@code
     *     false} otherwise.
     *     false} otherwise.
+19 −0
Original line number Original line Diff line number Diff line
@@ -1947,6 +1947,25 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        return mAmInternal.getActivityInfoForUser(aInfo, userId);
        return mAmInternal.getActivityInfoForUser(aInfo, userId);
    }
    }


    /**
     * Checks if a task opened on the display with the given ID can be repositioned on screen using
     * the {@link android.app.ActivityManager.AppTask#moveTaskTo} method.
     * <p>
     * This method does not guarantee that a subsequent call to reposition a task on the given
     * display will succeed. Instead, it indicates whether the given display's windowing mode
     * configuration allows for handling repositioning requests.
     *
     * @param displayId Target display ID
     * @return Whether the windowing mode active on display with given ID allows task repositioning
     */
    public boolean isTaskMoveAllowedOnDisplay(int displayId) {
        if (checkCallingPermission(Manifest.permission.REPOSITION_SELF_WINDOWS)
                != PackageManager.PERMISSION_GRANTED) {
            return false;
        }
        return mRootWindowContainer.isTaskMoveAllowedOnDisplay(displayId);
    }

    @Override
    @Override
    public IActivityClientController getActivityClientController() {
    public IActivityClientController getActivityClientController() {
        return mActivityClientController;
        return mActivityClientController;
Loading