public static boolean areBoundsIdenticalToWindow(AccessibilityNodeInfoCompat node, View view) {
    Window window = null;
    Context context = view.getContext();
    while (context instanceof ContextWrapper) {
      if (context instanceof Activity) {
        window = ((Activity) context).getWindow();
      }
      context = ((ContextWrapper) context).getBaseContext();
    }

    if (window == null) {
      return false;
    }

    WindowManager.LayoutParams windowParams = window.getAttributes();
    Rect windowBounds =
        new Rect(
            windowParams.x,
            windowParams.y,
            windowParams.x + windowParams.width,
            windowParams.y + windowParams.height);

    Rect nodeBounds = new Rect();
    node.getBoundsInScreen(nodeBounds);

    return windowBounds.equals(nodeBounds);
  }
Returns whether a AccessibilityNodeInfoCompat has the same size and position as its containing
Window.

@param node The {@link AccessibilityNodeInfoCompat} to evaluate
@return {@code true} if node has equal bounds to its containing Window
core/src/main/java/com/facebook/testing/screenshot/layouthierarchy/AccessibilityUtil.java