Skip to content

Commit 3b23b5b

Browse files
committed
Update Logic per comments
1 parent 45a5202 commit 3b23b5b

File tree

5 files changed

+23
-22
lines changed

5 files changed

+23
-22
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory
139139
uint16_t productId) override;
140140

141141
void AddAdminVendorId(uint16_t vendorId);
142-
142+
// Add the app to the list of mContentApps
143143
void InstallContentApp(uint16_t vendorId, uint16_t productId);
144-
void UninstallContentApp(uint16_t vendorId, uint16_t productId);
144+
// Remove the app from the list of mContentApps
145+
bool UninstallContentApp(uint16_t vendorId, uint16_t productId);
145146

146147
protected:
147148
std::vector<std::unique_ptr<ContentAppImpl>> mContentApps;

examples/tv-app/tv-common/shell/AppTvShellCommands.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,13 @@ static CHIP_ERROR AppPlatformHandler(int argc, char ** argv)
279279
pid = (uint16_t) strtol(argv[2], &eptr, 10);
280280
}
281281
ContentAppFactoryImpl * factory = GetContentAppFactoryImpl();
282-
factory->UninstallContentApp(vid, pid);
282+
bool isAppUninstalled = factory->UninstallContentApp(vid, pid);
283283

284-
ChipLogProgress(DeviceLayer, "uninstalled an app");
284+
if (isAppUninstalled) {
285+
ChipLogProgress(DeviceLayer, "uninstalled an app");
286+
} else {
287+
ChipLogProgress(DeviceLayer, "app not found.");
288+
}
285289

286290
return CHIP_NO_ERROR;
287291
}

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

+8-7
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ MyPasscodeService gMyPasscodeService;
154154

155155
class MyAppInstallationService : public AppInstallationService
156156
{
157-
// TODO: rename the method
158-
// intentionally ambigiously named, need to find a better method name
159-
bool HasContentApp(uint16_t vendorId, uint16_t productId) override
157+
bool LookupTargetContentApp(uint16_t vendorId, uint16_t productId) override
160158
{
161159
return ContentAppPlatform::GetInstance().LoadContentAppByClient(vendorId, productId) != nullptr;
162160
}
@@ -573,6 +571,8 @@ void ContentAppFactoryImpl::AddAdminVendorId(uint16_t vendorId)
573571

574572
void ContentAppFactoryImpl::InstallContentApp(uint16_t vendorId, uint16_t productId)
575573
{
574+
ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl: InstallContentApp vendorId=%d productId=%d ",
575+
vendorId, productId);
576576
if (vendorId == 1 && productId == 11) {
577577
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("Vendor1", vendorId, "exampleid", productId, "Version1", "34567890"));
578578
} else if (vendorId == 65521 && productId == 32768) {
@@ -586,9 +586,9 @@ void ContentAppFactoryImpl::InstallContentApp(uint16_t vendorId, uint16_t produc
586586
}
587587
}
588588

589-
void ContentAppFactoryImpl::UninstallContentApp(uint16_t vendorId, uint16_t productId)
589+
bool ContentAppFactoryImpl::UninstallContentApp(uint16_t vendorId, uint16_t productId)
590590
{
591-
ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl: RemoveContentApp vendorId=%d productId=%d ",
591+
ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl: UninstallContentApp vendorId=%d productId=%d ",
592592
vendorId, productId);
593593

594594
int index = 0;
@@ -599,13 +599,14 @@ void ContentAppFactoryImpl::UninstallContentApp(uint16_t vendorId, uint16_t prod
599599
ChipLogProgress(DeviceLayer, "Looking next vid=%d pid=%d", app->GetApplicationBasicDelegate()->HandleGetVendorId(), app->GetApplicationBasicDelegate()->HandleGetProductId());
600600

601601
if (app->MatchesPidVid(productId, vendorId)) {
602-
ChipLogProgress(DeviceLayer, "Found an app. vid=%d pid=%d. Uninstalling it.", app->GetApplicationBasicDelegate()->HandleGetVendorId(), app->GetApplicationBasicDelegate()->HandleGetProductId());
602+
ChipLogProgress(DeviceLayer, "Found an app vid=%d pid=%d. Uninstalling it.", app->GetApplicationBasicDelegate()->HandleGetVendorId(), app->GetApplicationBasicDelegate()->HandleGetProductId());
603603
mContentApps.erase(mContentApps.begin() + index);
604-
return;
604+
return true;
605605
}
606606

607607
index++;
608608
}
609+
return false;
609610
}
610611

611612
Access::Privilege ContentAppFactoryImpl::GetVendorPrivilege(uint16_t vendorId)

src/controller/CommissionerDiscoveryController.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,10 @@ void CommissionerDiscoveryController::InternalOk()
220220
return;
221221
}
222222

223-
bool isContentAppInstalled = mAppInstallationService->HasContentApp(client->GetVendorId(), client->GetProductId());
224-
225-
if (!isContentAppInstalled) {
223+
if (!mAppInstallationService->LookupTargetContentApp(client->GetVendorId(), client->GetProductId())) {
226224
ChipLogDetail(AppServer, "UX InternalOk: app not installed.");
227225

228-
// prompt user to install missing app
226+
// notify client that app will be installed
229227
CommissionerDeclaration cd;
230228
cd.SetErrorCode(CommissionerDeclaration::CdError::kAppInstallConsentPending);
231229
mUdcServer->SendCDCMessage(cd, Transport::PeerAddress::UDP(client->GetPeerAddress().GetIPAddress(), client->GetCdPort()));
@@ -240,7 +238,6 @@ void CommissionerDiscoveryController::InternalOk()
240238
mUserPrompter->PromptForAppInstallOKPermission(client->GetVendorId(), client->GetProductId(), client->GetDeviceName());
241239
}
242240
ChipLogDetail(Controller, "------Via Shell Enter: app install <pid> <vid>");
243-
// TODO: force user to send again "cast request <id>" command?
244241
return;
245242
}
246243

src/controller/CommissionerDiscoveryController.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class DLL_EXPORT PasscodeService
174174
public:
175175
/**
176176
* @brief
177-
* Called to determine if the given target app is available to the commissionee with the given given
177+
* Called to determine if the given target app is available to the commissionee with the given
178178
* vendorId/productId, and if so, return the passcode.
179179
*
180180
* This will be called by the main chip thread so any blocking work should be moved to a separate thread.
@@ -225,18 +225,16 @@ class DLL_EXPORT AppInstallationService
225225
public:
226226
/**
227227
* @brief
228-
* Called to get the setup passcode from the content app corresponding to the given vendorId/productId.
228+
* Called to check if the given target app is available to the commissione with th given
229+
* vendorId/productId
229230
*
230231
* This will be called by the main chip thread so any blocking work should be moved to a separate thread.
231232
*
232-
* After attempting to obtain the passcode, implementor should call HandleContentAppPasscodeResponse();
233-
*
234233
* @param[in] vendorId The vendorId in the DNS-SD advertisement of the requesting commissionee.
235234
* @param[in] productId The productId in the DNS-SD advertisement of the requesting commissionee.
236-
* @param[in] rotatingId The rotatingId in the DNS-SD advertisement of the requesting commissionee.
237235
*
238236
*/
239-
virtual bool HasContentApp(uint16_t vendorId, uint16_t productId) = 0;
237+
virtual bool LookupTargetContentApp(uint16_t vendorId, uint16_t productId) = 0;
240238

241239
virtual ~AppInstallationService() = default;
242240
};

0 commit comments

Comments
 (0)