From 75f1528f21ddee9357807d57f373eeff53968e49 Mon Sep 17 00:00:00 2001 From: Amit Jain Date: Tue, 28 Jun 2022 10:11:51 -0700 Subject: [PATCH] Failure handling and fixed typo --- .../AppContentLauncherManager.cpp | 25 +++++++++++-------- .../java/ContentAppCommandDelegate.cpp | 6 ++++- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp b/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp index 122442e5d6f8a0..0f8486466c92aa 100644 --- a/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp +++ b/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp @@ -92,17 +92,19 @@ CHIP_ERROR AppContentLauncherManager::HandleGetAcceptHeaderList(AttributeValueEn { Json::Reader reader; Json::Value value; - reader.parse(resStr, value); - std::string attrId = to_string(chip::app::Clusters::ContentLauncher::Attributes::AcceptHeader::Id).c_str(); - ChipLogProgress(Zcl, - "AppContentLauncherManager::HandleGetSupportedStreamingProtocols response parsing done. reading attr %s", - attrId.c_str()); - if (value[attrId].isArray()) + if (reader.parse(resStr, value)) { - mAcceptHeaderList.clear(); - for (Json::Value & entry : value[attrId]) + std::string attrId = to_string(chip::app::Clusters::ContentLauncher::Attributes::AcceptHeader::Id); + ChipLogProgress(Zcl, + "AppContentLauncherManager::HandleGetSupportedStreamingProtocols response parsing done. reading attr %s", + attrId.c_str()); + if (value[attrId].isArray()) { - mAcceptHeaderList.push_back(entry.asString()); + mAcceptHeaderList.clear(); + for (Json::Value & entry : value[attrId]) + { + mAcceptHeaderList.push_back(entry.asString()); + } } } } @@ -132,7 +134,10 @@ uint32_t AppContentLauncherManager::HandleGetSupportedStreamingProtocols() Json::Reader reader; Json::Value value; - reader.parse(resStr, value); + if (!reader.parse(resStr, value)) + { + return mSupportedStreamingProtocols; + } std::string attrId = to_string(chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::Id); ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSupportedStreamingProtocols response parsing done. reading attr %s", attrId.c_str()); diff --git a/examples/tv-app/android/java/ContentAppCommandDelegate.cpp b/examples/tv-app/android/java/ContentAppCommandDelegate.cpp index 200c2cacb0f93c..966f532ecd18ac 100644 --- a/examples/tv-app/android/java/ContentAppCommandDelegate.cpp +++ b/examples/tv-app/android/java/ContentAppCommandDelegate.cpp @@ -112,7 +112,11 @@ void ContentAppCommandDelegate::FormatResponseData(CommandHandlerInterface::Hand { Json::Reader reader; Json::Value value; - reader.parse(response, value); + if (!reader.parse(response, value)) + { + handlerContext.SetCommandNotHandled(); + return; + } switch (handlerContext.mRequestPath.mClusterId) {