private static Object createIWindow() throws Exception {
    Class cIWindow = Class.forName("android.view.IWindow");

    // Since IWindow is an interface, I don't need dexmaker for this
    InvocationHandler handler =
        new InvocationHandler() {
          @Override
          public @Nullable Object invoke(Object proxy, Method method, Object[] args) {
            if (method.getName().equals("asBinder")) {
              return new Binder();
            }
            return null;
          }
        };

    return Proxy.newProxyInstance(cIWindow.getClassLoader(), new Class[] {cIWindow}, handler);
  }
Simulates the view as being attached.
core/src/main/java/com/facebook/testing/screenshot/WindowAttachment.java