Merge "Adding utility method to dump encoded view hierarchy" into pi-dev am: ce42933ae3
am: 7e7ad73005
Change-Id: If9041ce31a967fdc2c502027699a17385f8d05a5
This commit is contained in:
@@ -17,6 +17,10 @@
|
||||
package com.android.systemui.shared.system;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.View;
|
||||
import android.view.ViewHierarchyEncoder;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
public class ActivityCompat {
|
||||
private final Activity mWrapped;
|
||||
@@ -31,4 +35,27 @@ public class ActivityCompat {
|
||||
public void registerRemoteAnimations(RemoteAnimationDefinitionCompat definition) {
|
||||
mWrapped.registerRemoteAnimations(definition.getWrapped());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see android.view.ViewDebug#dumpv2(View, ByteArrayOutputStream)
|
||||
*/
|
||||
public boolean encodeViewHierarchy(ByteArrayOutputStream out) {
|
||||
View view = null;
|
||||
if (mWrapped.getWindow() != null &&
|
||||
mWrapped.getWindow().peekDecorView() != null &&
|
||||
mWrapped.getWindow().peekDecorView().getViewRootImpl() != null) {
|
||||
view = mWrapped.getWindow().peekDecorView().getViewRootImpl().getView();
|
||||
}
|
||||
if (view == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ViewHierarchyEncoder encoder = new ViewHierarchyEncoder(out);
|
||||
int[] location = view.getLocationOnScreen();
|
||||
encoder.addProperty("window:left", location[0]);
|
||||
encoder.addProperty("window:top", location[1]);
|
||||
view.encode(encoder);
|
||||
encoder.endStream();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user