Skip to content

Commit feca44a

Browse files
Implement UI affordance to run cert tests from the android casting app. (project-chip#24321)
* Implement UI affordance to run cert tests from the android casting app. * Restyled by google-java-format * Restyled by clang-format * Restyled by gn Co-authored-by: Restyled.io <commits@restyled.io>
1 parent e170a9c commit feca44a

File tree

24 files changed

+819
-15
lines changed

24 files changed

+819
-15
lines changed

examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/AppPlatformService.java

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ public void init(@NonNull Context context) {
7272
registerContentAppUpdatesReceiver();
7373
}
7474

75+
public void addSelfVendorAsAdmin() {
76+
mAppPlatform.addSelfVendorAsAdmin();
77+
}
78+
7579
private void initializeContentAppEndpoints() {
7680

7781
// Read the metadada of previously discovered endpoints.

examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/MatterServantService.java

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public void onCreate() {
2424
MatterServant.get().initCommissioner();
2525

2626
AppPlatformService.get().init(this.getApplicationContext());
27+
AppPlatformService.get().addSelfVendorAsAdmin();
2728
}
2829

2930
@Nullable

examples/tv-app/android/java/AppImpl.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@
4444
#include <lib/support/CodeUtils.h>
4545
#include <lib/support/ZclString.h>
4646
#include <platform/CHIPDeviceLayer.h>
47+
#include <platform/DeviceInstanceInfoProvider.h>
4748

4849
using namespace chip;
4950
using namespace chip::AppPlatform;
51+
using namespace chip::DeviceLayer;
5052

5153
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
5254
ContentAppFactoryImpl gFactory;
@@ -407,6 +409,20 @@ std::list<ClusterId> ContentAppFactoryImpl::GetAllowedClusterListForStaticEndpoi
407409
{
408410
if (endpointId == kLocalVideoPlayerEndpointId)
409411
{
412+
if (GetVendorPrivilege(vendorId) == Access::Privilege::kAdminister)
413+
{
414+
ChipLogProgress(DeviceLayer,
415+
"ContentAppFactoryImpl GetAllowedClusterListForStaticEndpoint priviledged vendor accessible clusters "
416+
"being returned.");
417+
return { chip::app::Clusters::Descriptor::Id, chip::app::Clusters::OnOff::Id,
418+
chip::app::Clusters::WakeOnLan::Id, chip::app::Clusters::MediaPlayback::Id,
419+
chip::app::Clusters::LowPower::Id, chip::app::Clusters::KeypadInput::Id,
420+
chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::AudioOutput::Id,
421+
chip::app::Clusters::ApplicationLauncher::Id };
422+
}
423+
ChipLogProgress(
424+
DeviceLayer,
425+
"ContentAppFactoryImpl GetAllowedClusterListForStaticEndpoint operator vendor accessible clusters being returned.");
410426
return { chip::app::Clusters::Descriptor::Id, chip::app::Clusters::OnOff::Id,
411427
chip::app::Clusters::WakeOnLan::Id, chip::app::Clusters::MediaPlayback::Id,
412428
chip::app::Clusters::LowPower::Id, chip::app::Clusters::KeypadInput::Id,
@@ -478,3 +494,16 @@ void ReportAttributeChange(EndpointId epId, chip::ClusterId clusterId, chip::Att
478494
{
479495
MatterReportingAttributeChangeCallback(epId, clusterId, attributeId);
480496
}
497+
498+
void AddSelfVendorAsAdmin()
499+
{
500+
uint16_t value;
501+
if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetVendorId(value) != CHIP_NO_ERROR)
502+
{
503+
ChipLogDetail(Discovery, "AppImpl addSelfVendorAsAdmin Vendor ID not known");
504+
}
505+
else
506+
{
507+
gFactory.AddAdminVendorId(value);
508+
}
509+
}

examples/tv-app/android/java/AppImpl.h

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ EndpointId AddContentApp(const char * szVendorName, uint16_t vendorId, const cha
6060
EndpointId RemoveContentApp(EndpointId epId);
6161
void ReportAttributeChange(EndpointId epId, chip::ClusterId clusterId, chip::AttributeId attributeId);
6262

63+
void AddSelfVendorAsAdmin();
64+
6365
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
6466

6567
namespace chip {

examples/tv-app/android/java/AppPlatform-JNI.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,9 @@ JNI_METHOD(void, reportAttributeChange)
8787
ReportAttributeChange(static_cast<EndpointId>(endpointId), static_cast<chip::ClusterId>(clusterId),
8888
static_cast<chip::AttributeId>(attributeId));
8989
}
90+
91+
JNI_METHOD(void, addSelfVendorAsAdmin)
92+
(JNIEnv *, jobject, jint endpointId, jint clusterId, jint attributeId)
93+
{
94+
AddSelfVendorAsAdmin();
95+
}

examples/tv-app/android/java/src/com/matter/tv/server/tvapp/AppPlatform.java

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public native int addContentAppAtEndpoint(
5555
// Method to report attribute change for content app endpoints to the SDK
5656
public native void reportAttributeChange(int endpointId, int clusterId, int attributeId);
5757

58+
// Method to add the current vendorId of the node as an admin to enable clients from same vendor
59+
// to be admins
60+
public native void addSelfVendorAsAdmin();
61+
5862
static {
5963
System.loadLibrary("TvApp");
6064
}

examples/tv-app/linux/AppImpl.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <lib/support/CodeUtils.h>
4242
#include <lib/support/ZclString.h>
4343
#include <platform/CHIPDeviceLayer.h>
44+
#include <platform/DeviceInstanceInfoProvider.h>
4445
#include <zap-generated/CHIPClusters.h>
4546

4647
using namespace chip;
@@ -502,6 +503,20 @@ std::list<ClusterId> ContentAppFactoryImpl::GetAllowedClusterListForStaticEndpoi
502503
{
503504
if (endpointId == kLocalVideoPlayerEndpointId)
504505
{
506+
if (GetVendorPrivilege(vendorId) == Access::Privilege::kAdminister)
507+
{
508+
ChipLogProgress(DeviceLayer,
509+
"ContentAppFactoryImpl GetAllowedClusterListForStaticEndpoint priviledged vendor accessible clusters "
510+
"being returned.");
511+
return { chip::app::Clusters::Descriptor::Id, chip::app::Clusters::OnOff::Id,
512+
chip::app::Clusters::WakeOnLan::Id, chip::app::Clusters::MediaPlayback::Id,
513+
chip::app::Clusters::LowPower::Id, chip::app::Clusters::KeypadInput::Id,
514+
chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::AudioOutput::Id,
515+
chip::app::Clusters::ApplicationLauncher::Id };
516+
}
517+
ChipLogProgress(
518+
DeviceLayer,
519+
"ContentAppFactoryImpl GetAllowedClusterListForStaticEndpoint operator vendor accessible clusters being returned.");
505520
return { chip::app::Clusters::Descriptor::Id, chip::app::Clusters::OnOff::Id,
506521
chip::app::Clusters::WakeOnLan::Id, chip::app::Clusters::MediaPlayback::Id,
507522
chip::app::Clusters::LowPower::Id, chip::app::Clusters::KeypadInput::Id,
@@ -520,6 +535,15 @@ CHIP_ERROR InitVideoPlayerPlatform()
520535
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
521536
ContentAppPlatform::GetInstance().SetupAppPlatform();
522537
ContentAppPlatform::GetInstance().SetContentAppFactory(&gFactory);
538+
uint16_t value;
539+
if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetVendorId(value) != CHIP_NO_ERROR)
540+
{
541+
ChipLogDetail(Discovery, "AppImpl InitVideoPlayerPlatform Vendor ID not known");
542+
}
543+
else
544+
{
545+
gFactory.AddAdminVendorId(value);
546+
}
523547
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
524548

525549
#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE

examples/tv-casting-app/android/App/app/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ android {
4444
sourceSets {
4545
main {
4646
jniLibs.srcDirs = ['libs/jniLibs']
47+
java.srcDirs = [
48+
'src/main/java',
49+
'src/main/jni',
50+
]
4751

4852
// uncomment this code to debug
4953
// java.srcDirs = [

0 commit comments

Comments
 (0)