Skip to content

Commit

Permalink
Handle error cases in Android OnAttributeData
Browse files Browse the repository at this point in the history
  • Loading branch information
g-coppock committed May 2, 2022
1 parent fb68954 commit 098475b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/controller/java/AndroidCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,14 @@ void ReportCallback::OnAttributeData(const app::ConcreteDataAttributePath & aPat
// Convert TLV to JSON
Json::Value json;
err = TlvToJson(readerForJson, json);
VerifyOrReturn(err == CHIP_NO_ERROR, ReportError(attributePathObj, err));

UtfString jsonString(env, JsonToString(json).c_str());

// Create AttributeState object
jclass attributeStateCls;
err = JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/model/AttributeState", attributeStateCls);
VerifyOrReturnError(err == CHIP_NO_ERROR, ChipLogError(Controller, "Could not find AttributeState class"));
VerifyOrReturn(attributeStateCls != nullptr, ChipLogError(Controller, "Could not find AttributeState class"));
chip::JniClass attributeStateJniCls(attributeStateCls);
jmethodID attributeStateCtor = env->GetMethodID(attributeStateCls, "<init>", "(Ljava/lang/Object;[BLjava/lang/String;)V");
Expand Down

0 comments on commit 098475b

Please sign in to comment.