From 0613f7bde4309ea97189f9391f301dd0c68d39c1 Mon Sep 17 00:00:00 2001 From: Lazar Kovacic Date: Tue, 14 May 2024 21:08:39 +0200 Subject: [PATCH] Update code --- examples/tv-app/android/.idea/workspace.xml | 55 +++++++++++++++++++ .../tv-common/shell/AppTvShellCommands.cpp | 2 + examples/tv-app/tv-common/src/AppTv.cpp | 5 +- .../CommissionerDiscoveryController.cpp | 41 +++++++------- 4 files changed, 80 insertions(+), 23 deletions(-) create mode 100644 examples/tv-app/android/.idea/workspace.xml diff --git a/examples/tv-app/android/.idea/workspace.xml b/examples/tv-app/android/.idea/workspace.xml new file mode 100644 index 00000000000000..12d4da26dfc41f --- /dev/null +++ b/examples/tv-app/android/.idea/workspace.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + { + "customColor": "", + "associatedIndex": 1 +} + + + + { + "keyToString": { + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.cidr.known.project.marker": "true", + "cf.first.check.clang-format": "false", + "cidr.known.project.marker": "true", + "git-widget-placeholder": "demoable-matter" + } +} + + + + + 1713559912316 + + + + \ No newline at end of file diff --git a/examples/tv-app/tv-common/shell/AppTvShellCommands.cpp b/examples/tv-app/tv-common/shell/AppTvShellCommands.cpp index ee85cf099ff380..45957b4c25459a 100644 --- a/examples/tv-app/tv-common/shell/AppTvShellCommands.cpp +++ b/examples/tv-app/tv-common/shell/AppTvShellCommands.cpp @@ -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"); diff --git a/examples/tv-app/tv-common/src/AppTv.cpp b/examples/tv-app/tv-common/src/AppTv.cpp index 687826e1c4ab7a..8ca3c7fbd97eb8 100644 --- a/examples/tv-app/tv-common/src/AppTv.cpp +++ b/examples/tv-app/tv-common/src/AppTv.cpp @@ -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; diff --git a/src/controller/CommissionerDiscoveryController.cpp b/src/controller/CommissionerDiscoveryController.cpp index a6a98af95c3fad..64ff965ed0d04b 100644 --- a/src/controller/CommissionerDiscoveryController.cpp +++ b/src/controller/CommissionerDiscoveryController.cpp @@ -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 "); + // TODO: force user to send again "cast request " command? + return; + } + if (client->GetUDCClientProcessingState() != UDCClientProcessingState::kPromptingUser) { ChipLogError(AppServer, "UX InternalOk: invalid state for ok"); @@ -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");