-
Notifications
You must be signed in to change notification settings - Fork 4
RDK-57914: Dynamic WhoAmI feature control for Manintenance Manager #82
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d0dd2ac
Add WAI support check logic to header file
gomathishankar37 ff65bb1
Add Runtime Whoami Middleware Checks in MaintenanceManager
gomathishankar37 a630a4f
Merge branch 'develop' into feature/whoami-mw
gomathishankar37 4b555b0
Update MaintenanceManager.cpp
gomathishankar37 4f88c84
RDK-57914: Dynamic WhoAmI feature control for Maintenance Manager
yogeswaransky 3d03e91
RDK-57914: Dynamic WhoAmI feature control for Maintenance Manager
yogeswaransky d70f2b1
RDK-57914: Dynamic WhoAmI feature control for Maintenance Manager
yogeswaransky c9bcb6b
RDK-57914: Dynamic WhoAmI feature control for Manintenance Manager
yogeswaransky 6eedbaa
RDK-57914: Dynamic WhoAmI feature control for Manintenance Manager
yogeswaransky dbfd276
Merge branch 'develop' into feature/whoami-mw
yogeswaransky 9835d5a
RDK-57914: Dynamic WhoAmI feature control for Manintenance Manager
yogeswaransky b0195a1
RDK-57914: Dynamic WhoAmI feature control for Manintenance Manager
yogeswaransky 6a09e04
RDK-57914: Dynamic WhoAmI feature control for Manintenance Manager
yogeswaransky 04cf70c
RDK-57914: Dynamic WhoAmI feature control for Manintenance Manager
yogeswaransky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| /** | ||
|
Check failure on line 1 in MaintenanceManager/MaintenanceManager.cpp
|
||
| * If not stated otherwise in this file or this component's LICENSE | ||
| * file the following copyright and licenses apply: | ||
| * | ||
|
|
@@ -45,6 +45,7 @@ | |
| #include "UtilsIarm.h" | ||
| #include "UtilsJsonRpc.h" | ||
| #include "UtilsfileExists.h" | ||
| #include "UtilsgetFileContent.h" | ||
|
|
||
| #if defined(USE_IARMBUS) || defined(USE_IARM_BUS) | ||
| #include "libIARM.h" | ||
|
|
@@ -70,11 +71,10 @@ | |
| #define RDK_PATH "/lib/rdk/" | ||
| #define MAINTENANCE_MANAGER_RFC_CALLER_ID "MaintenanceManager" | ||
|
|
||
| #if defined(ENABLE_WHOAMI) | ||
| #define TR181_PARTNER_ID "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.PartnerName" | ||
| #define TR181_TARGET_OS_CLASS "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.OsClass" | ||
| #define TR181_XCONFURL "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.XconfUrl" | ||
| #endif | ||
|
|
||
|
|
||
| #define TASK_SCRIPT RDK_PATH "Start_MaintenanceTasks.sh" | ||
| #define IMAGE_CHECK_SCRIPT RDK_PATH "xconfImageCheck.sh" | ||
|
|
@@ -337,15 +337,13 @@ | |
| MaintenanceManager::m_task_map[task_names_foreground[TASK_SWUPDATE].c_str()] = false; | ||
| MaintenanceManager::m_task_map[task_names_foreground[TASK_LOGUPLOAD].c_str()] = false; | ||
|
|
||
| #if defined(ENABLE_WHOAMI) | ||
| MaintenanceManager::m_param_map[kDeviceInitContextKeyVals[0].c_str()] = TR181_PARTNER_ID; | ||
| MaintenanceManager::m_param_map[kDeviceInitContextKeyVals[1].c_str()] = TR181_TARGET_OS_CLASS; | ||
| MaintenanceManager::m_param_map[kDeviceInitContextKeyVals[2].c_str()] = TR181_XCONFURL; | ||
|
|
||
| MaintenanceManager::m_paramType_map[kDeviceInitContextKeyVals[0].c_str()] = DATA_TYPE::WDMP_STRING; | ||
| MaintenanceManager::m_paramType_map[kDeviceInitContextKeyVals[1].c_str()] = DATA_TYPE::WDMP_STRING; | ||
| MaintenanceManager::m_paramType_map[kDeviceInitContextKeyVals[2].c_str()] = DATA_TYPE::WDMP_STRING; | ||
| #endif | ||
| } | ||
|
|
||
| void MaintenanceManager::task_execution_thread() | ||
|
|
@@ -361,13 +359,12 @@ | |
| std::unique_lock<std::mutex> wailck(m_waiMutex); | ||
| MM_LOGINFO("Executing Maintenance tasks"); | ||
|
|
||
| #if defined(ENABLE_WHOAMI) | ||
| /* Purposefully delaying MAINTENANCE_STARTED status to honor POWER compliance */ | ||
| if (UNSOLICITED_MAINTENANCE == g_maintenance_type) | ||
| if (UNSOLICITED_MAINTENANCE == g_maintenance_type && g_whoami_support_enabled) | ||
| { | ||
| delayMaintenanceStarted = true; | ||
| } | ||
| #endif | ||
|
|
||
| if (!delayMaintenanceStarted) | ||
| { | ||
| m_statusMutex.lock(); | ||
|
|
@@ -381,55 +378,65 @@ | |
| tasks.erase(tasks.begin(), tasks.end()); | ||
| } | ||
|
|
||
| #if defined(SUPPRESS_MAINTENANCE) && !defined(ENABLE_WHOAMI) | ||
| bool skipFirmwareCheck = false; | ||
| bool activationStatus = getActivatedStatus(skipFirmwareCheck); /* Activation check */ | ||
| /* we proceed with network check only if | ||
| * "activation-connect", | ||
| * "activation-ready" | ||
| * "not-activated", | ||
| * "activated" */ | ||
| if (activationStatus) | ||
| bool skipFirmwareCheck = false; | ||
| if (!g_whoami_support_enabled && g_suppress_maintenance_enabled) | ||
| { | ||
| MM_LOGINFO("WhoAmI feature is disabled and suppress maintenance is enabled"); | ||
| bool activationStatus = getActivatedStatus(skipFirmwareCheck); /* Activation check */ | ||
| /* we proceed with network check only if | ||
| * "activation-connect", | ||
| * "activation-ready" | ||
| * "not-activated", | ||
| * "activated" */ | ||
| if (activationStatus) | ||
| { | ||
| internetConnectStatus = isDeviceOnline(); /* Network check */ | ||
| } | ||
| } | ||
| else | ||
| { | ||
| internetConnectStatus = isDeviceOnline(); /* Network check */ | ||
| } | ||
| #else | ||
| internetConnectStatus = isDeviceOnline(); /* Network check */ | ||
| #endif | ||
|
|
||
| #if defined(ENABLE_WHOAMI) | ||
| if (UNSOLICITED_MAINTENANCE == g_maintenance_type) | ||
| if (g_whoami_support_enabled) | ||
| { | ||
| string activation_status = checkActivatedStatus(); /* Device Activation Status Check */ | ||
| bool whoAmIStatus = knowWhoAmI(activation_status); /* WhoAmI Response & Set Status Check */ | ||
| MM_LOGINFO("knowWhoAmI() returned %s", (whoAmIStatus) ? "successfully" : "false"); | ||
|
|
||
| if (!whoAmIStatus && activation_status != "activated") | ||
| MM_LOGINFO("WhoAmI feature is enabled"); | ||
| if (UNSOLICITED_MAINTENANCE == g_maintenance_type) | ||
| { | ||
| MM_LOGINFO("knowWhoAmI() returned false and Device is not already Activated"); | ||
| g_listen_to_deviceContextUpdate = true; | ||
| MM_LOGINFO("Waiting for onDeviceInitializationContextUpdate event"); | ||
| task_thread.wait(wailck); | ||
| string activation_status = checkActivatedStatus(); /* Device Activation Status Check */ | ||
| bool whoAmIStatus = knowWhoAmI(activation_status); /* WhoAmI Response & Set Status Check */ | ||
| MM_LOGINFO("knowWhoAmI() returned %s", (whoAmIStatus) ? "successfully" : "false"); | ||
|
|
||
| if (!whoAmIStatus && activation_status != "activated") | ||
| { | ||
| MM_LOGINFO("knowWhoAmI() returned false and Device is not already Activated"); | ||
| g_listen_to_deviceContextUpdate = true; | ||
| MM_LOGINFO("Waiting for onDeviceInitializationContextUpdate event"); | ||
| task_thread.wait(wailck); | ||
| } | ||
| else if (!internetConnectStatus && activation_status == "activated") | ||
| { | ||
| MM_LOGINFO("Device is not connected to the Internet and Device is already Activated"); | ||
| exitOnNoNetwork = true; | ||
| } | ||
| } | ||
| else if (!internetConnectStatus && activation_status == "activated") | ||
| else /* Solicited Maintenance in WHOAMI */ | ||
| { | ||
| MM_LOGINFO("Device is not connected to the Internet and Device is already Activated"); | ||
| exitOnNoNetwork = true; | ||
| if (!internetConnectStatus) | ||
| { | ||
| exitOnNoNetwork = true; | ||
| } | ||
| } | ||
| } | ||
| else /* Solicited Maintenance in WHOAMI */ | ||
| else | ||
| { | ||
| MM_LOGINFO("WhoAmI feature is disabled"); | ||
| if (!internetConnectStatus) | ||
| { | ||
| exitOnNoNetwork = true; | ||
| } | ||
| } | ||
| #else | ||
| if (!internetConnectStatus) | ||
| { | ||
| exitOnNoNetwork = true; | ||
| } | ||
| #endif | ||
|
|
||
| if (exitOnNoNetwork) /* Exit Maintenance Cycle if no Internet */ | ||
| { | ||
| m_statusMutex.lock(); | ||
|
|
@@ -453,9 +460,8 @@ | |
|
|
||
| MM_LOGINFO("Reboot_Pending :%s", g_is_reboot_pending.c_str()); | ||
| MM_LOGINFO("%s", UNSOLICITED_MAINTENANCE == g_maintenance_type ? "---------------UNSOLICITED_MAINTENANCE--------------" : "=============SOLICITED_MAINTENANCE==============="); | ||
|
|
||
| #if defined(SUPPRESS_MAINTENANCE) && !defined(ENABLE_WHOAMI) | ||
| if (skipFirmwareCheck) | ||
|
|
||
| if (!g_whoami_support_enabled && g_suppress_maintenance_enabled && skipFirmwareCheck) | ||
| { | ||
| /* set the task status of Firmware Download */ | ||
| SET_STATUS(g_task_status, SWUPDATE_SUCCESS); | ||
|
|
@@ -464,17 +470,13 @@ | |
| tasks.push_back(task_names_foreground[TASK_RFC].c_str()); | ||
| tasks.push_back(task_names_foreground[TASK_LOGUPLOAD].c_str()); | ||
| } | ||
| else | ||
| else | ||
| { | ||
| tasks.push_back(task_names_foreground[TASK_RFC].c_str()); | ||
| tasks.push_back(task_names_foreground[TASK_SWUPDATE].c_str()); | ||
| tasks.push_back(task_names_foreground[TASK_LOGUPLOAD].c_str()); | ||
| } | ||
| #else | ||
| tasks.push_back(task_names_foreground[TASK_RFC].c_str()); | ||
| tasks.push_back(task_names_foreground[TASK_SWUPDATE].c_str()); | ||
| tasks.push_back(task_names_foreground[TASK_LOGUPLOAD].c_str()); | ||
| #endif | ||
|
|
||
| std::unique_lock<std::mutex> lck(m_callMutex); | ||
| for (i = 0; i < static_cast<int>(tasks.size()) && !m_abort_flag; i++) | ||
| { | ||
|
|
@@ -563,7 +565,19 @@ | |
| MM_LOGINFO("Worker Thread Completed"); | ||
| } /* end of task_execution_thread() */ | ||
|
|
||
| #if defined(ENABLE_WHOAMI) || defined(GTEST_ENABLE) | ||
| bool MaintenanceManager::isWhoAmIEnabled() | ||
| { | ||
| bool wai_enabled = false; | ||
| std::string wai_prop_val; | ||
| if (!Utils::readPropertyFromFile(DEVICE_PROP_FILE, WHOAMI_PROP_KEY, wai_prop_val)) { | ||
| MM_LOGERR("Failed to read %s property", WHOAMI_PROP_KEY); | ||
| return wai_enabled; | ||
| } | ||
|
|
||
| wai_enabled = (wai_prop_val == "true"); | ||
| return wai_enabled; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Determines the device identity by querying the Security Manager. | ||
| * | ||
|
|
@@ -641,7 +655,6 @@ | |
| } | ||
| } while (true); | ||
| } | ||
| #endif /* end of ENABLE_WHOAMI */ | ||
|
|
||
| /** | ||
| * @brief Retrieves a handle to the specified Thunder plugin with authentication. | ||
|
|
@@ -1453,9 +1466,12 @@ | |
|
|
||
| m_service = service; | ||
| m_service->AddRef(); | ||
| #if defined(ENABLE_WHOAMI) | ||
| subscribeToDeviceInitializationEvent(); | ||
| #endif | ||
| if ((g_whoami_support_enabled = isWhoAmIEnabled())) { | ||
| MM_LOGINFO("WhoAmI feature is enabled"); | ||
| subscribeToDeviceInitializationEvent(); | ||
| } else { | ||
| MM_LOGINFO("WhoAmI feature is disabled"); | ||
| } | ||
|
|
||
| #if defined(USE_IARMBUS) || defined(USE_IARM_BUS) | ||
| InitializeIARM(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| /** | ||
|
Check failure on line 1 in MaintenanceManager/MaintenanceManager.h
|
||
| * If not stated otherwise in this file or this component's LICENSE | ||
| * file the following copyright and licenses apply: | ||
| * | ||
|
|
@@ -113,6 +113,9 @@ | |
|
|
||
| #define BASE_CLOCK CLOCK_BOOTTIME | ||
|
|
||
| #define WHOAMI_PROP_KEY "WHOAMI_SUPPORT" | ||
| #define DEVICE_PROP_FILE "/etc/device.properties" | ||
|
|
||
| #define FOREGROUND_MODE "FOREGROUND" | ||
| #define BACKGROUND_MODE "BACKGROUND" | ||
|
|
||
|
|
@@ -200,7 +203,12 @@ | |
| bool g_subscribed_for_nwevents = false; | ||
| bool g_listen_to_deviceContextUpdate = false; | ||
| bool g_subscribed_for_deviceContextUpdate = false; | ||
|
|
||
| bool g_whoami_support_enabled = false; | ||
| #if defined(SUPPRESS_MAINTENANCE) | ||
| bool g_suppress_maintenance_enabled = true; | ||
| #else | ||
| bool g_suppress_maintenance_enabled = false; | ||
| #endif | ||
| std::mutex m_callMutex; | ||
| std::mutex m_waiMutex; | ||
| std::mutex m_statusMutex; | ||
|
|
@@ -229,6 +237,7 @@ | |
| void deviceInitializationContextEventHandler(const JsonObject ¶meters); | ||
| void startCriticalTasks(); | ||
| bool checkNetwork(); | ||
| bool isWhoAmIEnabled(); | ||
| bool knowWhoAmI(string &activation_status); | ||
| bool subscribeToDeviceInitializationEvent(); | ||
| bool setDeviceInitializationContext(JsonObject joGetResult); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.