diff options
author | Siva Velusamy <vsiva@google.com> | 2015-04-22 10:23:56 -0700 |
---|---|---|
committer | Siva Velusamy <vsiva@google.com> | 2015-05-07 18:44:15 -0700 |
commit | 0d857b9028f2702ce439e13feccde8182d40e1e5 (patch) | |
tree | a20bf172e726bef479b16ab121ee5a348df6b613 /core/java/android/content | |
parent | 0a008049a21c5fbe36eac8047c5411c2e3aff41b (diff) | |
download | frameworks_base-0d857b9028f2702ce439e13feccde8182d40e1e5.zip frameworks_base-0d857b9028f2702ce439e13feccde8182d40e1e5.tar.gz frameworks_base-0d857b9028f2702ce439e13feccde8182d40e1e5.tar.bz2 |
Improve hierarchy viewer dump hierarchy latency
Hierarchy Viewer obtains the properties for each view by using
reflection and looking for fields and methods that have the
@ExportedProperty annotation. Using reflection made it quite slow
for large view hierarchies.
This CL adds a new method (encode) to each class that wishes to
export data to hiererachy viewer. Inside this method, the object
can write a sequence of key, value pairs corresponding to the
values it wants exported.
With this change, the dump hierarchy operation that used to take
more than 10 seconds can be performed in a few hundred milliseconds.
Change-Id: I199ac2e7ca3c59ebcfec7e6bd201e134c41fd583
Diffstat (limited to 'core/java/android/content')
-rw-r--r-- | core/java/android/content/res/Resources.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index 1d108a2..e65b4ca 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -20,7 +20,6 @@ import android.annotation.AttrRes; import android.annotation.ColorInt; import android.annotation.StyleRes; import android.annotation.StyleableRes; - import com.android.internal.util.GrowingArrayUtils; import com.android.internal.util.XmlUtils; @@ -62,6 +61,7 @@ import android.util.Pools.SynchronizedPool; import android.util.Slog; import android.util.TypedValue; import android.view.ViewDebug; +import android.view.ViewHierarchyEncoder; import java.io.IOException; import java.io.InputStream; @@ -1806,12 +1806,27 @@ public class Resources { for (int i = 0, j = N - 1; i < themes.length; i += 2, --j) { final int resId = mKey.mResId[i]; final boolean forced = mKey.mForce[i]; - themes[i] = getResourceName(resId); + try { + themes[i] = getResourceName(resId); + } catch (NotFoundException e) { + themes[i] = Integer.toHexString(i); + } themes[i + 1] = forced ? "forced" : "not forced"; } return themes; } + /** @hide */ + public void encode(@NonNull ViewHierarchyEncoder encoder) { + encoder.beginObject(this); + // TODO: revert after getTheme() is fixed + String[] properties = new String[0]; // getTheme(); + for (int i = 0; i < properties.length; i += 2) { + encoder.addProperty(properties[i], properties[i+1]); + } + encoder.endObject(); + } + /** * Rebases the theme against the parent Resource object's current * configuration by re-applying the styles passed to |