Skip to content

Commit

Permalink
Resolving android tv-casting-app build issues (#18018)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadb-amazon authored and pull[bot] committed Jan 25, 2024
1 parent e056a8a commit c32475a
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 64 deletions.
1 change: 0 additions & 1 deletion examples/tv-casting-app/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ group("default") {
":java",
":jni",
"${chip_root}/src/app/server/java",
"${chip_root}/src/controller/java",
"${chip_root}/src/platform/android:java",
]
}
5 changes: 5 additions & 0 deletions examples/tv-casting-app/linux/CastingUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@

#include "CastingUtils.h"

using namespace chip;
using namespace chip::System;
using namespace chip::DeviceLayer;
using namespace chip::Dnssd;

CHIP_ERROR DiscoverCommissioners()
{
// Send discover commissioners request
Expand Down
4 changes: 2 additions & 2 deletions examples/tv-casting-app/linux/CastingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ CHIP_ERROR DiscoverCommissioners();

CHIP_ERROR RequestCommissioning(int index);

void PrepareForCommissioning(const Dnssd::DiscoveredNodeData * selectedCommissioner = nullptr);
void PrepareForCommissioning(const chip::Dnssd::DiscoveredNodeData * selectedCommissioner = nullptr);

void InitCommissioningFlow(intptr_t commandArg);

#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
void HandleUDCSendExpiration(System::Layer * aSystemLayer, void * context);
void HandleUDCSendExpiration(chip::System::Layer * aSystemLayer, void * context);
#endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT

void PrintFabrics();
4 changes: 3 additions & 1 deletion examples/tv-casting-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,16 @@ int main(int argc, char * argv[])
#endif
CHIP_ERROR err = CHIP_NO_ERROR;

DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().Init(CHIP_CONFIG_KVS_PATH);

// Init the commissionable data provider based on command line options
// to handle custom verifiers, discriminators, etc.
err = InitCommissionableDataProvider(gCommissionableDataProvider, LinuxDeviceOptions::GetInstance());
SuccessOrExit(err);
DeviceLayer::SetCommissionableDataProvider(&gCommissionableDataProvider);

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider());

// Initialize device attestation verifier from a constant version
{
Expand Down
12 changes: 5 additions & 7 deletions examples/tv-casting-app/tv-casting-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ chip_data_model("tv-casting-common") {
"src/TargetVideoPlayerInfo.cpp",
]

deps = [
"${chip_root}/examples/platform/linux:app-main",
"${chip_root}/src/credentials:default_attestation_verifier",
"${chip_root}/src/lib",
"${chip_root}/third_party/inipp",
"${chip_root}/third_party/jsoncpp",
]
deps = [ "${chip_root}/third_party/jsoncpp" ]

if (chip_enable_transport_trace) {
public_deps = [ "${chip_root}/examples/common/tracing:trace_handlers" ]
}

public_configs = [ ":config" ]

Expand Down
29 changes: 13 additions & 16 deletions examples/tv-casting-app/tv-casting-common/include/CastingServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@
#include "TargetEndpointInfo.h"
#include "TargetVideoPlayerInfo.h"

using namespace chip;
using namespace chip::Controller;
using namespace chip::Credentials;
using namespace chip::app::Clusters::ContentLauncher::Commands;

constexpr System::Clock::Seconds16 kCommissioningWindowTimeout = System::Clock::Seconds16(3 * 60);
constexpr EndpointId kTvEndpoint = 1;
constexpr chip::System::Clock::Seconds16 kCommissioningWindowTimeout = chip::System::Clock::Seconds16(3 * 60);
constexpr chip::EndpointId kTvEndpoint = 1;

/**
* @brief Represents a TV Casting server that can get the casting app commissioned
Expand All @@ -48,7 +43,7 @@ class CastingServer
void InitServer();

CHIP_ERROR DiscoverCommissioners();
const Dnssd::DiscoveredNodeData * GetDiscoveredCommissioner(int index);
const chip::Dnssd::DiscoveredNodeData * GetDiscoveredCommissioner(int index);
CHIP_ERROR OpenBasicCommissioningWindow();
#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
CHIP_ERROR SendUserDirectedCommissioningRequest(chip::Transport::PeerAddress commissioner);
Expand All @@ -57,19 +52,21 @@ class CastingServer
CHIP_ERROR InitBindingHandlers();
TargetVideoPlayerInfo * GetTargetVideoPlayerInfo() { return &mTargetVideoPlayerInfo; }
CHIP_ERROR TargetVideoPlayerInfoInit(chip::NodeId nodeId, chip::FabricIndex fabricIndex);
void ReadServerClusters(EndpointId endpointId);
void ReadServerClusters(chip::EndpointId endpointId);
void ReadServerClustersForNode(chip::NodeId nodeId);
static void OnDescriptorReadSuccessResponse(void * context, const app::DataModel::DecodableList<ClusterId> & responseList);
static void OnDescriptorReadSuccessResponse(void * context,
const chip::app::DataModel::DecodableList<chip::ClusterId> & responseList);
static void OnDescriptorReadFailureResponse(void * context, CHIP_ERROR error);
CHIP_ERROR ContentLauncherLaunchURL(const char * contentUrl, const char * contentDisplayStr);
static void OnContentLauncherSuccessResponse(void * context, const LaunchResponse::DecodableType & response);
static void OnContentLauncherSuccessResponse(
void * context, const chip::app::Clusters::ContentLauncher::Commands::LaunchResponse::DecodableType & response);
static void OnContentLauncherFailureResponse(void * context, CHIP_ERROR error);
static void DeviceEventCallback(const DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
static void DeviceEventCallback(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);

NodeId GetVideoPlayerNodeForFabricIndex(FabricIndex fabricIndex);
FabricIndex GetVideoPlayerFabricIndexForNode(NodeId nodeId);
chip::NodeId GetVideoPlayerNodeForFabricIndex(chip::FabricIndex fabricIndex);
chip::FabricIndex GetVideoPlayerFabricIndexForNode(chip::NodeId nodeId);
void PrintBindings();
FabricIndex CurrentFabricIndex() { return mTargetVideoPlayerInfo.GetFabricIndex(); }
chip::FabricIndex CurrentFabricIndex() { return mTargetVideoPlayerInfo.GetFabricIndex(); }
void SetDefaultFabricIndex();

private:
Expand All @@ -78,5 +75,5 @@ class CastingServer

bool mInited = false;
TargetVideoPlayerInfo mTargetVideoPlayerInfo;
CommissionableNodeController mCommissionableNodeController;
chip::Controller::CommissionableNodeController mCommissionableNodeController;
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,21 @@

#include <platform/CHIPDeviceLayer.h>

using namespace chip;

class TargetEndpointInfo
{
public:
void Initialize(EndpointId endpointId);
void Initialize(chip::EndpointId endpointId);
void Reset() { mInitialized = false; }
bool IsInitialized() { return mInitialized; }
EndpointId GetEndpointId() const { return mEndpointId; }
chip::EndpointId GetEndpointId() const { return mEndpointId; }

bool HasCluster(ClusterId clusterId);
bool AddCluster(ClusterId clusterId);
bool HasCluster(chip::ClusterId clusterId);
bool AddCluster(chip::ClusterId clusterId);
void PrintInfo();

private:
static constexpr size_t kMaxNumberOfClustersPerEndpoint = 10;
ClusterId mClusters[kMaxNumberOfClustersPerEndpoint] = {};
EndpointId mEndpointId;
static constexpr size_t kMaxNumberOfClustersPerEndpoint = 10;
chip::ClusterId mClusters[kMaxNumberOfClustersPerEndpoint] = {};
chip::EndpointId mEndpointId;
bool mInitialized = false;
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include "app/clusters/bindings/BindingManager.h"
#include <platform/CHIPDeviceLayer.h>

using namespace chip;

class TargetVideoPlayerInfo
{
public:
Expand All @@ -32,39 +30,39 @@ class TargetVideoPlayerInfo
{}

bool IsInitialized() { return mInitialized; }
NodeId GetNodeId() const { return mNodeId; }
FabricIndex GetFabricIndex() const { return mFabricIndex; }
OperationalDeviceProxy * GetOperationalDeviceProxy() const { return mOperationalDeviceProxy; }
chip::NodeId GetNodeId() const { return mNodeId; }
chip::FabricIndex GetFabricIndex() const { return mFabricIndex; }
chip::OperationalDeviceProxy * GetOperationalDeviceProxy() const { return mOperationalDeviceProxy; }

CHIP_ERROR Initialize(NodeId nodeId, FabricIndex fabricIndex);
TargetEndpointInfo * GetOrAddEndpoint(EndpointId endpointId);
TargetEndpointInfo * GetEndpoint(EndpointId endpointId);
bool HasEndpoint(EndpointId endpointId);
CHIP_ERROR Initialize(chip::NodeId nodeId, chip::FabricIndex fabricIndex);
TargetEndpointInfo * GetOrAddEndpoint(chip::EndpointId endpointId);
TargetEndpointInfo * GetEndpoint(chip::EndpointId endpointId);
bool HasEndpoint(chip::EndpointId endpointId);
void PrintInfo();

private:
static void HandleDeviceConnected(void * context, OperationalDeviceProxy * device)
static void HandleDeviceConnected(void * context, chip::OperationalDeviceProxy * device)
{
TargetVideoPlayerInfo * _this = static_cast<TargetVideoPlayerInfo *>(context);
_this->mOperationalDeviceProxy = device;
_this->mInitialized = true;
ChipLogProgress(AppServer, "HandleDeviceConnected created an instance of OperationalDeviceProxy");
}

static void HandleDeviceConnectionFailure(void * context, PeerId peerId, CHIP_ERROR error)
static void HandleDeviceConnectionFailure(void * context, chip::PeerId peerId, CHIP_ERROR error)
{
TargetVideoPlayerInfo * _this = static_cast<TargetVideoPlayerInfo *>(context);
_this->mOperationalDeviceProxy = nullptr;
}

static constexpr size_t kMaxNumberOfEndpoints = 5;
TargetEndpointInfo mEndpoints[kMaxNumberOfEndpoints];
NodeId mNodeId;
FabricIndex mFabricIndex;
OperationalDeviceProxy * mOperationalDeviceProxy;
chip::NodeId mNodeId;
chip::FabricIndex mFabricIndex;
chip::OperationalDeviceProxy * mOperationalDeviceProxy;

Callback::Callback<OnDeviceConnected> mOnConnectedCallback;
Callback::Callback<OnDeviceConnectionFailure> mOnConnectionFailureCallback;
chip::Callback::Callback<chip::OnDeviceConnected> mOnConnectedCallback;
chip::Callback::Callback<chip::OnDeviceConnectionFailure> mOnConnectionFailureCallback;

bool mInitialized = false;
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@

#include "CastingServer.h"

using namespace chip;
using namespace chip::Controller;
using namespace chip::Credentials;
using namespace chip::app::Clusters::ContentLauncher::Commands;

CastingServer * CastingServer::castingServer_ = nullptr;

// TODO: Accept these values over CLI
Expand All @@ -39,7 +44,6 @@ void CastingServer::InitServer()
{
return;
}
DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().Init(CHIP_CONFIG_KVS_PATH);

// Enter commissioning mode, open commissioning window
static chip::CommonCaseDeviceServerInitParams initParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
#include "TargetEndpointInfo.h"

using namespace chip;

void TargetEndpointInfo::Initialize(EndpointId endpointId)
{
mEndpointId = endpointId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
#include "TargetVideoPlayerInfo.h"

using namespace chip;

CASEClientPool<CHIP_CONFIG_DEVICE_MAX_ACTIVE_CASE_CLIENTS> gCASEClientPool;

CHIP_ERROR TargetVideoPlayerInfo::Initialize(NodeId nodeId, FabricIndex fabricIndex)
Expand Down
4 changes: 1 addition & 3 deletions scripts/build/builders/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ def copyToExampleAndroid(self):
title='Prepare Native libs ' + self.identifier)

if self.app.ExampleName() == 'tv-casting-app':
libs = ['libCHIPController.so',
'libc++_shared.so', 'libTvCastingApp.so']
libs = ['libc++_shared.so', 'libTvCastingApp.so']
else:
libs = ['libSetupPayloadParser.so',
'libc++_shared.so', 'libTvApp.so']
Expand All @@ -202,7 +201,6 @@ def copyToExampleAndroid(self):
jars = {
'AndroidPlatform.jar': 'third_party/connectedhomeip/src/platform/android/AndroidPlatform.jar',
'CHIPAppServer.jar': 'third_party/connectedhomeip/src/app/server/java/CHIPAppServer.jar',
'CHIPController.jar': 'third_party/connectedhomeip/src/controller/java/CHIPController.jar',
'TvCastingApp.jar': 'TvCastingApp.jar',
}
else:
Expand Down
8 changes: 0 additions & 8 deletions scripts/build/testdata/build_all_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,6 @@ ninja -C {out}/android-arm-chip-tv-casting-app
# Prepare Native libs android-arm-chip-tv-casting-app
mkdir -p {root}/examples/tv-casting-app/android/App/app/libs/jniLibs/armeabi-v7a

cp {out}/android-arm-chip-tv-casting-app/lib/jni/armeabi-v7a/libCHIPController.so {root}/examples/tv-casting-app/android/App/app/libs/jniLibs/armeabi-v7a/libCHIPController.so

cp {out}/android-arm-chip-tv-casting-app/lib/jni/armeabi-v7a/libc++_shared.so {root}/examples/tv-casting-app/android/App/app/libs/jniLibs/armeabi-v7a/libc++_shared.so

cp {out}/android-arm-chip-tv-casting-app/lib/jni/armeabi-v7a/libTvCastingApp.so {root}/examples/tv-casting-app/android/App/app/libs/jniLibs/armeabi-v7a/libTvCastingApp.so
Expand All @@ -1031,8 +1029,6 @@ cp {out}/android-arm-chip-tv-casting-app/lib/third_party/connectedhomeip/src/pla

cp {out}/android-arm-chip-tv-casting-app/lib/third_party/connectedhomeip/src/app/server/java/CHIPAppServer.jar {root}/examples/tv-casting-app/android/App/app/libs/CHIPAppServer.jar

cp {out}/android-arm-chip-tv-casting-app/lib/third_party/connectedhomeip/src/controller/java/CHIPController.jar {root}/examples/tv-casting-app/android/App/app/libs/CHIPController.jar

cp {out}/android-arm-chip-tv-casting-app/lib/TvCastingApp.jar {root}/examples/tv-casting-app/android/App/app/libs/TvCastingApp.jar

# Building Example android-arm-chip-tv-casting-app
Expand Down Expand Up @@ -1112,8 +1108,6 @@ ninja -C {out}/android-arm64-chip-tv-casting-app
# Prepare Native libs android-arm64-chip-tv-casting-app
mkdir -p {root}/examples/tv-casting-app/android/App/app/libs/jniLibs/arm64-v8a

cp {out}/android-arm64-chip-tv-casting-app/lib/jni/arm64-v8a/libCHIPController.so {root}/examples/tv-casting-app/android/App/app/libs/jniLibs/arm64-v8a/libCHIPController.so

cp {out}/android-arm64-chip-tv-casting-app/lib/jni/arm64-v8a/libc++_shared.so {root}/examples/tv-casting-app/android/App/app/libs/jniLibs/arm64-v8a/libc++_shared.so

cp {out}/android-arm64-chip-tv-casting-app/lib/jni/arm64-v8a/libTvCastingApp.so {root}/examples/tv-casting-app/android/App/app/libs/jniLibs/arm64-v8a/libTvCastingApp.so
Expand All @@ -1122,8 +1116,6 @@ cp {out}/android-arm64-chip-tv-casting-app/lib/third_party/connectedhomeip/src/p

cp {out}/android-arm64-chip-tv-casting-app/lib/third_party/connectedhomeip/src/app/server/java/CHIPAppServer.jar {root}/examples/tv-casting-app/android/App/app/libs/CHIPAppServer.jar

cp {out}/android-arm64-chip-tv-casting-app/lib/third_party/connectedhomeip/src/controller/java/CHIPController.jar {root}/examples/tv-casting-app/android/App/app/libs/CHIPController.jar

cp {out}/android-arm64-chip-tv-casting-app/lib/TvCastingApp.jar {root}/examples/tv-casting-app/android/App/app/libs/TvCastingApp.jar

# Building Example android-arm64-chip-tv-casting-app
Expand Down

0 comments on commit c32475a

Please sign in to comment.