Merge "Dump accessibility hierarchy on test failure" into sc-v2-dev am: 8aac1952af am: 3ac216c4bb

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15364776

Change-Id: I278d73506a7535f88d05d04ef55043794c37ed10
diff --git a/tests/src/com/android/launcher3/util/rule/FailureWatcher.java b/tests/src/com/android/launcher3/util/rule/FailureWatcher.java
index dc59bdd..5fbf847 100644
--- a/tests/src/com/android/launcher3/util/rule/FailureWatcher.java
+++ b/tests/src/com/android/launcher3/util/rule/FailureWatcher.java
@@ -61,13 +61,23 @@
             out.putNextEntry(new ZipEntry("visible_windows.zip"));
             dumpCommand("cmd window dump-visible-window-views", out);
             out.closeEntry();
-        } catch (IOException ex) { }
+        } catch (IOException ex) {
+        }
 
         Log.e(TAG, "Failed test " + description.getMethodName()
                 + ",\nscreenshot will be saved to " + sceenshot
                 + ",\nUI dump at: " + hierarchy
                 + " (use go/web-hv to open the dump file)", e);
         device.takeScreenshot(sceenshot);
+
+        // Dump accessibility hierarchy
+        final File accessibilityHierarchyFile = new File(parentFile,
+                "AccessibilityHierarchy-" + description.getMethodName() + ".uix");
+        try {
+            device.dumpWindowHierarchy(accessibilityHierarchyFile);
+        } catch (IOException ex) {
+            Log.e(TAG, "Failed to save accessibility hierarchy", ex);
+        }
     }
 
     private static void dumpStringCommand(String cmd, OutputStream out) throws IOException {