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

Update App Install Flow & Attribute Retrieval Status Errors #33981

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
69623e2
Update App Install Flow Error & Attribute Retrieval Status
lazarkov Jun 17, 2024
32b4941
Update code break
lazarkov Jun 18, 2024
083b3d0
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 18, 2024
4e0302a
Restyled by whitespace
restyled-commits Jun 18, 2024
2e6e42a
Restyled by clang-format
restyled-commits Jun 18, 2024
42e11a1
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 18, 2024
7e05e43
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 18, 2024
8a3dae8
Update per comments
lazarkov Jun 18, 2024
77d2074
Update per comments
lazarkov Jun 18, 2024
61dde7a
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 19, 2024
21fce36
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 20, 2024
58c7c28
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 20, 2024
4c90b3a
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 20, 2024
5eff1f4
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 21, 2024
d7f3aea
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 21, 2024
04a996d
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 22, 2024
8bf7d58
Update Content app nullptrs
lazarkov Jun 24, 2024
19d5dc6
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 24, 2024
8914178
Restyled by google-java-format
restyled-commits Jun 24, 2024
fe92e23
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 24, 2024
cad7283
Update
lazarkov Jun 24, 2024
3d045a7
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 24, 2024
0847fd4
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 24, 2024
e1ba701
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
lazarkov Jun 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public void setEndpointId(int endpoint) {
}

public Set<SupportedCluster> getSupportedClusters() {
return Collections.unmodifiableSet(supportedClusters);
return supportedClusters != null
? Collections.unmodifiableSet(supportedClusters)
: Collections.EMPTY_SET;
}

public String getVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -198,6 +199,7 @@ private Collection<ContentAppSupportedCluster> mapSupportedClusters(
Collection<SupportedCluster> supportedClusters) {
return supportedClusters
.stream()
.filter(Objects::nonNull)
.map(AppPlatformService::mapSupportedCluster)
.collect(Collectors.toList());
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tv-app/android/java/AppPlatform-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ std::vector<ContentApp::SupportedCluster> convert_to_cpp(JNIEnv * env, jobject s
// Find Java classes. WARNING: Reflection
jclass collectionClass = env->FindClass("java/util/Collection");
jclass iteratorClass = env->FindClass("java/util/Iterator");
jclass clusterClass = env->FindClass("com/matter/tv/server/tvapp/SupportedCluster");
jclass clusterClass = env->FindClass("com/matter/tv/server/tvapp/ContentAppSupportedCluster");
if (collectionClass == nullptr || iteratorClass == nullptr || clusterClass == nullptr)
{
return {};
Expand Down
9 changes: 0 additions & 9 deletions examples/tv-app/android/java/MyUserPrompter-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,6 @@ bool JNIMyUserPrompter::DisplaysPasscodeAndQRCode()
return false;
}

/**
* Called to prompt the user for consent to allow the app commissioneeName/vendorId/productId to be installed.
* For example "[commissioneeName] is requesting permission to install app to this TV, approve?"
*/
void JNIMyUserPrompter::PromptForAppInstallOKPermission(uint16_t vendorId, uint16_t productId, const char * commissioneeName)
{
ChipLogError(Zcl, "JNIMyUserPrompter::PromptForAppInstallOKPermission Needs Implementation");
}

/**
* Called to display the given setup passcode to the user,
* for commissioning the given commissioneeName with the given vendorId and productId,
Expand Down
1 change: 0 additions & 1 deletion examples/tv-app/android/java/MyUserPrompter-JNI.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class JNIMyUserPrompter : public UserPrompter
void PromptForCommissionOKPermission(uint16_t vendorId, uint16_t productId, const char * commissioneeName) override;
void PromptForCommissionPasscode(uint16_t vendorId, uint16_t productId, const char * commissioneeName, uint16_t pairingHint,
const char * pairingInstruction) override;
void PromptForAppInstallOKPermission(uint16_t vendorId, uint16_t productId, const char * commissioneeName) override;
void HidePromptsOnCancel(uint16_t vendorId, uint16_t productId, const char * commissioneeName) override;
bool DisplaysPasscodeAndQRCode() override;
void PromptWithCommissionerPasscode(uint16_t vendorId, uint16_t productId, const char * commissioneeName, uint32_t passcode,
Expand Down
11 changes: 11 additions & 0 deletions examples/tv-app/android/java/TVApp-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@ class MyPincodeService : public PasscodeService
};
MyPincodeService gMyPincodeService;

class SampleTvAppInstallationService : public AppInstallationService
{
bool LookupTargetContentApp(uint16_t vendorId, uint16_t productId) override
{
return ContentAppPlatform::GetInstance().LoadContentAppByClient(vendorId, productId) != nullptr;
}
};

SampleTvAppInstallationService gSampleTvAppInstallationService;

class MyPostCommissioningListener : public PostCommissioningListener
{
void CommissioningCompleted(uint16_t vendorId, uint16_t productId, NodeId nodeId, Messaging::ExchangeManager & exchangeMgr,
Expand Down Expand Up @@ -372,6 +382,7 @@ void TvAppJNI::InitializeCommissioner(JNIMyUserPrompter * userPrompter)
if (cdc != nullptr && userPrompter != nullptr)
{
cdc->SetPasscodeService(&gMyPincodeService);
cdc->SetAppInstallationService(&gSampleTvAppInstallationService);
cdc->SetUserPrompter(userPrompter);
cdc->SetPostCommissioningListener(&gMyPostCommissioningListener);
}
Expand Down
4 changes: 4 additions & 0 deletions examples/tv-app/tv-common/include/AppTv.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory
void InstallContentApp(uint16_t vendorId, uint16_t productId);
// Remove the app from the list of mContentApps
bool UninstallContentApp(uint16_t vendorId, uint16_t productId);
// Print mContentApps and endpoints
void LogInstalledApps();
// TODO: method to retrieve list of mContentApps
// https://github.com/project-chip/connectedhomeip/issues/34020

protected:
std::vector<std::unique_ptr<ContentAppImpl>> mContentApps;
Expand Down
64 changes: 43 additions & 21 deletions examples/tv-app/tv-common/src/AppTv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ class MyUserPrompter : public UserPrompter

// tv should override this with a dialog prompt
inline void PromptCommissioningFailed(const char * commissioneeName, CHIP_ERROR error) override { return; }

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

MyUserPrompter gMyUserPrompter;
Expand Down Expand Up @@ -583,28 +577,33 @@ void ContentAppFactoryImpl::InstallContentApp(uint16_t vendorId, uint16_t produc
ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl: InstallContentApp vendorId=%d productId=%d ", vendorId, productId);
if (vendorId == 1 && productId == 11)
{
mContentApps.emplace_back(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());
mContentApps.emplace_back(std::move(ptr));
}
else if (vendorId == 65521 && productId == 32768)
else if (vendorId == 65521 && productId == 32769)
{
mContentApps.emplace_back(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());
mContentApps.emplace_back(std::move(ptr));
}
else if (vendorId == 9050 && productId == 22)
{
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("Vendor3", vendorId, "App3", productId, "Version3", "20202021",
make_default_supported_clusters()));
auto ptr = std::make_unique<ContentAppImpl>("Vendor3", vendorId, "App3", productId, "Version3", "20202021",
make_default_supported_clusters());
mContentApps.emplace_back(std::move(ptr));
}
else if (vendorId == 1111 && productId == 22)
{
mContentApps.emplace_back(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());
mContentApps.emplace_back(std::move(ptr));
}
else
{
mContentApps.emplace_back(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());
mContentApps.emplace_back(std::move(ptr));
}
}

Expand All @@ -627,6 +626,7 @@ bool ContentAppFactoryImpl::UninstallContentApp(uint16_t vendorId, uint16_t prod
app->GetApplicationBasicDelegate()->HandleGetVendorId(),
app->GetApplicationBasicDelegate()->HandleGetProductId());
mContentApps.erase(mContentApps.begin() + index);
// TODO: call ContentAppPlatform->RemoveContentApp(ids...)
return true;
}

Expand All @@ -635,6 +635,18 @@ bool ContentAppFactoryImpl::UninstallContentApp(uint16_t vendorId, uint16_t prod
return false;
}

void ContentAppFactoryImpl::LogInstalledApps()
{
for (auto & contentApp : mContentApps)
{
auto app = contentApp.get();

ChipLogProgress(DeviceLayer, "Content app vid=%d pid=%d is on ep=%d",
app->GetApplicationBasicDelegate()->HandleGetVendorId(),
app->GetApplicationBasicDelegate()->HandleGetProductId(), app->GetEndpointId());
}
}

Access::Privilege ContentAppFactoryImpl::GetVendorPrivilege(uint16_t vendorId)
{
for (size_t i = 0; i < mAdminVendorIds.size(); ++i)
Expand Down Expand Up @@ -689,12 +701,22 @@ std::list<ClusterId> ContentAppFactoryImpl::GetAllowedClusterListForStaticEndpoi
CHIP_ERROR AppTvInit()
{
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
// test data for apps
constexpr uint16_t kApp1VendorId = 1;
constexpr uint16_t kApp1ProductId = 11;
constexpr uint16_t kApp2VendorId = 65521;
constexpr uint16_t kApp2ProductId = 32769;
constexpr uint16_t kApp3VendorId = 9050;
constexpr uint16_t kApp3ProductId = 22;
constexpr uint16_t kApp4VendorId = 1111;
constexpr uint16_t kApp4ProductId = 22;

ContentAppPlatform::GetInstance().SetupAppPlatform();
ContentAppPlatform::GetInstance().SetContentAppFactory(&gFactory);
gFactory.InstallContentApp((uint16_t) 1, (uint16_t) 11);
gFactory.InstallContentApp((uint16_t) 65521, (uint16_t) 32768);
gFactory.InstallContentApp((uint16_t) 9050, (uint16_t) 22);
gFactory.InstallContentApp((uint16_t) 1111, (uint16_t) 22);
gFactory.InstallContentApp(kApp1VendorId, kApp1ProductId);
gFactory.InstallContentApp(kApp2VendorId, kApp2ProductId);
gFactory.InstallContentApp(kApp3VendorId, kApp3ProductId);
gFactory.InstallContentApp(kApp4VendorId, kApp4ProductId);
uint16_t value;
if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetVendorId(value) != CHIP_NO_ERROR)
{
Expand Down
16 changes: 0 additions & 16 deletions src/controller/CommissionerDiscoveryController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,22 +229,6 @@ void CommissionerDiscoveryController::InternalOk()
if (!mAppInstallationService->LookupTargetContentApp(client->GetVendorId(), client->GetProductId()))
{
ChipLogDetail(AppServer, "UX InternalOk: app not installed.");

// notify client that app will be installed
lazarkov marked this conversation as resolved.
Show resolved Hide resolved
CommissionerDeclaration cd;
cd.SetErrorCode(CommissionerDeclaration::CdError::kAppInstallConsentPending);
mUdcServer->SendCDCMessage(cd, Transport::PeerAddress::UDP(client->GetPeerAddress().GetIPAddress(), client->GetCdPort()));

// dialog
ChipLogDetail(Controller, "------PROMPT USER: %s is requesting to install app on this TV. vendorId=%d, productId=%d",
client->GetDeviceName(), client->GetVendorId(), client->GetProductId());

if (mUserPrompter != nullptr)
{
mUserPrompter->PromptForAppInstallOKPermission(client->GetVendorId(), client->GetProductId(), client->GetDeviceName());
}
ChipLogDetail(Controller, "------Via Shell Enter: app install <pid> <vid>");
return;
}

if (client->GetUDCClientProcessingState() != UDCClientProcessingState::kPromptingUser)
Expand Down
17 changes: 0 additions & 17 deletions src/controller/CommissionerDiscoveryController.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,6 @@ class DLL_EXPORT UserPrompter
*/
virtual void PromptCommissioningFailed(const char * commissioneeName, CHIP_ERROR error) = 0;

/**
* @brief
* Called to prompt the user for consent to allow the app commissioneeName/vendorId/productId to be installed.
* For example "[commissioneeName] is requesting permission to install app to this TV, approve?"
*
* If user responds with OK then implementor should call CommissionerRespondOk();
* If user responds with Cancel then implementor should call CommissionerRespondCancel();
*
* @param[in] vendorId The vendorId in the DNS-SD advertisement of the requesting commissionee.
* @param[in] productId The productId in the DNS-SD advertisement of the requesting commissionee.
* @param[in] commissioneeName The commissioneeName in the DNS-SD advertisement of the requesting commissionee.
*
*/
virtual void PromptForAppInstallOKPermission(uint16_t vendorId, uint16_t productId, const char * commissioneeName) = 0;

virtual ~UserPrompter() = default;
};

Expand Down Expand Up @@ -227,8 +212,6 @@ class DLL_EXPORT AppInstallationService
* Called to check if the given target app is available to the commissione with th given
* vendorId/productId
*
* This will be called by the main chip thread so any blocking work should be moved to a separate thread.
tcarmelveilleux marked this conversation as resolved.
Show resolved Hide resolved
*
* @param[in] vendorId The vendorId in the DNS-SD advertisement of the requesting commissionee.
* @param[in] productId The productId in the DNS-SD advertisement of the requesting commissionee.
*
Expand Down
Loading