diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index 5b8dc4055509f..1121133892051 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -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 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; + } } diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index 5ce43df538199..65ff7c7f5a0fd 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -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 surface(reinterpret_cast(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 };