-
Notifications
You must be signed in to change notification settings - Fork 2
RDKEMW-14517: Use IARM for PowerManager clients #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| #include "frontPanelTextDisplay.hpp" | ||
|
|
||
| #include "libIBus.h" | ||
| #include "rdk/iarmmgrs-hal/pwrMgr.h" | ||
|
|
||
| #include "UtilsJsonRpc.h" | ||
| #include "UtilsIarm.h" | ||
|
|
@@ -66,9 +67,6 @@ | |
| #define API_VERSION_NUMBER_MINOR 0 | ||
| #define API_VERSION_NUMBER_PATCH 6 | ||
|
|
||
| using PowerState = WPEFramework::Exchange::IPowerManager::PowerState; | ||
|
|
||
|
|
||
| namespace | ||
| { | ||
|
|
||
|
|
@@ -179,8 +177,6 @@ namespace WPEFramework | |
| : PluginHost::JSONRPC() | ||
| , m_updateTimer(this) | ||
| , m_runUpdateTimer(false) | ||
| , _pwrMgrNotification(*this) | ||
| , _registeredEventHandlers(false) | ||
| { | ||
| FrontPanel::_instance = this; | ||
| m_runUpdateTimer = false; | ||
|
|
@@ -204,20 +200,12 @@ namespace WPEFramework | |
|
|
||
| FrontPanel::~FrontPanel() | ||
| { | ||
| if (_powerManagerPlugin) { | ||
| _powerManagerPlugin->Unregister(_pwrMgrNotification.baseInterface<Exchange::IPowerManager::IModeChangedNotification>()); | ||
| _powerManagerPlugin.Reset(); | ||
| } | ||
|
|
||
| _registeredEventHandlers = false; | ||
| } | ||
|
|
||
| const string FrontPanel::Initialize(PluginHost::IShell *service) | ||
| const string FrontPanel::Initialize(PluginHost::IShell * /* service */) | ||
| { | ||
| InitializePowerManager(service); | ||
| FrontPanel::_instance = this; | ||
| CFrontPanel::instance(service); | ||
| CFrontPanel::instance()->start(); | ||
| InitializeIARM(); | ||
| CFrontPanel::instance()->start(); | ||
| CFrontPanel::instance()->addEventObserver(this); | ||
| loadPreferences(); | ||
|
|
||
|
|
@@ -233,41 +221,46 @@ namespace WPEFramework | |
| m_runUpdateTimer = false; | ||
| } | ||
| patternUpdateTimer.Revoke(m_updateTimer); | ||
| } | ||
|
|
||
| void FrontPanel::InitializePowerManager(PluginHost::IShell *service) | ||
| { | ||
| _powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager")) | ||
| .withIShell(service) | ||
| .withRetryIntervalMS(200) | ||
| .withRetryCount(25) | ||
| .createInterface(); | ||
| registerEventHandlers(); | ||
| DeinitializeIARM(); | ||
| } | ||
| void FrontPanel::powerModeChange(const char *owner, IARM_EventId_t eventId, void *data, size_t len) | ||
| { | ||
| if (strcmp(owner, IARM_BUS_PWRMGR_NAME) == 0) { | ||
| if (eventId == IARM_BUS_PWRMGR_EVENT_MODECHANGED ) { | ||
| IARM_Bus_PWRMgr_EventData_t *param = (IARM_Bus_PWRMgr_EventData_t *)data; | ||
| LOGINFO("Event IARM_BUS_PWRMGR_EVENT_MODECHANGED: State Changed %d -- > %d\r", | ||
| param->data.state.curState, param->data.state.newState); | ||
| if(param->data.state.newState == IARM_BUS_PWRMGR_POWERSTATE_ON) | ||
| { | ||
| LOGINFO("setPowerStatus true"); | ||
| CFrontPanel::instance()->setPowerStatus(true); | ||
| } | ||
| else | ||
| { | ||
| LOGINFO("setPowerStatus false"); | ||
| CFrontPanel::instance()->setPowerStatus(false); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void FrontPanel::onPowerModeChanged(const PowerState currentState, const PowerState newState) | ||
| void FrontPanel::InitializeIARM() | ||
| { | ||
| if(newState == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON) | ||
| { | ||
| LOGINFO("setPowerStatus true"); | ||
| CFrontPanel::instance()->setPowerStatus(true); | ||
| } | ||
| else | ||
| if (Utils::IARM::init()) | ||
| { | ||
| LOGINFO("setPowerStatus false"); | ||
| CFrontPanel::instance()->setPowerStatus(false); | ||
| IARM_Result_t res; | ||
| IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_PWRMGR_NAME,IARM_BUS_PWRMGR_EVENT_MODECHANGED, powerModeChange) ); | ||
|
Comment on lines
+252
to
+253
|
||
| } | ||
| return; | ||
| } | ||
|
|
||
| void FrontPanel::registerEventHandlers() | ||
| void FrontPanel::DeinitializeIARM() | ||
| { | ||
| ASSERT (_powerManagerPlugin); | ||
|
|
||
| if(!_registeredEventHandlers && _powerManagerPlugin) { | ||
| _registeredEventHandlers = true; | ||
| _powerManagerPlugin->Register(_pwrMgrNotification.baseInterface<Exchange::IPowerManager::IModeChangedNotification>()); | ||
| } | ||
| if (Utils::IARM::isConnected()) | ||
| { | ||
| IARM_Result_t res; | ||
| IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_PWRMGR_NAME,IARM_BUS_PWRMGR_EVENT_MODECHANGED, powerModeChange) ); | ||
|
Comment on lines
+261
to
+262
|
||
| } | ||
| } | ||
|
|
||
| void setResponseArray(JsonObject& response, const char* key, const std::vector<std::string>& items) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -41,16 +41,12 @@ | |||||||||||
|
|
||||||||||||
| #if defined(HAS_API_POWERSTATE) | ||||||||||||
| #include "libIBus.h" | ||||||||||||
| #include <interfaces/IPowerManager.h> | ||||||||||||
|
|
||||||||||||
| using namespace WPEFramework; | ||||||||||||
| using PowerState = WPEFramework::Exchange::IPowerManager::PowerState; | ||||||||||||
| #include "pwrMgr.h" | ||||||||||||
| #endif | ||||||||||||
|
|
||||||||||||
| #include "UtilsJsonRpc.h" | ||||||||||||
| #include "UtilsLogging.h" | ||||||||||||
| #include "UtilssyncPersistFile.h" | ||||||||||||
| #include "PowerManagerInterface.h" | ||||||||||||
| #include "UtilsSearchRDKProfile.h" | ||||||||||||
|
|
||||||||||||
| #define FP_SETTINGS_FILE_JSON "/opt/fp_service_preferences.json" | ||||||||||||
|
|
@@ -85,7 +81,6 @@ namespace WPEFramework | |||||||||||
| static int m_currentBlinkListIndex = 0; | ||||||||||||
| static std::vector<std::string> m_lights; | ||||||||||||
| static device::List <device::FrontPanelIndicator> fpIndicators; | ||||||||||||
| static PowerManagerInterfaceRef _powerManagerPlugin; | ||||||||||||
|
|
||||||||||||
| static Core::TimerType<BlinkInfo> blinkTimer(64 * 1024, "BlinkTimer"); | ||||||||||||
|
|
||||||||||||
|
|
@@ -128,18 +123,10 @@ namespace WPEFramework | |||||||||||
| { | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| CFrontPanel* CFrontPanel::instance(PluginHost::IShell *service) | ||||||||||||
| CFrontPanel* CFrontPanel::instance() | ||||||||||||
| { | ||||||||||||
| if (!initDone) | ||||||||||||
| { | ||||||||||||
| if (nullptr != service) | ||||||||||||
| { | ||||||||||||
| _powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager")) | ||||||||||||
| .withIShell(service) | ||||||||||||
| .withRetryIntervalMS(200) | ||||||||||||
| .withRetryCount(25) | ||||||||||||
| .createInterface(); | ||||||||||||
| } | ||||||||||||
| if (!s_instance) | ||||||||||||
| s_instance = new CFrontPanel; | ||||||||||||
| #ifdef USE_DS | ||||||||||||
|
|
@@ -161,18 +148,13 @@ namespace WPEFramework | |||||||||||
|
|
||||||||||||
| #if defined(HAS_API_POWERSTATE) | ||||||||||||
| { | ||||||||||||
| Core::hresult res = Core::ERROR_GENERAL; | ||||||||||||
| PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; | ||||||||||||
| PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; | ||||||||||||
| ASSERT (_powerManagerPlugin); | ||||||||||||
| if (_powerManagerPlugin) { | ||||||||||||
| res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev); | ||||||||||||
| if (Core::ERROR_NONE == res) | ||||||||||||
| { | ||||||||||||
| if (pwrStateCur == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON) | ||||||||||||
| powerStatus = true; | ||||||||||||
| } | ||||||||||||
| LOGINFO("pwrStateCur[%d] pwrStatePrev[%d] powerStatus[%d]", pwrStateCur, pwrStatePrev, powerStatus); | ||||||||||||
| IARM_Bus_PWRMgr_GetPowerState_Param_t param; | ||||||||||||
| IARM_Result_t res = IARM_Bus_Call(IARM_BUS_PWRMGR_NAME, IARM_BUS_PWRMGR_API_GetPowerState, | ||||||||||||
| (void*)¶m, sizeof(param)); | ||||||||||||
|
|
||||||||||||
| if (res == IARM_RESULT_SUCCESS) { | ||||||||||||
| if (param.curState == IARM_BUS_PWRMGR_POWERSTATE_ON) | ||||||||||||
| powerStatus = true; | ||||||||||||
|
||||||||||||
| powerStatus = true; | |
| powerStatus = true; | |
| } else { | |
| LOGERR("IARM_Bus_Call(%s, %s) failed with result %d; leaving powerStatus as %d", | |
| IARM_BUS_PWRMGR_NAME, IARM_BUS_PWRMGR_API_GetPowerState, res, powerStatus); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logging format string contains '\r' (carriage return) which is inconsistent with other LOGINFO statements in the codebase. Line 275 uses '\n' (newline) instead. For consistency, this should use '\n' or no line ending at all, as LOGINFO likely adds its own line termination.