Skip to content

Commit

Permalink
Implement UI affordance to run cert tests from the android casting ap…
Browse files Browse the repository at this point in the history
…p. (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 <[email protected]>
  • Loading branch information
2 people authored and cletnick committed Jan 10, 2023
1 parent d9ccca2 commit c70f535
Show file tree
Hide file tree
Showing 24 changed files with 819 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public void init(@NonNull Context context) {
registerContentAppUpdatesReceiver();
}

public void addSelfVendorAsAdmin() {
mAppPlatform.addSelfVendorAsAdmin();
}

private void initializeContentAppEndpoints() {

// Read the metadada of previously discovered endpoints.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public void onCreate() {
MatterServant.get().initCommissioner();

AppPlatformService.get().init(this.getApplicationContext());
AppPlatformService.get().addSelfVendorAsAdmin();
}

@Nullable
Expand Down
29 changes: 29 additions & 0 deletions examples/tv-app/android/java/AppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@
#include <lib/support/CodeUtils.h>
#include <lib/support/ZclString.h>
#include <platform/CHIPDeviceLayer.h>
#include <platform/DeviceInstanceInfoProvider.h>

using namespace chip;
using namespace chip::AppPlatform;
using namespace chip::DeviceLayer;

#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ContentAppFactoryImpl gFactory;
Expand Down Expand Up @@ -407,6 +409,20 @@ std::list<ClusterId> ContentAppFactoryImpl::GetAllowedClusterListForStaticEndpoi
{
if (endpointId == kLocalVideoPlayerEndpointId)
{
if (GetVendorPrivilege(vendorId) == Access::Privilege::kAdminister)
{
ChipLogProgress(DeviceLayer,
"ContentAppFactoryImpl GetAllowedClusterListForStaticEndpoint priviledged vendor accessible clusters "
"being returned.");
return { chip::app::Clusters::Descriptor::Id, chip::app::Clusters::OnOff::Id,
chip::app::Clusters::WakeOnLan::Id, chip::app::Clusters::MediaPlayback::Id,
chip::app::Clusters::LowPower::Id, chip::app::Clusters::KeypadInput::Id,
chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::AudioOutput::Id,
chip::app::Clusters::ApplicationLauncher::Id };
}
ChipLogProgress(
DeviceLayer,
"ContentAppFactoryImpl GetAllowedClusterListForStaticEndpoint operator vendor accessible clusters being returned.");
return { chip::app::Clusters::Descriptor::Id, chip::app::Clusters::OnOff::Id,
chip::app::Clusters::WakeOnLan::Id, chip::app::Clusters::MediaPlayback::Id,
chip::app::Clusters::LowPower::Id, chip::app::Clusters::KeypadInput::Id,
Expand Down Expand Up @@ -478,3 +494,16 @@ void ReportAttributeChange(EndpointId epId, chip::ClusterId clusterId, chip::Att
{
MatterReportingAttributeChangeCallback(epId, clusterId, attributeId);
}

void AddSelfVendorAsAdmin()
{
uint16_t value;
if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetVendorId(value) != CHIP_NO_ERROR)
{
ChipLogDetail(Discovery, "AppImpl addSelfVendorAsAdmin Vendor ID not known");
}
else
{
gFactory.AddAdminVendorId(value);
}
}
2 changes: 2 additions & 0 deletions examples/tv-app/android/java/AppImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ EndpointId AddContentApp(const char * szVendorName, uint16_t vendorId, const cha
EndpointId RemoveContentApp(EndpointId epId);
void ReportAttributeChange(EndpointId epId, chip::ClusterId clusterId, chip::AttributeId attributeId);

void AddSelfVendorAsAdmin();

#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED

namespace chip {
Expand Down
6 changes: 6 additions & 0 deletions examples/tv-app/android/java/AppPlatform-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,9 @@ JNI_METHOD(void, reportAttributeChange)
ReportAttributeChange(static_cast<EndpointId>(endpointId), static_cast<chip::ClusterId>(clusterId),
static_cast<chip::AttributeId>(attributeId));
}

JNI_METHOD(void, addSelfVendorAsAdmin)
(JNIEnv *, jobject, jint endpointId, jint clusterId, jint attributeId)
{
AddSelfVendorAsAdmin();
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public native int addContentAppAtEndpoint(
// Method to report attribute change for content app endpoints to the SDK
public native void reportAttributeChange(int endpointId, int clusterId, int attributeId);

// Method to add the current vendorId of the node as an admin to enable clients from same vendor
// to be admins
public native void addSelfVendorAsAdmin();

static {
System.loadLibrary("TvApp");
}
Expand Down
24 changes: 24 additions & 0 deletions examples/tv-app/linux/AppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <lib/support/CodeUtils.h>
#include <lib/support/ZclString.h>
#include <platform/CHIPDeviceLayer.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <zap-generated/CHIPClusters.h>

using namespace chip;
Expand Down Expand Up @@ -502,6 +503,20 @@ std::list<ClusterId> ContentAppFactoryImpl::GetAllowedClusterListForStaticEndpoi
{
if (endpointId == kLocalVideoPlayerEndpointId)
{
if (GetVendorPrivilege(vendorId) == Access::Privilege::kAdminister)
{
ChipLogProgress(DeviceLayer,
"ContentAppFactoryImpl GetAllowedClusterListForStaticEndpoint priviledged vendor accessible clusters "
"being returned.");
return { chip::app::Clusters::Descriptor::Id, chip::app::Clusters::OnOff::Id,
chip::app::Clusters::WakeOnLan::Id, chip::app::Clusters::MediaPlayback::Id,
chip::app::Clusters::LowPower::Id, chip::app::Clusters::KeypadInput::Id,
chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::AudioOutput::Id,
chip::app::Clusters::ApplicationLauncher::Id };
}
ChipLogProgress(
DeviceLayer,
"ContentAppFactoryImpl GetAllowedClusterListForStaticEndpoint operator vendor accessible clusters being returned.");
return { chip::app::Clusters::Descriptor::Id, chip::app::Clusters::OnOff::Id,
chip::app::Clusters::WakeOnLan::Id, chip::app::Clusters::MediaPlayback::Id,
chip::app::Clusters::LowPower::Id, chip::app::Clusters::KeypadInput::Id,
Expand All @@ -520,6 +535,15 @@ CHIP_ERROR InitVideoPlayerPlatform()
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ContentAppPlatform::GetInstance().SetupAppPlatform();
ContentAppPlatform::GetInstance().SetContentAppFactory(&gFactory);
uint16_t value;
if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetVendorId(value) != CHIP_NO_ERROR)
{
ChipLogDetail(Discovery, "AppImpl InitVideoPlayerPlatform Vendor ID not known");
}
else
{
gFactory.AddAdminVendorId(value);
}
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED

#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
Expand Down
4 changes: 4 additions & 0 deletions examples/tv-casting-app/android/App/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ android {
sourceSets {
main {
jniLibs.srcDirs = ['libs/jniLibs']
java.srcDirs = [
'src/main/java',
'src/main/jni',
]

// uncomment this code to debug
// java.srcDirs = [
Expand Down
Loading

0 comments on commit c70f535

Please sign in to comment.