From 90e379ee5166c3cbc06f6cb198ce39df1c445f12 Mon Sep 17 00:00:00 2001 From: Austin Hsieh <77706079+austinh0@users.noreply.github.com> Date: Thu, 17 Feb 2022 22:11:29 -0800 Subject: [PATCH] Unlock stack in AndroidCallbacks (#15335) --- src/controller/java/AndroidCallbacks.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/controller/java/AndroidCallbacks.cpp b/src/controller/java/AndroidCallbacks.cpp index cb73e9b027c480..faa64789399dc8 100644 --- a/src/controller/java/AndroidCallbacks.cpp +++ b/src/controller/java/AndroidCallbacks.cpp @@ -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(device)); } @@ -108,6 +109,7 @@ void GetConnectedDeviceCallback::OnDeviceConnectionFailureFn(void * context, Pee jmethodID exceptionConstructor = env->GetMethodID(controllerExceptionCls, "", "(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); } @@ -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); } @@ -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); }