Loading core/java/android/view/SurfaceControlFpsListener.java +6 −5 Original line number Diff line number Diff line Loading @@ -57,14 +57,14 @@ public abstract class SurfaceControlFpsListener { public abstract void onFpsReported(float fps); /** * Registers the sampling listener. * Registers the sampling listener for a particular task ID */ public void register(@NonNull SurfaceControl layer) { public void register(int taskId) { if (mNativeListener == 0) { return; } nativeRegister(mNativeListener, layer.mNativeObject); nativeRegister(mNativeListener, taskId); } /** Loading @@ -82,12 +82,13 @@ public abstract class SurfaceControlFpsListener { * * Called from native code on a binder thread. */ private static void dispatchOnFpsReported(SurfaceControlFpsListener listener, float fps) { private static void dispatchOnFpsReported( @NonNull SurfaceControlFpsListener listener, float fps) { listener.onFpsReported(fps); } private static native long nativeCreate(SurfaceControlFpsListener thiz); private static native void nativeDestroy(long ptr); private static native void nativeRegister(long ptr, long layerObject); private static native void nativeRegister(long ptr, int taskId); private static native void nativeUnregister(long ptr); } core/jni/android_view_SurfaceControlFpsListener.cpp +3 −5 Original line number Diff line number Diff line Loading @@ -84,11 +84,9 @@ void nativeDestroy(JNIEnv* env, jclass clazz, jlong ptr) { listener->decStrong((void*)nativeCreate); } void nativeRegister(JNIEnv* env, jclass clazz, jlong ptr, jlong layerObj) { void nativeRegister(JNIEnv* env, jclass clazz, jlong ptr, jint taskId) { sp<SurfaceControlFpsListener> listener = reinterpret_cast<SurfaceControlFpsListener*>(ptr); auto layer = reinterpret_cast<SurfaceControl*>(layerObj); sp<IBinder> layerHandle = layer != nullptr ? layer->getHandle() : nullptr; if (SurfaceComposerClient::addFpsListener(layerHandle, listener) != OK) { if (SurfaceComposerClient::addFpsListener(taskId, listener) != OK) { constexpr auto error_msg = "Couldn't addFpsListener"; ALOGE(error_msg); jniThrowRuntimeException(env, error_msg); Loading @@ -109,7 +107,7 @@ const JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ {"nativeCreate", "(Landroid/view/SurfaceControlFpsListener;)J", (void*)nativeCreate}, {"nativeDestroy", "(J)V", (void*)nativeDestroy}, {"nativeRegister", "(JJ)V", (void*)nativeRegister}, {"nativeRegister", "(JI)V", (void*)nativeRegister}, {"nativeUnregister", "(J)V", (void*)nativeUnregister}}; } // namespace Loading core/tests/coretests/src/android/view/SurfaceControlFpsListenerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public class SurfaceControlFpsListenerTest { } }; listener.register(new SurfaceControl()); listener.register(0); listener.unregister(); } Loading Loading
core/java/android/view/SurfaceControlFpsListener.java +6 −5 Original line number Diff line number Diff line Loading @@ -57,14 +57,14 @@ public abstract class SurfaceControlFpsListener { public abstract void onFpsReported(float fps); /** * Registers the sampling listener. * Registers the sampling listener for a particular task ID */ public void register(@NonNull SurfaceControl layer) { public void register(int taskId) { if (mNativeListener == 0) { return; } nativeRegister(mNativeListener, layer.mNativeObject); nativeRegister(mNativeListener, taskId); } /** Loading @@ -82,12 +82,13 @@ public abstract class SurfaceControlFpsListener { * * Called from native code on a binder thread. */ private static void dispatchOnFpsReported(SurfaceControlFpsListener listener, float fps) { private static void dispatchOnFpsReported( @NonNull SurfaceControlFpsListener listener, float fps) { listener.onFpsReported(fps); } private static native long nativeCreate(SurfaceControlFpsListener thiz); private static native void nativeDestroy(long ptr); private static native void nativeRegister(long ptr, long layerObject); private static native void nativeRegister(long ptr, int taskId); private static native void nativeUnregister(long ptr); }
core/jni/android_view_SurfaceControlFpsListener.cpp +3 −5 Original line number Diff line number Diff line Loading @@ -84,11 +84,9 @@ void nativeDestroy(JNIEnv* env, jclass clazz, jlong ptr) { listener->decStrong((void*)nativeCreate); } void nativeRegister(JNIEnv* env, jclass clazz, jlong ptr, jlong layerObj) { void nativeRegister(JNIEnv* env, jclass clazz, jlong ptr, jint taskId) { sp<SurfaceControlFpsListener> listener = reinterpret_cast<SurfaceControlFpsListener*>(ptr); auto layer = reinterpret_cast<SurfaceControl*>(layerObj); sp<IBinder> layerHandle = layer != nullptr ? layer->getHandle() : nullptr; if (SurfaceComposerClient::addFpsListener(layerHandle, listener) != OK) { if (SurfaceComposerClient::addFpsListener(taskId, listener) != OK) { constexpr auto error_msg = "Couldn't addFpsListener"; ALOGE(error_msg); jniThrowRuntimeException(env, error_msg); Loading @@ -109,7 +107,7 @@ const JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ {"nativeCreate", "(Landroid/view/SurfaceControlFpsListener;)J", (void*)nativeCreate}, {"nativeDestroy", "(J)V", (void*)nativeDestroy}, {"nativeRegister", "(JJ)V", (void*)nativeRegister}, {"nativeRegister", "(JI)V", (void*)nativeRegister}, {"nativeUnregister", "(J)V", (void*)nativeUnregister}}; } // namespace Loading
core/tests/coretests/src/android/view/SurfaceControlFpsListenerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public class SurfaceControlFpsListenerTest { } }; listener.register(new SurfaceControl()); listener.register(0); listener.unregister(); } Loading