-
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
Changes from 6 commits
d0dd2ac
ff65bb1
a630a4f
4b555b0
4f88c84
3d03e91
d70f2b1
c9bcb6b
6eedbaa
dbfd276
9835d5a
b0195a1
6a09e04
04cf70c
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 |
|---|---|---|
| @@ -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,21 +337,20 @@ | |
| 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() | ||
| { | ||
| int i = 0; | ||
| string task = ""; | ||
| bool isMaintenanceSuppressed = false; | ||
| bool internetConnectStatus = false; | ||
| bool delayMaintenanceStarted = false; | ||
| bool exitOnNoNetwork = false; | ||
|
|
@@ -361,13 +360,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 +379,68 @@ | |
| 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) | ||
| #if defined(SUPPRESS_MAINTENANCE) | ||
| if (!g_whoami_support_enabled) | ||
| { | ||
| MM_LOGINFO("WHOAMI_SUPPORT is disabled\n"); | ||
| isMaintenanceSuppressed = true; | ||
| 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) | ||
| { | ||
| internetConnectStatus = isDeviceOnline(); /* Network check */ | ||
| } | ||
| } | ||
| #endif | ||
| if (!isMaintenanceSuppressed) | ||
| { | ||
| 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_SUPPORT is enabled\n"); | ||
yogeswaransky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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); | ||
yogeswaransky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| 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_SUPPORT is disabled\n"); | ||
yogeswaransky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (!internetConnectStatus) | ||
| { | ||
| exitOnNoNetwork = true; | ||
| } | ||
| } | ||
| #else | ||
| if (!internetConnectStatus) | ||
| { | ||
| exitOnNoNetwork = true; | ||
| } | ||
| #endif | ||
|
|
||
| if (exitOnNoNetwork) /* Exit Maintenance Cycle if no Internet */ | ||
| { | ||
| m_statusMutex.lock(); | ||
|
|
@@ -453,28 +464,34 @@ | |
|
|
||
| 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 defined(SUPPRESS_MAINTENANCE) | ||
| if (!g_whoami_support_enabled && isMaintenanceSuppressed) | ||
| { | ||
| /* set the task status of Firmware Download */ | ||
| SET_STATUS(g_task_status, SWUPDATE_SUCCESS); | ||
| SET_STATUS(g_task_status, SWUPDATE_COMPLETE); | ||
| /* Skip Firmware Download Task and add other tasks */ | ||
| tasks.push_back(task_names_foreground[TASK_RFC].c_str()); | ||
| tasks.push_back(task_names_foreground[TASK_LOGUPLOAD].c_str()); | ||
| if (skipFirmwareCheck) | ||
| { | ||
| /* set the task status of Firmware Download */ | ||
| SET_STATUS(g_task_status, SWUPDATE_SUCCESS); | ||
| SET_STATUS(g_task_status, SWUPDATE_COMPLETE); | ||
| /* Skip Firmware Download Task and add other tasks */ | ||
| tasks.push_back(task_names_foreground[TASK_RFC].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()); | ||
| } | ||
| } | ||
| else | ||
| #endif | ||
| if (!isMaintenanceSuppressed) | ||
| { | ||
| 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++) | ||
| { | ||
|
|
@@ -561,7 +578,28 @@ | |
| MM_LOGINFO("Worker Thread Completed"); | ||
| } /* end of task_execution_thread() */ | ||
|
|
||
| #if defined(ENABLE_WHOAMI) | ||
| void MaintenanceManager::isWhoAmIEnabled() | ||
yogeswaransky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| std::string wai_prop_val; | ||
| if (Utils::readPropertyFromFile(DEVICE_PROP_FILE, WHOAMI_PROP_KEY, wai_prop_val)) | ||
| { | ||
| if (wai_prop_val == "true") | ||
| { | ||
| g_whoami_support_enabled = true; | ||
| MM_LOGINFO("Device is in WhoAmI mode"); | ||
| } | ||
| else | ||
| { | ||
| g_whoami_support_enabled = false; | ||
| MM_LOGINFO("Device is not in WhoAmI mode"); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| MM_LOGERR("Failed to read %s property", WHOAMI_PROP_KEY); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief Determines the device identity by querying the Security Manager. | ||
| * | ||
|
|
@@ -639,7 +677,6 @@ | |
| } | ||
| } while (true); | ||
| } | ||
| #endif /* end of ENABLE_WHOAMI */ | ||
|
|
||
| /** | ||
| * @brief Retrieves a handle to the specified Thunder plugin with authentication. | ||
|
|
@@ -1437,15 +1474,17 @@ | |
|
|
||
| const string MaintenanceManager::Initialize(PluginHost::IShell *service) | ||
| { | ||
| isWhoAmIEnabled(); | ||
| ASSERT(service != nullptr); | ||
| ASSERT(m_service == nullptr); | ||
| ASSERT(timerid != nullptr); | ||
|
|
||
| m_service = service; | ||
| m_service->AddRef(); | ||
| #if defined(ENABLE_WHOAMI) | ||
| subscribeToDeviceInitializationEvent(); | ||
| #endif | ||
| if (g_whoami_support_enabled) { | ||
yogeswaransky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| MM_LOGINFO("WHOAMI_SUPPORT is enabled\n"); | ||
| subscribeToDeviceInitializationEvent(); | ||
| } | ||
|
|
||
| #if defined(USE_IARMBUS) || defined(USE_IARM_BUS) | ||
| InitializeIARM(); | ||
|
|
||
| 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: | ||
| * | ||
|
|
@@ -114,6 +114,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" | ||
|
|
||
|
|
@@ -193,6 +196,7 @@ | |
| bool g_subscribed_for_nwevents = false; | ||
| bool g_listen_to_deviceContextUpdate = false; | ||
| bool g_subscribed_for_deviceContextUpdate = false; | ||
| bool g_whoami_support_enabled = false; | ||
|
|
||
yogeswaransky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| std::mutex m_callMutex; | ||
| std::mutex m_waiMutex; | ||
|
|
@@ -222,6 +226,7 @@ | |
| void deviceInitializationContextEventHandler(const JsonObject ¶meters); | ||
| void startCriticalTasks(); | ||
| bool checkNetwork(); | ||
| void isWhoAmIEnabled(); | ||
| bool knowWhoAmI(string &activation_status); | ||
| bool subscribeToDeviceInitializationEvent(); | ||
| bool setDeviceInitializationContext(JsonObject joGetResult); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.