Skip to content

Commit 8ce8da8

Browse files
authored
Merge pull request rdkcentral#5892 from fzahir786/main
RDK-53843: Added getBoottypeInfo method
2 parents 62be198 + 63c1153 commit 8ce8da8

File tree

4 files changed

+69
-3
lines changed

4 files changed

+69
-3
lines changed

SystemServices/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ All notable changes to this RDK Service will be documented in this file.
1616

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

19+
## [3.4.0] - 2024-12-09
20+
### Added
21+
- Added implementation for BootType get API.
22+
1923
## [3.3.2] - 2024-10-9
2024
### Added
2125
- Added implementation for FSR get and set API.

SystemServices/System.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1973,7 +1973,15 @@
19731973
"type": "string",
19741974
"example": "DO_NOT_SHARE"
19751975
}
1976-
}
1976+
},
1977+
"getBootTypeInfo":{
1978+
"summary": "Getting Boot Type",
1979+
"result": {
1980+
"summary": "BOOT Type Info",
1981+
"type": "string",
1982+
"example": "BOOT_UPDATE"
1983+
}
1984+
}
19771985
},
19781986
"events": {
19791987
"onFirmwarePendingReboot":{

SystemServices/SystemServices.cpp

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
using namespace std;
6767

6868
#define API_VERSION_NUMBER_MAJOR 3
69-
#define API_VERSION_NUMBER_MINOR 3
70-
#define API_VERSION_NUMBER_PATCH 2
69+
#define API_VERSION_NUMBER_MINOR 4
70+
#define API_VERSION_NUMBER_PATCH 0
7171

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

101101
#define PRIVACY_MODE_FILE "/opt/secure/persistent/System/privacymode.txt"
102+
#define BOOTVERSION "/opt/.bootversion"
102103

103104
/**
104105
* @struct firmwareUpdate
@@ -497,6 +498,7 @@ namespace WPEFramework {
497498

498499
registerMethod("setPrivacyMode", &SystemServices::setPrivacyMode, this);
499500
registerMethod("getPrivacyMode", &SystemServices::getPrivacyMode, this);
501+
registerMethod("getBootTypeInfo", &SystemServices::getBootTypeInfo, this);
500502

501503
}
502504

@@ -4849,6 +4851,57 @@ namespace WPEFramework {
48494851
returnResponse(status);
48504852
}
48514853

4854+
/**
4855+
* @brief : API to query BootType details
4856+
*
4857+
* @param1[in] : {"params":{}}}
4858+
* @param2[out] : "result":{<key>:<BootType Info Details>,"success":<bool>}
4859+
* @return : Core::<StatusCode>
4860+
*/
4861+
4862+
uint32_t SystemServices::getBootTypeInfo(const JsonObject& parameters, JsonObject& response)
4863+
{
4864+
LOGINFOMETHOD();
4865+
//check if file exists
4866+
std::ifstream file_read(BOOTVERSION);
4867+
if (! file_read){
4868+
LOGERR("Failed to open file %s\n", BOOTVERSION);
4869+
returnResponse(false);
4870+
}
4871+
//Read the file and get the imagename, version and fw_class
4872+
std::string line,key_val,value;
4873+
std::map<std::string,std::vector<std::string>> boot_val;
4874+
while(std::getline(file_read, line)){
4875+
size_t pos=0, start=0;
4876+
pos = line.find(':', start);
4877+
key_val = line.substr(start, pos);
4878+
value = line.substr(pos+1);
4879+
if (key_val == "imagename" || key_val == "VERSION" || key_val == "FW_CLASS") {
4880+
boot_val[key_val].push_back(value);
4881+
}
4882+
}
4883+
file_read.close();
4884+
//if both the slots are present then we can get the boot type or it is inconclusive
4885+
if(boot_val["FW_CLASS"].size() == 2 ) {
4886+
if(boot_val["FW_CLASS"][0] != boot_val["FW_CLASS"][1]) {
4887+
response["bootType"] = "BOOT_MIGRATION";
4888+
LOGINFO("Boot Type is BOOT_MIGRATION\n");
4889+
}
4890+
else if((boot_val["FW_CLASS"][0] == boot_val["FW_CLASS"][1]) && (boot_val["imagename"][0] == boot_val["imagename"][1])){
4891+
response["bootType"] = "BOOT_NORMAL";
4892+
LOGINFO("Boot Type is BOOT_NORMAL\n");
4893+
}
4894+
else if((boot_val["FW_CLASS"][0] == boot_val["FW_CLASS"][1]) && (boot_val["imagename"][0] != boot_val["imagename"][1])) {
4895+
response["bootType"] = "BOOT_UPDATE";
4896+
LOGINFO("Boot Type is BOOT_UPDATE\n");
4897+
}
4898+
}// only one slot is populated and both cannot be empty since file is present
4899+
else{
4900+
response["bootType"] = "BOOT_INCONCLUSIVE";
4901+
LOGINFO("Boot Type is BOOT_INCONCLUSIVE\n");
4902+
}
4903+
returnResponse(true);
4904+
}//end of getBootTypeInfo
48524905

48534906
} /* namespace Plugin */
48544907
} /* namespace WPEFramework */

SystemServices/SystemServices.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ namespace WPEFramework {
308308
uint32_t getPrivacyMode(const JsonObject& parameters, JsonObject& response);
309309
uint32_t setFSRFlag(const JsonObject& parameters, JsonObject& response);
310310
uint32_t getFSRFlag(const JsonObject& parameters, JsonObject& response);
311+
uint32_t getBootTypeInfo(const JsonObject& parameters, JsonObject& response);
311312
}; /* end of system service class */
312313
} /* end of plugin */
313314
} /* end of wpeframework */

0 commit comments

Comments
 (0)