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

Commit 9e2c5762 authored by Winson Chung's avatar Winson Chung
Browse files

Fallback to focused window state if input focus target is not a window

- If the current input focus target is neither a window nor embedded
  window, then accessibility should fall back to using the currently
  focused window for computing changes

Bug: 424253885
Flag: com.android.window.flags.use_input_reported_focus_for_accessibility
Test: atest AccessibilityWindowManagerTest
Change-Id: I2b9185d8a0df164198f6ced67307d96f633e866f
parent 0219d4b6
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -1226,8 +1226,21 @@ final class AccessibilityController {
                // Gets the top focused display Id and window token for supporting multi-display.
                if (Flags.useInputReportedFocusForAccessibility()) {
                    topFocusedDisplayId = mAccessibilityController.mFocusedDisplay;
                    topFocusedWindowToken = mAccessibilityController.mFocusedWindow.get(
                    final IBinder focusedInputToken = mAccessibilityController.mFocusedWindow.get(
                            topFocusedDisplayId);
                    if (focusedInputToken != null) {
                        topFocusedWindowToken = focusedInputToken;
                    } else {
                        // If there is no focused target as reported by input, then fall back to the
                        // currently focused window in WM (if it exists). This can happen if there
                        // are other input windows that are focused that are neither WindowStates
                        // nor EmbeddedWindows (ie. input consumers)
                        final WindowState topFocusedWindowState =
                                mService.mRoot.getDisplayContent(topFocusedDisplayId).mCurrentFocus;
                        topFocusedWindowToken = topFocusedWindowState != null
                                ? topFocusedWindowState.mClient.asBinder()
                                : null;
                    }
                } else {
                    final WindowState topFocusedWindowState =
                            mService.mRoot.getTopFocusedDisplayContent().mCurrentFocus;