diff --git a/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp b/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp index a9754851d3e542..362561461cad0d 100644 --- a/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp +++ b/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp @@ -27,7 +27,7 @@ using namespace chip::app::DataModel; using namespace chip::app::Clusters::ContentLauncher; using ContentAppAttributeDelegate = chip::AppPlatform::ContentAppAttributeDelegate; -AppContentLauncherManager::AppContentLauncherManager(ContentAppAttributeDelegate * attributeDelegate, +AppContentLauncherManager::AppContentLauncherManager(ContentAppAttributeDelegate attributeDelegate, list acceptHeaderList, uint32_t supportedStreamingProtocols) : mAttributeDelegate(attributeDelegate) { @@ -85,7 +85,7 @@ CHIP_ERROR AppContentLauncherManager::HandleGetAcceptHeaderList(AttributeValueEn ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetAcceptHeaderList"); chip::app::ConcreteReadAttributePath aPath(mEndpointId, chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::ContentLauncher::Attributes::AcceptHeader::Id); - const char * resStr = mAttributeDelegate->Read(aPath); + const char * resStr = mAttributeDelegate.Read(aPath); ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSupportedStreamingProtocols response %s", resStr); if (resStr != nullptr && *resStr != 0) @@ -93,9 +93,9 @@ CHIP_ERROR AppContentLauncherManager::HandleGetAcceptHeaderList(AttributeValueEn Json::Reader reader; Json::Value value; reader.parse(resStr, value); - const char * attrId = to_string(chip::app::Clusters::ContentLauncher::Attributes::AcceptHeader::Id).c_str(); + 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); + Zcl, "AppContentLauncherManager::HandleGetSupportedStreamingProtocols response parsing done. reading attr %s", attrId.c_str()); if (value[attrId].isArray()) { mAcceptHeaderList.clear(); @@ -121,7 +121,7 @@ uint32_t AppContentLauncherManager::HandleGetSupportedStreamingProtocols() ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSupportedStreamingProtocols"); chip::app::ConcreteReadAttributePath aPath(mEndpointId, chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::Id); - const char * resStr = mAttributeDelegate->Read(aPath); + const char * resStr = mAttributeDelegate.Read(aPath); ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSupportedStreamingProtocols response %s", resStr); if (resStr == nullptr || *resStr == 0) @@ -132,9 +132,9 @@ uint32_t AppContentLauncherManager::HandleGetSupportedStreamingProtocols() Json::Reader reader; Json::Value value; reader.parse(resStr, value); - const char * attrId = to_string(chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::Id).c_str(); + std::string attrId = to_string(chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::Id); ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSupportedStreamingProtocols response parsing done. reading attr %s", - attrId); + attrId.c_str()); if (!value[attrId].empty()) { uint32_t supportedStreamingProtocols = static_cast(value[attrId].asInt()); diff --git a/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.h b/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.h index eebaf358ef3be5..09834f4f3b9b26 100644 --- a/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.h +++ b/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.h @@ -34,7 +34,7 @@ using ContentAppAttributeDelegate = chip::AppPlatform::ContentAppAttributeDelega class AppContentLauncherManager : public ContentLauncherDelegate { public: - AppContentLauncherManager(ContentAppAttributeDelegate * attributeDelegate, std::list acceptHeaderList, + AppContentLauncherManager(ContentAppAttributeDelegate attributeDelegate, std::list acceptHeaderList, uint32_t supportedStreamingProtocols); void HandleLaunchContent(CommandResponseHelper & helper, @@ -53,5 +53,5 @@ class AppContentLauncherManager : public ContentLauncherDelegate private: EndpointId mEndpointId; - ContentAppAttributeDelegate * mAttributeDelegate; + ContentAppAttributeDelegate mAttributeDelegate; }; diff --git a/examples/tv-app/android/java/AppImpl.h b/examples/tv-app/android/java/AppImpl.h index e8321825db6cec..a1399746acb240 100644 --- a/examples/tv-app/android/java/AppImpl.h +++ b/examples/tv-app/android/java/AppImpl.h @@ -87,7 +87,7 @@ class DLL_EXPORT ContentAppImpl : public ContentApp mApplicationBasicDelegate(kCatalogVendorId, BuildAppId(vendorId), szVendorName, vendorId, szApplicationName, productId, szApplicationVersion), mAccountLoginDelegate(setupPIN), - mContentLauncherDelegate(new ContentAppAttributeDelegate(manager), { "image/*", "video/*" }, + mContentLauncherDelegate(ContentAppAttributeDelegate(manager), { "image/*", "video/*" }, to_underlying(SupportedStreamingProtocol::kDash) | to_underlying(SupportedStreamingProtocol::kHls)), mTargetNavigatorDelegate({ "home", "search", "info", "guide", "menu" }, 0){}; diff --git a/examples/tv-app/android/java/ContentAppAttributeDelegate.cpp b/examples/tv-app/android/java/ContentAppAttributeDelegate.cpp index 3a133ddde19942..7fcf0b313a62a5 100644 --- a/examples/tv-app/android/java/ContentAppAttributeDelegate.cpp +++ b/examples/tv-app/android/java/ContentAppAttributeDelegate.cpp @@ -36,28 +36,28 @@ using LaunchResponseType = chip::app::Clusters::ContentLauncher::Commands::Launc const char * ContentAppAttributeDelegate::Read(const chip::app::ConcreteReadAttributePath & aPath) { - if (aPath.mEndpointId >= FIXED_ENDPOINT_COUNT) + if (aPath.mEndpointId < FIXED_ENDPOINT_COUNT) { - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + return ""; + } + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - ChipLogProgress(Zcl, "ContentAppAttributeDelegate::Read being called for endpoint %d cluster %d attribute %d", - aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId); + ChipLogProgress(Zcl, "ContentAppAttributeDelegate::Read being called for endpoint %d cluster %d attribute %d", + aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId); - jstring resp = - (jstring) env->CallObjectMethod(mContentAppEndpointManager, mReadAttributeMethod, static_cast(aPath.mEndpointId), - static_cast(aPath.mClusterId), static_cast(aPath.mAttributeId)); - if (env->ExceptionCheck()) - { - ChipLogError(Zcl, "Java exception in ContentAppAttributeDelegate::Read"); - env->ExceptionDescribe(); - env->ExceptionClear(); - return ""; - } - const char * respStr = env->GetStringUTFChars(resp, 0); - ChipLogProgress(Zcl, "ContentAppAttributeDelegate::Read got response %s", respStr); - return respStr; + jstring resp = + (jstring) env->CallObjectMethod(mContentAppEndpointManager, mReadAttributeMethod, static_cast(aPath.mEndpointId), + static_cast(aPath.mClusterId), static_cast(aPath.mAttributeId)); + if (env->ExceptionCheck()) + { + ChipLogError(Zcl, "Java exception in ContentAppAttributeDelegate::Read"); + env->ExceptionDescribe(); + env->ExceptionClear(); + return ""; } - return ""; + const char * respStr = env->GetStringUTFChars(resp, 0); + ChipLogProgress(Zcl, "ContentAppAttributeDelegate::Read got response %s", respStr); + return respStr; } } // namespace AppPlatform