Skip to content

Commit 5839b4a

Browse files
committedMay 14, 2024·
Add more logic
1 parent 6fff237 commit 5839b4a

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed
 

‎examples/tv-app/tv-common/include/AppTv.h

+12-7
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,19 @@ class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory
139139

140140
void AddAdminVendorId(uint16_t vendorId);
141141

142+
void AddContentApp(uint16_t vendorId, uint16_t productId);
143+
142144
protected:
143-
ContentAppImpl mContentApps[APP_LIBRARY_SIZE] = {
144-
ContentAppImpl("Vendor1", 1, "exampleid", 11, "Version1", "34567890"),
145-
// ContentAppImpl("Vendor2", 65521, "exampleString", 32768, "Version2", "20202021"),
146-
ContentAppImpl("Vendor2", 2, "exampleString", 10, "Version2", "20202021"),
147-
ContentAppImpl("Vendor3", 9050, "App3", 22, "Version3", "20202021"),
148-
ContentAppImpl("TestSuiteVendor", 1111, "applicationId", 22, "v2", "20202021")
149-
};
145+
// ContentAppImpl mContentApps[APP_LIBRARY_SIZE] = {
146+
// ContentAppImpl("Vendor1", 1, "exampleid", 11, "Version1", "34567890"),
147+
// // ContentAppImpl("Vendor2", 65521, "exampleString", 32768, "Version2", "20202021"),
148+
// ContentAppImpl("Vendor2", 2, "exampleString", 10, "Version2", "20202021"),
149+
// ContentAppImpl("Vendor3", 9050, "App3", 22, "Version3", "20202021"),
150+
// ContentAppImpl("TestSuiteVendor", 1111, "applicationId", 22, "v2", "20202021")
151+
// };
152+
153+
ContentAppImpl mContentApps[APP_LIBRARY_SIZE];
154+
// = [];
150155

151156
std::vector<uint16_t> mAdminVendorIds{};
152157
};

‎examples/tv-app/tv-common/src/AppTv.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ using namespace chip::AppPlatform;
5555
using namespace chip::app::Clusters;
5656
using namespace chip::Protocols::UserDirectedCommissioning;
5757

58+
ContentAppFactoryImpl gFactory;
59+
5860
#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
5961
class MyUserPrompter : public UserPrompter
6062
{
@@ -102,6 +104,13 @@ class MyUserPrompter : public UserPrompter
102104
// tv should override this with a dialog prompt
103105
inline void PromptForAppInstallOKPermission(uint16_t vendorId, uint16_t productId, const char * commissioneeName) override
104106
{
107+
// mContentApps[5] = ContentAppImpl("Vendor1", vendorId, "exampleid", productId, "Version3", "20202021");
108+
109+
gFactory.AddContentApp(vendorId, productId);
110+
// ContentAppFactoryImpl::GetContentAppFactoryImpl().AddContentApp(vendorId, productId);
111+
112+
ContentAppPlatform::GetInstance().LoadContentAppByClient(vendorId, productId);
113+
105114
return;
106115
}
107116
};
@@ -154,6 +163,7 @@ MyPasscodeService gMyPasscodeService;
154163

155164
class MyAppInstallationService : public AppInstallationService
156165
{
166+
// intentionally ambigiously named, need to find a better method name
157167
bool HasContentApp(uint16_t vendorId, uint16_t productId) override
158168
{
159169
return ContentAppPlatform::GetInstance().LoadContentAppByClient(vendorId, productId) != nullptr;
@@ -288,7 +298,6 @@ MyPostCommissioningListener gMyPostCommissioningListener;
288298
#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
289299

290300
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
291-
ContentAppFactoryImpl gFactory;
292301

293302
ContentAppFactoryImpl * GetContentAppFactoryImpl()
294303
{
@@ -567,6 +576,11 @@ void ContentAppFactoryImpl::AddAdminVendorId(uint16_t vendorId)
567576
mAdminVendorIds.push_back(vendorId);
568577
}
569578

579+
void ContentAppFactoryImpl::AddContentApp(uint16_t vendorId, uint16_t productId)
580+
{
581+
// mContentApps[5] = ContentAppImpl("Vendor1", vendorId, "exampleid", productId, "Version3", "20202021");
582+
}
583+
570584
Access::Privilege ContentAppFactoryImpl::GetVendorPrivilege(uint16_t vendorId)
571585
{
572586
for (size_t i = 0; i < mAdminVendorIds.size(); ++i)

‎src/controller/CommissionerDiscoveryController.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,11 @@ void CommissionerDiscoveryController::InternalOk()
255255
"------PROMPT USER: %s is requesting to install app on this TV, accept? [" ChipLogFormatMEI "," ChipLogFormatMEI "]",
256256
client->GetDeviceName(), ChipLogValueMEI(client->GetVendorId()), ChipLogValueMEI(client->GetProductId()));
257257

258-
mUserPrompter->PromptForAppInstallOKPermission(client->GetVendorId(), client->GetProductId(), client->GetDeviceName());
258+
if (mUserPrompter != nullptr)
259+
{
260+
mUserPrompter->PromptForAppInstallOKPermission(client->GetVendorId(), client->GetProductId(), client->GetDeviceName());
261+
}
262+
ChipLogDetail(Controller, "------Via Shell Enter: controller ux accept|cancel");
259263
return;
260264
}
261265

0 commit comments

Comments
 (0)
Please sign in to comment.