Skip to content

Commit

Permalink
Fixed issues identified during review
Browse files Browse the repository at this point in the history
  • Loading branch information
amitnj committed Jun 24, 2022
1 parent 0ab0873 commit 0413d2d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> acceptHeaderList, uint32_t supportedStreamingProtocols) :
mAttributeDelegate(attributeDelegate)
{
Expand Down Expand Up @@ -85,17 +85,17 @@ 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)
{
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();
Expand All @@ -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)
Expand All @@ -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<uint32_t>(value[attrId].asInt());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using ContentAppAttributeDelegate = chip::AppPlatform::ContentAppAttributeDelega
class AppContentLauncherManager : public ContentLauncherDelegate
{
public:
AppContentLauncherManager(ContentAppAttributeDelegate * attributeDelegate, std::list<std::string> acceptHeaderList,
AppContentLauncherManager(ContentAppAttributeDelegate attributeDelegate, std::list<std::string> acceptHeaderList,
uint32_t supportedStreamingProtocols);

void HandleLaunchContent(CommandResponseHelper<LaunchResponseType> & helper,
Expand All @@ -53,5 +53,5 @@ class AppContentLauncherManager : public ContentLauncherDelegate

private:
EndpointId mEndpointId;
ContentAppAttributeDelegate * mAttributeDelegate;
ContentAppAttributeDelegate mAttributeDelegate;
};
2 changes: 1 addition & 1 deletion examples/tv-app/android/java/AppImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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){};
Expand Down
36 changes: 18 additions & 18 deletions examples/tv-app/android/java/ContentAppAttributeDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<jint>(aPath.mEndpointId),
static_cast<jint>(aPath.mClusterId), static_cast<jint>(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<jint>(aPath.mEndpointId),
static_cast<jint>(aPath.mClusterId), static_cast<jint>(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
Expand Down

0 comments on commit 0413d2d

Please sign in to comment.