android.view.accessibility.AccessibilityWindowInfo#getType ( )源码实例Demo

下面列出了android.view.accessibility.AccessibilityWindowInfo#getType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: talkback   文件: WindowManager.java
/** returns true if there is no window with windowType after baseWindow */
public boolean isLastWindow(AccessibilityWindowInfo baseWindow, int windowType) {
  int index = getWindowIndex(baseWindow);
  if (index == WRONG_INDEX) {
    return true;
  }

  int count = mWindows.size();
  for (int i = index + 1; i < count; i++) {
    AccessibilityWindowInfo window = mWindows.get(i);
    if (window != null && window.getType() == windowType) {
      return false;
    }
  }

  return true;
}
 
源代码2 项目: talkback   文件: WindowManager.java
/** 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;
}
 
源代码3 项目: talkback   文件: WindowEventInterpreter.java
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;
}
 
源代码4 项目: talkback   文件: WindowEventInterpreter.java
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;
}
 
源代码5 项目: talkback   文件: ScreenState.java
/**
 * 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;
}
 
源代码6 项目: oversec   文件: OversecAccessibilityService.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private AccessibilityWindowInfo getWindowOfTypeIme() {
    try {
        List<AccessibilityWindowInfo> ww = getWindows();
        for (AccessibilityWindowInfo w : ww) {
            if (w.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) {
                return w;
            }
        }
    } catch (java.lang.SecurityException ex) {
        //This can only happen when switching users!
        Ln.e(ex, "failed to getWindows!");
    }
    return null;
}
 
源代码7 项目: quickstart-android   文件: MainActivityTest.java
private void closeKeyboard() {
  for (AccessibilityWindowInfo w : getInstrumentation().getUiAutomation().getWindows()) {
    if (w.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) {
      device.pressBack();
      return;
    }
  }
}
 
源代码8 项目: talkback   文件: WindowManager.java
public boolean isInputWindowOnScreen() {
  if (mWindows == null) {
    return false;
  }

  for (AccessibilityWindowInfo window : mWindows) {
    if (window != null && window.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) {
      return true;
    }
  }

  return false;
}
 
源代码9 项目: talkback   文件: WindowManager.java
public int getWindowType(int windowId) {
  if (mWindows != null) {
    for (AccessibilityWindowInfo window : mWindows) {
      if (window != null && window.getId() == windowId) {
        return window.getType();
      }
    }
  }

  return WRONG_WINDOW_TYPE;
}
 
源代码10 项目: talkback   文件: AccessibilityWindowInfoUtils.java
@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);
}
 
源代码11 项目: talkback   文件: AccessibilityWindowInfoUtils.java
@Override
public boolean accept(AccessibilityWindowInfo window) {
  if (window == null) {
    return false;
  }
  int type = window.getType();
  return (type == AccessibilityWindowInfo.TYPE_APPLICATION)
      || (type == AccessibilityWindowInfo.TYPE_SYSTEM);
}
 
源代码12 项目: talkback   文件: AccessibilityWindowInfoUtils.java
/**
 * Reorders the list of {@link AccessibilityWindowInfo} objects based on window positions on the
 * screen. Removes the {@link AccessibilityWindowInfo} for the split screen divider in
 * multi-window mode.
 */
public static void sortAndFilterWindows(List<AccessibilityWindowInfo> windows, boolean isInRTL) {
  if (windows == null) {
    return;
  }

  Collections.sort(windows, new WindowPositionComparator(isInRTL));
  for (AccessibilityWindowInfo window : windows) {
    if (window.getType() == AccessibilityWindowInfo.TYPE_SPLIT_SCREEN_DIVIDER) {
      windows.remove(window);
      return;
    }
  }
}
 
源代码13 项目: talkback   文件: ScreenState.java
/** Used by {@link #toString()}. */
private String getWindowListString(int windowType) {
  StringBuilder sb = new StringBuilder();
  for (AccessibilityWindowInfo window : idToWindowInfoMap.values()) {
    if ((window != null)
        && (window.getType() == windowType)
        && !AccessibilityWindowInfoUtils.isPictureInPicture(window)) {
      sb.append(getWindowDescription(window));
    }
  }
  return sb.toString();
}
 
源代码14 项目: talkback   文件: ScreenState.java
/** Used by {@link #toString()}. */
private boolean isInSplitScreenMode() {
  for (AccessibilityWindowInfo window : idToWindowInfoMap.values()) {
    if ((window != null)
        && window.getType() == AccessibilityWindowInfo.TYPE_SPLIT_SCREEN_DIVIDER) {
      return true;
    }
  }
  return false;
}
 
源代码15 项目: talkback   文件: SummaryOutput.java
/**
 * 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);
}
 
private WindowHierarchyElementAndroid construct(
    int id,
    @Nullable WindowHierarchyElementAndroid parent,
    AccessibilityWindowInfo fromWindow,
    Map<ViewHierarchyElementAndroid, AccessibilityNodeInfo> elementToNodeInfoMap) {
  // Bookkeeping
  this.parentId = (parent != null) ? parent.getId() : null;

  // Window properties
  this.windowId = fromWindow.getId();
  this.layer = fromWindow.getLayer();
  this.type = fromWindow.getType();
  this.focused = fromWindow.isFocused();
  this.accessibilityFocused = fromWindow.isAccessibilityFocused();
  this.active = fromWindow.isActive();

  android.graphics.Rect tempRect = new android.graphics.Rect();
  fromWindow.getBoundsInScreen(tempRect);
  this.boundsInScreen = new Rect(tempRect.left, tempRect.top, tempRect.right, tempRect.bottom);

  // Build the window's view hierarchy
  AccessibilityNodeInfo rootInfo = fromWindow.getRoot();
  this.viewHierarchyElements = new ArrayList<>(); // The ultimate size is unknown
  if (rootInfo != null) {
    buildViewHierarchy(
        rootInfo, viewHierarchyElements, null /* no parent */, elementToNodeInfoMap);
    rootInfo.recycle();
  } else {
    // This could occur in the case where the application state changes between the time that
    // the AccessibilityWindowInfo object is obtained and when its root AccessibilityNodeInfo is
    // extracted.
    LogUtils.w(TAG, "Constructed WindowHierarchyElement with no valid root.");
  }
  return new WindowHierarchyElementAndroid(
      id,
      parentId,
      childIds,
      windowId,
      layer,
      type,
      focused,
      accessibilityFocused,
      active,
      boundsInScreen,
      viewHierarchyElements);
}
 
源代码17 项目: talkback   文件: WindowManager.java
private boolean isFocusedWindowType(int windowType) {
  AccessibilityWindowInfo info = getCurrentWindow(false /* useInputFocus */);
  return info != null && info.getType() == windowType;
}
 
源代码18 项目: talkback   文件: WindowTransitionInfo.java
private static boolean isSystemOrImeWindow(AccessibilityWindowInfo window) {
  return (window.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD)
      || (window.getType() == AccessibilityWindowInfo.TYPE_SYSTEM);
}