From 4d6330866750bc5e75164e202400292c72b4e676 Mon Sep 17 00:00:00 2001 From: amitnj <74272437+amitnj@users.noreply.github.com> Date: Mon, 27 Feb 2023 12:50:46 -0800 Subject: [PATCH] Fix JNI error in tv-app (#25331) * Change default passcode returned from account login cluster. Move use of JniUtfString in a code block so that ReleaseStringUTFChars does not happen after DeleteLocalRef. * Restyled by clang-format --------- Co-authored-by: Restyled.io --- .../com/example/contentapp/CommandResponseHolder.java | 2 +- .../tv-app/android/java/ContentAppCommandDelegate.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/tv-app/android/App/content-app/src/main/java/com/example/contentapp/CommandResponseHolder.java b/examples/tv-app/android/App/content-app/src/main/java/com/example/contentapp/CommandResponseHolder.java index aaaeaa0cba7005..61ee303b408587 100644 --- a/examples/tv-app/android/App/content-app/src/main/java/com/example/contentapp/CommandResponseHolder.java +++ b/examples/tv-app/android/App/content-app/src/main/java/com/example/contentapp/CommandResponseHolder.java @@ -30,7 +30,7 @@ private CommandResponseHolder() { setResponseValue( Clusters.AccountLogin.Id, Clusters.AccountLogin.Commands.GetSetupPIN.ID, - "{\"0\":\"12345678\"}"); + "{\"0\":\"20202021\"}"); }; public static CommandResponseHolder getInstance() { diff --git a/examples/tv-app/android/java/ContentAppCommandDelegate.cpp b/examples/tv-app/android/java/ContentAppCommandDelegate.cpp index 4708700874304a..b477b75333866b 100644 --- a/examples/tv-app/android/java/ContentAppCommandDelegate.cpp +++ b/examples/tv-app/android/java/ContentAppCommandDelegate.cpp @@ -81,11 +81,13 @@ void ContentAppCommandDelegate::InvokeCommand(CommandHandlerInterface::HandlerCo env->ExceptionDescribe(); env->ExceptionClear(); FormatResponseData(handlerContext, "{\"value\":{}}"); - return; } - JniUtfString respStr(env, resp); - ChipLogProgress(Zcl, "ContentAppCommandDelegate::InvokeCommand got response %s", respStr.c_str()); - FormatResponseData(handlerContext, respStr.c_str()); + else + { + JniUtfString respStr(env, resp); + ChipLogProgress(Zcl, "ContentAppCommandDelegate::InvokeCommand got response %s", respStr.c_str()); + FormatResponseData(handlerContext, respStr.c_str()); + } env->DeleteLocalRef(resp); } else