summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewDebug.java
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-06-14 10:00:31 -0700
committerJohn Reck <jreck@google.com>2012-06-14 14:01:20 -0700
commit926cf56676d760579573470c7848dbf119a86779 (patch)
treebdcb7c27462efd0897d144390e1fc83290d6b979 /core/java/android/view/ViewDebug.java
parenteb859df3f97afa84db85c18bda9c125071dc8747 (diff)
Show WebView layers in hierarchyviewer
Change-Id: I373e084d236baafe17982cfc367d167b81ca3e20
Diffstat (limited to 'core/java/android/view/ViewDebug.java')
-rw-r--r--core/java/android/view/ViewDebug.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java
index dd671dc4cf4e..2e01c9b5b3f2 100644
--- a/core/java/android/view/ViewDebug.java
+++ b/core/java/android/view/ViewDebug.java
@@ -255,6 +255,35 @@ public class ViewDebug {
boolean retrieveReturn() default false;
}
+ /**
+ * Allows a View to inject custom children into HierarchyViewer. For example,
+ * WebView uses this to add its internal layer tree as a child to itself
+ * @hide
+ */
+ public interface HierarchyHandler {
+ /**
+ * Dumps custom children to hierarchy viewer.
+ * See {@link ViewDebug#dumpViewWithProperties(Context, View, BufferedWriter, int)}
+ * for the format
+ *
+ * An empty implementation should simply do nothing
+ *
+ * @param out The output writer
+ * @param level The indentation level
+ */
+ public void dumpViewHierarchyWithProperties(BufferedWriter out, int level);
+
+ /**
+ * Returns a View to enable grabbing screenshots from custom children
+ * returned in dumpViewHierarchyWithProperties.
+ *
+ * @param className The className of the view to find
+ * @param hashCode The hashCode of the view to find
+ * @return the View to capture from, or null if not found
+ */
+ public View findHierarchyView(String className, int hashCode);
+ }
+
private static HashMap<Class<?>, Method[]> mCapturedViewMethodsForClasses = null;
private static HashMap<Class<?>, Field[]> mCapturedViewFieldsForClasses = null;
@@ -759,6 +788,13 @@ public class ViewDebug {
} else if (isRequestedView(view, className, hashCode)) {
return view;
}
+ if (view instanceof HierarchyHandler) {
+ final View found = ((HierarchyHandler)view)
+ .findHierarchyView(className, hashCode);
+ if (found != null) {
+ return found;
+ }
+ }
}
return null;
@@ -783,6 +819,9 @@ public class ViewDebug {
dumpViewWithProperties(context, view, out, level + 1);
}
}
+ if (group instanceof HierarchyHandler) {
+ ((HierarchyHandler)group).dumpViewHierarchyWithProperties(out, level + 1);
+ }
}
private static boolean dumpViewWithProperties(Context context, View view,