Skip to content

Commit

Permalink
Add more ContentApp cluster handlers (#12634)
Browse files Browse the repository at this point in the history
* Draft: add more ContentApp cluster handlers

* hook up application launcher to app platform

* fix android build

* fix android build

* add content launch and target navigation hooks

* fix target nav tests

* fix android compile

* fix android compile

* undo changes that impact test cases

* readme for tv-app usage

* fix CI

* fix CI

* Restyle Add more ContentApp cluster handlers (#12760)

* Restyled by prettier-markdown

* Restyled by prettier-yaml

Co-authored-by: Restyled.io <commits@restyled.io>

Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
3 people authored Dec 13, 2021
1 parent d3322e3 commit f85d6ed
Show file tree
Hide file tree
Showing 31 changed files with 742 additions and 79 deletions.
20 changes: 20 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
14
15
16
17
ContentApp's
18
19
20
21
22

AAAA
aabbccddeeff
aarch
Expand Down Expand Up @@ -36,7 +47,9 @@ AnnounceOTAProvider
APIs
apk
AppConfig
AppImpl
ApplicationBasic
ApplicationId
ApplicationIdentifier
ApplicationLauncher
ApplyUpdateRequest
Expand All @@ -55,6 +68,7 @@ AssertionError
ASYNC
att
attId
attr
attributeValue
attrListName
attrMask
Expand Down Expand Up @@ -123,6 +137,7 @@ cacerts
CAfile
cancelled
capacitive
CatalogVendorId
CBB
cbd
CCMP
Expand Down Expand Up @@ -203,6 +218,8 @@ ConnectivityManagerImpl
connstring
conntype
const
ContentApp
ContentAppPlatform
ContentLaunch
ContentLauncher
contrib
Expand Down Expand Up @@ -864,6 +881,7 @@ ServiceId
SetDns
SetImageProcessorDelegate
SetOtaRequestorDriver
setpin
SetpointRaiseLower
SetRequestorInstance
SetUpPINCode
Expand Down Expand Up @@ -985,6 +1003,8 @@ TvChannel
TXD
txt
UART
UDC
udc
udhcpc
UDP
UDPEndPoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ Application ApplicationBasicManager::getApplicationForEndpoint(chip::EndpointId
return app;
}

bool applicationBasicClusterChangeApplicationStatus(app::Clusters::ApplicationBasic::ApplicationBasicStatus status,
chip::EndpointId endpoint)
bool applicationBasicClusterChangeApplicationStatus(chip::EndpointId endpoint,
app::Clusters::ApplicationBasic::ApplicationBasicStatus status)
{
// TODO: Insert code here
ChipLogProgress(Zcl, "Sent an application status change request %d for endpoint %d", to_underlying(status), endpoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ CHIP_ERROR ApplicationLauncherManager::proxyGetApplicationList(chip::app::Attrib
});
}

ApplicationLauncherResponse applicationLauncherClusterLaunchApp(ApplicationLauncherApp application, std::string data)
ApplicationLauncherResponse applicationLauncherClusterLaunchApp(chip::EndpointId endpoint, ApplicationLauncherApp application,
std::string data)
{
// TODO: Insert your code
ApplicationLauncherResponse response;
Expand All @@ -56,3 +57,27 @@ ApplicationLauncherResponse applicationLauncherClusterLaunchApp(ApplicationLaunc

return response;
}

ApplicationLauncherResponse applicationLauncherClusterStopApp(chip::EndpointId endpoint, ApplicationLauncherApp application,
std::string data)
{
ChipLogProgress(Zcl, "ApplicationLauncherManager::applicationLauncherClusterStopApp");

ApplicationLauncherResponse response;
const char * testData = "data";
response.data = (uint8_t *) testData;
response.status = EMBER_ZCL_APPLICATION_LAUNCHER_STATUS_SUCCESS;
return response;
}

ApplicationLauncherResponse applicationLauncherClusterHideApp(chip::EndpointId endpoint, ApplicationLauncherApp application,
std::string data)
{
ChipLogProgress(Zcl, "ApplicationLauncherManager::applicationLauncherClusterHideApp");

ApplicationLauncherResponse response;
const char * testData = "data";
response.data = (uint8_t *) testData;
response.status = EMBER_ZCL_APPLICATION_LAUNCHER_STATUS_SUCCESS;
return response;
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ CHIP_ERROR TargetNavigatorManager::proxyGetTargetInfoList(chip::app::AttributeVa
});
}

TargetNavigatorResponse targetNavigatorClusterNavigateTarget(uint8_t target, std::string data)
TargetNavigatorResponse targetNavigatorClusterNavigateTarget(chip::EndpointId endpointId, uint8_t target, std::string data)
{
// TODO: Insert code here
TargetNavigatorResponse response;
Expand Down
8 changes: 5 additions & 3 deletions examples/tv-app/android/java/ContentLauncherManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ void emberAfContentLauncherClusterInitCallback(EndpointId endpoint)
}
}

ContentLaunchResponse contentLauncherClusterLaunchContent(std::list<ContentLaunchParamater> parameterList, bool autoplay,
ContentLaunchResponse contentLauncherClusterLaunchContent(chip::EndpointId endpointId,
std::list<ContentLaunchParamater> parameterList, bool autoplay,
const chip::CharSpan & data)
{
return ContentLauncherMgr().LaunchContent(parameterList, autoplay, data);
return ContentLauncherMgr().LaunchContent(endpointId, parameterList, autoplay, data);
}

ContentLaunchResponse contentLauncherClusterLaunchUrl(const chip::CharSpan & contentUrl, const chip::CharSpan & displayString,
Expand Down Expand Up @@ -241,7 +242,8 @@ CHIP_ERROR ContentLauncherManager::GetSupportedStreamingTypes(chip::app::Attribu
return err;
}

ContentLaunchResponse ContentLauncherManager::LaunchContent(std::list<ContentLaunchParamater> parameterList, bool autoplay,
ContentLaunchResponse ContentLauncherManager::LaunchContent(chip::EndpointId endpointId,
std::list<ContentLaunchParamater> parameterList, bool autoplay,
const chip::CharSpan & data)
{
ContentLaunchResponse response;
Expand Down
2 changes: 1 addition & 1 deletion examples/tv-app/android/java/ContentLauncherManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ContentLauncherManager
void InitializeWithObjects(jobject managerObject);
CHIP_ERROR GetAcceptsHeader(chip::app::AttributeValueEncoder & aEncoder);
CHIP_ERROR GetSupportedStreamingTypes(chip::app::AttributeValueEncoder & aEncoder);
ContentLaunchResponse LaunchContent(std::list<ContentLaunchParamater> parameterList, bool autoplay,
ContentLaunchResponse LaunchContent(chip::EndpointId endpointId, std::list<ContentLaunchParamater> parameterList, bool autoplay,
const chip::CharSpan & data);
ContentLaunchResponse LaunchUrl(const chip::CharSpan & contentUrl, const chip::CharSpan & displayString,
ContentLaunchBrandingInformation & brandingInformation);
Expand Down
69 changes: 60 additions & 9 deletions examples/tv-app/linux/AppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ DECLARE_DYNAMIC_ATTRIBUTE(ZCL_TV_CHANNEL_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAt
DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(contentAppClusters)
DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, applicationBasicAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, keypadInputAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, applicationLauncherAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, accountLoginAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, contentLauncherAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, mediaPlaybackAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, targetNavigatorAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, channelAttrs) DECLARE_DYNAMIC_CLUSTER_LIST_END;
DECLARE_DYNAMIC_CLUSTER(ZCL_KEYPAD_INPUT_CLUSTER_ID, keypadInputAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_LAUNCHER_CLUSTER_ID, applicationLauncherAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_ACCOUNT_LOGIN_CLUSTER_ID, accountLoginAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_CONTENT_LAUNCH_CLUSTER_ID, contentLauncherAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_MEDIA_PLAYBACK_CLUSTER_ID, mediaPlaybackAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_TARGET_NAVIGATOR_CLUSTER_ID, targetNavigatorAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_TV_CHANNEL_CLUSTER_ID, channelAttrs) DECLARE_DYNAMIC_CLUSTER_LIST_END;

// Declare Content App endpoint
DECLARE_DYNAMIC_ENDPOINT(contentAppEndpoint, contentAppClusters);
Expand Down Expand Up @@ -191,6 +191,34 @@ uint32_t AccountLoginImpl::GetSetupPIN(const char * tempAccountId)
return mSetupPIN;
}

ApplicationLauncherResponse ApplicationLauncherImpl::LaunchApp(ApplicationLauncherApp application, std::string data)
{
std::string appId(application.applicationId.data(), application.applicationId.size());
ChipLogProgress(DeviceLayer,
"ApplicationLauncherResponse: LaunchApp application.catalogVendorId=%d "
"application.applicationId=%s data=%s",
application.catalogVendorId, appId.c_str(), data.c_str());

ApplicationLauncherResponse response;
const char * testData = "data";
response.data = (uint8_t *) testData;
response.status = EMBER_ZCL_APPLICATION_LAUNCHER_STATUS_SUCCESS;

return response;
}

ContentLaunchResponse ContentLauncherImpl::LaunchContent(std::list<ContentLaunchParamater> parameterList, bool autoplay,
std::string data)
{
ChipLogProgress(DeviceLayer, "ContentLauncherImpl: LaunchContent autoplay=%d data=\"%s\"", autoplay ? 1 : 0, data.c_str());

ContentLaunchResponse response;
response.err = CHIP_NO_ERROR;
response.data = "Example app data";
response.status = EMBER_ZCL_CONTENT_LAUNCH_STATUS_SUCCESS;
return response;
}

ContentAppFactoryImpl::ContentAppFactoryImpl()
{
mContentApps[1].GetAccountLogin()->SetSetupPIN(34567890);
Expand All @@ -199,12 +227,12 @@ ContentAppFactoryImpl::ContentAppFactoryImpl()

ContentApp * ContentAppFactoryImpl::LoadContentAppByVendorId(uint16_t vendorId)
{
for (unsigned int i = 0; i < sizeof(mContentApps); i++)
for (unsigned int i = 0; i < APP_LIBRARY_SIZE; i++)
{
ContentAppImpl app = mContentApps[i];
if (app.GetApplicationBasic()->GetVendorId() == vendorId)
{
AppPlatform::GetInstance().AddContentApp(&app, &contentAppEndpoint, DEVICE_TYPE_CONTENT_APP);
AppPlatform::GetInstance().AddContentApp(&mContentApps[i], &contentAppEndpoint, DEVICE_TYPE_CONTENT_APP);
return &mContentApps[i];
}
}
Expand All @@ -213,6 +241,29 @@ ContentApp * ContentAppFactoryImpl::LoadContentAppByVendorId(uint16_t vendorId)
return nullptr;
}

ContentApp * ContentAppFactoryImpl::LoadContentAppByAppId(ApplicationLauncherApp application)
{
std::string appId(application.applicationId.data(), application.applicationId.size());
ChipLogProgress(DeviceLayer,
"ContentAppFactoryImpl: LoadContentAppByAppId application.catalogVendorId=%d "
"application.applicationIdSize=%ld application.applicationId=%s ",
application.catalogVendorId, application.applicationId.size(), appId.c_str());

for (unsigned int i = 0; i < APP_LIBRARY_SIZE; i++)
{
ContentAppImpl app = mContentApps[i];
ChipLogProgress(DeviceLayer, " Looking next=%s ", app.GetApplicationBasic()->GetApplicationName());
if (strcmp(app.GetApplicationBasic()->GetApplicationName(), appId.c_str()) == 0)
{
AppPlatform::GetInstance().AddContentApp(&mContentApps[i], &contentAppEndpoint, DEVICE_TYPE_CONTENT_APP);
return &mContentApps[i];
}
}
ChipLogProgress(DeviceLayer, "LoadContentAppByAppId() - app id %s not found ", appId.c_str());

return nullptr;
}

} // namespace AppPlatform
} // namespace chip

Expand Down
74 changes: 71 additions & 3 deletions examples/tv-app/linux/AppImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,59 @@ class DLL_EXPORT AccountLoginImpl : public AccountLogin
uint32_t mSetupPIN = 0;
};

class DLL_EXPORT KeypadInputImpl : public KeypadInput
{
public:
virtual ~KeypadInputImpl() {}

protected:
};

class DLL_EXPORT ApplicationLauncherImpl : public ApplicationLauncher
{
public:
virtual ~ApplicationLauncherImpl() {}

ApplicationLauncherResponse LaunchApp(ApplicationLauncherApp application, std::string data) override;

protected:
};

class DLL_EXPORT ContentLauncherImpl : public ContentLauncher
{
public:
virtual ~ContentLauncherImpl() {}

ContentLaunchResponse LaunchContent(std::list<ContentLaunchParamater> parameterList, bool autoplay, std::string data) override;

protected:
};

class DLL_EXPORT MediaPlaybackImpl : public MediaPlayback
{
public:
virtual ~MediaPlaybackImpl() {}

protected:
};

class DLL_EXPORT TargetNavigatorImpl : public TargetNavigator
{
public:
TargetNavigatorImpl() : TargetNavigator{ { "home", "search", "info", "guide", "menu" }, 0 } {};
virtual ~TargetNavigatorImpl() {}

protected:
};

class DLL_EXPORT ChannelImpl : public Channel
{
public:
virtual ~ChannelImpl() {}

protected:
};

class DLL_EXPORT ContentAppImpl : public ContentApp
{
public:
Expand All @@ -94,24 +147,39 @@ class DLL_EXPORT ContentAppImpl : public ContentApp

inline ApplicationBasic * GetApplicationBasic() override { return &mApplicationBasic; };
inline AccountLogin * GetAccountLogin() override { return &mAccountLogin; };
inline KeypadInput * GetKeypadInput() override { return &mKeypadInput; };
inline ApplicationLauncher * GetApplicationLauncher() override { return &mApplicationLauncher; };
inline ContentLauncher * GetContentLauncher() override { return &mContentLauncher; };
inline MediaPlayback * GetMediaPlayback() override { return &mMediaPlayback; };
inline TargetNavigator * GetTargetNavigator() override { return &mTargetNavigator; };
inline Channel * GetChannel() override { return &mChannel; };

protected:
ApplicationBasicImpl mApplicationBasic;
AccountLoginImpl mAccountLogin;
KeypadInputImpl mKeypadInput;
ApplicationLauncherImpl mApplicationLauncher;
ContentLauncherImpl mContentLauncher;
MediaPlaybackImpl mMediaPlayback;
TargetNavigatorImpl mTargetNavigator;
ChannelImpl mChannel;
};

class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory
{
#define APP_LIBRARY_SIZE 4
public:
ContentAppFactoryImpl();
virtual ~ContentAppFactoryImpl() {}

ContentApp * LoadContentAppByVendorId(uint16_t vendorId);
ContentApp * LoadContentAppByAppId(ApplicationLauncherApp application);

protected:
ContentAppImpl mContentApps[3] = { ContentAppImpl("Vendor1", 1, "App1", 11, "Version1"),
ContentAppImpl("Vendor2", 2, "App2", 22, "Version2"),
ContentAppImpl("Vendor3", 9050, "App3", 22, "Version3") };
ContentAppImpl mContentApps[APP_LIBRARY_SIZE] = { ContentAppImpl("Vendor1", 1, "App1", 11, "Version1"),
ContentAppImpl("Vendor2", 2222, "App2", 22, "Version2"),
ContentAppImpl("Vendor3", 9050, "App3", 22, "Version3"),
ContentAppImpl("TestSuiteVendor", 1111, "applicationId", 22, "v2") };
};

} // namespace AppPlatform
Expand Down
Loading

0 comments on commit f85d6ed

Please sign in to comment.