List of usage examples for android.view.accessibility AccessibilityWindowInfo TYPE_APPLICATION
int TYPE_APPLICATION
To view the source code for android.view.accessibility AccessibilityWindowInfo TYPE_APPLICATION.
Click Source Link
From source file:com.android.utils.WindowManager.java
/** * Returns whether accessibility focused window has AccessibilityWindowInfo.TYPE_APPLICATION * type.//from w w w .ja v a 2s . c o m */ public boolean isApplicationWindowFocused() { return isFocusedWindowType(AccessibilityWindowInfo.TYPE_APPLICATION); }
From source file:com.android.talkback.formatter.TouchExplorationFormatter.java
/** * Resets cached scrollable state when touch exploration after window state * changes./*from w w w . ja v a 2 s . co m*/ */ @Override public void onAccessibilityEvent(AccessibilityEvent event) { switch (event.getEventType()) { case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: // Reset cached scrollable state. mLastNodeWasScrollable = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Store window title in the map. List<CharSequence> titles = event.getText(); if (titles.size() > 0) { AccessibilityNodeInfo node = event.getSource(); if (node != null) { int windowType = getWindowType(node); if (windowType == AccessibilityWindowInfo.TYPE_APPLICATION || windowType == AccessibilityWindowInfo.TYPE_SYSTEM) { mWindowTitlesMap.put(node.getWindowId(), titles.get(0)); } node.recycle(); } } } break; case AccessibilityEvent.TYPE_WINDOWS_CHANGED: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Copy key set not to modify original map. HashSet<Integer> windowIdsToBeRemoved = new HashSet<Integer>(); windowIdsToBeRemoved.addAll(mWindowTitlesMap.keySet()); // Enumerate window ids to be removed. List<AccessibilityWindowInfo> windows = mService.getWindows(); for (AccessibilityWindowInfo window : windows) { windowIdsToBeRemoved.remove(window.getId()); } // Delete titles of non-existing window ids. for (Integer windowId : windowIdsToBeRemoved) { mWindowTitlesMap.remove(windowId); } } break; } }
From source file:com.android.utils.WindowManager.java
private static AccessibilityWindowInfo getDefaultWindow(List<AccessibilityWindowInfo> windows) { if (windows.size() == 0) { return null; }// w ww .ja va 2 s . c o m for (AccessibilityWindowInfo window : windows) { if (window != null && window.getType() == AccessibilityWindowInfo.TYPE_APPLICATION) { return window; } } return windows.get(0); }
From source file:com.android.talkback.formatter.TouchExplorationFormatter.java
/** * Populates utterance about window transition. We populate this feedback only when user is in * split screen mode to avoid verbosity of feedback. *//* w ww . j a va 2s .c o m*/ private void addWindowTransition(Utterance utterance, AccessibilityNodeInfoCompat announcedNode) { int windowId = announcedNode.getWindowId(); if (windowId == mLastFocusedWindowId) { return; } int windowType = getWindowType(announcedNode); if (windowType != AccessibilityWindowInfoCompat.TYPE_APPLICATION && windowType != AccessibilityWindowInfoCompat.TYPE_SYSTEM) { return; } List<AccessibilityWindowInfo> windows = mService.getWindows(); List<AccessibilityWindowInfo> applicationWindows = new ArrayList<>(); for (AccessibilityWindowInfo window : windows) { if (window.getType() == AccessibilityWindowInfo.TYPE_APPLICATION) { if (window.getParent() == null) { applicationWindows.add(window); } } } // Provide window transition feedback only when user is in split screen mode or navigating // with keyboard. We consider user is in split screen mode if there are two none-parented // application windows. if (applicationWindows.size() != 2 && mService.getInputModeManager().getInputMode() != InputModeManager.INPUT_MODE_KEYBOARD) { return; } WindowManager windowManager = new WindowManager(mService.isScreenLayoutRTL()); windowManager.setWindows(windows); CharSequence title = null; if (!applicationWindows.isEmpty() && windowManager.isStatusBar(windowId)) { title = mService.getString(R.string.status_bar); } else if (!applicationWindows.isEmpty() && windowManager.isNavigationBar(windowId)) { title = mService.getString(R.string.navigation_bar); } else { title = mWindowTitlesMap.get(windowId); if (title == null && BuildCompat.isAtLeastN()) { for (AccessibilityWindowInfo window : windows) { if (window.getId() == windowId) { title = window.getTitle(); break; } } } if (title == null) { title = mService.getApplicationLabel(announcedNode.getPackageName()); } } int templateId = windowType == AccessibilityWindowInfo.TYPE_APPLICATION ? R.string.template_window_switch_application : R.string.template_window_switch_system; utterance.addSpoken( mService.getString(templateId, WindowManager.formatWindowTitleForFeedback(title, mService))); }
From source file:com.android.talkback.eventprocessor.ProcessorScreen.java
private void updateScreenState(AccessibilityEvent event) { switch (event.getEventType()) { case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: // Do nothing if split screen mode is available since it can be covered by // TYPE_WINDOWS_CHANGED events. if (mIsSplitScreenModeAvailable) { return; }/*from ww w .ja v a2s.com*/ mWindowIdA = getWindowId(event); break; case AccessibilityEvent.TYPE_WINDOWS_CHANGED: // Do nothing if split screen mode is NOT available since it can be covered by // TYPE_WINDOW_STATE_CHANGED events. if (!mIsSplitScreenModeAvailable) { return; } ArrayList<AccessibilityWindowInfo> applicationWindows = new ArrayList<>(); ArrayList<AccessibilityWindowInfo> systemWindows = new ArrayList<>(); ArrayList<AccessibilityWindowInfo> accessibilityOverlayWindows = new ArrayList<>(); List<AccessibilityWindowInfo> windows = mService.getWindows(); // If there are no windows available, clear the cached IDs. if (windows.isEmpty()) { mAccessibilityOverlayWindowId = WINDOW_ID_NONE; mWindowIdA = WINDOW_ID_NONE; mWindowIdB = WINDOW_ID_NONE; return; } for (int i = 0; i < windows.size(); i++) { AccessibilityWindowInfo window = windows.get(i); switch (window.getType()) { case AccessibilityWindowInfo.TYPE_APPLICATION: if (window.getParent() == null) { applicationWindows.add(window); } break; case AccessibilityWindowInfo.TYPE_SYSTEM: systemWindows.add(window); break; case AccessibilityWindowInfo.TYPE_ACCESSIBILITY_OVERLAY: accessibilityOverlayWindows.add(window); break; } } if (accessibilityOverlayWindows.size() == windows.size()) { // TODO: investigate whether there is a case where we have more than one // accessibility overlay, and add a logic for it if there is. mAccessibilityOverlayWindowId = accessibilityOverlayWindows.get(0).getId(); return; } mAccessibilityOverlayWindowId = WINDOW_ID_NONE; if (applicationWindows.size() == 0) { mWindowIdA = WINDOW_ID_NONE; mWindowIdB = WINDOW_ID_NONE; // If there is no application window but a system window, consider it as a // current window. This logic handles notification shade and lock screen. if (systemWindows.size() > 0) { Collections.sort(systemWindows, new WindowManager.WindowPositionComparator(mService.isScreenLayoutRTL())); mWindowIdA = systemWindows.get(0).getId(); } } else if (applicationWindows.size() == 1) { mWindowIdA = applicationWindows.get(0).getId(); mWindowIdB = WINDOW_ID_NONE; } else if (applicationWindows.size() == 2) { Collections.sort(applicationWindows, new WindowManager.WindowPositionComparator(mService.isScreenLayoutRTL())); mWindowIdA = applicationWindows.get(0).getId(); mWindowIdB = applicationWindows.get(1).getId(); } else { // If there are more than 2 windows, report the active window as the current // window. for (AccessibilityWindowInfo applicationWindow : applicationWindows) { if (applicationWindow.isActive()) { mWindowIdA = applicationWindow.getId(); mWindowIdB = WINDOW_ID_NONE; return; } } } break; } }
From source file:com.android.screenspeak.controller.CursorControllerApp.java
@SuppressLint("InlinedApi") private boolean needPauseInTraversalAfterCurrentWindow(int direction) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { // always pause before loop in one-window conditions return true; }/*from w w w . j av a2s .co m*/ WindowManager windowsManager = new WindowManager(); windowsManager.setWindows(mService.getWindows()); if (!windowsManager.isApplicationWindowFocused()) { // need pause before looping traversal in non-application window return true; } if (direction == NodeFocusFinder.SEARCH_FORWARD) { return windowsManager.isLastWindow(windowsManager.getCurrentWindow(), AccessibilityWindowInfo.TYPE_APPLICATION); } else { return windowsManager.isFirstWindow(windowsManager.getCurrentWindow(), AccessibilityWindowInfo.TYPE_APPLICATION); } }
From source file:com.android.screenspeak.controller.CursorControllerApp.java
private boolean navigateToNextApplicationWindow(int direction) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { WindowManager windowsManager = new WindowManager(); windowsManager.setWindows(mService.getWindows()); if (!windowsManager.isApplicationWindowFocused()) { return false; }//from ww w . j a va 2 s .co m AccessibilityWindowInfo currentWindow = windowsManager.getCurrentWindow(); if (currentWindow == null) { return false; } AccessibilityWindowInfo targetWindow = null; AccessibilityWindowInfo pivotWindow = currentWindow; while (!currentWindow.equals(targetWindow)) { switch (direction) { case NodeFocusFinder.SEARCH_FORWARD: targetWindow = windowsManager.getNextWindow(pivotWindow); break; case NodeFocusFinder.SEARCH_BACKWARD: targetWindow = windowsManager.getPreviousWindow(pivotWindow); break; } pivotWindow = targetWindow; if (targetWindow == null) { return false; } if (targetWindow.getType() != AccessibilityWindowInfo.TYPE_APPLICATION) { continue; } AccessibilityNodeInfo windowRoot = targetWindow.getRoot(); if (windowRoot == null) { continue; } AccessibilityNodeInfoCompat compatRoot = new AccessibilityNodeInfoCompat(windowRoot); TraversalStrategy traversalStrategy = new OrderedTraversalStrategy(compatRoot); if (navigateWrapAround(compatRoot, direction, traversalStrategy)) { return true; } } } return false; }
From source file:com.android.talkback.controller.CursorControllerApp.java
@SuppressLint("InlinedApi") private boolean needPauseInTraversalAfterCurrentWindow(@TraversalStrategy.SearchDirection int direction) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { // always pause before loop in one-window conditions return true; }// w w w .j a va2s . co m WindowManager windowManager = new WindowManager(mService.isScreenLayoutRTL()); windowManager.setWindows(mService.getWindows()); if (!windowManager.isApplicationWindowFocused() && !windowManager.isSplitScreenDividerFocused()) { // need pause before looping traversal in non-application window return true; } @TraversalStrategy.SearchDirection int logicalDirection = TraversalStrategyUtils.getLogicalDirection(direction, mService.isScreenLayoutRTL()); if (logicalDirection == TraversalStrategy.SEARCH_FOCUS_FORWARD) { return windowManager.isLastWindow(windowManager.getCurrentWindow(false /* useInputFocus */), AccessibilityWindowInfo.TYPE_APPLICATION); } else if (logicalDirection == TraversalStrategy.SEARCH_FOCUS_BACKWARD) { return windowManager.isFirstWindow(windowManager.getCurrentWindow(false /* useInputFocus */), AccessibilityWindowInfo.TYPE_APPLICATION); } else { throw new IllegalStateException("Unknown logical direction"); } }
From source file:com.android.talkback.controller.CursorControllerApp.java
private boolean matchWindowType(AccessibilityWindowInfo window, int windowTypeFilter) { int windowType = window.getType(); if ((windowTypeFilter & WINDOW_TYPE_SYSTEM) != 0 && windowType == AccessibilityWindowInfo.TYPE_SYSTEM) { return true; } else if ((windowTypeFilter & WINDOW_TYPE_APPLICATION) != 0 && windowType == AccessibilityWindowInfo.TYPE_APPLICATION) { return true; } else if ((windowTypeFilter & WINDOW_TYPE_SPLIT_SCREEN_DIVIDER) != 0 && windowType == AccessibilityWindowInfo.TYPE_SPLIT_SCREEN_DIVIDER) { return true; } else {//from w w w. ja v a 2 s. c om return false; } }