Skip to content
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

RDK-53843: Added getBoottypeInfo method #5892

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions SystemServices/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ All notable changes to this RDK Service will be documented in this file.

* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.

## [3.3.3] - 2024-11-28
### Added
- Added implementation for BootType get API.

## [3.3.2] - 2024-10-9
### Added
- Added implementation for FSR get and set API.
Expand Down
10 changes: 9 additions & 1 deletion SystemServices/System.json
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,15 @@
"type": "string",
"example": "DO_NOT_SHARE"
}
}
},
"getBootTypeInfo":{
"summary": "Getting Boot Type",
"result": {
"summary": "BOOT Type Info",
"type": "string",
"example": "BOOT_UPDATE"
}
}
},
"events": {
"onFirmwarePendingReboot":{
Expand Down
55 changes: 54 additions & 1 deletion SystemServices/SystemServices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ using namespace std;

#define API_VERSION_NUMBER_MAJOR 3
#define API_VERSION_NUMBER_MINOR 3
#define API_VERSION_NUMBER_PATCH 2
#define API_VERSION_NUMBER_PATCH 3

#define MAX_REBOOT_DELAY 86400 /* 24Hr = 86400 sec */
#define TR181_FW_DELAY_REBOOT "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AutoReboot.fwDelayReboot"
Expand Down Expand Up @@ -99,6 +99,7 @@ using namespace std;
#define LOG_UPLOAD_STATUS_ABORTED "UPLOAD_ABORTED"

#define PRIVACY_MODE_FILE "/opt/secure/persistent/System/privacymode.txt"
#define BOOTVERSION "/opt/.bootversion"

/**
* @struct firmwareUpdate
Expand Down Expand Up @@ -497,6 +498,7 @@ namespace WPEFramework {

registerMethod("setPrivacyMode", &SystemServices::setPrivacyMode, this);
registerMethod("getPrivacyMode", &SystemServices::getPrivacyMode, this);
registerMethod("getBootTypeInfo", &SystemServices::getBootTypeInfo, this);

}

Expand Down Expand Up @@ -4849,6 +4851,57 @@ namespace WPEFramework {
returnResponse(status);
}

/**
* @brief : API to query BootType details
*
* @param1[in] : {"params":{}}}
* @param2[out] : "result":{<key>:<BootType Info Details>,"success":<bool>}
* @return : Core::<StatusCode>
*/

uint32_t SystemServices::getBootTypeInfo(const JsonObject& parameters, JsonObject& response)
{
LOGINFOMETHOD();
//check if file exists
std::ifstream file_read(BOOTVERSION);
if (! file_read){
LOGERR("Failed to open file %s\n", BOOTVERSION);
returnResponse(false);
}
//Read the file and get the imagename, version and fw_class
std::string line,key_val,value;
std::map<std::string,std::vector<std::string>> boot_val;
while(std::getline(file_read, line)){
size_t pos=0, start=0;
pos = line.find(':', start);
key_val = line.substr(start, pos);
value = line.substr(pos+1);
if (key_val == "imagename" || key_val == "VERSION" || key_val == "FW_CLASS") {
boot_val[key_val].push_back(value);
}
}
file_read.close();
//if both the slots are present then we can get the boot type or it is inconclusive
if(boot_val["FW_CLASS"].size() == 2 ) {
if(boot_val["FW_CLASS"][0] != boot_val["FW_CLASS"][1]) {
response["bootType"] = "BOOT_MIGRATION";
LOGINFO("Boot Type is BOOT_MIGRATION\n");
}
else if((boot_val["FW_CLASS"][0] == boot_val["FW_CLASS"][1]) && (boot_val["imagename"][0] == boot_val["imagename"][1])){
response["bootType"] = "BOOT_NORMAL";
LOGINFO("Boot Type is BOOT_NORMAL\n");
}
else if((boot_val["FW_CLASS"][0] == boot_val["FW_CLASS"][1]) && (boot_val["imagename"][0] != boot_val["imagename"][1])) {
response["bootType"] = "BOOT_UPDATE";
LOGINFO("Boot Type is BOOT_UPDATE\n");
}
}// only one slot is populated and both cannot be empty since file is present
else{
response["bootType"] = "BOOT_INCONCLUSIVE";
LOGINFO("Boot Type is BOOT_INCONCLUSIVE\n");
}
returnResponse(true);
}//end of getBootTypeInfo

} /* namespace Plugin */
} /* namespace WPEFramework */
Expand Down
1 change: 1 addition & 0 deletions SystemServices/SystemServices.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ namespace WPEFramework {
uint32_t getPrivacyMode(const JsonObject& parameters, JsonObject& response);
uint32_t setFSRFlag(const JsonObject& parameters, JsonObject& response);
uint32_t getFSRFlag(const JsonObject& parameters, JsonObject& response);
uint32_t getBootTypeInfo(const JsonObject& parameters, JsonObject& response);
}; /* end of system service class */
} /* end of plugin */
} /* end of wpeframework */
Expand Down
Loading