Skip to content

Commit a1d4d87

Browse files
RDK-56621: Update all the power manager plugin clients to new register events
1 parent 9d73332 commit a1d4d87

File tree

7 files changed

+56
-24
lines changed

7 files changed

+56
-24
lines changed

HdcpProfile/HdcpProfile.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ namespace WPEFramework
117117
{
118118
_powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager"))
119119
.withIShell(service)
120+
.withRetry(25)
120121
.createInterface();
121122
}
122123

HdmiCecSink/HdmiCecSink.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ namespace WPEFramework
901901
{
902902
_powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager"))
903903
.withIShell(service)
904+
.withRetry(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 INTERFACE>
607+
T* baseInterface()
608+
{
609+
static_assert(std::is_base_of<T, Notification>(), "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/HdmiCecSource.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ namespace WPEFramework
519519

520520
if(!_registeredEventHandlers && _powerManagerPlugin) {
521521
_registeredEventHandlers = true;
522-
_powerManagerPlugin->Register(&_pwrMgrNotification);
522+
_powerManagerPlugin->Register(_pwrMgrNotification.baseInterface<Exchange::IPowerManager::IModeChangedNotification>());
523523
}
524524
}
525525

@@ -721,6 +721,7 @@ namespace WPEFramework
721721
LOGINFO("Connect the COM-RPC socket\n");
722722
_powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager"))
723723
.withIShell(service)
724+
.withRetry(25)
724725
.createInterface();
725726
registerEventHandlers();
726727
}

HdmiCecSource/HdmiCecSource.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ namespace WPEFramework {
229229
END_INTERFACE_MAP
230230

231231
private:
232-
class PowerManagerNotification : public Exchange::IPowerManager::INotification {
232+
class PowerManagerNotification : public Exchange::IPowerManager::IModeChangedNotification {
233233
private:
234234
PowerManagerNotification(const PowerManagerNotification&) = delete;
235235
PowerManagerNotification& operator=(const PowerManagerNotification&) = delete;
@@ -246,14 +246,16 @@ namespace WPEFramework {
246246
{
247247
_parent.onPowerModeChanged(currentState, newState);
248248
}
249-
void OnPowerModePreChange(const PowerState &currentState, const PowerState &newState) override {}
250-
void OnDeepSleepTimeout(const int &wakeupTimeout) override {}
251-
void OnNetworkStandbyModeChanged(const bool &enabled) override {}
252-
void OnThermalModeChanged(const ThermalTemperature &currentThermalLevel, const ThermalTemperature &newThermalLevel, const float &currentTemperature) override {}
253-
void OnRebootBegin(const string &rebootReasonCustom, const string &rebootReasonOther, const string &rebootRequestor) override {}
249+
250+
template <typename INTERFACE>
251+
T* baseInterface()
252+
{
253+
static_assert(std::is_base_of<T, Notification>(), "base type mismatch");
254+
return static_cast<T*>(this);
255+
}
254256

255257
BEGIN_INTERFACE_MAP(PowerManagerNotification)
256-
INTERFACE_ENTRY(Exchange::IPowerManager::INotification)
258+
INTERFACE_ENTRY(Exchange::IPowerManager::IModeChangedNotification)
257259
END_INTERFACE_MAP
258260

259261
private:

helpers/PluginInterfaceBuilder.h

100644100755
Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,29 @@ 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+
int count = 0;
105+
103106
if (!controller) {
104107
LOGERR("Invalid controller");
105108
return nullptr;
106109
}
107110

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

110-
if (pluginInterface) {
111-
pluginInterface->AddRef();
112-
}
114+
if (pluginInterface) {
115+
pluginInterface->AddRef();
116+
return pluginInterface;
117+
}
118+
else
119+
{
120+
count++;
121+
usleep(200*1000);
122+
}
123+
}while(count < retry_count);
113124

114-
return pluginInterface;
125+
return nullptr;
115126
}
116127

117128
template <typename T, typename... Args>
@@ -127,13 +138,15 @@ namespace Plugin {
127138
PluginHost::IShell* _service;
128139
uint32_t _version;
129140
uint32_t _timeout;
141+
int _retry_count;
130142

131143
public:
132144
PluginInterfaceBuilder(const char* callsign)
133145
: _callsign(callsign)
134146
, _service(nullptr)
135147
, _version(static_cast<uint32_t>(~0))
136148
, _timeout(3000)
149+
,_retry_count(0)
137150
{
138151
}
139152

@@ -158,6 +171,12 @@ namespace Plugin {
158171
return *this;
159172
}
160173

174+
inline PluginInterfaceBuilder& withRetry(int retryCount)
175+
{
176+
_retry_count = retryCount;
177+
return *this;
178+
}
179+
161180
PluginInterfaceRef<INTERFACE> createInterface()
162181
{
163182
auto* interface = ::WPEFramework::Plugin::createInterface<INTERFACE>(*this);
@@ -170,6 +189,11 @@ namespace Plugin {
170189
return std::move(PluginInterfaceRef<INTERFACE>(interface, _service));
171190
}
172191

192+
const int retryCount() const
193+
{
194+
return _callsign;
195+
}
196+
173197
const std::string& callSign() const
174198
{
175199
return _callsign;

helpers/frontpanel.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ namespace WPEFramework
135135
{
136136
_powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager"))
137137
.withIShell(service)
138+
.withRetry(25)
138139
.createInterface();
139140
}
140141
if (!s_instance)

0 commit comments

Comments
 (0)