Skip to content

Commit

Permalink
RDK-53686 Analytics JsonRpc uses autogenerated API
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianM27 committed Oct 29, 2024
1 parent fac3716 commit f1a005f
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 219 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/L1-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ jobs:
run: >
cd "${{github.workspace}}/ThunderInterfaces"
&&
git apply "${{github.workspace}}/rdkservices/Tests/L1Tests/patches/0001-Add-IAnalytics-interface-R2.patch"
&&
cd ..
- name: Build ThunderInterfaces
Expand Down Expand Up @@ -296,8 +294,6 @@ jobs:
-DPLUGIN_TEXTTOSPEECH=ON
-DPLUGIN_SYSTEMAUDIOPLAYER=ON
-DPLUGIN_MIRACAST=ON
-DPLUGIN_ANALYTICS=ON
-DPLUGIN_ANALYTICS_SIFT_BACKEND=ON
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
&&
cmake --build build/rdkservices -j8
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/L2-tests-R4-4-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ jobs:
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/RDKV-48604-User-Settings-Thunder-Plugin.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/Use_Legact_Alt_In_ThunderInterfaces_Based_On_ThunderTools_R4.4.3.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/RDK-51362-System-Mode-Thunder-Plugin.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0001-Add-IAnalytics-interface-R4.4.patch
cd ..
- name: Build ThunderInterfaces
Expand Down Expand Up @@ -278,6 +279,8 @@ jobs:
-DPLUGIN_L2Tests=ON
-DRDK_SERVICE_L2_TEST=ON
-DDS_FOUND=ON
-DPLUGIN_ANALYTICS=ON
-DPLUGIN_ANALYTICS_SIFT_BACKEND=ON
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
&&
cmake --build build/rdkservices -j8
Expand Down
28 changes: 23 additions & 5 deletions Analytics/Analytics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,25 @@ namespace {
namespace Plugin {
SERVICE_REGISTRATION(Analytics, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH);

Analytics::Analytics(): mConnectionId(0), mAnalytics(nullptr)
{
SYSLOG(Logging::Startup, (_T("Analytics Constructor")));
}

Analytics::~Analytics()
{
SYSLOG(Logging::Shutdown, (string(_T("Analytics Destructor"))));
}

/* virtual */ const string Analytics::Initialize(PluginHost::IShell* service)
{
ASSERT(service != nullptr);
mService = service;

ASSERT(mAnalytics == nullptr);

SYSLOG(Logging::Startup, (_T("Analytics::Initialize: PID=%u"), getpid()));

mService = service;

mAnalytics = service->Root<Exchange::IAnalytics>(mConnectionId, 2000, _T("AnalyticsImplementation"));
ASSERT(mAnalytics != nullptr);

Expand All @@ -58,7 +70,12 @@ namespace Plugin {
configConnection->Configure(service);
configConnection->Release();
}
RegisterAll();
// Invoking Plugin API register to wpeframework
Exchange::JAnalytics::Register(*this, mAnalytics);
}
else
{
SYSLOG(Logging::Startup, (_T("Analytics::Initialize: Failed to initialise Analytics plugin")));
}
// On success return empty, to indicate there is no error text.
return ((mAnalytics != nullptr))
Expand All @@ -68,10 +85,11 @@ namespace Plugin {

/* virtual */ void Analytics::Deinitialize(PluginHost::IShell* service)
{
TRACE(Trace::Information, (_T("Analytics::Deinitialize")));
SYSLOG(Logging::Shutdown, (string(_T("Analytics::Deinitialize"))));
ASSERT(service == mService);

if (mAnalytics != nullptr) {
Exchange::JAnalytics::Unregister(*this);

RPC::IRemoteConnection *connection(service->RemoteConnection(mConnectionId));
VARIABLE_IS_NOT_USED uint32_t result = mAnalytics->Release();
Expand All @@ -93,12 +111,12 @@ namespace Plugin {
connection->Release();
}
}
SYSLOG(Logging::Shutdown, (string(_T("Analytics de-initialised"))));
}

void Analytics::Deactivated(RPC::IRemoteConnection* connection)
{
if (connection->Id() == mConnectionId) {
TRACE(Trace::Information, (_T("Analytics::Deactivated")));

ASSERT(mService != nullptr);

Expand Down
19 changes: 4 additions & 15 deletions Analytics/Analytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "Module.h"

#include <interfaces/IAnalytics.h>
#include <interfaces/json/JsonData_Analytics.h>
#include <interfaces/json/JAnalytics.h>

namespace WPEFramework {

Expand All @@ -47,16 +49,8 @@ namespace WPEFramework {
Analytics& operator=(const Analytics&) = delete;

public:
Analytics():
mConnectionId(0),
mAnalytics(nullptr)
{
RegisterAll();
}
virtual ~Analytics()
{
UnregisterAll();
}
Analytics();
virtual ~Analytics();
virtual const string Initialize(PluginHost::IShell* shell) override;
virtual void Deinitialize(PluginHost::IShell* service) override;
virtual string Information() const override { return {}; }
Expand All @@ -71,11 +65,6 @@ namespace WPEFramework {

private:
void Deactivated(RPC::IRemoteConnection* connection);
// JSONRPC methods
void RegisterAll();
void UnregisterAll();

uint32_t SendEventWrapper(const JsonObject& parameters, JsonObject& response);

private:
PluginHost::IShell* mService;
Expand Down
91 changes: 0 additions & 91 deletions Analytics/AnalyticsJsonRpc.cpp

This file was deleted.

5 changes: 0 additions & 5 deletions Analytics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ message("Setup ${MODULE_NAME} v${MODULE_VERSION}")
find_package(${NAMESPACE}Plugins REQUIRED)
find_package(${NAMESPACE}Definitions REQUIRED)
find_package(CompileSettingsDebug CONFIG REQUIRED)
find_package(DS)
find_package(IARMBus)

add_library(${MODULE_NAME} SHARED
Analytics.cpp
AnalyticsJsonRpc.cpp
Implementation/AnalyticsImplementation.cpp
Module.cpp)

Expand All @@ -87,8 +84,6 @@ target_link_libraries(${MODULE_NAME}
CompileSettingsDebug::CompileSettingsDebug
${NAMESPACE}Plugins::${NAMESPACE}Plugins
${NAMESPACE}Definitions::${NAMESPACE}Definitions
${DS_LIBRARIES}
${IARMBUS_LIBRARIES}
${MODULE_NAME}Backends
${MODULE_NAME}SystemTime)

Expand Down
27 changes: 27 additions & 0 deletions Analytics/Implementation/AnalyticsImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,33 @@ namespace Plugin {
LOGINFO("Uptime Timestamp: %" PRIu64, uptimeTimestamp);
LOGINFO("Event Payload: %s", eventPayload.c_str());

bool valid = true;
if (eventName.empty())
{
LOGERR("eventName is empty");
valid = false;
}
if (eventSource.empty())
{
LOGERR("eventSource is empty");
valid = false;
}
if (eventSourceVersion.empty())
{
LOGERR("eventSourceVersion is empty");
valid = false;
}
if (eventPayload.empty())
{
LOGERR("eventPayload is empty");
valid = false;
}

if (valid == false)
{
return Core::ERROR_GENERAL;
}

// Fill the uptime if no time provided
if (event->epochTimestamp == 0 && event->uptimeTimestamp == 0)
{
Expand Down
3 changes: 0 additions & 3 deletions Tests/L1Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ include_directories(../../LocationSync
../../Miracast/MiracastService/P2P
../../Miracast/MiracastPlayer
../../Miracast/MiracastPlayer/RTSP
../../Analytics
)
link_directories(../../LocationSync
../../SecurityAgent
Expand Down Expand Up @@ -142,7 +141,6 @@ link_directories(../../LocationSync
../../TextToSpeech
../../SystemAudioPlayer
../../Miracast
../../Analytics
)

target_link_libraries(${PROJECT_NAME}
Expand Down Expand Up @@ -187,7 +185,6 @@ target_link_libraries(${PROJECT_NAME}
${NAMESPACE}SystemAudioPlayer
${NAMESPACE}MiracastService
${NAMESPACE}MiracastPlayer
${NAMESPACE}Analytics
)

target_include_directories(${PROJECT_NAME}
Expand Down
59 changes: 0 additions & 59 deletions Tests/L1Tests/patches/0001-Add-IAnalytics-interface-R2.patch

This file was deleted.

Loading

0 comments on commit f1a005f

Please sign in to comment.