Skip to content

Commit

Permalink
Unlock stack in AndroidCallbacks (#15335)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinh0 authored Feb 18, 2022
1 parent 4d69db1 commit 90e379e
Showing 1 changed file with 4 additions and 0 deletions.
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

0 comments on commit 90e379e

Please sign in to comment.