Skip to content

Commit 69623e2

Browse files
committed
Update App Install Flow Error & Attribute Retrieval Status
1 parent 8ba371a commit 69623e2

File tree

6 files changed

+58
-55
lines changed

6 files changed

+58
-55
lines changed

examples/tv-app/android/java/AppPlatform-JNI.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ std::vector<ContentApp::SupportedCluster> convert_to_cpp(JNIEnv * env, jobject s
128128
// Find Java classes. WARNING: Reflection
129129
jclass collectionClass = env->FindClass("java/util/Collection");
130130
jclass iteratorClass = env->FindClass("java/util/Iterator");
131-
jclass clusterClass = env->FindClass("com/matter/tv/server/tvapp/SupportedCluster");
131+
jclass clusterClass = env->FindClass("com/matter/tv/server/tvapp/ContentAppSupportedCluster");
132132
if (collectionClass == nullptr || iteratorClass == nullptr || clusterClass == nullptr)
133133
{
134134
return {};

examples/tv-app/android/java/TVApp-JNI.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,16 @@ class MyPincodeService : public PasscodeService
240240
};
241241
MyPincodeService gMyPincodeService;
242242

243+
class MyAppInstallationService : public AppInstallationService
244+
{
245+
bool LookupTargetContentApp(uint16_t vendorId, uint16_t productId) override
246+
{
247+
return ContentAppPlatform::GetInstance().LoadContentAppByClient(vendorId, productId) != nullptr;
248+
}
249+
};
250+
251+
MyAppInstallationService gMyAppInstallationService;
252+
243253
class MyPostCommissioningListener : public PostCommissioningListener
244254
{
245255
void CommissioningCompleted(uint16_t vendorId, uint16_t productId, NodeId nodeId, Messaging::ExchangeManager & exchangeMgr,
@@ -372,6 +382,7 @@ void TvAppJNI::InitializeCommissioner(JNIMyUserPrompter * userPrompter)
372382
if (cdc != nullptr && userPrompter != nullptr)
373383
{
374384
cdc->SetPasscodeService(&gMyPincodeService);
385+
cdc->SetAppInstallationService(&gMyAppInstallationService);
375386
cdc->SetUserPrompter(userPrompter);
376387
cdc->SetPostCommissioningListener(&gMyPostCommissioningListener);
377388
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory
149149
void InstallContentApp(uint16_t vendorId, uint16_t productId);
150150
// Remove the app from the list of mContentApps
151151
bool UninstallContentApp(uint16_t vendorId, uint16_t productId);
152+
// Print mContentApps and endpoints
153+
void PrintInstalledApps();
152154

153155
protected:
154156
std::vector<std::unique_ptr<ContentAppImpl>> mContentApps;

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

+43-22
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,6 @@ class MyUserPrompter : public UserPrompter
9898

9999
// tv should override this with a dialog prompt
100100
inline void PromptCommissioningFailed(const char * commissioneeName, CHIP_ERROR error) override { return; }
101-
102-
// tv should override this with a dialog prompt
103-
inline void PromptForAppInstallOKPermission(uint16_t vendorId, uint16_t productId, const char * commissioneeName) override
104-
{
105-
return;
106-
}
107101
};
108102

109103
MyUserPrompter gMyUserPrompter;
@@ -583,28 +577,33 @@ void ContentAppFactoryImpl::InstallContentApp(uint16_t vendorId, uint16_t produc
583577
ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl: InstallContentApp vendorId=%d productId=%d ", vendorId, productId);
584578
if (vendorId == 1 && productId == 11)
585579
{
586-
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("Vendor1", vendorId, "exampleid", productId, "Version1",
587-
"34567890", make_default_supported_clusters()));
580+
auto ptr = std::make_unique<ContentAppImpl>("Vendor1", vendorId, "exampleid", productId, "Version1",
581+
"34567890", make_default_supported_clusters());
582+
mContentApps.emplace_back(std::move(ptr));
588583
}
589-
else if (vendorId == 65521 && productId == 32768)
584+
else if (vendorId == 65521 && productId == 32769)
590585
{
591-
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("Vendor2", vendorId, "exampleString", productId, "Version2",
592-
"20202021", make_default_supported_clusters()));
586+
auto ptr = std::make_unique<ContentAppImpl>("Vendor2", vendorId, "exampleString", productId, "Version2",
587+
"20202021", make_default_supported_clusters());
588+
mContentApps.emplace_back(std::move(ptr));
593589
}
594590
else if (vendorId == 9050 && productId == 22)
595-
{
596-
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("Vendor3", vendorId, "App3", productId, "Version3", "20202021",
597-
make_default_supported_clusters()));
591+
{
592+
auto ptr = std::make_unique<ContentAppImpl>("Vendor3", vendorId, "App3", productId, "Version3", "20202021",
593+
make_default_supported_clusters());
594+
mContentApps.emplace_back(std::move(ptr));
598595
}
599596
else if (vendorId == 1111 && productId == 22)
600597
{
601-
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("TestSuiteVendor", vendorId, "applicationId", productId, "v2",
602-
"20202021", make_default_supported_clusters()));
598+
auto ptr = std::make_unique<ContentAppImpl>("TestSuiteVendor", vendorId, "applicationId", productId, "v2",
599+
"20202021", make_default_supported_clusters());
600+
mContentApps.emplace_back(std::move(ptr));
603601
}
604602
else
605603
{
606-
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("NewAppVendor", vendorId, "newAppApplicationId", productId, "v2",
607-
"20202021", make_default_supported_clusters()));
604+
auto ptr = std::make_unique<ContentAppImpl>("NewAppVendor", vendorId, "newAppApplicationId", productId, "v2",
605+
"20202021", make_default_supported_clusters());
606+
mContentApps.emplace_back(std::move(ptr));
608607
}
609608
}
610609

@@ -627,6 +626,7 @@ bool ContentAppFactoryImpl::UninstallContentApp(uint16_t vendorId, uint16_t prod
627626
app->GetApplicationBasicDelegate()->HandleGetVendorId(),
628627
app->GetApplicationBasicDelegate()->HandleGetProductId());
629628
mContentApps.erase(mContentApps.begin() + index);
629+
// TODO: call ContentAppPlatform->RemoveContentApp(ids...)
630630
return true;
631631
}
632632

@@ -635,6 +635,17 @@ bool ContentAppFactoryImpl::UninstallContentApp(uint16_t vendorId, uint16_t prod
635635
return false;
636636
}
637637

638+
void ContentAppFactoryImpl::PrintInstalledApps()
639+
{
640+
for (auto & contentApp : mContentApps)
641+
{
642+
auto app = contentApp.get();
643+
644+
ChipLogProgress(DeviceLayer, "Content app vid=%d pid=%d is on ep=%d", app->GetApplicationBasicDelegate()->HandleGetVendorId(),
645+
app->GetApplicationBasicDelegate()->HandleGetProductId(), app->GetEndpointId());
646+
}
647+
}
648+
638649
Access::Privilege ContentAppFactoryImpl::GetVendorPrivilege(uint16_t vendorId)
639650
{
640651
for (size_t i = 0; i < mAdminVendorIds.size(); ++i)
@@ -689,12 +700,22 @@ std::list<ClusterId> ContentAppFactoryImpl::GetAllowedClusterListForStaticEndpoi
689700
CHIP_ERROR AppTvInit()
690701
{
691702
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
703+
// test data for apps
704+
constexpr uint16_t kApp1VendorId = 1;
705+
constexpr uint16_t kApp1ProductId = 11;
706+
constexpr uint16_t kApp2VendorId = 65521;
707+
constexpr uint16_t kApp2ProductId = 32769;
708+
constexpr uint16_t kApp3VendorId = 9050;
709+
constexpr uint16_t kApp3ProductId = 22;
710+
constexpr uint16_t kApp4VendorId = 1111;
711+
constexpr uint16_t kApp4ProductId = 22;
712+
692713
ContentAppPlatform::GetInstance().SetupAppPlatform();
693714
ContentAppPlatform::GetInstance().SetContentAppFactory(&gFactory);
694-
gFactory.InstallContentApp((uint16_t) 1, (uint16_t) 11);
695-
gFactory.InstallContentApp((uint16_t) 65521, (uint16_t) 32768);
696-
gFactory.InstallContentApp((uint16_t) 9050, (uint16_t) 22);
697-
gFactory.InstallContentApp((uint16_t) 1111, (uint16_t) 22);
715+
gFactory.InstallContentApp(kApp1VendorId, kApp1ProductId);
716+
gFactory.InstallContentApp(kApp2VendorId, kApp2ProductId);
717+
gFactory.InstallContentApp(kApp3VendorId, kApp3ProductId);
718+
gFactory.InstallContentApp(kApp4VendorId, kApp4ProductId);
698719
uint16_t value;
699720
if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetVendorId(value) != CHIP_NO_ERROR)
700721
{

src/controller/CommissionerDiscoveryController.cpp

+1-15
Original file line numberDiff line numberDiff line change
@@ -230,21 +230,7 @@ void CommissionerDiscoveryController::InternalOk()
230230
{
231231
ChipLogDetail(AppServer, "UX InternalOk: app not installed.");
232232

233-
// notify client that app will be installed
234-
CommissionerDeclaration cd;
235-
cd.SetErrorCode(CommissionerDeclaration::CdError::kAppInstallConsentPending);
236-
mUdcServer->SendCDCMessage(cd, Transport::PeerAddress::UDP(client->GetPeerAddress().GetIPAddress(), client->GetCdPort()));
237-
238-
// dialog
239-
ChipLogDetail(Controller, "------PROMPT USER: %s is requesting to install app on this TV. vendorId=%d, productId=%d",
240-
client->GetDeviceName(), client->GetVendorId(), client->GetProductId());
241-
242-
if (mUserPrompter != nullptr)
243-
{
244-
mUserPrompter->PromptForAppInstallOKPermission(client->GetVendorId(), client->GetProductId(), client->GetDeviceName());
245-
}
246-
ChipLogDetail(Controller, "------Via Shell Enter: app install <pid> <vid>");
247-
return;
233+
// TODO: Prepare app to be installed or add it to the mContentApps
248234
}
249235

250236
if (client->GetUDCClientProcessingState() != UDCClientProcessingState::kPromptingUser)

src/controller/CommissionerDiscoveryController.h

-17
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,6 @@ class DLL_EXPORT UserPrompter
150150
*/
151151
virtual void PromptCommissioningFailed(const char * commissioneeName, CHIP_ERROR error) = 0;
152152

153-
/**
154-
* @brief
155-
* Called to prompt the user for consent to allow the app commissioneeName/vendorId/productId to be installed.
156-
* For example "[commissioneeName] is requesting permission to install app to this TV, approve?"
157-
*
158-
* If user responds with OK then implementor should call CommissionerRespondOk();
159-
* If user responds with Cancel then implementor should call CommissionerRespondCancel();
160-
*
161-
* @param[in] vendorId The vendorId in the DNS-SD advertisement of the requesting commissionee.
162-
* @param[in] productId The productId in the DNS-SD advertisement of the requesting commissionee.
163-
* @param[in] commissioneeName The commissioneeName in the DNS-SD advertisement of the requesting commissionee.
164-
*
165-
*/
166-
virtual void PromptForAppInstallOKPermission(uint16_t vendorId, uint16_t productId, const char * commissioneeName) = 0;
167-
168153
virtual ~UserPrompter() = default;
169154
};
170155

@@ -227,8 +212,6 @@ class DLL_EXPORT AppInstallationService
227212
* Called to check if the given target app is available to the commissione with th given
228213
* vendorId/productId
229214
*
230-
* This will be called by the main chip thread so any blocking work should be moved to a separate thread.
231-
*
232215
* @param[in] vendorId The vendorId in the DNS-SD advertisement of the requesting commissionee.
233216
* @param[in] productId The productId in the DNS-SD advertisement of the requesting commissionee.
234217
*

0 commit comments

Comments
 (0)