Skip to content

Commit ddd2ea2

Browse files
RDK-56621: Update all the power manager plugin clients to new register events (#17)
* RDK-56621: Update all the power manager plugin clients to new register events * Assign retry interval from client plugins * Change the baseinterface typename * Added debug print to get retry count * Update the HDMICEC to use Power Manager Plugin * Revert "Update the HDMICEC to use Power Manager Plugin" This reverts commit d295d38. * Reapply "Update the HDMICEC to use Power Manager Plugin" This reverts commit 99f121c. * Moved the powerManager instance changes to impl --------- Co-authored-by: skamath <[email protected]>
1 parent 9ad5e3a commit ddd2ea2

File tree

8 files changed

+78
-28
lines changed

8 files changed

+78
-28
lines changed

HdcpProfile/HdcpProfile.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ namespace WPEFramework
117117
{
118118
_powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager"))
119119
.withIShell(service)
120+
.withRetryIntervalMS(200)
121+
.withRetryCount(25)
120122
.createInterface();
121123
}
122124

HdmiCecSink/HdmiCecSink.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "ccec/CECFrame.hpp"
2424
#include "ccec/MessageEncoder.hpp"
2525
#include "host.hpp"
26-
#include "ccec/host/RDK.hpp"
2726
#include "UtilsgetRFCConfig.h"
2827

2928
#include "dsMgr.h"
@@ -901,6 +900,8 @@ namespace WPEFramework
901900
{
902901
_powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager"))
903902
.withIShell(service)
903+
.withRetryIntervalMS(200)
904+
.withRetryCount(25)
904905
.createInterface();
905906
registerEventHandlers();
906907
}
@@ -910,7 +911,7 @@ namespace WPEFramework
910911

911912
if(!_registeredEventHandlers && _powerManagerPlugin) {
912913
_registeredEventHandlers = true;
913-
_powerManagerPlugin->Register(&_pwrMgrNotification);
914+
_powerManagerPlugin->Register(_pwrMgrNotification.baseInterface<Exchange::IPowerManager::IModeChangedNotification>());
914915
}
915916
}
916917

HdmiCecSink/HdmiCecSink.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -585,33 +585,35 @@ namespace WPEFramework {
585585
END_INTERFACE_MAP
586586

587587
private:
588-
class PowerManagerNotification : public Exchange::IPowerManager::INotification {
588+
class PowerManagerNotification : public Exchange::IPowerManager::IModeChangedNotification {
589589
private:
590590
PowerManagerNotification(const PowerManagerNotification&) = delete;
591591
PowerManagerNotification& operator=(const PowerManagerNotification&) = delete;
592-
592+
593593
public:
594594
explicit PowerManagerNotification(HdmiCecSink& parent)
595595
: _parent(parent)
596596
{
597597
}
598598
~PowerManagerNotification() override = default;
599-
599+
600600
public:
601601
void OnPowerModeChanged(const PowerState &currentState, const PowerState &newState) override
602602
{
603603
_parent.onPowerModeChanged(currentState, newState);
604604
}
605-
void OnPowerModePreChange(const PowerState &currentState, const PowerState &newState) override {}
606-
void OnDeepSleepTimeout(const int &wakeupTimeout) override {}
607-
void OnNetworkStandbyModeChanged(const bool &enabled) override {}
608-
void OnThermalModeChanged(const ThermalTemperature &currentThermalLevel, const ThermalTemperature &newThermalLevel, const float &currentTemperature) override {}
609-
void OnRebootBegin(const string &rebootReasonCustom, const string &rebootReasonOther, const string &rebootRequestor) override {}
605+
606+
template <typename T>
607+
T* baseInterface()
608+
{
609+
static_assert(std::is_base_of<T, PowerManagerNotification>(), "base type mismatch");
610+
return static_cast<T*>(this);
611+
}
610612

611613
BEGIN_INTERFACE_MAP(PowerManagerNotification)
612-
INTERFACE_ENTRY(Exchange::IPowerManager::INotification)
614+
INTERFACE_ENTRY(Exchange::IPowerManager::IModeChangedNotification)
613615
END_INTERFACE_MAP
614-
616+
615617
private:
616618
HdmiCecSink& _parent;
617619
};

HdmiCecSource/HdmiCecSourceImplementation.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ namespace WPEFramework
474474

475475
if(!_registeredEventHandlers && _powerManagerPlugin) {
476476
_registeredEventHandlers = true;
477-
_powerManagerPlugin->Register(&_pwrMgrNotification);
477+
_powerManagerPlugin->Register(_pwrMgrNotification.baseInterface<Exchange::IPowerManager::IModeChangedNotification>());
478478
}
479479

480480

@@ -725,6 +725,8 @@ namespace WPEFramework
725725
LOGINFO("Connect the COM-RPC socket\n");
726726
_powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager"))
727727
.withIShell(service)
728+
.withRetryIntervalMS(200)
729+
.withRetryCount(25)
728730
.createInterface();
729731
registerEventHandlers();
730732
}

HdmiCecSource/HdmiCecSourceImplementation.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ namespace WPEFramework {
226226

227227

228228
private:
229-
class PowerManagerNotification : public Exchange::IPowerManager::INotification {
229+
class PowerManagerNotification : public Exchange::IPowerManager::IModeChangedNotification {
230230
private:
231231
PowerManagerNotification(const PowerManagerNotification&) = delete;
232232
PowerManagerNotification& operator=(const PowerManagerNotification&) = delete;
@@ -243,14 +243,16 @@ namespace WPEFramework {
243243
{
244244
_parent.onPowerModeChanged(currentState, newState);
245245
}
246-
void OnPowerModePreChange(const PowerState &currentState, const PowerState &newState) override {}
247-
void OnDeepSleepTimeout(const int &wakeupTimeout) override {}
248-
void OnNetworkStandbyModeChanged(const bool &enabled) override {}
249-
void OnThermalModeChanged(const ThermalTemperature &currentThermalLevel, const ThermalTemperature &newThermalLevel, const float &currentTemperature) override {}
250-
void OnRebootBegin(const string &rebootReasonCustom, const string &rebootReasonOther, const string &rebootRequestor) override {}
251-
246+
247+
template <typename T>
248+
T* baseInterface()
249+
{
250+
static_assert(std::is_base_of<T, PowerManagerNotification>(), "base type mismatch");
251+
return static_cast<T*>(this);
252+
}
253+
252254
BEGIN_INTERFACE_MAP(PowerManagerNotification)
253-
INTERFACE_ENTRY(Exchange::IPowerManager::INotification)
255+
INTERFACE_ENTRY(Exchange::IPowerManager::IModeChangedNotification)
254256
END_INTERFACE_MAP
255257

256258
private:

cmake/FindCEC.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@ find_library(OSAL_LIBRARIES NAMES RCECOSHal)
3131

3232
find_path(CEC_INCLUDE_DIRS NAMES ccec/Connection.hpp PATH_SUFFIXES ccec/include)
3333
find_path(OSAL_INCLUDE_DIRS NAMES osal/Mutex.hpp PATH_SUFFIXES osal/include)
34-
find_path(CEC_HOST_INCLUDE_DIRS NAMES ccec/host/RDK.hpp PATH_SUFFIXES host/include)
3534

3635
set(CEC_LIBRARIES "-Wl,--no-as-needed" ${CEC_LIBRARIES} ${CEC_HAL_LIBRARIES} ${OSAL_LIBRARIES} "-Wl,--as-needed")
3736

3837
set(CEC_LIBRARIES ${CEC_LIBRARIES} CACHE PATH "Path to CEC library")
3938

40-
set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} ${OSAL_INCLUDE_DIRS} ${CEC_HOST_INCLUDE_DIRS})
39+
set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} ${OSAL_INCLUDE_DIRS})
4140
set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} CACHE PATH "Path to CEC include")
4241

4342
include(FindPackageHandleStandardArgs)

helpers/PluginInterfaceBuilder.h

100644100755
Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,32 @@ namespace Plugin {
100100
{
101101
WPEFramework::PluginHost::IShell* controller = builder.controller();
102102
const std::string& callsign = builder.callSign();
103+
const int retry_count = builder.retryCount();
104+
const uint32_t retry_interval = builder.retryInterval();
105+
int count = 0;
106+
103107
if (!controller) {
104108
LOGERR("Invalid controller");
105109
return nullptr;
106110
}
107111

108-
auto pluginInterface = controller->QueryInterfaceByCallsign<INTERFACE>(callsign.c_str());
112+
do {
113+
auto pluginInterface = controller->QueryInterfaceByCallsign<INTERFACE>(callsign.c_str());
109114

110-
if (pluginInterface) {
111-
pluginInterface->AddRef();
112-
}
115+
if (pluginInterface) {
116+
pluginInterface->AddRef();
117+
LOGINFO("plugin interface succeed and retry count: %d",count);
118+
return pluginInterface;
119+
}
120+
else
121+
{
122+
count++;
123+
LOGERR("plugin interface failed and retry: %d",count);
124+
usleep(retry_interval*1000);
125+
}
126+
}while(count < retry_count);
113127

114-
return pluginInterface;
128+
return nullptr;
115129
}
116130

117131
template <typename T, typename... Args>
@@ -127,13 +141,17 @@ namespace Plugin {
127141
PluginHost::IShell* _service;
128142
uint32_t _version;
129143
uint32_t _timeout;
144+
int _retry_count;
145+
uint32_t _retry_interval;
130146

131147
public:
132148
PluginInterfaceBuilder(const char* callsign)
133149
: _callsign(callsign)
134150
, _service(nullptr)
135151
, _version(static_cast<uint32_t>(~0))
136152
, _timeout(3000)
153+
,_retry_count(0)
154+
,_retry_interval(0)
137155
{
138156
}
139157

@@ -158,6 +176,18 @@ namespace Plugin {
158176
return *this;
159177
}
160178

179+
inline PluginInterfaceBuilder& withRetryIntervalMS(int retryInterval)
180+
{
181+
_retry_interval = retryInterval;
182+
return *this;
183+
}
184+
185+
inline PluginInterfaceBuilder& withRetryCount(int retryCount)
186+
{
187+
_retry_count = retryCount;
188+
return *this;
189+
}
190+
161191
PluginInterfaceRef<INTERFACE> createInterface()
162192
{
163193
auto* interface = ::WPEFramework::Plugin::createInterface<INTERFACE>(*this);
@@ -170,6 +200,16 @@ namespace Plugin {
170200
return std::move(PluginInterfaceRef<INTERFACE>(interface, _service));
171201
}
172202

203+
const uint32_t retryInterval() const
204+
{
205+
return _retry_interval;
206+
}
207+
208+
const int retryCount() const
209+
{
210+
return _retry_count;
211+
}
212+
173213
const std::string& callSign() const
174214
{
175215
return _callsign;

helpers/frontpanel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ namespace WPEFramework
135135
{
136136
_powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager"))
137137
.withIShell(service)
138+
.withRetryIntervalMS(200)
139+
.withRetryCount(25)
138140
.createInterface();
139141
}
140142
if (!s_instance)

0 commit comments

Comments
 (0)