[DO NOT MERGE] 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
(cherry picked from commit 9e98140a17)
This commit is contained in:
Pablo Gamito
2021-09-01 15:24:32 +00:00
committed by Nataniel Borges
parent 2f28af9c44
commit 865a06b236
2 changed files with 20 additions and 2 deletions

View File

@@ -242,6 +242,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")
@@ -357,8 +358,6 @@ public final class SurfaceControl implements Parcelable {
@GuardedBy("mLock")
private int mHeight;
private int mTransformHint;
private WeakReference<View> mLocalOwnerView;
static GlobalTransactionWrapper sGlobalTransaction;
@@ -3675,4 +3674,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;
}
}

View File

@@ -1827,6 +1827,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<SurfaceControl> surface(reinterpret_cast<SurfaceControl*>(nativeSurfaceControl));
return surface->getLayerId();
}
// ----------------------------------------------------------------------------
static const JNINativeMethod sSurfaceControlMethods[] = {
@@ -2026,6 +2032,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
(void*)nativeSetTrustedOverlay },
{"nativeSetDropInputMode", "(JJI)V",
(void*)nativeSetDropInputMode },
{"nativeGetLayerId", "(J)I",
(void*)nativeGetLayerId },
// clang-format on
};