Skip to content

Commit

Permalink
cleanup acl print shell command, disable placeholder endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdecenzo committed Jul 27, 2022
1 parent eb29dda commit f7b0f02
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 8 deletions.
2 changes: 0 additions & 2 deletions examples/tv-app/android/java/AppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,6 @@ CHIP_ERROR InitVideoPlayerPlatform(JNIMyUserPrompter * userPrompter, jobject con
// Disable last fixed endpoint, which is used as a placeholder for all of the
// supported clusters so that ZAP will generated the requisite code.
ChipLogDetail(DeviceLayer, "TV App: Disabling Fixed Content App Endpoints");
emberAfEndpointEnableDisable(5, false);
emberAfEndpointEnableDisable(4, false);
emberAfEndpointEnableDisable(3, false);

return CHIP_NO_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion examples/tv-app/android/java/MediaPlaybackManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void MediaPlaybackManager::InitializeWithObjects(jobject managerObject)
}

mGetPositionMethod =
env->GetMethodID(mMediaPlaybackManagerClass, "getPosition", "()[Lcom/matter/tv/server/tvapp/MediaPlaybackPosition;");
env->GetMethodID(mMediaPlaybackManagerClass, "getPosition", "()Lcom/matter/tv/server/tvapp/MediaPlaybackPosition;");
if (mGetPositionMethod == nullptr)
{
ChipLogError(Zcl, "Failed to access MediaPlaybackManager 'getPosition' method");
Expand Down
82 changes: 79 additions & 3 deletions examples/tv-app/linux/AppPlatformShellCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
using namespace ::chip::Controller;
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
using namespace chip::AppPlatform;
using namespace chip::Access;
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
using namespace chip::app::Clusters;

Expand Down Expand Up @@ -105,6 +106,82 @@ static CHIP_ERROR pairApp(bool printHeader, size_t index)
return CHIP_NO_ERROR;
}

static CHIP_ERROR DumpAccessControlEntry(const Access::AccessControl::Entry & entry)
{
CHIP_ERROR err;

ChipLogDetail(DeviceLayer, "----- BEGIN ENTRY -----");

{
FabricIndex fabricIndex;
SuccessOrExit(err = entry.GetFabricIndex(fabricIndex));
ChipLogDetail(DeviceLayer, "fabricIndex: %u", fabricIndex);
}

{
Privilege privilege;
SuccessOrExit(err = entry.GetPrivilege(privilege));
ChipLogDetail(DeviceLayer, "privilege: %d", to_underlying(privilege));
}

{
AuthMode authMode;
SuccessOrExit(err = entry.GetAuthMode(authMode));
ChipLogDetail(DeviceLayer, "authMode: %d", to_underlying(authMode));
}

{
size_t count;
SuccessOrExit(err = entry.GetSubjectCount(count));
if (count)
{
ChipLogDetail(DeviceLayer, "subjects: %u", static_cast<unsigned>(count));
for (size_t i = 0; i < count; ++i)
{
NodeId subject;
SuccessOrExit(err = entry.GetSubject(i, subject));
ChipLogDetail(DeviceLayer, " %u: 0x" ChipLogFormatX64, static_cast<unsigned>(i), ChipLogValueX64(subject));
}
}
}

{
size_t count;
SuccessOrExit(err = entry.GetTargetCount(count));
if (count)
{
ChipLogDetail(DeviceLayer, "targets: %u", static_cast<unsigned>(count));
for (size_t i = 0; i < count; ++i)
{
Access::AccessControl::Entry::Target target;
SuccessOrExit(err = entry.GetTarget(i, target));
if (target.flags & Access::AccessControl::Entry::Target::kCluster)
{
ChipLogDetail(DeviceLayer, " %u: cluster: 0x" ChipLogFormatMEI, static_cast<unsigned>(i),
ChipLogValueMEI(target.cluster));
}
if (target.flags & Access::AccessControl::Entry::Target::kEndpoint)
{
ChipLogDetail(DeviceLayer, " %u: endpoint: %u", static_cast<unsigned>(i), target.endpoint);
}
if (target.flags & Access::AccessControl::Entry::Target::kDeviceType)
{
ChipLogDetail(DeviceLayer, " %u: deviceType: 0x" ChipLogFormatMEI, static_cast<unsigned>(i),
ChipLogValueMEI(target.deviceType));
}
}
}
}

ChipLogDetail(DeviceLayer, "----- END ENTRY -----");

return CHIP_NO_ERROR;

exit:
ChipLogError(DeviceLayer, "DumpAccessControlEntry: dump failed %" CHIP_ERROR_FORMAT, err.Format());
return err;
}

static CHIP_ERROR PrintAllCommands()
{
streamer_t * sout = streamer_get();
Expand Down Expand Up @@ -231,13 +308,12 @@ static CHIP_ERROR AppPlatformHandler(int argc, char ** argv)
else if (strcmp(argv[0], "print-app-access") == 0)
{
Access::AccessControl::EntryIterator iterator;
Access::AccessControl & accessControl = Access::GetAccessControl();
ReturnErrorOnFailure(accessControl.Entries(GetDeviceCommissioner()->GetFabricIndex(), iterator));
ReturnErrorOnFailure(Access::GetAccessControl().Entries(GetDeviceCommissioner()->GetFabricIndex(), iterator));

Access::AccessControl::Entry entry;
while (iterator.Next(entry) == CHIP_NO_ERROR)
{
accessControl.Dump(entry);
DumpAccessControlEntry(entry);
}
return CHIP_NO_ERROR;
}
Expand Down
10 changes: 9 additions & 1 deletion examples/tv-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ static TargetNavigatorManager targetNavigatorManager;
static WakeOnLanManager wakeOnLanManager;
} // namespace

void ApplicationInit() {}
void ApplicationInit()
{
ChipLogProgress(Zcl, "TV Linux App: ApplicationInit()");

// Disable last fixed endpoint, which is used as a placeholder for all of the
// supported clusters so that ZAP will generated the requisite code.
ChipLogDetail(DeviceLayer, "TV Linux App: Disabling Fixed Content App Endpoints");
emberAfEndpointEnableDisable(3, false);
}

int main(int argc, char * argv[])
{
Expand Down
2 changes: 1 addition & 1 deletion src/access/AccessControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <lib/core/CHIPCore.h>

// Dump function for use during development only (0 for disabled, non-zero for enabled).
#define CHIP_ACCESS_CONTROL_DUMP_ENABLED 1
#define CHIP_ACCESS_CONTROL_DUMP_ENABLED 0

namespace chip {
namespace Access {
Expand Down

0 comments on commit f7b0f02

Please sign in to comment.