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

Commit ed4dd9a8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "API for moving all tasks from the virtual display to the default one" into main

parents 4fc65ff5 4e6f1a41
Loading
Loading
Loading
Loading
+25 −9
Original line number Diff line number Diff line
@@ -122,15 +122,6 @@ public final class ComputerControlSession implements AutoCloseable {
    @Nullable
    private ImageReader mImageReader;

    /** Perform provided action on the trusted virtual display. */
    public void performAction(@Action int actionCode) {
        try {
            mSession.performAction(actionCode);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** @hide */
    public ComputerControlSession(int displayId, @NonNull IVirtualDisplayCallback displayToken,
            @NonNull IComputerControlSession session) {
@@ -174,6 +165,22 @@ public final class ComputerControlSession implements AutoCloseable {
        }
    }

    /**
     * Hand over full control of the automation session to the user.
     *
     * <p>All of the applications currently automated in the session are moved from the session's
     * display to the user's default display. No further automation is possible on these tasks,
     * although the session remains active and new applications may be launched via
     * {@link #launchApplication(String)}</p>
     */
    public void handOverApplications() {
        try {
            mSession.handOverApplications();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Screenshot the current display content.
     *
@@ -291,6 +298,15 @@ public final class ComputerControlSession implements AutoCloseable {
        }
    }

    /** Perform provided action on the trusted virtual display. */
    public void performAction(@Action int actionCode) {
        try {
            mSession.performAction(actionCode);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** Injects a touch event into the trusted virtual display. */
    public void sendTouchEvent(@NonNull VirtualTouchEvent event) {
        try {
+3 −0
Original line number Diff line number Diff line
@@ -32,6 +32,9 @@ interface IComputerControlSession {
    /** Launches an application on the trusted virtual display. */
    void launchApplication(in String packageName);

    /** Hand over full control of the automation session to the user. */
    void handOverApplications();

    /* Injects a tap event into the trusted virtual display. */
    void tap(int x, int y);

+12 −0
Original line number Diff line number Diff line
@@ -114,6 +114,18 @@ public final class ComputerControlSession implements AutoCloseable {
        mAccessibilityProxy.resetStabilityState();
    }

    /**
     * Hand over full control of the automation session to the user.
     *
     * <p>All of the applications currently automated in the session are moved from the session's
     * display to the user's default display. No further automation is possible on these tasks,
     * although the session remains active and new applications may be launched via
     * {@link #launchApplication(String)}</p>
     */
    public void handOverApplications() {
        mSession.handOverApplications();
    }

    /**
     * Screenshot the current display content.
     *
+14 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import com.android.internal.inputmethod.InputConnectionCommandHeader;
import com.android.server.LocalServices;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.pm.UserManagerInternal;
import com.android.server.wm.ActivityTaskManagerInternal;
import com.android.server.wm.WindowManagerInternal;

import java.util.ArrayList;
@@ -337,6 +338,12 @@ final class ComputerControlSessionImpl extends IComputerControlSession.Stub
        notifyApplicationLaunchToStabilityCalculator();
    }

    @Override
    public void handOverApplications() {
        Binder.withCleanCallingIdentity(
                () -> mInjector.moveAllTasks(mVirtualDisplayId, mMainDisplayId));
    }

    @Override
    public void tap(@IntRange(from = 0) int x, @IntRange(from = 0) int y) throws RemoteException {
        cancelOngoingTouchGestures();
@@ -696,6 +703,7 @@ final class ComputerControlSessionImpl extends IComputerControlSession.Stub
        private final WindowManagerInternal mWindowManagerInternal;
        private final InputMethodManagerInternal mInputMethodManagerInternal;
        private final UserManagerInternal mUserManagerInternal;
        private final ActivityTaskManagerInternal mActivityTaskManagerInternal;

        Injector(Context context) {
            mContext = context;
@@ -704,6 +712,8 @@ final class ComputerControlSessionImpl extends IComputerControlSession.Stub
            mInputMethodManagerInternal = LocalServices.getService(
                    InputMethodManagerInternal.class);
            mUserManagerInternal = LocalServices.getService(UserManagerInternal.class);
            mActivityTaskManagerInternal = LocalServices.getService(
                    ActivityTaskManagerInternal.class);
        }

        public String getPermissionControllerPackageName() {
@@ -758,5 +768,9 @@ final class ComputerControlSessionImpl extends IComputerControlSession.Stub
            return mInputMethodManagerInternal.getComputerControlInputConnection(
                    mUserManagerInternal.getUserAssignedToDisplay(displayId), displayId);
        }

        public void moveAllTasks(int fromDisplayId, int toDisplayId) {
            mActivityTaskManagerInternal.moveAllTasks(fromDisplayId, toDisplayId);
        }
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -844,4 +844,7 @@ public abstract class ActivityTaskManagerInternal implements ActiveUids.Observer
    /** Unregisters a listener for handoff enablement changes. */
    public abstract void unregisterHandoffEnablementListener(
        @NonNull HandoffEnablementListener listener);

    /** Moves all tasks from the source display to the destination display. */
    public abstract void moveAllTasks(int fromDisplayId, int toDisplayId);
}
Loading