diff --git a/.github/workflows/L1-tests.yml b/.github/workflows/L1-tests.yml index 168cec11fb..9f00c60f58 100755 --- a/.github/workflows/L1-tests.yml +++ b/.github/workflows/L1-tests.yml @@ -14,7 +14,7 @@ env: jobs: l1-tests: name: Build and run unit tests - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: compiler: [ gcc, clang ] diff --git a/.github/workflows/L2-tests-R4-4-1.yml b/.github/workflows/L2-tests-R4-4-1.yml index eea725c3bb..84f4f8b9ea 100755 --- a/.github/workflows/L2-tests-R4-4-1.yml +++ b/.github/workflows/L2-tests-R4-4-1.yml @@ -14,7 +14,7 @@ env: jobs: L2-tests-R4-4-1: name: L2 tests with Thunder R4.4.1 - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: compiler: [ gcc, clang ] diff --git a/.github/workflows/L2-tests.yml b/.github/workflows/L2-tests.yml index 1fe3e0227c..e9b5e5f3b7 100755 --- a/.github/workflows/L2-tests.yml +++ b/.github/workflows/L2-tests.yml @@ -14,7 +14,7 @@ env: jobs: l2-tests: name: Build and run L2 tests - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: compiler: [ gcc, clang ] diff --git a/SystemServices/System.json b/SystemServices/System.json index caca85f0ec..249eb2ff1c 100644 --- a/SystemServices/System.json +++ b/SystemServices/System.json @@ -2385,6 +2385,46 @@ "privacyMode" ] } + }, + "setFSRFlag":{ + "summary": "Set the FSR flag into the emmc raw area. This API will fail if you attempt to set the same value.", + "result": { + "type": "object", + "properties": { + "fsrFlag": { + "summary": "FSR flag", + "type": "boolean", + "example": true + }, + "success":{ + "$ref": "#/common/success" + } + }, + "required": [ + "fsrFlag", + "success" + ] + } + }, + "getFSRFlag":{ + "summary": "Get the FSR flag from the emmc raw area.", + "result": { + "type": "object", + "properties": { + "fsrFlag": { + "summary": "FSR flag.", + "type": "boolean", + "example": true + }, + "success":{ + "$ref": "#/common/success" + } + }, + "required": [ + "fsrFlag", + "success" + ] + } } } } diff --git a/SystemServices/SystemServices.cpp b/SystemServices/SystemServices.cpp index 45a6a22e35..c3b0274882 100644 --- a/SystemServices/SystemServices.cpp +++ b/SystemServices/SystemServices.cpp @@ -492,6 +492,8 @@ namespace WPEFramework { registerMethod("getFriendlyName", &SystemServices::getFriendlyName, this); registerMethod("setFriendlyName", &SystemServices::setFriendlyName, this); registerMethod("getThunderStartReason", &SystemServices::getThunderStartReason, this); + registerMethod("setFSRFlag", &SystemServices::setFSRFlag, this); + registerMethod("getFSRFlag", &SystemServices::getFSRFlag, this); registerMethod("setPrivacyMode", &SystemServices::setPrivacyMode, this); registerMethod("getPrivacyMode", &SystemServices::getPrivacyMode, this); @@ -4772,6 +4774,69 @@ namespace WPEFramework { returnResponse(true); } + + + /*** + * @brief : To set the fsr flag into the emmc raw area. + * @param1[in] : {"params":{"fsrFlag":} + * @param2[out] : {"result":{"success":}} + * @return : Core:: + */ + uint32_t SystemServices::setFSRFlag(const JsonObject& parameters, + JsonObject& response) + { + LOGINFOMETHOD(); + bool fsrFlag = 0; + bool status = false; + + if(parameters.HasLabel("fsrFlag")) + { + fsrFlag = parameters["fsrFlag"].Boolean(); + IARM_Bus_MFRLib_FsrFlag_Param_t param; + param = fsrFlag; + + LOGINFO("Param %d \n", param); + IARM_Result_t res = IARM_Bus_Call(IARM_BUS_MFRLIB_NAME, + IARM_BUS_MFRLIB_API_SetFsrFlag, (void *)¶m, + sizeof(param)); + if (IARM_RESULT_SUCCESS == res) { + status = true; + } else { + status = false; + } + } + + returnResponse(status); + } + + /*** + * @brief : To get the fsr flag from emmc + * @param1[out] : {"params":{"params":{"fsrFlag":} + * @param2[out] : {"result":{"success":}} + * @return : Core:: + */ + uint32_t SystemServices::getFSRFlag(const JsonObject& parameters, + JsonObject& response) + { + LOGINFOMETHOD(); + bool fsrFlag = 0; + bool status = false; + IARM_Bus_MFRLib_FsrFlag_Param_t param; + + IARM_Result_t res = IARM_Bus_Call(IARM_BUS_MFRLIB_NAME, + IARM_BUS_MFRLIB_API_GetFsrFlag, (void *)¶m, + sizeof(param)); + if (IARM_RESULT_SUCCESS == res) { + fsrFlag = param; + status = true; + } else { + status = false; + } + response["fsrFlag"] = fsrFlag; + returnResponse(status); + } + + } /* namespace Plugin */ } /* namespace WPEFramework */ diff --git a/SystemServices/SystemServices.h b/SystemServices/SystemServices.h index f95c311007..1d40eea24a 100644 --- a/SystemServices/SystemServices.h +++ b/SystemServices/SystemServices.h @@ -305,6 +305,8 @@ namespace WPEFramework { uint32_t getThunderStartReason(const JsonObject& parameters, JsonObject& response); uint32_t setPrivacyMode(const JsonObject& parameters, JsonObject& response); uint32_t getPrivacyMode(const JsonObject& parameters, JsonObject& response); + uint32_t setFSRFlag(const JsonObject& parameters, JsonObject& response); + uint32_t getFSRFlag(const JsonObject& parameters, JsonObject& response); }; /* end of system service class */ } /* end of plugin */ } /* end of wpeframework */ diff --git a/Tests/L1Tests/tests/test_SystemServices.cpp b/Tests/L1Tests/tests/test_SystemServices.cpp index bec14391b0..11deb01f10 100755 --- a/Tests/L1Tests/tests/test_SystemServices.cpp +++ b/Tests/L1Tests/tests/test_SystemServices.cpp @@ -252,6 +252,8 @@ TEST_F(SystemServicesTest, TestedAPIsShouldExist) EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("uploadLogs"))); EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("uploadLogsAsync"))); EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("abortLogUpload"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setFSRFlag"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getFSRFlag"))); } TEST_F(SystemServicesTest, SystemUptime) @@ -6229,3 +6231,65 @@ TEST_F(SystemServicesEmptyTest, system_service_settings_conf_as_dir) EXPECT_TRUE(Core::Directory("/opt/system_service_settings.conf").Destroy(true)); } + +TEST_F(SystemServicesTest, setFSRSuccess){ + 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_SetFsrFlag))); + auto param = static_cast(arg); + EXPECT_EQ(param, (1)); + return IARM_RESULT_SUCCESS; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setFSRFlag"), _T("{\"fsrFlag\":0}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(SystemServicesTest, setFSRFailure){ + 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_SetFsrFlag))); + auto param = static_cast(arg); + EXPECT_EQ(param, (1)); + return IARM_RESULT_INVALID_STATE; + }); + + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setFSRFlag"), _T("{\"fsrFlag\":1}"), response)); +} + +TEST_F(SystemServicesTest, getFSRSuccess){ + 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_GetFsrFlag))); + auto param = static_cast(arg); + EXPECT_EQ(param, (1)); + return IARM_RESULT_SUCCESS; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getFSRFlag"), _T("{}"), response)); + EXPECT_EQ(response, string("{\"fsrFlag\":true,\"success\":true}")); +} + +TEST_F(SystemServicesTest, getFSRFailure){ + 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_GetFsrFlag))); + auto param = static_cast(arg); + EXPECT_EQ(param, (1)); + return IARM_RESULT_INVALID_STATE; + }); + + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getFSRFlag"), _T("{}"), response)); +} \ No newline at end of file diff --git a/Tests/mocks/Iarm.h b/Tests/mocks/Iarm.h index 9fb958d441..0b7e9310cb 100644 --- a/Tests/mocks/Iarm.h +++ b/Tests/mocks/Iarm.h @@ -947,6 +947,8 @@ typedef struct _IARM_Bus_MFRLib_SetBLSplashScreen_Param{ char path[255]; } IARM_Bus_MFRLib_SetBLSplashScreen_Param_t; +typedef bool IARM_Bus_MFRLib_FsrFlag_Param_t; // true or false + #define IARM_BUS_CECMGR_API_isAvailable "isAvailable" #define IARM_BUS_DSMGR_API_dsHdmiInGetNumberOfInputs "dsHdmiInGetNumberOfInputs" #define IARM_BUS_DSMGR_API_dsHdmiInGetStatus "dsHdmiInGetStatus"