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

Commit 63ae30e1 authored by Antonio Kantek's avatar Antonio Kantek Committed by Android (Google) Code Review
Browse files

Merge "(TouchMode Permission 2.6/n) Revert Instrumentation#setInTouchMode"

parents 65f122bd 66152339
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -381,10 +381,6 @@ public class Instrumentation {
     * Force the global system in or out of touch mode. This can be used if your
     * instrumentation relies on the UI being in one more or the other when it starts.
     *
     * <p><b>Note:</b> Starting from Android {@link Build.VERSION_CODES#TIRAMISU}, this method
     * will only have an effect if the calling process is also the focused window owner or has
     * {@link android.permission#MODIFY_TOUCH_MODE_STATE} permission granted.
     *
     * @param inTouch Set to true to be in touch mode, false to be in focus mode.
     */
    public void setInTouchMode(boolean inTouch) {
+12 −0
Original line number Diff line number Diff line
@@ -5267,6 +5267,18 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }
    }

    /**
     * Returns {@code true} if the process represented by the pid passed as argument is
     * instrumented.
     */
    boolean isInstrumenting(int pid) {
        final WindowProcessController process;
        synchronized (mGlobalLock) {
            process = mProcessMap.getProcess(pid);
        }
        return process != null ? process.isInstrumenting() : false;
    }

    final class H extends Handler {
        static final int REPORT_TIME_TRACKER_MSG = 1;
        static final int UPDATE_PROCESS_ANIMATING_STATE = 2;
+5 −3
Original line number Diff line number Diff line
@@ -3683,7 +3683,8 @@ public class WindowManagerService extends IWindowManager.Stub
     * Sets the touch mode state.
     *
     * To be able to change touch mode state, the caller must either own the focused window, or must
     * have the MODIFY_TOUCH_MODE_STATE permission.
     * have the MODIFY_TOUCH_MODE_STATE permission. Instrumented processes are allowed to switch
     * touch mode at any time.
     *
     * @param mode the touch mode to set
     */
@@ -3695,8 +3696,9 @@ public class WindowManagerService extends IWindowManager.Stub
            }
            final int pid = Binder.getCallingPid();
            final int uid = Binder.getCallingUid();
            final boolean hasPermission = checkCallingPermission(MODIFY_TOUCH_MODE_STATE,
                    "setInTouchMode()");

            final boolean hasPermission = mAtmService.isInstrumenting(pid)
                    || checkCallingPermission(MODIFY_TOUCH_MODE_STATE, "setInTouchMode()");
            final long token = Binder.clearCallingIdentity();
            try {
                if (mInputManager.setInTouchMode(mode, pid, uid, hasPermission)) {