Skip to content

Commit

Permalink
Use JniUtfString.
Browse files Browse the repository at this point in the history
  • Loading branch information
amitnj committed Jan 25, 2023
1 parent c99ddf6 commit d87c074
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions examples/tv-app/android/java/ContentAppCommandDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ void ContentAppCommandDelegate::InvokeCommand(CommandHandlerInterface::HandlerCo
FormatResponseData(handlerContext, "{\"value\":{}}");
return;
}
const char * respStr = env->GetStringUTFChars(resp, 0);
ChipLogProgress(Zcl, "ContentAppCommandDelegate::InvokeCommand got response %s", respStr);
FormatResponseData(handlerContext, respStr);
env->ReleaseStringUTFChars(resp, respStr);
JniUtfString respStr(env, resp);
ChipLogProgress(Zcl, "ContentAppCommandDelegate::InvokeCommand got response %s", respStr.c_str());
FormatResponseData(handlerContext, respStr.c_str());
env->DeleteLocalRef(resp);
}
else
Expand Down Expand Up @@ -115,15 +114,15 @@ Status ContentAppCommandDelegate::InvokeCommand(EndpointId epId, ClusterId clust
}
else
{
const char * respStr = env->GetStringUTFChars(resp, 0);
ChipLogProgress(Zcl, "ContentAppCommandDelegate::InvokeCommand got response %s", respStr);
JniUtfString respStr(env, resp);
ChipLogProgress(Zcl, "ContentAppCommandDelegate::InvokeCommand got response %s", respStr.c_str());

Json::Reader reader;
if (!reader.parse(respStr, value))
if (!reader.parse(respStr.c_str(), value))
{
env->DeleteLocalRef(resp);
return Protocols::InteractionModel::Status::Failure;
}
env->ReleaseStringUTFChars(resp, respStr);
}
env->DeleteLocalRef(resp);

Expand Down

0 comments on commit d87c074

Please sign in to comment.