Skip to content

Commit

Permalink
[Android]add missing stack unlock for onattribute and onevent callbac…
Browse files Browse the repository at this point in the history
…k for android IM (#32217)

* add missing unlock for onattribute and onevent callback for android IM

* Restyled by whitespace

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Mar 8, 2024
1 parent 1c569c2 commit 0b27288
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/controller/java/AndroidCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ jobject GetNodeStateObj(JNIEnv * env, const char * nodeStateClassSignature, jobj
JniReferences::GetInstance().FindMethod(env, wrapperCallback, "getNodeState", nodeStateClassSignature, &getNodeStateMethod);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, ChipLogError(Controller, "Could not find getNodeState method"));

DeviceLayer::StackUnlock unlock;
jobject ret = env->CallObjectMethod(wrapperCallback, getNodeStateMethod);
VerifyOrReturnValue(!env->ExceptionCheck(), nullptr, env->ExceptionDescribe());

Expand Down Expand Up @@ -270,6 +269,7 @@ CHIP_ERROR ConvertReportTlvToJson(const uint32_t id, TLV::TLVReader & data, std:
void ReportCallback::OnAttributeData(const app::ConcreteDataAttributePath & aPath, TLV::TLVReader * apData,
const app::StatusIB & aStatus)
{
DeviceLayer::StackUnlock unlock;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread"));
Expand Down Expand Up @@ -408,6 +408,7 @@ void ReportCallback::UpdateClusterDataVersion()

void ReportCallback::OnEventData(const app::EventHeader & aEventHeader, TLV::TLVReader * apData, const app::StatusIB * apStatus)
{
DeviceLayer::StackUnlock unlock;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread"));
Expand Down Expand Up @@ -642,7 +643,6 @@ void ReportCallback::ReportError(const app::ConcreteAttributePath * attributePat
eventClusterId = static_cast<jlong>(eventPath->mClusterId);
eventId = static_cast<jlong>(eventPath->mEventId);
}

env->CallVoidMethod(wrapperCallback, onErrorMethod, isAttributePath, attributeEndpointId, attributeClusterId, attributeId,
isEventPath, eventEndpointId, eventClusterId, eventId, exception);
VerifyOrReturn(!env->ExceptionCheck(), env->ExceptionDescribe());
Expand Down

0 comments on commit 0b27288

Please sign in to comment.