@@ -98,12 +98,6 @@ class MyUserPrompter : public UserPrompter
98
98
99
99
// tv should override this with a dialog prompt
100
100
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
- }
107
101
};
108
102
109
103
MyUserPrompter gMyUserPrompter ;
@@ -158,6 +152,11 @@ class MyAppInstallationService : public AppInstallationService
158
152
{
159
153
return ContentAppPlatform::GetInstance ().LoadContentAppByClient (vendorId, productId) != nullptr ;
160
154
}
155
+
156
+ void AddUninstalledContentApp (uint16_t vendorId, uint16_t productId) override
157
+ {
158
+ GetContentAppFactoryImpl ()->AddUninstalledContentApp (vendorId, productId);
159
+ }
161
160
};
162
161
163
162
MyAppInstallationService gMyAppInstallationService ;
@@ -571,6 +570,21 @@ void ContentAppFactoryImpl::AddAdminVendorId(uint16_t vendorId)
571
570
mAdminVendorIds .push_back (vendorId);
572
571
}
573
572
573
+ void ContentAppFactoryImpl::AddUninstalledContentApp (uint16_t vendorId, uint16_t productId)
574
+ {
575
+ auto make_default_supported_clusters = []() {
576
+ return std::vector<ContentApp::SupportedCluster>{ { Descriptor::Id }, { ApplicationBasic::Id },
577
+ { KeypadInput::Id }, { ApplicationLauncher::Id } };
578
+ };
579
+
580
+ auto ptr = std::make_unique<ContentAppImpl>(" Vendor1" , vendorId, " exampleid" , productId, " Version1" ,
581
+ " 0" , make_default_supported_clusters ());
582
+
583
+ ptr.get ()->GetApplicationBasicDelegate ()->SetApplicationStatus (app::Clusters::ApplicationBasic::ApplicationStatusEnum::kNotInstalled );
584
+
585
+ mContentApps .emplace_back (std::move (ptr));
586
+ }
587
+
574
588
void ContentAppFactoryImpl::InstallContentApp (uint16_t vendorId, uint16_t productId)
575
589
{
576
590
auto make_default_supported_clusters = []() {
@@ -583,28 +597,48 @@ void ContentAppFactoryImpl::InstallContentApp(uint16_t vendorId, uint16_t produc
583
597
ChipLogProgress (DeviceLayer, " ContentAppFactoryImpl: InstallContentApp vendorId=%d productId=%d " , vendorId, productId);
584
598
if (vendorId == 1 && productId == 11 )
585
599
{
586
- mContentApps .emplace_back (std::make_unique<ContentAppImpl>(" Vendor1" , vendorId, " exampleid" , productId, " Version1" ,
587
- " 34567890" , make_default_supported_clusters ()));
600
+ auto ptr = std::make_unique<ContentAppImpl>(" Vendor1" , vendorId, " exampleid" , productId, " Version1" ,
601
+ " 34567890" , make_default_supported_clusters ());
602
+
603
+ ptr.get ()->GetApplicationBasicDelegate ()->SetApplicationStatus (app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled );
604
+
605
+ mContentApps .emplace_back (std::move (ptr));
588
606
}
589
- else if (vendorId == 65521 && productId == 32768 )
607
+ else if (vendorId == 65521 && productId == 32769 )
590
608
{
591
- mContentApps .emplace_back (std::make_unique<ContentAppImpl>(" Vendor2" , vendorId, " exampleString" , productId, " Version2" ,
592
- " 20202021" , make_default_supported_clusters ()));
609
+ auto ptr = std::make_unique<ContentAppImpl>(" Vendor2" , vendorId, " exampleString" , productId, " Version2" ,
610
+ " 20202021" , make_default_supported_clusters ());
611
+
612
+ ptr.get ()->GetApplicationBasicDelegate ()->SetApplicationStatus (app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled );
613
+
614
+ mContentApps .emplace_back (std::move (ptr));
593
615
}
594
616
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 ()));
617
+ {
618
+ auto ptr = std::make_unique<ContentAppImpl>(" Vendor3" , vendorId, " App3" , productId, " Version3" , " 20202021" ,
619
+ make_default_supported_clusters ());
620
+
621
+ ptr.get ()->GetApplicationBasicDelegate ()->SetApplicationStatus (app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled );
622
+
623
+ mContentApps .emplace_back (std::move (ptr));
598
624
}
599
625
else if (vendorId == 1111 && productId == 22 )
600
626
{
601
- mContentApps .emplace_back (std::make_unique<ContentAppImpl>(" TestSuiteVendor" , vendorId, " applicationId" , productId, " v2" ,
602
- " 20202021" , make_default_supported_clusters ()));
627
+ auto ptr = std::make_unique<ContentAppImpl>(" TestSuiteVendor" , vendorId, " applicationId" , productId, " v2" ,
628
+ " 20202021" , make_default_supported_clusters ());
629
+
630
+ ptr.get ()->GetApplicationBasicDelegate ()->SetApplicationStatus (app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled );
631
+
632
+ mContentApps .emplace_back (std::move (ptr));
603
633
}
604
634
else
605
635
{
606
- mContentApps .emplace_back (std::make_unique<ContentAppImpl>(" NewAppVendor" , vendorId, " newAppApplicationId" , productId, " v2" ,
607
- " 20202021" , make_default_supported_clusters ()));
636
+ auto ptr = std::make_unique<ContentAppImpl>(" NewAppVendor" , vendorId, " newAppApplicationId" , productId, " v2" ,
637
+ " 20202021" , make_default_supported_clusters ());
638
+
639
+ ptr.get ()->GetApplicationBasicDelegate ()->SetApplicationStatus (app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled );
640
+
641
+ mContentApps .emplace_back (std::move (ptr));
608
642
}
609
643
}
610
644
@@ -627,6 +661,7 @@ bool ContentAppFactoryImpl::UninstallContentApp(uint16_t vendorId, uint16_t prod
627
661
app->GetApplicationBasicDelegate ()->HandleGetVendorId (),
628
662
app->GetApplicationBasicDelegate ()->HandleGetProductId ());
629
663
mContentApps .erase (mContentApps .begin () + index );
664
+ // TODO: call ContentAppPlatform->RemoveContentApp(ids...)
630
665
return true ;
631
666
}
632
667
@@ -635,6 +670,46 @@ bool ContentAppFactoryImpl::UninstallContentApp(uint16_t vendorId, uint16_t prod
635
670
return false ;
636
671
}
637
672
673
+ // Helper function to convert enum to string
674
+ std::string ApplicationBasicStatusToString (app::Clusters::ApplicationBasic::ApplicationStatusEnum status)
675
+ {
676
+ switch (status)
677
+ {
678
+ case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kStopped :
679
+ return " kStopped" ;
680
+ case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kActiveVisibleFocus :
681
+ return " kActiveVisibleFocus" ;
682
+ case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kActiveHidden :
683
+ return " kActiveHidden" ;
684
+ case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kActiveVisibleNotFocus :
685
+ return " kActiveVisibleNotFocus" ;
686
+ case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kNotInstalled :
687
+ return " kNotInstalled" ;
688
+ case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalling :
689
+ return " kInstalling" ;
690
+ case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstallationFailed :
691
+ return " kInstallationFailed" ;
692
+ case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled :
693
+ return " kInstalled" ;
694
+ case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kUnknownEnumValue :
695
+ return " kUnknownEnumValue" ;
696
+ default :
697
+ return " UnknownEnumValue" ;
698
+ }
699
+ }
700
+
701
+ void ContentAppFactoryImpl::PrintInstalledApps ()
702
+ {
703
+ for (auto & contentApp : mContentApps )
704
+ {
705
+ auto app = contentApp.get ();
706
+
707
+ ChipLogProgress (DeviceLayer, " Content app vid=%d pid=%d is on ep=%d with app's basic status=%s" , app->GetApplicationBasicDelegate ()->HandleGetVendorId (),
708
+ app->GetApplicationBasicDelegate ()->HandleGetProductId (), app->GetEndpointId (),
709
+ ApplicationBasicStatusToString (app->GetApplicationBasicDelegate ()->HandleGetStatus ()).c_str ());
710
+ }
711
+ }
712
+
638
713
Access::Privilege ContentAppFactoryImpl::GetVendorPrivilege (uint16_t vendorId)
639
714
{
640
715
for (size_t i = 0 ; i < mAdminVendorIds .size (); ++i)
@@ -689,12 +764,22 @@ std::list<ClusterId> ContentAppFactoryImpl::GetAllowedClusterListForStaticEndpoi
689
764
CHIP_ERROR AppTvInit ()
690
765
{
691
766
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
767
+ // test data for apps
768
+ constexpr uint16_t kApp1VendorId = 1 ;
769
+ constexpr uint16_t kApp1ProductId = 11 ;
770
+ constexpr uint16_t kApp2VendorId = 65521 ;
771
+ constexpr uint16_t kApp2ProductId = 32769 ;
772
+ constexpr uint16_t kApp3VendorId = 9050 ;
773
+ constexpr uint16_t kApp3ProductId = 22 ;
774
+ constexpr uint16_t kApp4VendorId = 1111 ;
775
+ constexpr uint16_t kApp4ProductId = 22 ;
776
+
692
777
ContentAppPlatform::GetInstance ().SetupAppPlatform ();
693
778
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 );
779
+ gFactory .InstallContentApp (kApp1VendorId , kApp1ProductId );
780
+ gFactory .InstallContentApp (kApp2VendorId , kApp2ProductId );
781
+ gFactory .InstallContentApp (kApp3VendorId , kApp3ProductId );
782
+ gFactory .InstallContentApp (kApp4VendorId , kApp4ProductId );
698
783
uint16_t value;
699
784
if (DeviceLayer::GetDeviceInstanceInfoProvider ()->GetVendorId (value) != CHIP_NO_ERROR)
700
785
{
0 commit comments