Skip to content

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarkov committed May 14, 2024
1 parent 5407248 commit 0613f7b
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 23 deletions.
55 changes: 55 additions & 0 deletions examples/tv-app/android/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions examples/tv-app/tv-common/shell/AppTvShellCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ static CHIP_ERROR AppPlatformHandler(int argc, char ** argv)
{
pid = (uint16_t) strtol(argv[2], &eptr, 10);
}
ContentAppFactoryImpl * factory = GetContentAppFactoryImpl();
factory->AddContentApp(vid, pid);
ContentAppPlatform::GetInstance().LoadContentAppByClient(vid, pid);

ChipLogProgress(DeviceLayer, "added app");
Expand Down
5 changes: 1 addition & 4 deletions examples/tv-app/tv-common/src/AppTv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ class MyUserPrompter : public UserPrompter

// tv should override this with a dialog prompt
inline void PromptForAppInstallOKPermission(uint16_t vendorId, uint16_t productId, const char * commissioneeName) override
{
gFactory.AddContentApp(vendorId, productId);
return;
}
{ return; }
};

MyUserPrompter gMyUserPrompter;
Expand Down
41 changes: 22 additions & 19 deletions src/controller/CommissionerDiscoveryController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,28 @@ void CommissionerDiscoveryController::InternalOk()
ChipLogError(AppServer, "UX InternalOk: could not find instance=%s", mCurrentInstance);
return;
}

bool isContentAppInstalled = mAppInstallationService->HasContentApp(client->GetVendorId(), client->GetProductId());

if (!isContentAppInstalled) {
ChipLogDetail(AppServer, "UX InternalOk: app not installed.");

// TODO: send CDC message that user is prompted to install the app

// dialog
ChipLogDetail(Controller,
"------PROMPT USER: %s is requesting to install app on this TV. [" ChipLogFormatMEI "," ChipLogFormatMEI "]",
client->GetDeviceName(), ChipLogValueMEI(client->GetVendorId()), ChipLogValueMEI(client->GetProductId()));

if (mUserPrompter != nullptr)
{
mUserPrompter->PromptForAppInstallOKPermission(client->GetVendorId(), client->GetProductId(), client->GetDeviceName());
}
ChipLogDetail(Controller, "------Via Shell Enter: app add <pid> <vid>");
// TODO: force user to send again "cast request <id>" command?
return;
}

if (client->GetUDCClientProcessingState() != UDCClientProcessingState::kPromptingUser)
{
ChipLogError(AppServer, "UX InternalOk: invalid state for ok");
Expand All @@ -245,25 +267,6 @@ void CommissionerDiscoveryController::InternalOk()

uint8_t targetAppCount = client->GetNumTargetAppInfos();

bool isContentAppInstalled = mAppInstallationService->HasContentApp(client->GetVendorId(), client->GetProductId());

if (!isContentAppInstalled) {
ChipLogDetail(AppServer, "UX InternalOk: app not installed.");

// dialog
ChipLogDetail(Controller,
"------PROMPT USER: %s is requesting to install app on this TV, accept? [" ChipLogFormatMEI "," ChipLogFormatMEI "]",
client->GetDeviceName(), ChipLogValueMEI(client->GetVendorId()), ChipLogValueMEI(client->GetProductId()));

if (mUserPrompter != nullptr)
{
mUserPrompter->PromptForAppInstallOKPermission(client->GetVendorId(), client->GetProductId(), client->GetDeviceName());
}
ChipLogDetail(Controller, "------Via Shell Enter: controller ux accept|cancel");
client->SetUDCClientProcessingState(UDCClientProcessingState::kPromptingUser);
return;
}

if (targetAppCount > 0)
{
ChipLogDetail(AppServer, "UX InternalOk: checking for each target app specified");
Expand Down

0 comments on commit 0613f7b

Please sign in to comment.