From e2f82b122e2b08ecbfb50f184bb793963764c39c Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 2 Aug 2019 16:34:58 -0700 Subject: [PATCH] Implement JNI code to invoke Android JSResponder methods from C++ Summary: This diff implements the JNI code required for Android to receive JSResponderHandler calls Reviewed By: JoshuaGross, makovkastar Differential Revision: D16543431 fbshipit-source-id: 38cff16a05633fccefa201b189d761d503a9b839 --- .../com/facebook/react/fabric/jni/Binding.cpp | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index 0b6407a93305db..94ef5ef5e49fe5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -728,9 +728,36 @@ void Binding::schedulerDidSetJSResponder( SurfaceId surfaceId, const ShadowView &shadowView, const ShadowView &initialShadowView, - bool blockNativeResponder) { } + bool blockNativeResponder) { -void Binding::schedulerDidClearJSResponder() { } + jni::global_ref localJavaUIManager = getJavaUIManager(); + if (!localJavaUIManager) { + LOG(ERROR) << "Binding::schedulerSetJSResponder: JavaUIManager disappeared"; + return; + } + + static auto setJSResponder = + jni::findClassStatic(UIManagerJavaDescriptor) + ->getMethod( + "setJSResponder"); + + setJSResponder(localJavaUIManager, shadowView.tag, initialShadowView.tag, (jboolean) blockNativeResponder); +} + +void Binding::schedulerDidClearJSResponder() { + jni::global_ref localJavaUIManager = getJavaUIManager(); + if (!localJavaUIManager) { + LOG(ERROR) << "Binding::schedulerClearJSResponder: JavaUIManager disappeared"; + return; + } + + static auto clearJSResponder = + jni::findClassStatic(UIManagerJavaDescriptor) + ->getMethod("clearJSResponder"); + + clearJSResponder(localJavaUIManager); +} void Binding::registerNatives() { registerHybrid(