Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdecenzo committed Feb 18, 2024
1 parent ea479f3 commit d6e6041
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 16 deletions.
9 changes: 9 additions & 0 deletions examples/tv-app/android/java/ChannelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void ChannelManager::NewManager(jint endpoint, jobject manager)

CHIP_ERROR ChannelManager::HandleGetChannelList(AttributeValueEncoder & aEncoder)
{
DeviceLayer::StackUnlock unlock;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NULL_OBJECT, ChipLogError(Zcl, "Could not get JNIEnv for current thread"));
Expand Down Expand Up @@ -136,6 +137,7 @@ CHIP_ERROR ChannelManager::HandleGetChannelList(AttributeValueEncoder & aEncoder

CHIP_ERROR ChannelManager::HandleGetLineup(AttributeValueEncoder & aEncoder)
{
DeviceLayer::StackUnlock unlock;
chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type lineupInfo;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
Expand Down Expand Up @@ -201,6 +203,7 @@ CHIP_ERROR ChannelManager::HandleGetLineup(AttributeValueEncoder & aEncoder)

CHIP_ERROR ChannelManager::HandleGetCurrentChannel(AttributeValueEncoder & aEncoder)
{
DeviceLayer::StackUnlock unlock;
chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type channelInfo;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
Expand Down Expand Up @@ -279,6 +282,7 @@ CHIP_ERROR ChannelManager::HandleGetCurrentChannel(AttributeValueEncoder & aEnco

void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResponseType> & helper, const CharSpan & match)
{
DeviceLayer::StackUnlock unlock;
std::string name(match.data(), match.size());
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNIEnv for current thread"));
Expand Down Expand Up @@ -326,6 +330,7 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp

bool ChannelManager::HandleChangeChannelByNumber(const uint16_t & majorNumber, const uint16_t & minorNumber)
{
DeviceLayer::StackUnlock unlock;
jboolean ret = JNI_FALSE;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread"));
Expand Down Expand Up @@ -354,6 +359,7 @@ bool ChannelManager::HandleChangeChannelByNumber(const uint16_t & majorNumber, c

bool ChannelManager::HandleSkipChannel(const int16_t & count)
{
DeviceLayer::StackUnlock unlock;
jboolean ret = JNI_FALSE;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread"));
Expand Down Expand Up @@ -386,6 +392,7 @@ void ChannelManager::HandleGetProgramGuide(
const chip::Optional<chip::app::DataModel::DecodableList<AdditionalInfoType>> & externalIdList,
const chip::Optional<chip::ByteSpan> & data)
{
DeviceLayer::StackUnlock unlock;
ProgramGuideResponseType response;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
Expand Down Expand Up @@ -600,6 +607,7 @@ bool ChannelManager::HandleRecordProgram(const chip::CharSpan & programIdentifie
const DataModel::DecodableList<AdditionalInfo> & externalIdList,
const chip::ByteSpan & data)
{
DeviceLayer::StackUnlock unlock;
jboolean ret = JNI_FALSE;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread"));
Expand Down Expand Up @@ -637,6 +645,7 @@ bool ChannelManager::HandleCancelRecordProgram(const chip::CharSpan & programIde
const DataModel::DecodableList<AdditionalInfo> & externalIdList,
const chip::ByteSpan & data)
{
DeviceLayer::StackUnlock unlock;
jboolean ret = JNI_FALSE;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread"));
Expand Down
2 changes: 2 additions & 0 deletions examples/tv-app/android/java/ContentAppAttributeDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <lib/support/CHIPJNIError.h>
#include <lib/support/JniReferences.h>
#include <lib/support/JniTypeWrappers.h>
#include <platform/PlatformManager.h>
#include <zap-generated/endpoint_config.h>

namespace chip {
Expand All @@ -43,6 +44,7 @@ std::string ContentAppAttributeDelegate::Read(const chip::app::ConcreteReadAttri
return "";
}

DeviceLayer::StackUnlock unlock;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
ChipLogProgress(Zcl, "ContentAppAttributeDelegate::Read being called for endpoint %d cluster %d attribute %d",
aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId);
Expand Down
2 changes: 2 additions & 0 deletions examples/tv-app/android/java/ContentAppCommandDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <lib/support/JniReferences.h>
#include <lib/support/JniTypeWrappers.h>
#include <lib/support/jsontlv/TlvJson.h>
#include <platform/PlatformManager.h>
#include <zap-generated/endpoint_config.h>

namespace chip {
Expand All @@ -50,6 +51,7 @@ void ContentAppCommandDelegate::InvokeCommand(CommandHandlerInterface::HandlerCo
{
if (handlerContext.mRequestPath.mEndpointId >= FIXED_ENDPOINT_COUNT)
{
DeviceLayer::StackUnlock unlock;
TLV::TLVReader readerForJson;
readerForJson.Init(handlerContext.mPayload);

Expand Down
4 changes: 4 additions & 0 deletions examples/tv-app/android/java/ContentLauncherManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void ContentLauncherManager::HandleLaunchContent(CommandResponseHelper<LaunchRes
const chip::Optional<PlaybackPreferencesType> playbackPreferences,
bool useCurrentContext)
{
DeviceLayer::StackUnlock unlock;
Commands::LauncherResponse::Type response;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
Expand Down Expand Up @@ -107,6 +108,7 @@ void ContentLauncherManager::HandleLaunchUrl(CommandResponseHelper<LaunchRespons
const chip::CharSpan & displayString,
const BrandingInformationType & brandingInformation)
{
DeviceLayer::StackUnlock unlock;
Commands::LauncherResponse::Type response;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
Expand Down Expand Up @@ -163,6 +165,7 @@ void ContentLauncherManager::HandleLaunchUrl(CommandResponseHelper<LaunchRespons

CHIP_ERROR ContentLauncherManager::HandleGetAcceptHeaderList(AttributeValueEncoder & aEncoder)
{
DeviceLayer::StackUnlock unlock;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
std::list<std::string> acceptedHeadersList;
Expand Down Expand Up @@ -208,6 +211,7 @@ CHIP_ERROR ContentLauncherManager::HandleGetAcceptHeaderList(AttributeValueEncod

uint32_t ContentLauncherManager::HandleGetSupportedStreamingProtocols()
{
DeviceLayer::StackUnlock unlock;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
uint32_t supportedStreamingProtocols = 0;
Expand Down
1 change: 1 addition & 0 deletions examples/tv-app/android/java/KeypadInputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void KeypadInputManager::NewManager(jint endpoint, jobject manager)

void KeypadInputManager::HandleSendKey(CommandResponseHelper<SendKeyResponseType> & helper, const CECKeyCodeEnum & keyCode)
{
DeviceLayer::StackUnlock unlock;
Commands::SendKeyResponse::Type response;

jint ret = -1;
Expand Down
1 change: 1 addition & 0 deletions examples/tv-app/android/java/LevelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ CHIP_ERROR LevelManager::InitializeWithObjects(jobject managerObject)

void LevelManager::HandleLevelChanged(uint8_t value)
{
DeviceLayer::StackUnlock unlock;
ChipLogProgress(Zcl, "LevelManager::HandleLevelChanged");

JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
Expand Down
1 change: 1 addition & 0 deletions examples/tv-app/android/java/LowPowerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void LowPowerManager::InitializeWithObjects(jobject managerObject)

bool LowPowerManager::HandleSleep()
{
DeviceLayer::StackUnlock unlock;
jboolean ret = JNI_FALSE;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
JniLocalReferenceScope scope(env);
Expand Down
6 changes: 6 additions & 0 deletions examples/tv-app/android/java/MediaInputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void MediaInputManager::NewManager(jint endpoint, jobject manager)

CHIP_ERROR MediaInputManager::HandleGetInputList(chip::app::AttributeValueEncoder & aEncoder)
{
DeviceLayer::StackUnlock unlock;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NO_ENV, ChipLogError(Zcl, "Could not get JNIEnv for current thread"));
Expand Down Expand Up @@ -123,6 +124,7 @@ CHIP_ERROR MediaInputManager::HandleGetInputList(chip::app::AttributeValueEncode

uint8_t MediaInputManager::HandleGetCurrentInput()
{
DeviceLayer::StackUnlock unlock;
CHIP_ERROR err = CHIP_NO_ERROR;
jint index = -1;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
Expand Down Expand Up @@ -157,6 +159,7 @@ uint8_t MediaInputManager::HandleGetCurrentInput()

bool MediaInputManager::HandleSelectInput(const uint8_t index)
{
DeviceLayer::StackUnlock unlock;
jboolean ret = JNI_FALSE;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread"));
Expand All @@ -182,6 +185,7 @@ bool MediaInputManager::HandleSelectInput(const uint8_t index)

bool MediaInputManager::HandleShowInputStatus()
{
DeviceLayer::StackUnlock unlock;
jboolean ret = JNI_FALSE;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread"));
Expand All @@ -207,6 +211,7 @@ bool MediaInputManager::HandleShowInputStatus()

bool MediaInputManager::HandleHideInputStatus()
{
DeviceLayer::StackUnlock unlock;
jboolean ret = JNI_FALSE;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread"));
Expand All @@ -232,6 +237,7 @@ bool MediaInputManager::HandleHideInputStatus()

bool MediaInputManager::HandleRenameInput(const uint8_t index, const chip::CharSpan & name)
{
DeviceLayer::StackUnlock unlock;
std::string inputname(name.data(), name.size());
jboolean ret = JNI_FALSE;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
Expand Down
8 changes: 8 additions & 0 deletions examples/tv-app/android/java/MediaPlaybackManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ CHIP_ERROR MediaPlaybackManager::HandleGetActiveAudioTrack(AttributeValueEncoder

CHIP_ERROR MediaPlaybackManager::HandleGetActiveTrack(bool audio, AttributeValueEncoder & aEncoder)
{
DeviceLayer::StackUnlock unlock;
Structs::TrackStruct::Type response;
Structs::TrackAttributesStruct::Type trackAttributes;
response.trackAttributes = Nullable<Structs::TrackAttributesStruct::Type>(trackAttributes);
Expand Down Expand Up @@ -170,6 +171,7 @@ CHIP_ERROR MediaPlaybackManager::HandleGetAvailableAudioTracks(AttributeValueEnc

CHIP_ERROR MediaPlaybackManager::HandleGetAvailableTracks(bool audio, AttributeValueEncoder & aEncoder)
{
DeviceLayer::StackUnlock unlock;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NULL_OBJECT, ChipLogError(Zcl, "Could not get JNIEnv for current thread"));
Expand Down Expand Up @@ -319,6 +321,7 @@ bool MediaPlaybackManager::HandleActivateAudioTrack(const chip::CharSpan & track

bool MediaPlaybackManager::HandleActivateTrack(bool audio, const chip::CharSpan & trackId)
{
DeviceLayer::StackUnlock unlock;
std::string id(trackId.data(), trackId.size());

jint ret = -1;
Expand Down Expand Up @@ -355,6 +358,7 @@ bool MediaPlaybackManager::HandleActivateTextTrack(const chip::CharSpan & trackI

bool MediaPlaybackManager::HandleDeactivateTextTrack()
{
DeviceLayer::StackUnlock unlock;
jint ret = -1;
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
Expand Down Expand Up @@ -443,6 +447,7 @@ void MediaPlaybackManager::InitializeWithObjects(jobject managerObject)

uint64_t MediaPlaybackManager::HandleMediaRequestGetAttribute(MediaPlaybackRequestAttribute attribute)
{
DeviceLayer::StackUnlock unlock;
uint64_t ret = std::numeric_limits<uint64_t>::max();
jlong jAttributeValue = -1;
CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down Expand Up @@ -486,6 +491,7 @@ uint64_t MediaPlaybackManager::HandleMediaRequestGetAttribute(MediaPlaybackReque

long MediaPlaybackManager::HandleMediaRequestGetLongAttribute(MediaPlaybackRequestAttribute attribute)
{
DeviceLayer::StackUnlock unlock;
long ret = 0;
jlong jAttributeValue = -1;
CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down Expand Up @@ -524,6 +530,7 @@ Commands::PlaybackResponse::Type MediaPlaybackManager::HandleMediaRequest(MediaP
uint64_t deltaPositionMilliseconds)

{
DeviceLayer::StackUnlock unlock;
Commands::PlaybackResponse::Type response;

jint ret = -1;
Expand Down Expand Up @@ -561,6 +568,7 @@ Commands::PlaybackResponse::Type MediaPlaybackManager::HandleMediaRequest(MediaP

CHIP_ERROR MediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncoder & aEncoder)
{
DeviceLayer::StackUnlock unlock;
Structs::PlaybackPositionStruct::Type response;
response.updatedAt = 0;
response.position = Nullable<uint64_t>(0);
Expand Down
Loading

0 comments on commit d6e6041

Please sign in to comment.