Merge "Move input focus for a11y actions with WM instead of ActivityTaskManager" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
972b94afd7
@@ -81,7 +81,6 @@ import android.view.MagnificationSpec;
|
|||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowInfo;
|
|
||||||
import android.view.accessibility.AccessibilityCache;
|
import android.view.accessibility.AccessibilityCache;
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
import android.view.accessibility.AccessibilityNodeInfo;
|
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.AccessibilityWindowManager.RemoteAccessibilityConnection;
|
||||||
import com.android.server.accessibility.magnification.MagnificationProcessor;
|
import com.android.server.accessibility.magnification.MagnificationProcessor;
|
||||||
import com.android.server.inputmethod.InputMethodManagerInternal;
|
import com.android.server.inputmethod.InputMethodManagerInternal;
|
||||||
import com.android.server.wm.ActivityTaskManagerInternal;
|
|
||||||
import com.android.server.wm.WindowManagerInternal;
|
import com.android.server.wm.WindowManagerInternal;
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
@@ -2081,7 +2079,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
|||||||
IAccessibilityInteractionConnectionCallback callback, int fetchFlags,
|
IAccessibilityInteractionConnectionCallback callback, int fetchFlags,
|
||||||
long interrogatingTid) {
|
long interrogatingTid) {
|
||||||
RemoteAccessibilityConnection connection;
|
RemoteAccessibilityConnection connection;
|
||||||
IBinder activityToken = null;
|
IBinder windowToken = null;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
connection = mA11yWindowManager.getConnectionLocked(userId, resolvedWindowId);
|
connection = mA11yWindowManager.getConnectionLocked(userId, resolvedWindowId);
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
@@ -2090,9 +2088,8 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
|||||||
final boolean isA11yFocusAction = (action == ACTION_ACCESSIBILITY_FOCUS)
|
final boolean isA11yFocusAction = (action == ACTION_ACCESSIBILITY_FOCUS)
|
||||||
|| (action == ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
|| (action == ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
||||||
if (!isA11yFocusAction) {
|
if (!isA11yFocusAction) {
|
||||||
final WindowInfo windowInfo =
|
windowToken = mA11yWindowManager.getWindowTokenForUserAndWindowIdLocked(
|
||||||
mA11yWindowManager.findWindowInfoByIdLocked(resolvedWindowId);
|
userId, resolvedWindowId);
|
||||||
if (windowInfo != null) activityToken = windowInfo.activityToken;
|
|
||||||
}
|
}
|
||||||
final AccessibilityWindowInfo a11yWindowInfo =
|
final AccessibilityWindowInfo a11yWindowInfo =
|
||||||
mA11yWindowManager.findA11yWindowInfoByIdLocked(resolvedWindowId);
|
mA11yWindowManager.findA11yWindowInfoByIdLocked(resolvedWindowId);
|
||||||
@@ -2113,9 +2110,8 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
|||||||
if (action == ACTION_CLICK || action == ACTION_LONG_CLICK) {
|
if (action == ACTION_CLICK || action == ACTION_LONG_CLICK) {
|
||||||
mA11yWindowManager.notifyOutsideTouch(userId, resolvedWindowId);
|
mA11yWindowManager.notifyOutsideTouch(userId, resolvedWindowId);
|
||||||
}
|
}
|
||||||
if (activityToken != null) {
|
if (windowToken != null) {
|
||||||
LocalServices.getService(ActivityTaskManagerInternal.class)
|
mWindowManagerService.requestWindowFocus(windowToken);
|
||||||
.setFocusedActivity(activityToken);
|
|
||||||
}
|
}
|
||||||
if (intConnTracingEnabled()) {
|
if (intConnTracingEnabled()) {
|
||||||
logTraceIntConn("performAccessibilityAction",
|
logTraceIntConn("performAccessibilityAction",
|
||||||
|
|||||||
@@ -262,12 +262,6 @@ public abstract class ActivityTaskManagerInternal {
|
|||||||
*/
|
*/
|
||||||
public abstract void setVr2dDisplayId(int vr2dDisplayId);
|
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);
|
public abstract void registerScreenObserver(ScreenObserver observer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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
|
@Override
|
||||||
public int getDisplayId(IBinder token) {
|
public int getDisplayId(IBinder token) {
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
ActivityRecord r = ActivityRecord.forTokenLocked(token);
|
ActivityRecord r = ActivityRecord.forTokenLocked(token);
|
||||||
if (r == null) {
|
if (r == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"setFocusedActivity: No activity record matching token=" + token);
|
"getDisplayId: No activity record matching token=" + token);
|
||||||
}
|
}
|
||||||
return r.getDisplayId();
|
return r.getDisplayId();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -448,6 +448,19 @@ public abstract class WindowManagerInternal {
|
|||||||
*/
|
*/
|
||||||
public abstract void moveDisplayToTopIfAllowed(int displayId);
|
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.
|
* @return Whether the keyguard is engaged.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5652,7 +5652,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
case ON_POINTER_DOWN_OUTSIDE_FOCUS: {
|
case ON_POINTER_DOWN_OUTSIDE_FOCUS: {
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
final IBinder touchedToken = (IBinder) msg.obj;
|
final IBinder touchedToken = (IBinder) msg.obj;
|
||||||
onPointerDownOutsideFocusLocked(touchedToken);
|
onPointerDownOutsideFocusLocked(getInputTargetFromToken(touchedToken));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -7751,6 +7751,15 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
WindowManagerService.this.moveDisplayToTopIfAllowed(displayId);
|
WindowManagerService.this.moveDisplayToTopIfAllowed(displayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void requestWindowFocus(IBinder windowToken) {
|
||||||
|
synchronized (mGlobalLock) {
|
||||||
|
final InputTarget inputTarget =
|
||||||
|
WindowManagerService.this.getInputTargetFromWindowTokenLocked(windowToken);
|
||||||
|
WindowManagerService.this.onPointerDownOutsideFocusLocked(inputTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isKeyguardLocked() {
|
public boolean isKeyguardLocked() {
|
||||||
return WindowManagerService.this.isKeyguardLocked();
|
return WindowManagerService.this.isKeyguardLocked();
|
||||||
@@ -8590,8 +8599,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPointerDownOutsideFocusLocked(IBinder touchedToken) {
|
private void onPointerDownOutsideFocusLocked(InputTarget t) {
|
||||||
InputTarget t = getInputTargetFromToken(touchedToken);
|
|
||||||
if (t == null || !t.receiveFocusFromTapOutside()) {
|
if (t == null || !t.receiveFocusFromTapOutside()) {
|
||||||
// If the window that received the input event cannot receive keys, don't move the
|
// 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.
|
// display it's on to the top since that window won't be able to get focus anyway.
|
||||||
|
|||||||
Reference in New Issue
Block a user