From 560e95999bec6171aad85a64505eb5da171671cc Mon Sep 17 00:00:00 2001 From: ramkumarpraba Date: Mon, 20 May 2024 12:01:30 +0000 Subject: [PATCH 1/5] RDK-49198 RDK Thunder provide API to install and clear bootloader splash Reason for change: Adding System.setBootLoaderSplashScreen API Test Procedure: verify build success and basic test Risks: Low Priority: P1 Signed-off-by: ramkumar_prabaharan@comcast.com --- SystemServices/SystemServices.cpp | 29 +++++++++++++++++++++++++++++ SystemServices/SystemServices.h | 1 + 2 files changed, 30 insertions(+) diff --git a/SystemServices/SystemServices.cpp b/SystemServices/SystemServices.cpp index c4180345ba..ccc6d4fecb 100644 --- a/SystemServices/SystemServices.cpp +++ b/SystemServices/SystemServices.cpp @@ -400,6 +400,7 @@ namespace WPEFramework { registerMethod("updateFirmware", &SystemServices::updateFirmware, this); registerMethod("setMode", &SystemServices::setMode, this); registerMethod("setBootLoaderPattern", &SystemServices::setBootLoaderPattern, this); + registerMethod("setBootLoaderSplashScreen", &SystemServices::setBootLoaderSplashScreen, this); registerMethod("getFirmwareUpdateInfo", &SystemServices::getFirmwareUpdateInfo, this); registerMethod("setDeepSleepTimer", &SystemServices::setDeepSleepTimer, @@ -1324,6 +1325,34 @@ namespace WPEFramework { returnResponse(status); } + /*** + * @brief : To update bootloader splash screen. + * @param1[in] : {"path":""} + * @param2[out] : {"result":{"success":}} + * @return : Core:: + */ + uint32_t SystemServices::setBootLoaderSplashScreen(const JsonObject& parameters, + JsonObject& response) + { + returnIfParamNotFound(parameters, "path"); + bool status = false; + string strBLSplashScreenPath = parameters["path"].String(); + if(strBLSplashScreenPath != "") + { + status =true; + IARM_Bus_MFRLib_SetBLSplashScreen_Param_t mfrparam; + std::strcpy(mfrparam.path, strBLSplashScreenPath.c_str()); + + if(status == true) + { + if (IARM_RESULT_SUCCESS != IARM_Bus_Call(IARM_BUS_MFRLIB_NAME, IARM_BUS_MFRLIB_API_SetBlSplashScreen, (void *)&mfrparam, sizeof(mfrparam))){ + status = false; + } + } + } + returnResponse(status); + } + /*** * @brief : Sets the mode of the STB. The object consists of two properties, mode (String) and * duration (Integer) mode can be one of following: diff --git a/SystemServices/SystemServices.h b/SystemServices/SystemServices.h index a240b42106..5dc1607b63 100644 --- a/SystemServices/SystemServices.h +++ b/SystemServices/SystemServices.h @@ -234,6 +234,7 @@ namespace WPEFramework { uint32_t updateFirmware(const JsonObject& parameters, JsonObject& response); uint32_t setMode(const JsonObject& parameters, JsonObject& response); uint32_t setBootLoaderPattern(const JsonObject& parameters, JsonObject& response); + uint32_t setBootLoaderSplashScreen(const JsonObject& parameters, JsonObject& response); static void firmwareUpdateInfoReceived(void); uint32_t getFirmwareUpdateInfo(const JsonObject& parameters, JsonObject& response); void reportFirmwareUpdateInfoReceived(string firmwareUpdateVersion, From 71e0378c36c1820746594be4e043a55197473c30 Mon Sep 17 00:00:00 2001 From: ramkumarpraba Date: Mon, 20 May 2024 12:01:30 +0000 Subject: [PATCH 2/5] RDK-49198 RDK Thunder provide API to install and clear bootloader splash Reason for change: Adding System.setBootLoaderSplashScreen API Test Procedure: verify build success and basic test Risks: Low Priority: P1 Signed-off-by: ramkumar_prabaharan@comcast.com --- SystemServices/SystemServices.cpp | 45 +++++++++ SystemServices/SystemServices.h | 1 + Tests/L1Tests/tests/test_SystemServices.cpp | 72 +++++++++++++++ .../tests/SystemService_L2Test.cpp | 91 +++++++++++++++++++ Tests/mocks/Iarm.h | 5 + 5 files changed, 214 insertions(+) diff --git a/SystemServices/SystemServices.cpp b/SystemServices/SystemServices.cpp index c4180345ba..e20150bc2e 100644 --- a/SystemServices/SystemServices.cpp +++ b/SystemServices/SystemServices.cpp @@ -400,6 +400,7 @@ namespace WPEFramework { registerMethod("updateFirmware", &SystemServices::updateFirmware, this); registerMethod("setMode", &SystemServices::setMode, this); registerMethod("setBootLoaderPattern", &SystemServices::setBootLoaderPattern, this); + registerMethod("setBootLoaderSplashScreen", &SystemServices::setBootLoaderSplashScreen, this); registerMethod("getFirmwareUpdateInfo", &SystemServices::getFirmwareUpdateInfo, this); registerMethod("setDeepSleepTimer", &SystemServices::setDeepSleepTimer, @@ -1324,6 +1325,50 @@ namespace WPEFramework { returnResponse(status); } + /*** + * @brief : To update bootloader splash screen. + * @param1[in] : {"path":""} + * @param2[out] : {"result":{"success":}} + * @return : Core:: + */ + uint32_t SystemServices::setBootLoaderSplashScreen(const JsonObject& parameters, + JsonObject& response) + { + returnIfParamNotFound(parameters, "path"); + bool status = false; + string strBLSplashScreenPath = parameters["path"].String(); + bool fileExists = Utils::fileExists(strBLSplashScreenPath.c_str()); + if((strBLSplashScreenPath != "") && fileExists) + { + IARM_Bus_MFRLib_SetBLSplashScreen_Param_t mfrparam; + std::strcpy(mfrparam.path, strBLSplashScreenPath.c_str()); + IARM_Result_t result = IARM_Bus_Call(IARM_BUS_MFRLIB_NAME, IARM_BUS_MFRLIB_API_SetBlSplashScreen, (void *)&mfrparam, sizeof(mfrparam)); + if (result != IARM_RESULT_SUCCESS){ + LOGERR("Update failed. path: %s, fileExists %s, IARM result %d ",strBLSplashScreenPath.c_str(),fileExists ? "true" : "false",result); + JsonObject error; + error["message"] = "Update failed"; + error["code"] = "-32002"; + response["error"] = error; + status = false; + } + else + { + LOGINFO("BootLoaderSplashScreen updated successfully"); + status =true; + } + } + else + { + LOGERR("Invalid path. path: %s, fileExists %s ",strBLSplashScreenPath.c_str(),fileExists ? "true" : "false"); + JsonObject error; + error["message"] = "Invalid path"; + error["code"] = "-32001"; + response["error"] = error; + status = false; + } + returnResponse(status); + } + /*** * @brief : Sets the mode of the STB. The object consists of two properties, mode (String) and * duration (Integer) mode can be one of following: diff --git a/SystemServices/SystemServices.h b/SystemServices/SystemServices.h index a240b42106..5dc1607b63 100644 --- a/SystemServices/SystemServices.h +++ b/SystemServices/SystemServices.h @@ -234,6 +234,7 @@ namespace WPEFramework { uint32_t updateFirmware(const JsonObject& parameters, JsonObject& response); uint32_t setMode(const JsonObject& parameters, JsonObject& response); uint32_t setBootLoaderPattern(const JsonObject& parameters, JsonObject& response); + uint32_t setBootLoaderSplashScreen(const JsonObject& parameters, JsonObject& response); static void firmwareUpdateInfoReceived(void); uint32_t getFirmwareUpdateInfo(const JsonObject& parameters, JsonObject& response); void reportFirmwareUpdateInfoReceived(string firmwareUpdateVersion, diff --git a/Tests/L1Tests/tests/test_SystemServices.cpp b/Tests/L1Tests/tests/test_SystemServices.cpp index 13c7a32544..477037bdc5 100755 --- a/Tests/L1Tests/tests/test_SystemServices.cpp +++ b/Tests/L1Tests/tests/test_SystemServices.cpp @@ -734,6 +734,78 @@ TEST_F(SystemServicesTest, SystemVersions) EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getSystemVersions"), _T("{}"), response)); EXPECT_EQ(response, string("{\"stbVersion\":\"PX051AEI_VBN_2203_sprint_20220331225312sdy_NG\",\"receiverVersion\":\"000.36.0.0\",\"stbTimestamp\":\"Fri 05 Aug 2022 16:14:54 UTC\",\"success\":true}")); } +/******************************************************************************************************************* + * Test function for :setBootLoaderSplashScreen + * @brief : To update bootloader splash screen. + * @param1[in] : {"path":""} + * @param2[out] : {"result":{"success":}} + * @return : Core:: + * Use case coverage: + * @Success :1 + * @Failure :3 + ********************************************************************************************************************/ + + +TEST_F(SystemServicesTest, setBootLoaderSplashScreen_IARM_fail) +{ + ofstream file("/tmp/osd1"); + file << "testing setBootLoaderSplashScreen"; + file.close(); + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_Call) + .Times(::testing::AnyNumber()) + .WillRepeatedly( + [](const char* ownerName, const char* methodName, void* arg, size_t argLen) { + EXPECT_EQ(string(ownerName), string(_T(IARM_BUS_MFRLIB_NAME))); + EXPECT_EQ(string(methodName), string(_T(IARM_BUS_MFRLIB_API_SetBlSplashScreen))); + auto param = static_cast(arg); + EXPECT_EQ(param->path, "/tmp/osd1"); + return IARM_RESULT_OOM; + }); + + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setBootLoaderSplashScreen"), _T("{\"path\": \"/tmp/osd1\"}"), response)); + + EXPECT_EQ(response, string("{\"error\":{\"message\":\"Update failed\",\"code\":\"-32002\"},\"success\":false}")); +} + +TEST_F(SystemServicesTest, setBootLoaderSplashScreen_IARM_success) +{ + ofstream file("/tmp/osd1"); + file << "testing setBootLoaderSplashScreen"; + file.close(); + + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_Call) + .Times(::testing::AnyNumber()) + .WillRepeatedly( + [](const char* ownerName, const char* methodName, void* arg, size_t argLen) { + EXPECT_EQ(string(ownerName), string(_T(IARM_BUS_MFRLIB_NAME))); + EXPECT_EQ(string(methodName), string(_T(IARM_BUS_MFRLIB_API_SetBootLoaderPattern))); + auto param = static_cast(arg); + EXPECT_EQ(param->path, "/tmp/osd1"); + return IARM_RESULT_SUCCESS; + }); + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setBootLoaderSplashScreen"), _T("{\"path\": \"/tmp/osd1\"}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(SystemServicesTest, setBootLoaderSplashScreen_empty_path) +{ + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_Call) + .Times(0); + + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setBootLoaderSplashScreen"), _T("{\"path\": \"\"}"), response)); + EXPECT_EQ(response, string("{\"error\":{\"message\":\"Invalid path\",\"code\":\"-32001\"},\"success\":false}")); +} + +TEST_F(SystemServicesTest, setBootLoaderSplashScreen_invalid_path) +{ + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_Call) + .Times(0); + + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setBootLoaderSplashScreen"), _T("{\"path\": \"/tmp/osd2\"}"), response)); + + EXPECT_EQ(response, string("{\"error\":{\"message\":\"Invalid path\",\"code\":\"-32001\"},\"success\":false}")); +} + TEST_F(SystemServicesTest, MocaStatus) { diff --git a/Tests/L2Tests/L2TestsPlugin/tests/SystemService_L2Test.cpp b/Tests/L2Tests/L2TestsPlugin/tests/SystemService_L2Test.cpp index 1d55860633..daa5ca4488 100755 --- a/Tests/L2Tests/L2TestsPlugin/tests/SystemService_L2Test.cpp +++ b/Tests/L2Tests/L2TestsPlugin/tests/SystemService_L2Test.cpp @@ -441,3 +441,94 @@ TEST_F(SystemService_L2Test,SystemServiceUploadLogsAndSystemPowerStateChange) jsonrpc.Unsubscribe(JSON_TIMEOUT, _T("onSystemPowerStateChanged")); } +/******************************************************** +************Test case Details ************************** +** 1. setBootLoaderSplashScreen success +** 2. setBootLoaderSplashScreen fail +** 3. setBootLoaderSplashScreen invalid path +** 4. setBootLoaderSplashScreen empty path +*******************************************************/ + +TEST_F(SystemService_L2Test,setBootLoaderSplashScreen) +{ + JSONRPC::LinkType jsonrpc(SYSTEM_CALLSIGN,L2TEST_CALLSIGN); + StrictMock async_handler; + uint32_t status = Core::ERROR_GENERAL; + JsonObject params; + JsonObject result; + uint32_t signalled = SYSTEMSERVICEL2TEST_STATE_INVALID; + std::string message; + JsonObject expected_status; + params["path"] = "/tmp/osd1"; + + + std::ofstream file("/tmp/osd1"); + file << "testing setBootLoaderSplashScreen"; + file.close(); + + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_Call) + .Times(::testing::AnyNumber()) + .WillRepeatedly( + [](const char* ownerName, const char* methodName, void* arg, size_t argLen) { + EXPECT_EQ(string(ownerName), string(_T(IARM_BUS_MFRLIB_NAME))); + EXPECT_EQ(string(methodName), string(_T(IARM_BUS_MFRLIB_API_SetBlSplashScreen))); + auto param = static_cast(arg); + EXPECT_EQ(param->path, "/tmp/osd1"); + return IARM_RESULT_SUCCESS; + }); + + status = InvokeServiceMethod("org.rdk.System.1", "setBootLoaderSplashScreen", params, result); + EXPECT_EQ(Core::ERROR_NONE, status); + EXPECT_TRUE(result["success"].Boolean()); +// EXPECT_STREQ("{\"message\":\"Update failed\",\"code\":\"-32002\"}", result["error"].String().c_str()); + + + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_Call) + .Times(::testing::AnyNumber()) + .WillRepeatedly( + [](const char* ownerName, const char* methodName, void* arg, size_t argLen) { + EXPECT_EQ(string(ownerName), string(_T(IARM_BUS_MFRLIB_NAME))); + EXPECT_EQ(string(methodName), string(_T(IARM_BUS_MFRLIB_API_SetBlSplashScreen))); + auto param = static_cast(arg); + EXPECT_EQ(param->path, "/tmp/osd1"); + return IARM_RESULT_OOM; + }); + + status = InvokeServiceMethod("org.rdk.System.1", "setBootLoaderSplashScreen", params, result); + EXPECT_EQ(Core::ERROR_GENERAL, status); + EXPECT_FALSE(result["success"].Boolean()); + + params["path"] = "/tmp/osd2"; + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_Call) + .Times(::testing::AnyNumber()) + .WillRepeatedly( + [](const char* ownerName, const char* methodName, void* arg, size_t argLen) { + EXPECT_EQ(string(ownerName), string(_T(IARM_BUS_MFRLIB_NAME))); + EXPECT_EQ(string(methodName), string(_T(IARM_BUS_MFRLIB_API_SetBlSplashScreen))); + auto param = static_cast(arg); + EXPECT_EQ(param->path, "/tmp/osd2"); + return IARM_RESULT_OOM; + }); + + status = InvokeServiceMethod("org.rdk.System.1", "setBootLoaderSplashScreen", params, result); + EXPECT_EQ(Core::ERROR_GENERAL, status); + EXPECT_FALSE(result["success"].Boolean()); + + + params["path"] = ""; + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_Call) + .Times(::testing::AnyNumber()) + .WillRepeatedly( + [](const char* ownerName, const char* methodName, void* arg, size_t argLen) { + EXPECT_EQ(string(ownerName), string(_T(IARM_BUS_MFRLIB_NAME))); + EXPECT_EQ(string(methodName), string(_T(IARM_BUS_MFRLIB_API_SetBlSplashScreen))); + auto param = static_cast(arg); + EXPECT_EQ(param->path, "/tmp/osd2"); + return IARM_RESULT_OOM; + }); + + status = InvokeServiceMethod("org.rdk.System.1", "setBootLoaderSplashScreen", params, result); + EXPECT_EQ(Core::ERROR_GENERAL, status); + EXPECT_FALSE(result["success"].Boolean()); + +} diff --git a/Tests/mocks/Iarm.h b/Tests/mocks/Iarm.h index 724515f3da..9dbcf87b72 100644 --- a/Tests/mocks/Iarm.h +++ b/Tests/mocks/Iarm.h @@ -210,6 +210,7 @@ typedef struct _DeepSleepMgr_WakeupKeyCode_Param_t { #define IARM_BUS_MFRLIB_NAME "MFRLib" #define IARM_BUS_MFRLIB_API_SetBootLoaderPattern "mfrSetBootloaderPattern" +#define IARM_BUS_MFRLIB_API_SetBlSplashScreen "mfrSetBlSplashScreen" #define IARM_BUS_MFRLIB_API_GetSerializedData "mfrGetManufacturerData" typedef enum _mfrSerializedType_t { @@ -919,6 +920,10 @@ typedef struct _IARM_Bus_CECMgr_Status_Updated_Param_t int logicalAddress; }IARM_Bus_CECMgr_Status_Updated_Param_t; +typedef struct _IARM_Bus_MFRLib_SetBLSplashScreen_Param{ + char path[255]; +} IARM_Bus_MFRLib_SetBLSplashScreen_Param_t; + #define IARM_BUS_CECMGR_API_isAvailable "isAvailable" #define IARM_BUS_DSMGR_API_dsHdmiInGetNumberOfInputs "dsHdmiInGetNumberOfInputs" #define IARM_BUS_DSMGR_API_dsHdmiInGetStatus "dsHdmiInGetStatus" From 9b6e781d6eff33284086163ba64f52e9b0939770 Mon Sep 17 00:00:00 2001 From: ramkumarpraba <103193010+ramkumarpraba@users.noreply.github.com> Date: Thu, 23 May 2024 19:11:12 +0530 Subject: [PATCH 3/5] Update SystemServices.cpp --- SystemServices/SystemServices.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SystemServices/SystemServices.cpp b/SystemServices/SystemServices.cpp index e20150bc2e..6a5d55e65d 100644 --- a/SystemServices/SystemServices.cpp +++ b/SystemServices/SystemServices.cpp @@ -1333,8 +1333,7 @@ namespace WPEFramework { */ uint32_t SystemServices::setBootLoaderSplashScreen(const JsonObject& parameters, JsonObject& response) - { - returnIfParamNotFound(parameters, "path"); + { bool status = false; string strBLSplashScreenPath = parameters["path"].String(); bool fileExists = Utils::fileExists(strBLSplashScreenPath.c_str()); From 122ecdda2354d36bd298a1893f8339594fc1a68d Mon Sep 17 00:00:00 2001 From: ramkumarpraba Date: Fri, 24 May 2024 10:11:01 +0000 Subject: [PATCH 4/5] RDK-49832 Documentation for RDK Thunder provide API to install and clear bootloader splash Reason for change: Adding System.setBootLoaderSplashScreen API Test Procedure: verify build success and basic test Risks: Low Priority: P1 Signed-off-by: ramkumar_prabaharan@comcast.com --- SystemServices/System.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/SystemServices/System.json b/SystemServices/System.json index 4725979ada..5bd33b84ff 100644 --- a/SystemServices/System.json +++ b/SystemServices/System.json @@ -50,6 +50,11 @@ "type": "string", "example": "My Device" }, + "path": { + "summary": "Path to the pre-downloaded splash screen file location. Full path with file name", + "type": "string", + "example": "/tmp/osd1" + }, "modeInfo": { "summary": "The mode information", "type": "object", @@ -1859,6 +1864,23 @@ "$ref": "#/common/result" } }, + "setBootLoaderSplashScreen":{ + "summary": "Whenever there is a splash screen update, app (EPG) connects with QMS, downloads the updated splash screen, stores it in a predefined location (/tmp), and uses setBootLoaderSplashScreen to install / update the BL splash screens", + "params": { + "type":"object", + "properties": { + "path": { + "$ref": "#/definitions/path" + } + }, + "required": [ + "path" + ] + }, + "result": { + "$ref": "#/common/result" + } + }, "setTerritory":{ "summary": "Sets the system territory and region.Territory is a ISO-3166-1 alpha-3 standard (see https://en.wikipedia.org/wiki/ISO_3166-1). Region is a ISO-3166-2 alpha-2 standard (see https://en.wikipedia.org/wiki/ISO_3166-2).", "events":{ From 0813c4110271b9e3791a6f4ecd92660bdabea306 Mon Sep 17 00:00:00 2001 From: ramkumarpraba <103193010+ramkumarpraba@users.noreply.github.com> Date: Fri, 24 May 2024 19:57:51 +0530 Subject: [PATCH 5/5] Update setBootLoaderSplashScreen summary --- SystemServices/System.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SystemServices/System.json b/SystemServices/System.json index 5bd33b84ff..8c56db1c0b 100644 --- a/SystemServices/System.json +++ b/SystemServices/System.json @@ -1865,7 +1865,7 @@ } }, "setBootLoaderSplashScreen":{ - "summary": "Whenever there is a splash screen update, app (EPG) connects with QMS, downloads the updated splash screen, stores it in a predefined location (/tmp), and uses setBootLoaderSplashScreen to install / update the BL splash screens", + "summary": "Install or update the BootLoader Splash Screens. This is typically called by Resident Apps to configure the Splash Screen shown during device boot up.", "params": { "type":"object", "properties": {