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

Commit 7daebb63 authored by Daniel Norman's avatar Daniel Norman Committed by Automerger Merge Worker
Browse files

Merge "Move input focus for a11y actions with WM instead of...

Merge "Move input focus for a11y actions with WM instead of ActivityTaskManager" into udc-dev am: 972b94af am: 90a84524

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22821097



Change-Id: Iffe825a60c7a93daab59aad2072f5f374d2e0281
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c26615c3 90a84524
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ import android.view.MagnificationSpec;
import android.view.MotionEvent;
import android.view.SurfaceControl;
import android.view.View;
import android.view.WindowInfo;
import android.view.accessibility.AccessibilityCache;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -103,7 +102,6 @@ import com.android.server.LocalServices;
import com.android.server.accessibility.AccessibilityWindowManager.RemoteAccessibilityConnection;
import com.android.server.accessibility.magnification.MagnificationProcessor;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.wm.ActivityTaskManagerInternal;
import com.android.server.wm.WindowManagerInternal;

import java.io.FileDescriptor;
@@ -2081,7 +2079,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
            IAccessibilityInteractionConnectionCallback callback, int fetchFlags,
            long interrogatingTid) {
        RemoteAccessibilityConnection connection;
        IBinder activityToken = null;
        IBinder windowToken = null;
        synchronized (mLock) {
            connection = mA11yWindowManager.getConnectionLocked(userId, resolvedWindowId);
            if (connection == null)  {
@@ -2090,9 +2088,8 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
            final boolean isA11yFocusAction = (action == ACTION_ACCESSIBILITY_FOCUS)
                    || (action == ACTION_CLEAR_ACCESSIBILITY_FOCUS);
            if (!isA11yFocusAction) {
                final WindowInfo windowInfo =
                        mA11yWindowManager.findWindowInfoByIdLocked(resolvedWindowId);
                if (windowInfo != null) activityToken = windowInfo.activityToken;
                windowToken = mA11yWindowManager.getWindowTokenForUserAndWindowIdLocked(
                        userId, resolvedWindowId);
            }
            final AccessibilityWindowInfo a11yWindowInfo =
                    mA11yWindowManager.findA11yWindowInfoByIdLocked(resolvedWindowId);
@@ -2113,9 +2110,8 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
            if (action == ACTION_CLICK || action == ACTION_LONG_CLICK) {
                mA11yWindowManager.notifyOutsideTouch(userId, resolvedWindowId);
            }
            if (activityToken != null) {
                LocalServices.getService(ActivityTaskManagerInternal.class)
                        .setFocusedActivity(activityToken);
            if (windowToken != null) {
                mWindowManagerService.requestWindowFocus(windowToken);
            }
            if (intConnTracingEnabled()) {
                logTraceIntConn("performAccessibilityAction",
+0 −6
Original line number Diff line number Diff line
@@ -262,12 +262,6 @@ public abstract class ActivityTaskManagerInternal {
     */
    public abstract void setVr2dDisplayId(int vr2dDisplayId);

    /**
     * Set focus on an activity.
     * @param token The activity token.
     */
    public abstract void setFocusedActivity(IBinder token);

    public abstract void registerScreenObserver(ScreenObserver observer);

    /**
+1 −15
Original line number Diff line number Diff line
@@ -5817,27 +5817,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            }
        }

        @Override
        public void setFocusedActivity(IBinder token) {
            synchronized (mGlobalLock) {
                final ActivityRecord r = ActivityRecord.forTokenLocked(token);
                if (r == null) {
                    throw new IllegalArgumentException(
                            "setFocusedActivity: No activity record matching token=" + token);
                }
                if (r.moveFocusableActivityToTop("setFocusedActivity")) {
                    mRootWindowContainer.resumeFocusedTasksTopActivities();
                }
            }
        }

        @Override
        public int getDisplayId(IBinder token) {
            synchronized (mGlobalLock) {
                ActivityRecord r = ActivityRecord.forTokenLocked(token);
                if (r == null) {
                    throw new IllegalArgumentException(
                            "setFocusedActivity: No activity record matching token=" + token);
                            "getDisplayId: No activity record matching token=" + token);
                }
                return r.getDisplayId();
            }
+13 −0
Original line number Diff line number Diff line
@@ -448,6 +448,19 @@ public abstract class WindowManagerInternal {
     */
    public abstract void moveDisplayToTopIfAllowed(int displayId);

    /**
     * Request to move window input focus to the window with the provided window token.
     *
     * <p>
     * It is necessary to move window input focus before certain actions on views in a window can
     * be performed, such as opening an IME. Input normally requests to move focus on window touch
     * so this method should not be necessary in most cases; only features that bypass normal touch
     * behavior (like Accessibility actions) require this method.
     * </p>
     * @param windowToken The window token.
     */
    public abstract void requestWindowFocus(IBinder windowToken);

    /**
     * @return Whether the keyguard is engaged.
     */
+11 −3
Original line number Diff line number Diff line
@@ -5652,7 +5652,7 @@ public class WindowManagerService extends IWindowManager.Stub
                case ON_POINTER_DOWN_OUTSIDE_FOCUS: {
                    synchronized (mGlobalLock) {
                        final IBinder touchedToken = (IBinder) msg.obj;
                        onPointerDownOutsideFocusLocked(touchedToken);
                        onPointerDownOutsideFocusLocked(getInputTargetFromToken(touchedToken));
                    }
                    break;
                }
@@ -7751,6 +7751,15 @@ public class WindowManagerService extends IWindowManager.Stub
            WindowManagerService.this.moveDisplayToTopIfAllowed(displayId);
        }

        @Override
        public void requestWindowFocus(IBinder windowToken) {
            synchronized (mGlobalLock) {
                final InputTarget inputTarget =
                        WindowManagerService.this.getInputTargetFromWindowTokenLocked(windowToken);
                WindowManagerService.this.onPointerDownOutsideFocusLocked(inputTarget);
            }
        }

        @Override
        public boolean isKeyguardLocked() {
            return WindowManagerService.this.isKeyguardLocked();
@@ -8590,8 +8599,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    private void onPointerDownOutsideFocusLocked(IBinder touchedToken) {
        InputTarget t = getInputTargetFromToken(touchedToken);
    private void onPointerDownOutsideFocusLocked(InputTarget t) {
        if (t == null || !t.receiveFocusFromTapOutside()) {
            // If the window that received the input event cannot receive keys, don't move the
            // display it's on to the top since that window won't be able to get focus anyway.