Skip to content

Commit

Permalink
Implement JNI code to invoke Android JSResponder methods from C++
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mdvacca authored and facebook-github-bot committed Aug 2, 2019
1 parent 0e067fd commit e2f82b1
Showing 1 changed file with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<jobject> localJavaUIManager = getJavaUIManager();
if (!localJavaUIManager) {
LOG(ERROR) << "Binding::schedulerSetJSResponder: JavaUIManager disappeared";
return;
}

static auto setJSResponder =
jni::findClassStatic(UIManagerJavaDescriptor)
->getMethod<void(
jint, jint, jboolean)>(
"setJSResponder");

setJSResponder(localJavaUIManager, shadowView.tag, initialShadowView.tag, (jboolean) blockNativeResponder);
}

void Binding::schedulerDidClearJSResponder() {
jni::global_ref<jobject> localJavaUIManager = getJavaUIManager();
if (!localJavaUIManager) {
LOG(ERROR) << "Binding::schedulerClearJSResponder: JavaUIManager disappeared";
return;
}

static auto clearJSResponder =
jni::findClassStatic(UIManagerJavaDescriptor)
->getMethod<void()>("clearJSResponder");

clearJSResponder(localJavaUIManager);
}

void Binding::registerNatives() {
registerHybrid(
Expand Down

0 comments on commit e2f82b1

Please sign in to comment.