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

Commit 2b031a7d authored by Bartosz Chominski's avatar Bartosz Chominski
Browse files

Add API to check whether app may use the window repositioning APIs

Bug: 400407139
Bug: 407620668
API-Coverage-Bug: 421108103
Flag: com.android.window.flags.enable_window_repositioning_api
Test: ATMSTests, DCTests, RWCTests
Change-Id: I5170559a35332bcafbd4cc127bcc217784030577
parent 0b8b4e1d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4822,6 +4822,7 @@ package android.app {
    method public boolean isLowRamDevice();
    method @Deprecated public static boolean isRunningInTestHarness();
    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 @RequiresPermission(android.Manifest.permission.KILL_BACKGROUND_PROCESSES) public void killBackgroundProcesses(String);
    method @RequiresPermission(android.Manifest.permission.REORDER_TASKS) public void moveTaskToFront(int, int);
+24 −0
Original line number Diff line number Diff line
@@ -3184,6 +3184,30 @@ public class ActivityManager {
        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
     * currently running in the system.
+1 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ interface IActivityTaskManager {

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

    void unhandledBack();

+3 −0
Original line number 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>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 isTaskMoveAllowed {@code true} to allow containing self-movable tasks, {@code
     *     false} otherwise.
+19 −0
Original line number Diff line number Diff line
@@ -1947,6 +1947,25 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        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
    public IActivityClientController getActivityClientController() {
        return mActivityClientController;
Loading