From 9e98140a17e2e76a177112d993e307396f028a2c Mon Sep 17 00:00:00 2001 From: Pablo Gamito Date: Wed, 1 Sep 2021 15:24:32 +0000 Subject: [PATCH] Expose SurfaceControl's native mLayerId property to Java Expose the layerId so that we can dump it in WindowManager proto traces. This is to allow us to link windows to their respective layer accurately and consistently from the trace data. This enables Flicker as a Service (go/wm-fass) to tag and assocaite animations across the WindowManager trace and SurfaceFlinger trace and allows us to better display and associate errors across both WM and SF hierarchy views in Winscope. Test: N/A Bug: 197712697 Change-Id: Ic11f33b8dc3e134d6c19ac68bfe03f801af04d06 --- core/java/android/view/SurfaceControl.java | 14 ++++++++++++-- core/jni/android_view_SurfaceControl.cpp | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index d6186d71331e1..2c1a83f44cc13 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -239,6 +239,7 @@ public final class SurfaceControl implements Parcelable { private static native int nativeGetGPUContextPriority(); private static native void nativeSetTransformHint(long nativeObject, int transformHint); private static native int nativeGetTransformHint(long nativeObject); + private static native int nativeGetLayerId(long nativeObject); @Nullable @GuardedBy("mLock") @@ -354,8 +355,6 @@ public final class SurfaceControl implements Parcelable { @GuardedBy("mLock") private int mHeight; - private int mTransformHint; - private WeakReference mLocalOwnerView; static GlobalTransactionWrapper sGlobalTransaction; @@ -3652,4 +3651,15 @@ public final class SurfaceControl implements Parcelable { public void setTransformHint(@Surface.Rotation int transformHint) { nativeSetTransformHint(mNativeObject, transformHint); } + + /** + * @hide + */ + public int getLayerId() { + if (mNativeObject != 0) { + return nativeGetLayerId(mNativeObject); + } + + return -1; + } } diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index b9233a087c333..eeb6ce5375476 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -1815,6 +1815,12 @@ static jint nativeGetTransformHint(JNIEnv* env, jclass clazz, jlong nativeSurfac return toRotationInt(ui::Transform::toRotation((transformHintRotationFlags))); } +static jint nativeGetLayerId(JNIEnv* env, jclass clazz, jlong nativeSurfaceControl) { + sp surface(reinterpret_cast(nativeSurfaceControl)); + + return surface->getLayerId(); +} + // ---------------------------------------------------------------------------- static const JNINativeMethod sSurfaceControlMethods[] = { @@ -2010,6 +2016,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeGetTransformHint }, {"nativeSetTrustedOverlay", "(JJZ)V", (void*)nativeSetTrustedOverlay }, + {"nativeGetLayerId", "(J)I", + (void*)nativeGetLayerId }, // clang-format on };