Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Unlock stack in AndroidCallbacks #15335

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/controller/java/AndroidCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void GetConnectedDeviceCallback::OnDeviceConnectedFn(void * context, Operational
VerifyOrReturn(successMethod != nullptr, ChipLogError(Controller, "Could not find onDeviceConnected method"));

static_assert(sizeof(jlong) >= sizeof(void *), "Need to store a pointer in a Java handle");
DeviceLayer::StackUnlock unlock;
env->CallVoidMethod(javaCallback, successMethod, reinterpret_cast<jlong>(device));
}

Expand Down Expand Up @@ -108,6 +109,7 @@ void GetConnectedDeviceCallback::OnDeviceConnectionFailureFn(void * context, Pee
jmethodID exceptionConstructor = env->GetMethodID(controllerExceptionCls, "<init>", "(ILjava/lang/String;)V");
jobject exception = env->NewObject(controllerExceptionCls, exceptionConstructor, error, env->NewStringUTF(ErrorStr(error)));

DeviceLayer::StackUnlock unlock;
env->CallVoidMethod(javaCallback, failureMethod, peerId.GetNodeId(), exception);
}

Expand Down Expand Up @@ -173,6 +175,7 @@ void ReportCallback::OnReportEnd()
err = JniReferences::GetInstance().FindMethod(env, mReportCallbackRef, "onReport", "(Ljava/util/Map;)V", &onReportMethod);
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Controller, "Could not find onReport method"));

DeviceLayer::StackUnlock unlock;
env->CallVoidMethod(mReportCallbackRef, onReportMethod, map);
}

Expand Down Expand Up @@ -274,6 +277,7 @@ void ReportCallback::ReportError(jobject attributePath, const char * message, Ch
&onErrorMethod);
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Controller, "Unable to find onError method: %s", ErrorStr(err)));

DeviceLayer::StackUnlock unlock;
env->CallVoidMethod(mReportCallbackRef, onErrorMethod, attributePath, exception);
}

Expand Down