android.view.accessibility.AccessibilityWindowInfo Java Examples
The following examples show how to use
android.view.accessibility.AccessibilityWindowInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WindowManager.java From talkback with Apache License 2.0 | 6 votes |
private @Nullable AccessibilityWindowInfo getWindow( AccessibilityWindowInfo pivotWindow, int direction) { if (mWindows == null || pivotWindow == null || (direction != NEXT && direction != PREVIOUS)) { return null; } int currentWindowIndex = getWindowIndex(pivotWindow); int resultIndex; if (direction == NEXT) { resultIndex = getNextWindowIndex(currentWindowIndex); } else { resultIndex = getPreviousWindowIndex(currentWindowIndex); } if (resultIndex == WRONG_INDEX) { return null; } return mWindows.get(resultIndex); }
Example #2
Source File: TreeDebug.java From talkback with Apache License 2.0 | 6 votes |
/** Logs the node trees for given list of windows. */ public static void logNodeTrees(List<AccessibilityWindowInfo> windows) { if (windows == null) { return; } for (AccessibilityWindowInfo window : windows) { if (window == null) { continue; } // TODO: Filter and print useful window information. LogUtils.v(TAG, "Window: %s", window); AccessibilityNodeInfoCompat root = AccessibilityNodeInfoUtils.toCompat(AccessibilityWindowInfoUtils.getRoot(window)); logNodeTree(root); AccessibilityNodeInfoUtils.recycleNodes(root); } }
Example #3
Source File: ScreenState.java From talkback with Apache License 2.0 | 6 votes |
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Number of windows:").append(idToWindowInfoMap.size()).append('\n'); sb.append("System window: ") .append(getWindowListString(AccessibilityWindowInfo.TYPE_SYSTEM)) .append('\n'); sb.append("Application window: ") .append(getWindowListString(AccessibilityWindowInfo.TYPE_APPLICATION)) .append('\n'); sb.append("Accessibility window: ") .append(getWindowListString(AccessibilityWindowInfo.TYPE_ACCESSIBILITY_OVERLAY)) .append('\n'); sb.append("InputMethod window: ") .append(getWindowListString(AccessibilityWindowInfo.TYPE_INPUT_METHOD)) .append('\n'); sb.append("PicInPic window: ").append(getPicInPicWindowListString()).append('\n'); sb.append("isInSplitScreenMode:").append(isInSplitScreenMode()); return sb.toString(); }
Example #4
Source File: AccessibilityWindowInfoUtils.java From talkback with Apache License 2.0 | 6 votes |
/** Returns the root node of the tree of {@code windowInfo}. */ @Nullable public static AccessibilityNodeInfo getRoot(AccessibilityWindowInfo windowInfo) { AccessibilityNodeInfo nodeInfo = null; if (windowInfo == null) { return null; } try { nodeInfo = windowInfo.getRoot(); } catch (SecurityException e) { LogUtils.e( TAG, "SecurityException occurred at AccessibilityWindowInfoUtils#getRoot(): %s", e); } return nodeInfo; }
Example #5
Source File: WindowEventInterpreter.java From talkback with Apache License 2.0 | 6 votes |
private boolean isSystemWindow(int windowId) { if (systemWindowIdsSet.contains(windowId)) { return true; } if (!isSplitScreenModeAvailable) { return false; } for (AccessibilityWindowInfo window : AccessibilityServiceCompatUtils.getWindows(service)) { if (window.getId() == windowId && window.getType() == AccessibilityWindowInfo.TYPE_SYSTEM) { return true; } } return false; }
Example #6
Source File: AccessibilityWindow.java From talkback with Apache License 2.0 | 6 votes |
/** * Returns a node instance, or null. Should only be called by this class and sub-classes. Uses * factory argument to create sub-class instances, without creating unnecessary instances when * result should be null. Method is protected so that it can be called by sub-classes without * duplicating null-checking logic. * * @param windowBareArg The wrapped window info. Caller may retain responsibility to recycle. * @param windowCompatArg The wrapped window info. Caller may retain responsibility to recycle. * @param factory Creates instances of AccessibilityWindow or sub-classes. * @return AccessibilityWindow instance, that caller must recycle. */ @Nullable protected static <T extends AccessibilityWindow> T construct( @Nullable AccessibilityWindowInfo windowBareArg, @Nullable AccessibilityWindowInfoCompat windowCompatArg, Factory<T> factory) { // Check inputs. if (windowBareArg == null && windowCompatArg == null) { return null; } // Construct window wrapper. T instance = factory.create(); AccessibilityWindow windowBase = instance; windowBase.windowBare = windowBareArg; windowBase.windowCompat = windowCompatArg; return instance; }
Example #7
Source File: MainTreeBuilder.java From talkback with Apache License 2.0 | 6 votes |
private void removeStatusBarButtonsFromWindowList(List<SwitchAccessWindowInfo> windowList) { int statusBarHeight = DisplayUtils.getStatusBarHeightInPixel(service); final Iterator<SwitchAccessWindowInfo> windowIterator = windowList.iterator(); while (windowIterator.hasNext()) { SwitchAccessWindowInfo window = windowIterator.next(); /* Keep all non-system buttons */ if (window.getType() != AccessibilityWindowInfo.TYPE_SYSTEM) { continue; } final Rect windowBounds = new Rect(); window.getBoundsInScreen(windowBounds); /* Filter out items in the status bar */ if ((windowBounds.bottom <= statusBarHeight)) { windowIterator.remove(); } } }
Example #8
Source File: WindowEventInterpreter.java From talkback with Apache License 2.0 | 6 votes |
private static boolean hasOverlap( AccessibilityWindowInfo windowA, AccessibilityWindowInfo windowB) { Rect rectA = AccessibilityWindowInfoUtils.getBounds(windowA); log("hasOverlap() windowA=%s rectA=%s", windowA, rectA); if (rectA == null) { return false; } Rect rectB = AccessibilityWindowInfoUtils.getBounds(windowB); log("hasOverlap() windowB=%s rectB=%s", windowB, rectB); if (rectB == null) { return false; } return Rect.intersects(rectA, rectB); }
Example #9
Source File: WindowManager.java From talkback with Apache License 2.0 | 6 votes |
/** returns true if there is no window with windowType before baseWindow */ public boolean isFirstWindow(AccessibilityWindowInfo baseWindow, int windowType) { int index = getWindowIndex(baseWindow); if (index <= 0) { return true; } for (int i = index - 1; i > 0; i--) { AccessibilityWindowInfo window = mWindows.get(i); if (window != null && window.getType() == windowType) { return false; } } return true; }
Example #10
Source File: WindowManager.java From talkback with Apache License 2.0 | 6 votes |
/** * @return window that currently accessibilityFocused window. If there is no accessibility focused * window it returns first window that has TYPE_APPLICATION or null if there is no window with * TYPE_APPLICATION type */ public @Nullable AccessibilityWindowInfo getCurrentWindow(boolean useInputFocus) { int currentWindowIndex = getFocusedWindowIndex(mWindows, AccessibilityNodeInfo.FOCUS_ACCESSIBILITY); if (currentWindowIndex != WRONG_INDEX) { return mWindows.get(currentWindowIndex); } if (!useInputFocus) { return null; } currentWindowIndex = getFocusedWindowIndex(mWindows, AccessibilityNodeInfo.FOCUS_INPUT); if (currentWindowIndex != WRONG_INDEX) { return mWindows.get(currentWindowIndex); } return null; }
Example #11
Source File: WindowEventInterpreter.java From talkback with Apache License 2.0 | 6 votes |
public boolean isSplitScreenMode() { if (!isSplitScreenModeAvailable) { return false; } // TODO: Update this state when receiving a TYPE_WINDOWS_CHANGED event if possible. List<AccessibilityWindowInfo> windows = AccessibilityServiceCompatUtils.getWindows(service); List<AccessibilityWindowInfo> applicationWindows = new ArrayList<>(); for (AccessibilityWindowInfo window : windows) { if (window.getType() == AccessibilityWindowInfo.TYPE_APPLICATION) { if (window.getParent() == null && !AccessibilityWindowInfoUtils.isPictureInPicture(window)) { applicationWindows.add(window); } } } // We consider user to be in split screen mode if there are two non-parented // application windows. return applicationWindows.size() == 2; }
Example #12
Source File: WindowManager.java From talkback with Apache License 2.0 | 6 votes |
/** Gets the window whose anchor equals the given node. */ public @Nullable AccessibilityWindowInfo getAnchoredWindow( @Nullable AccessibilityNodeInfoCompat targetAnchor) { if (!BuildVersionUtils.isAtLeastN() || targetAnchor == null) { return null; } int windowCount = mWindows.size(); for (int i = 0; i < windowCount; ++i) { AccessibilityWindowInfo window = mWindows.get(i); if (window != null) { AccessibilityNodeInfo anchor = window.getAnchor(); if (anchor != null) { try { if (anchor.equals(targetAnchor.unwrap())) { return window; } } finally { anchor.recycle(); } } } } return null; }
Example #13
Source File: FocusProcessorForScreenStateChange.java From talkback with Apache License 2.0 | 6 votes |
/** * Sets initial focus in the active window. * * @return {@code true} if successfully set accessibility focus on a node. */ private boolean assignFocusOnWindow( AccessibilityWindowInfo activeWindow, @Nullable CharSequence windowTitle, EventId eventId) { // TODO: Initial focus is set with linear navigation strategy, which is inconsistent // with directional navigation strategy on TV, and introduces some bugs. Enable it when we have // a solid solution for this issue. boolean enabled = !isTv; AccessibilityNodeInfoCompat root = AccessibilityNodeInfoUtils.toCompat(AccessibilityWindowInfoUtils.getRoot(activeWindow)); try { return (enabled && restoreLastFocusedNode( root, activeWindow.getType(), activeWindow.getId(), windowTitle, eventId)) || syncA11yFocusToInputFocusedEditText(root, eventId) || (enabled && focusOnFirstFocusableNonTitleNode(root, windowTitle, eventId)); } finally { AccessibilityNodeInfoUtils.recycleNodes(root); } }
Example #14
Source File: WindowEventInterpreter.java From talkback with Apache License 2.0 | 6 votes |
public CharSequence getWindowTitle(int windowId) { // Try to get window title from the map. CharSequence windowTitle = windowTitlesMap.get(windowId); if (windowTitle != null) { return windowTitle; } if (!BuildVersionUtils.isAtLeastN()) { return null; } // Do not try to get system window title from AccessibilityWindowInfo.getTitle, it can // return non-translated value. if (isSystemWindow(windowId)) { return null; } // Try to get window title from AccessibilityWindowInfo. for (AccessibilityWindowInfo window : AccessibilityServiceCompatUtils.getWindows(service)) { if (window.getId() == windowId) { return window.getTitle(); } } return null; }
Example #15
Source File: UiDevice.java From JsDroidCmd with Mozilla Public License 2.0 | 6 votes |
/** * Returns a list containing the root {@link AccessibilityNodeInfo}s for * each active window */ public AccessibilityNodeInfo[] getWindowRoots() { ArrayList<AccessibilityNodeInfo> ret = new ArrayList<AccessibilityNodeInfo>(); if (getAutomatorBridge().getFastMode()) { List<AccessibilityWindowInfo> windows = mUiAutomationBridge .getUiAutomation().getWindows(); for (AccessibilityWindowInfo window : windows) { if (window != null) ret.add(window.getRoot()); } if (ret.size() == 0) { ret.add(mUiAutomationBridge.getUiAutomation() .getRootInActiveWindow()); } } else { ret.add(mUiAutomationBridge.getUiAutomation() .getRootInActiveWindow()); } return ret.toArray(new AccessibilityNodeInfo[ret.size()]); }
Example #16
Source File: WindowManager.java From talkback with Apache License 2.0 | 6 votes |
private static int getFocusedWindowIndex(List<AccessibilityWindowInfo> windows, int focusType) { if (windows == null) { return WRONG_INDEX; } for (int i = 0, size = windows.size(); i < size; i++) { AccessibilityWindowInfo window = windows.get(i); if (window == null) { continue; } if (focusType == AccessibilityNodeInfo.FOCUS_ACCESSIBILITY && window.isAccessibilityFocused()) { return i; } else if (focusType == AccessibilityNodeInfo.FOCUS_INPUT && window.isFocused()) { return i; } } return WRONG_INDEX; }
Example #17
Source File: UicdDevice.java From android-uiconductor with Apache License 2.0 | 6 votes |
/** Returns a list containing the root {@link AccessibilityNodeInfo}s for each active window */ @TargetApi(VERSION_CODES.LOLLIPOP) public static Set<AccessibilityNodeInfo> getWindowRoots() { Set<AccessibilityNodeInfo> roots = new HashSet(); // Start with the active window, which seems to sometimes be missing from the list returned // by the UiAutomation. UiAutomation uiAutomation = getUiAutomation(); AccessibilityNodeInfo activeRoot = uiAutomation.getRootInActiveWindow(); if (activeRoot != null) { roots.add(activeRoot); } // Support multi-window searches for API level 21 and up. for (AccessibilityWindowInfo window : uiAutomation.getWindows()) { AccessibilityNodeInfo root = window.getRoot(); Log.i(TAG, String.format("Getting Layer: %d", window.getLayer())); if (root == null) { Log.w(TAG, String.format("Skipping null root node for window: %s", window.toString())); continue; } roots.add(root); } return roots; }
Example #18
Source File: FocusProcessorForLogicalNavigation.java From talkback with Apache License 2.0 | 6 votes |
/** Returns {@code true} if current window is the last window on screen in traversal order. */ private static boolean needPauseWhenTraverseAcrossWindow( WindowManager windowManager, boolean isScreenRtl, AccessibilityWindowInfo currentWindow, @SearchDirection int searchDirection) { if (!AccessibilityWindowInfoUtils.FILTER_WINDOW_DIRECTIONAL_NAVIGATION.accept(currentWindow)) { // Need pause before looping traversal in non-application window return true; } @TraversalStrategy.SearchDirection int logicalDirection = TraversalStrategyUtils.getLogicalDirection(searchDirection, isScreenRtl); if (logicalDirection == TraversalStrategy.SEARCH_FOCUS_FORWARD) { return windowManager.isLastWindow(currentWindow, AccessibilityWindowInfo.TYPE_APPLICATION); } else if (logicalDirection == TraversalStrategy.SEARCH_FOCUS_BACKWARD) { return windowManager.isFirstWindow(currentWindow, AccessibilityWindowInfo.TYPE_APPLICATION); } else { throw new IllegalStateException("Unknown logical direction"); } }
Example #19
Source File: ScreenStateMonitor.java From talkback with Apache License 2.0 | 6 votes |
private void handleScreenStateChangeWhenUIStabilized(EventId eventId, int attempt) { AccessibilityWindowInfo activeWindow = latestScreenStateDuringTransition.getActiveWindow(); if ((activeWindow != null) && !AccessibilityWindowInfoUtils.isWindowContentVisible(activeWindow) && (attempt < MAXIMUM_ATTEMPTS)) { // UI might not be stabilized yet. Try again later. LogUtils.w(TAG, "Active window is invisible, try again later."); handler.postHandleScreenStateChanges(eventId, attempt + 1, TIMEOUT_RETRY_MS); return; } ScreenState oldScreenState = lastStableScreenState; ScreenState newScreenState = latestScreenStateDuringTransition; long transitionStartTime = screenTransitionStartTime; setStableScreenState(latestScreenStateDuringTransition); onScreenStateChanged(oldScreenState, newScreenState, transitionStartTime, eventId); }
Example #20
Source File: ScreenState.java From talkback with Apache License 2.0 | 6 votes |
/** * Returns title of window with given window ID. * * <p><strong>Note: </strong> This method returns null if the window has no title, or the window * is not visible, or the window is IME or system window. */ @Nullable public CharSequence getWindowTitle(int windowId) { AccessibilityWindowInfo window = idToWindowInfoMap.get(windowId); if ((window == null) || (window.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) || (window.getType() == AccessibilityWindowInfo.TYPE_SYSTEM) || (window.getType() == AccessibilityWindowInfo.TYPE_SPLIT_SCREEN_DIVIDER)) { // Only return title for application or accessibility windows. return null; } CharSequence eventTitle = overriddenWindowTitles.get(windowId); if (!TextUtils.isEmpty(eventTitle)) { return eventTitle; } if (BuildVersionUtils.isAtLeastN()) { // AccessibilityWindowInfo.getTitle() is available since API 24. CharSequence infoTitle = window.getTitle(); if (!TextUtils.isEmpty(infoTitle)) { return infoTitle; } } return null; }
Example #21
Source File: SwitchAccessWindowInfo.java From talkback with Apache License 2.0 | 5 votes |
/** * @param accessibilityWindowInfo The windowInfo to wrap * @param listOfWindowsAbove A list of all windows above this one */ public SwitchAccessWindowInfo( AccessibilityWindowInfo accessibilityWindowInfo, List<AccessibilityWindowInfo> listOfWindowsAbove) { if (accessibilityWindowInfo == null) { throw new NullPointerException(); } this.accessibilityWindowInfo = accessibilityWindowInfo; this.listOfWindowsAbove = listOfWindowsAbove; }
Example #22
Source File: FocusProcessorForScreenStateChange.java From talkback with Apache License 2.0 | 5 votes |
/** * Restores last focus from {@link AccessibilityFocusActionHistory} to the active window. Caller * should recycle {@code root}. * * @param root root node in the active window * @param windowType current active window type * @param windowId current active window id * @param windowTitle current active window title * @param eventId event id * @return {@code true} if successfully restore and set accessibility focus on the node. */ protected boolean restoreLastFocusedNode( AccessibilityNodeInfoCompat root, int windowType, int windowId, @Nullable CharSequence windowTitle, EventId eventId) { if (windowType == AccessibilityWindowInfo.TYPE_SYSTEM) { // Don't restore focus in system window. A exemption is when context menu closes, we might // restore focus in a system window in restoreFocusForContextMenu(). LogUtils.d(TAG, "Do not restore focus in system ui window."); return false; } AccessibilityFocusActionHistory.Reader history = actorState.getFocusHistory(); final FocusActionRecord lastFocusAction = history.getLastFocusActionRecordInWindow(windowId, windowTitle); if (lastFocusAction == null) { return false; } AccessibilityNodeInfoCompat nodeToRestoreFocus = getNodeToRestoreFocus(root, lastFocusAction); try { return (nodeToRestoreFocus != null) && nodeToRestoreFocus.isVisibleToUser() // When a pane changes, the nodes not in the pane become out of the window even though // they are still visible to user. The window id and title don't change, so the last // focused node, which searches from getFocusHistory(), may not be in the window. && AccessibilityNodeInfoUtils.isInWindow(nodeToRestoreFocus, root.getWindow()) && pipeline.returnFeedback( eventId, Feedback.focus(nodeToRestoreFocus, FOCUS_ACTION_INFO_RESTORED)); } finally { AccessibilityNodeInfoUtils.recycleNodes(nodeToRestoreFocus); } }
Example #23
Source File: FocusProcessorForScreenStateChange.java From talkback with Apache License 2.0 | 5 votes |
private boolean hasValidAccessibilityFocusInWindow(AccessibilityWindowInfo window) { AccessibilityNodeInfoCompat currentFocus = null; try { currentFocus = accessibilityFocusMonitor.getAccessibilityFocus(/* useInputFocusIfEmpty= */ false); return (currentFocus != null) && AccessibilityNodeInfoUtils.isVisible(currentFocus) && (currentFocus.getWindowId() == window.getId()); } finally { AccessibilityNodeInfoUtils.recycleNodes(currentFocus); } }
Example #24
Source File: FocusProcessorForLogicalNavigation.java From talkback with Apache License 2.0 | 5 votes |
/** * Navigate into the next or previous window. * * <p>Called when the user performs window navigation with keyboard shortcuts. * * <p><strong>Note:</strong> Caller is responsible to recycle the pivot. * * @return {@code true} if any accessibility action is successfully performed. */ private boolean navigateToWindowTarget( AccessibilityNodeInfoCompat pivot, NavigationAction navigationAction, EventId eventId) { AccessibilityWindowInfo currentWindow = AccessibilityNodeInfoUtils.getWindow(pivot.unwrap()); if (currentWindow == null) { return false; } AccessibilityNodeInfoCompat target = null; Map<AccessibilityNodeInfoCompat, Boolean> speakingNodeCache = new HashMap<>(); try { WindowManager windowManager = new WindowManager(service); boolean isScreenRtl = WindowManager.isScreenLayoutRTL(service); target = searchTargetInNextOrPreviousWindow( screenStateMonitor.getCurrentScreenState(), windowManager, isScreenRtl, currentWindow, navigationAction.searchDirection, /* shouldRestoreLastFocus= */ true, actorState.getFocusHistory(), AccessibilityWindowInfoUtils.FILTER_WINDOW_FOR_WINDOW_NAVIGATION, NavigationTarget.createNodeFilter( NavigationTarget.TARGET_DEFAULT, speakingNodeCache)); return (target != null) && setAccessibilityFocusInternal(target, navigationAction, eventId); } finally { AccessibilityNodeInfoUtils.recycleNodes(target); } }
Example #25
Source File: AccessibilityWindowInfoUtils.java From talkback with Apache License 2.0 | 5 votes |
@Override public boolean accept(AccessibilityWindowInfo window) { if (window == null) { return false; } int type = window.getType(); return (type == AccessibilityWindowInfoCompat.TYPE_APPLICATION) || (type == AccessibilityWindowInfoCompat.TYPE_SPLIT_SCREEN_DIVIDER); }
Example #26
Source File: WindowTransitionInfo.java From talkback with Apache License 2.0 | 5 votes |
private void cacheWindowTitleFromEvent( @Nullable AccessibilityWindowInfo sourceWindow, AccessibilityEvent event) { if (shouldIgnorePaneChanges(event)) { return; } final CharSequence windowTitle; final @RoleName int eventSourceRole = Role.getSourceRole(event); // For special layouts, assign window title even if event title is empty. // It's ok to hard code the title since it's used as an identifier. switch (eventSourceRole) { case Role.ROLE_DRAWER_LAYOUT: windowTitle = getEventTitle(sourceWindow, event) + " Menu"; break; case Role.ROLE_ICON_MENU: windowTitle = "Options"; break; case Role.ROLE_SLIDING_DRAWER: windowTitle = "Sliding drawer"; break; default: windowTitle = getEventTitle(sourceWindow, event); break; } if (!TextUtils.isEmpty(windowTitle)) { cachedWindowTitlesFromEvents.put(event.getWindowId(), windowTitle); } }
Example #27
Source File: AccessibilityServiceCompatUtils.java From talkback with Apache License 2.0 | 5 votes |
public static AccessibilityWindowInfo getActiveWidow(AccessibilityService service) { if (service == null) { return null; } AccessibilityNodeInfo rootInActiveWindow = service.getRootInActiveWindow(); if (rootInActiveWindow == null) { return null; } AccessibilityWindowInfo window = AccessibilityNodeInfoUtils.getWindow(rootInActiveWindow); rootInActiveWindow.recycle(); return window; }
Example #28
Source File: AccessibilityServiceCompatUtils.java From talkback with Apache License 2.0 | 5 votes |
/** @return root node of the window that currently has accessibility focus */ public static @Nullable AccessibilityNodeInfoCompat getRootInAccessibilityFocusedWindow( AccessibilityService service) { if (service == null) { return null; } AccessibilityNodeInfo focusedRoot = null; List<AccessibilityWindowInfo> windows = getWindows(service); // Create window manager with fake value of isInRTL = false. This is okay here since // isInRTL will not change the result of getCurrentWindow. WindowManager manager = new WindowManager(false /* isInRTL */); manager.setWindows(windows); AccessibilityWindowInfo accessibilityFocusedWindow = manager.getCurrentWindow(false /* useInputFocus */); if (accessibilityFocusedWindow != null) { focusedRoot = AccessibilityWindowInfoUtils.getRoot(accessibilityFocusedWindow); } if (focusedRoot == null) { focusedRoot = service.getRootInActiveWindow(); } if (focusedRoot == null) { return null; } return AccessibilityNodeInfoUtils.toCompat(focusedRoot); }
Example #29
Source File: SummaryOutput.java From talkback with Apache License 2.0 | 5 votes |
/** * Starts the SummaryActivity, passing it the application window which will be used to generate * the screen summary. */ public static void showOutput(AccessibilityService service) { List<AccessibilityWindowInfo> windows = AccessibilityServiceCompatUtils.getWindows(service); ArrayList<ArrayList<NodeData>> nodeDataList = new ArrayList<ArrayList<NodeData>>(); for (int i = 0; i < TreeTraversal.ZONE_COUNT; i++) { nodeDataList.add(new ArrayList<NodeData>()); } // Collect summary info from all windows of type application to account for split screen mode. // Also collect info if the window is an active system window, such as notification shade. for (AccessibilityWindowInfo window : windows) { int windowType = window.getType(); if (windowType == AccessibilityWindowInfo.TYPE_APPLICATION || (window.getType() == AccessibilityWindowInfo.TYPE_SYSTEM && window.isActive())) { ArrayList<ArrayList<NodeData>> windowSummary = TreeTraversal.checkRootNode(window, service); for (int i = 0; i < TreeTraversal.ZONE_COUNT; i++) { nodeDataList.get(i).addAll(windowSummary.get(i)); } } } // Attach summary elements to their location names in LocationData. Only add to the LocationData // list if the list of summary items is non empty. ArrayList<LocationData> locationDataList = new ArrayList<LocationData>(); String[] locationNames = getLocationNames(service); for (int i = 0; i < TreeTraversal.ZONE_COUNT; i++) { ArrayList<NodeData> nodeDataSubList = nodeDataList.get(i); if (!nodeDataSubList.isEmpty()) { locationDataList.add(new LocationData(locationNames[i], nodeDataList.get(i))); } } showDialog(service, locationDataList); }
Example #30
Source File: WindowManager.java From talkback with Apache License 2.0 | 5 votes |
private int getWindowIndex(AccessibilityWindowInfo windowInfo) { if (mWindows == null || windowInfo == null) { return WRONG_INDEX; } int windowSize = mWindows.size(); for (int i = 0; i < windowSize; i++) { if (windowInfo.equals(mWindows.get(i))) { return i; } } return WRONG_INDEX; }