Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle [Draft] Re-Implement App Install flow #33960

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions examples/tv-app/tv-common/shell/AppTvShellCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,13 @@ static CHIP_ERROR PrintAllCommands()
streamer_printf(sout,
" add-admin-vendor <vid> Add vendor ID to list which will receive admin privileges. Usage: app "
"add-admin-vendor 65521\r\n");
streamer_printf(sout,
" app list List installed apps. Usage: app list");
streamer_printf(sout, " app list List installed apps. Usage: app list");
streamer_printf(sout,
" app install <vid> <pid> Install app with given vendor ID and product ID. Usage: app install "
"65521 32768\r\n");
streamer_printf(
sout,
" app uninstall <vid> <pid> Uinstall app at given vendor ID and product ID. Usage: app uninstall "
"65521 32768\r\n");
streamer_printf(sout,
" app uninstall <vid> <pid> Uinstall app at given vendor ID and product ID. Usage: app uninstall "
"65521 32768\r\n");
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
streamer_printf(sout, " print-app-access Print all ACLs for app platform fabric. Usage: app print-app-access\r\n");
Expand Down
92 changes: 50 additions & 42 deletions examples/tv-app/tv-common/src/AppTv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,16 @@ void ContentAppFactoryImpl::AddAdminVendorId(uint16_t vendorId)
void ContentAppFactoryImpl::AddUninstalledContentApp(uint16_t vendorId, uint16_t productId)
{
auto make_default_supported_clusters = []() {
return std::vector<ContentApp::SupportedCluster>{ { Descriptor::Id }, { ApplicationBasic::Id },
{ KeypadInput::Id }, { ApplicationLauncher::Id } };
return std::vector<ContentApp::SupportedCluster>{
{ Descriptor::Id }, { ApplicationBasic::Id }, { KeypadInput::Id }, { ApplicationLauncher::Id }
};
};

auto ptr = std::make_unique<ContentAppImpl>("Vendor1", vendorId, "exampleid", productId, "Version1",
"0", make_default_supported_clusters());
auto ptr = std::make_unique<ContentAppImpl>("Vendor1", vendorId, "exampleid", productId, "Version1", "0",
make_default_supported_clusters());

ptr.get()->GetApplicationBasicDelegate()->SetApplicationStatus(app::Clusters::ApplicationBasic::ApplicationStatusEnum::kNotInstalled);
ptr.get()->GetApplicationBasicDelegate()->SetApplicationStatus(
app::Clusters::ApplicationBasic::ApplicationStatusEnum::kNotInstalled);

mContentApps.emplace_back(std::move(ptr));
}
Expand All @@ -597,46 +599,51 @@ void ContentAppFactoryImpl::InstallContentApp(uint16_t vendorId, uint16_t produc
ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl: InstallContentApp vendorId=%d productId=%d ", vendorId, productId);
if (vendorId == 1 && productId == 11)
{
auto ptr = std::make_unique<ContentAppImpl>("Vendor1", vendorId, "exampleid", productId, "Version1",
"34567890", make_default_supported_clusters());
auto ptr = std::make_unique<ContentAppImpl>("Vendor1", vendorId, "exampleid", productId, "Version1", "34567890",
make_default_supported_clusters());

ptr.get()->GetApplicationBasicDelegate()->SetApplicationStatus(app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled);
ptr.get()->GetApplicationBasicDelegate()->SetApplicationStatus(
app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled);

mContentApps.emplace_back(std::move(ptr));
}
else if (vendorId == 65521 && productId == 32769)
{
auto ptr = std::make_unique<ContentAppImpl>("Vendor2", vendorId, "exampleString", productId, "Version2",
"20202021", make_default_supported_clusters());
auto ptr = std::make_unique<ContentAppImpl>("Vendor2", vendorId, "exampleString", productId, "Version2", "20202021",
make_default_supported_clusters());

ptr.get()->GetApplicationBasicDelegate()->SetApplicationStatus(app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled);
ptr.get()->GetApplicationBasicDelegate()->SetApplicationStatus(
app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled);

mContentApps.emplace_back(std::move(ptr));
}
else if (vendorId == 9050 && productId == 22)
{
{
auto ptr = std::make_unique<ContentAppImpl>("Vendor3", vendorId, "App3", productId, "Version3", "20202021",
make_default_supported_clusters());
make_default_supported_clusters());

ptr.get()->GetApplicationBasicDelegate()->SetApplicationStatus(app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled);
ptr.get()->GetApplicationBasicDelegate()->SetApplicationStatus(
app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled);

mContentApps.emplace_back(std::move(ptr));
}
else if (vendorId == 1111 && productId == 22)
{
auto ptr = std::make_unique<ContentAppImpl>("TestSuiteVendor", vendorId, "applicationId", productId, "v2",
"20202021", make_default_supported_clusters());
auto ptr = std::make_unique<ContentAppImpl>("TestSuiteVendor", vendorId, "applicationId", productId, "v2", "20202021",
make_default_supported_clusters());

ptr.get()->GetApplicationBasicDelegate()->SetApplicationStatus(app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled);
ptr.get()->GetApplicationBasicDelegate()->SetApplicationStatus(
app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled);

mContentApps.emplace_back(std::move(ptr));
}
else
{
auto ptr = std::make_unique<ContentAppImpl>("NewAppVendor", vendorId, "newAppApplicationId", productId, "v2",
"20202021", make_default_supported_clusters());
auto ptr = std::make_unique<ContentAppImpl>("NewAppVendor", vendorId, "newAppApplicationId", productId, "v2", "20202021",
make_default_supported_clusters());

ptr.get()->GetApplicationBasicDelegate()->SetApplicationStatus(app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled);
ptr.get()->GetApplicationBasicDelegate()->SetApplicationStatus(
app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled);

mContentApps.emplace_back(std::move(ptr));
}
Expand Down Expand Up @@ -675,26 +682,26 @@ std::string ApplicationBasicStatusToString(app::Clusters::ApplicationBasic::Appl
{
switch (status)
{
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kStopped:
return "kStopped";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kActiveVisibleFocus:
return "kActiveVisibleFocus";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kActiveHidden:
return "kActiveHidden";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kActiveVisibleNotFocus:
return "kActiveVisibleNotFocus";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kNotInstalled:
return "kNotInstalled";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalling:
return "kInstalling";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstallationFailed:
return "kInstallationFailed";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled:
return "kInstalled";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kUnknownEnumValue:
return "kUnknownEnumValue";
default:
return "UnknownEnumValue";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kStopped:
return "kStopped";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kActiveVisibleFocus:
return "kActiveVisibleFocus";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kActiveHidden:
return "kActiveHidden";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kActiveVisibleNotFocus:
return "kActiveVisibleNotFocus";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kNotInstalled:
return "kNotInstalled";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalling:
return "kInstalling";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstallationFailed:
return "kInstallationFailed";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kInstalled:
return "kInstalled";
case app::Clusters::ApplicationBasic::ApplicationStatusEnum::kUnknownEnumValue:
return "kUnknownEnumValue";
default:
return "UnknownEnumValue";
}
}

Expand All @@ -704,8 +711,9 @@ void ContentAppFactoryImpl::PrintInstalledApps()
{
auto app = contentApp.get();

ChipLogProgress(DeviceLayer, "Content app vid=%d pid=%d is on ep=%d with app's basic status=%s", app->GetApplicationBasicDelegate()->HandleGetVendorId(),
app->GetApplicationBasicDelegate()->HandleGetProductId(), app->GetEndpointId(),
ChipLogProgress(DeviceLayer, "Content app vid=%d pid=%d is on ep=%d with app's basic status=%s",
app->GetApplicationBasicDelegate()->HandleGetVendorId(),
app->GetApplicationBasicDelegate()->HandleGetProductId(), app->GetEndpointId(),
ApplicationBasicStatusToString(app->GetApplicationBasicDelegate()->HandleGetStatus()).c_str());
}
}
Expand Down