title: AccessibilityNodeInfo in getRootInActiveWindow: Perform click fails with Rect() not contains X, Y coordenates
body: <p>I'm trying perform click using following code but <a href="https://github.com/chetbox/android-mouse-cursor" rel="nofollow noreferrer"><strong>here</strong></a> says that exists some limitations and i can see this in my tests.</p>
  
  <p>But seems that this bug is caused because <code>Rect()</code> not contains <strong>X</strong>, <strong>Y</strong> coordenates, why everytime that i click in a place where not is supported (probably some limitation like was said on readme file on the example) is executed this line in <code>findSmallestNodeAtPoint()</code> routine:</p>
  
  <pre><code>if (!bounds.contains(x, y)) {
        System.out.println("ERROR DETECTED!!! :::::: NOT bounds.contains(x, y) :::::::");
        return null;
     }
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/50775698/how-can-i-reliably-simulate-touch-events-on-android-without-root-like-automate"><strong>Here</strong></a> in this question, also is mentioned this example of Github and was gived a answer with a code example working 100% (tested) from android Nougat+ (api 24 and above), but in my case i need fix this code below to my app also support perform click in previous versions of android.</p>
  
  <p>Then already knowing where this code is failing, i want know what can be made related to:</p>
  
  <blockquote>
    <p><code>!bounds.contains(x, y)</code></p>
  </blockquote>
  
  <p>The main part of code is:</p>
  
  <pre><code>private static void logNodeHierachy(AccessibilityNodeInfo nodeInfo, int depth) {
      Rect bounds = new Rect();
      nodeInfo.getBoundsInScreen(bounds);
  
      StringBuilder sb = new StringBuilder();
      if (depth &gt; 0) {
          for (int i=0; i&lt;depth; i++) {
              sb.append("  ");
          }
          sb.append("\u2514 ");
      }
      sb.append(nodeInfo.getClassName());
      sb.append(" (" + nodeInfo.getChildCount() +  ")");
      sb.append(" " + bounds.toString());
      if (nodeInfo.getText() != null) {
          sb.append(" - \"" + nodeInfo.getText() + "\"");
      }
      System.out.println(sb.toString());
  
      for (int i=0; i&lt;nodeInfo.getChildCount(); i++) {
          AccessibilityNodeInfo childNode = nodeInfo.getChild(i);
          if (childNode != null) {
              logNodeHierachy(childNode, depth + 1);
          }
      }
  }
  
  private static AccessibilityNodeInfo findSmallestNodeAtPoint(AccessibilityNodeInfo sourceNode, int x, int y) {
      Rect bounds = new Rect();
      sourceNode.getBoundsInScreen(bounds);
  
      if (!bounds.contains(x, y)) {
          System.out.println(":::::: NOT bounds.contains(x, y) :::::::");
          return null;
      }
  
      for (int i=0; i&lt;sourceNode.getChildCount(); i++) {
          AccessibilityNodeInfo nearestSmaller = findSmallestNodeAtPoint(sourceNode.getChild(i), x, y);
          if (nearestSmaller != null) {
              return nearestSmaller;
          }
      }
      return sourceNode;
  }
  
  public void click(int x, int y) {
      System.out.println(String.format("Click [%d, %d]", x, y));
      AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
      if (nodeInfo == null) return;
      AccessibilityNodeInfo nearestNodeToMouse = findSmallestNodeAtPoint(nodeInfo, x, y);
      if (nearestNodeToMouse != null) {
          logNodeHierachy(nearestNodeToMouse, 0);
          nearestNodeToMouse.performAction(AccessibilityNodeInfo.ACTION_CLICK);
      }
      nodeInfo.recycle();
  }
  </code></pre>