|
66 | 66 | using namespace std;
|
67 | 67 |
|
68 | 68 | #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 |
71 | 71 |
|
72 | 72 | #define MAX_REBOOT_DELAY 86400 /* 24Hr = 86400 sec */
|
73 | 73 | #define TR181_FW_DELAY_REBOOT "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AutoReboot.fwDelayReboot"
|
@@ -99,6 +99,7 @@ using namespace std;
|
99 | 99 | #define LOG_UPLOAD_STATUS_ABORTED "UPLOAD_ABORTED"
|
100 | 100 |
|
101 | 101 | #define PRIVACY_MODE_FILE "/opt/secure/persistent/System/privacymode.txt"
|
| 102 | +#define BOOTVERSION "/opt/.bootversion" |
102 | 103 |
|
103 | 104 | /**
|
104 | 105 | * @struct firmwareUpdate
|
@@ -497,6 +498,7 @@ namespace WPEFramework {
|
497 | 498 |
|
498 | 499 | registerMethod("setPrivacyMode", &SystemServices::setPrivacyMode, this);
|
499 | 500 | registerMethod("getPrivacyMode", &SystemServices::getPrivacyMode, this);
|
| 501 | + registerMethod("getBootTypeInfo", &SystemServices::getBootTypeInfo, this); |
500 | 502 |
|
501 | 503 | }
|
502 | 504 |
|
@@ -4849,6 +4851,57 @@ namespace WPEFramework {
|
4849 | 4851 | returnResponse(status);
|
4850 | 4852 | }
|
4851 | 4853 |
|
| 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 |
4852 | 4905 |
|
4853 | 4906 | } /* namespace Plugin */
|
4854 | 4907 | } /* namespace WPEFramework */
|
|
0 commit comments