| From fe935ab613cabd6a7e2d77f6918e4404c0e85e74 Mon Sep 17 00:00:00 2001 |
| From: Balaji Punnuru <balaji_punnuru@cable.comcast.com> |
| Date: Fri, 4 Dec 2020 17:17:48 +0000 |
| Subject: [PATCH] Added Support for querying and publishing the Secure Timer |
| Status. |
| |
| Signed-off-by: Balaji Punnuru <balaji_punnuru@cable.comcast.com> |
| --- |
| SystemServices/SystemServices.cpp | 63 +++++++++++++++++++++++++++++++ |
| SystemServices/SystemServices.h | 11 ++++++ |
| broadcom.cmake | 4 ++ |
| realtek.cmake | 4 ++ |
| 4 files changed, 82 insertions(+) |
| |
| diff --git a/SystemServices/SystemServices.cpp b/SystemServices/SystemServices.cpp |
| index 719619e6..837d9623 100644 |
| --- a/SystemServices/SystemServices.cpp |
| +++ b/SystemServices/SystemServices.cpp |
| @@ -41,6 +41,10 @@ |
| #include "UtilsIarm.h" |
| #endif /* USE_IARMBUS || USE_IARM_BUS */ |
| |
| +#ifdef ENABLE_SYSTIMEMGR_SUPPORT |
| +#include "systimerifc/itimermsg.h" |
| +#endif// ENABLE_SYSTIMEMGR_SUPPORT |
| + |
| #ifdef ENABLE_THERMAL_PROTECTION |
| #include "thermonitor.h" |
| #endif /* ENABLE_THERMAL_PROTECTION */ |
| @@ -329,6 +333,10 @@ namespace WPEFramework { |
| void _thermMgrEventsHandler(const char *owner, IARM_EventId_t eventId, |
| void *data, size_t len); |
| #endif /* ENABLE_THERMAL_PROTECTION */ |
| +#ifdef ENABLE_SYSTIMEMGR_SUPPORT |
| + void _timerStatusEventHandler(const char *owner, IARM_EventId_t eventId, |
| + void *data, size_t len); |
| +#endif// ENABLE_SYSTIMEMGR_SUPPORT |
| |
| #if defined(USE_IARMBUS) || defined(USE_IARM_BUS) |
| static IARM_Result_t _SysModeChange(void *arg); |
| @@ -394,6 +402,9 @@ namespace WPEFramework { |
| registerMethod("setPowerState", &SystemServices::setDevicePowerState, |
| this); |
| #endif /* HAS_API_SYSTEM && HAS_API_POWERSTATE */ |
| +#ifdef ENABLE_SYSTIMEMGR_SUPPORT |
| + registerMethod("getTimeStatus", &SystemServices::getSystemTimeStatus,this); |
| +#endif// ENABLE_SYSTIMEMGR_SUPPORT |
| registerMethod("setGzEnabled", &SystemServices::setGZEnabled, this); |
| registerMethod("isGzEnabled", &SystemServices::isGZEnabled, this); |
| registerMethod("getMode", &SystemServices::getMode, this); |
| @@ -579,6 +590,9 @@ namespace WPEFramework { |
| #ifdef ENABLE_THERMAL_PROTECTION |
| IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_PWRMGR_NAME, IARM_BUS_PWRMGR_EVENT_THERMAL_MODECHANGED, _thermMgrEventsHandler)); |
| #endif //ENABLE_THERMAL_PROTECTION |
| +#ifdef ENABLE_SYSTIMEMGR_SUPPORT |
| + IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_SYSTIME_MGR_NAME, cTIMER_STATUS_UPDATE, _timerStatusEventHandler)); |
| +#endif// ENABLE_SYSTIMEMGR_SUPPORT |
| } |
| |
| RFC_ParamData_t param = {0}; |
| @@ -1899,6 +1913,18 @@ namespace WPEFramework { |
| |
| #endif |
| |
| +#ifdef ENABLE_SYSTIMEMGR_SUPPORT |
| + void SystemServices::onTimeStatusChanged(string timequality,string timesource, string utctime) |
| + { |
| + JsonObject params; |
| + params["TimeQuality"] = timequality; |
| + params["TimeSrc"] = timesource; |
| + params["Time"] = utctime; |
| + LOGWARN("TimeQuality = %s TimeSrc = %s Time = %s\n",timequality.c_str(),timesource.c_str(),utctime.c_str()); |
| + sendNotify(EVT_ONTIMESTATUSCHANGED, params); |
| + } |
| +#endif// ENABLE_SYSTIMEMGR_SUPPORT |
| + |
| /*** |
| * @brief Returns an array of strings containing the supported standby modes. |
| * Possible values are "LIGHT_SLEEP" and/or "DEEP_SLEEP". |
| @@ -3599,6 +3625,24 @@ namespace WPEFramework { |
| returnResponse(( E_OK == retVal)? true: false); |
| }//end of getStateInfo |
| |
| +#ifdef ENABLE_SYSTIMEMGR_SUPPORT |
| + uint32_t SystemServices::getSystemTimeStatus(const JsonObject& parameters, |
| + JsonObject& response) |
| + { |
| + IARM_Result_t ret = IARM_RESULT_SUCCESS; |
| + TimerMsg param; |
| + ret = IARM_Bus_Call(IARM_BUS_SYSTIME_MGR_NAME, TIMER_STATUS_MSG, (void*)¶m, sizeof(param)); |
| + if (ret != IARM_RESULT_SUCCESS ) { |
| + LOGWARN ("Query to get Timer Status Failed..\n"); |
| + returnResponse(false); |
| + } |
| + |
| + response["TimeQuality"] = std::string(param.message,cTIMER_STATUS_MESSAGE_LENGTH); |
| + response["TimeSrc"] = std::string(param.timerSrc,cTIMER_STATUS_MESSAGE_LENGTH); |
| + response["Time"] = std::string(param.currentTime,cTIMER_STATUS_MESSAGE_LENGTH); |
| + returnResponse(true); |
| + } |
| +#endif// ENABLE_SYSTIMEMGR_SUPPORT |
| #if defined(HAS_API_SYSTEM) && defined(HAS_API_POWERSTATE) |
| /*** |
| * @brief : To retrieve Device Power State. |
| @@ -4315,6 +4359,25 @@ namespace WPEFramework { |
| } |
| |
| #endif /* defined(USE_IARMBUS) || defined(USE_IARM_BUS) */ |
| +#ifdef ENABLE_SYSTIMEMGR_SUPPORT |
| + void _timerStatusEventHandler(const char *owner, IARM_EventId_t eventId, |
| + void *data, size_t len) |
| + { |
| + if ((!strcmp(IARM_BUS_SYSTIME_MGR_NAME, owner)) && (0 == eventId)) { |
| + LOGWARN("IARM_BUS_SYSTIME_MGR_NAME event received\n"); |
| + TimerMsg* pMsg = (TimerMsg*)data; |
| + string timequality = std::string(pMsg->message,cTIMER_STATUS_MESSAGE_LENGTH); |
| + string timersrc = std::string(pMsg->timerSrc,cTIMER_STATUS_MESSAGE_LENGTH); |
| + string timerStr = std::string(pMsg->currentTime,cTIMER_STATUS_MESSAGE_LENGTH); |
| + |
| + if (SystemServices::_instance) { |
| + SystemServices::_instance->onTimeStatusChanged(timequality,timersrc,timerStr); |
| + } else { |
| + LOGERR("SystemServices::_instance is NULL.\n"); |
| + } |
| + } |
| + } |
| +#endif// ENABLE_SYSTIMEMGR_SUPPORT |
| #ifdef ENABLE_THERMAL_PROTECTION |
| /*** |
| * @brief : To handle the event of Thermal Level change. THe event is registered |
| diff --git a/SystemServices/SystemServices.h b/SystemServices/SystemServices.h |
| index 50a49e0e..2c14838c 100644 |
| --- a/SystemServices/SystemServices.h |
| +++ b/SystemServices/SystemServices.h |
| @@ -71,6 +71,10 @@ using std::ofstream; |
| #define TERRITORYFILE "/opt/secure/persistent/System/Territory.txt" |
| |
| |
| +#ifdef ENABLE_SYSTIMEMGR_SUPPORT |
| +#define EVT_ONTIMESTATUSCHANGED "onTimeStatusChanged" |
| +#endif// ENABLE_SYSTIMEMGR_SUPPORT |
| + |
| namespace WPEFramework { |
| namespace Plugin { |
| |
| @@ -198,6 +202,9 @@ namespace WPEFramework { |
| void onLogUpload(int newState); |
| void onTemperatureThresholdChanged(string thresholdType, |
| bool exceed, float temperature); |
| +#ifdef ENABLE_SYSTIMEMGR_SUPPORT |
| + void onTimeStatusChanged(string timequality,string timesource, string utctime); |
| +#endif// ENABLE_SYSTIMEMGR_SUPPORT |
| void onRebootRequest(string reason); |
| void onFirmwarePendingReboot(int seconds); /* Event handler for Pending Reboot */ |
| void onTerritoryChanged(string oldTerritory, string newTerritory, string oldRegion="", string newRegion=""); |
| @@ -218,6 +225,9 @@ namespace WPEFramework { |
| uint32_t getDevicePowerState(const JsonObject& parameters,JsonObject& response); |
| uint32_t setDevicePowerState(const JsonObject& parameters,JsonObject& response); |
| #endif /* HAS_API_SYSTEM && HAS_API_POWERSTATE */ |
| +#ifdef ENABLE_SYSTIMEMGR_SUPPORT |
| + uint32_t getSystemTimeStatus(const JsonObject& parameters,JsonObject& response); |
| +#endif// ENABLE_SYSTIMEMGR_SUPPORT |
| uint32_t setGZEnabled(const JsonObject& parameters,JsonObject& response); |
| uint32_t isGZEnabled(const JsonObject& parameters,JsonObject& response); |
| uint32_t getSystemVersions(const JsonObject& parameters, JsonObject& response); |
| diff --git a/amlogic.cmake b/amlogic.cmake |
| index 6d682a74..cb284c90 100644 |
| --- a/amlogic.cmake |
| +++ b/amlogic.cmake |
| @@ -83,6 +83,11 @@ if (BUILD_ENABLE_THERMAL_PROTECTION) |
| add_definitions (-DBUILD_ENABLE_THERMAL_PROTECTION) |
| add_definitions (-DENABLE_THERMAL_PROTECTION) |
| endif() |
| +if (BUILD_ENABLE_SYSTIMEMGR_SUPPORT) |
| + message("Building with SYSTIMEMGR_SUPPORT enabled") |
| + add_definitions (-DENABLE_SYSTIMEMGR_SUPPORT) |
| +endif() |
| + |
| |
| if (BUILD_ENABLE_DEVICE_MANUFACTURER_INFO) |
| message("Building with device manufacturer info") |
| diff --git a/broadcom.cmake b/broadcom.cmake |
| index 80feae9f..c98dc5a0 100644 |
| --- a/broadcom.cmake |
| +++ b/broadcom.cmake |
| @@ -94,6 +94,10 @@ add_definitions (-DBUILD_ENABLE_THERMAL_PROTECTION) |
| add_definitions (-DENABLE_THERMAL_PROTECTION) |
| endif() |
| |
| +if (BUILD_ENABLE_SYSTIMEMGR_SUPPORT) |
| + message("Building with SYSTIMEMGR_SUPPORT enabled") |
| + add_definitions (-DENABLE_SYSTIMEMGR_SUPPORT) |
| +endif() |
| if (SCREENCAP_SVP_ENABLED) |
| message("Building with SCREENCAP_SVP_ENABLED") |
| add_definitions (-DSCREENCAP_SVP_ENABLED) |
| diff --git a/realtek.cmake b/realtek.cmake |
| index 0de092f1..db825da1 100644 |
| --- a/realtek.cmake |
| +++ b/realtek.cmake |
| @@ -83,6 +83,10 @@ if (BUILD_ENABLE_THERMAL_PROTECTION) |
| add_definitions (-DBUILD_ENABLE_THERMAL_PROTECTION) |
| add_definitions (-DENABLE_THERMAL_PROTECTION) |
| endif() |
| +if (BUILD_ENABLE_SYSTIMEMGR_SUPPORT) |
| + message("Building with SYSTIMEMGR_SUPPORT enabled") |
| + add_definitions (-DENABLE_SYSTIMEMGR_SUPPORT) |
| +endif() |
| |
| if (BUILD_ENABLE_DEVICE_MANUFACTURER_INFO) |
| message("Building with device manufacturer info") |