Skip to content

Commit

Permalink
RDKTV-31562: Remove deprecated Cache APIs from System Service
Browse files Browse the repository at this point in the history
  • Loading branch information
ks734 committed Jul 30, 2024
1 parent 8721893 commit d520543
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 542 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Use the existing services as a guide when learning the structure of both the plu
* Deprecation
* Breaking changes to the API that requires a major version update should first go through Deprecation by doing a minor version update. We recommend atleast 2 RDK releases with the deprecated API/s and minor version update to give time for clients and apps to make changes to remove the deprecated API. Following needs to be done for deprecation.
* The API/s getting deprecated should be marked with a ["deprecated"](https://github.com/rdkcentral/rdkservices/blob/main/SystemServices/System.json#L356) label in the json schema. This will ensure that it's updated in the API [documentation.](https://rdkcentral.github.io/rdkservices/#/api/SystemPlugin?id=cachecontains)
* The API/s getting deprecated should be marked with a ["deprecated"](https://github.com/rdkcentral/rdkservices/blob/main/SystemServices/System.json#L740) label in the json schema. This will ensure that it's updated in the API [documentation.](https://rdkcentral.github.io/rdkservices/#/api/SystemPlugin?id=getmilestones)
* Add a changelog entry with minor version update and include **Deprecated** label to call out the API/s getting deprecated.
* If this API/s is getting replaced by a newer API then it can come in the same minor version update with changelog entry with **Added** label.
<br><br>
Expand All @@ -306,4 +306,4 @@ This checklist is primarily intended for maintainers or reviewers. Please check
If you have any questions or concerns reach out to [Anand Kandasamy](mailto:[email protected])
For a plugin specific question, maintainers might refer you to the plugin owner(s).
<br><br>
<br><br>
96 changes: 0 additions & 96 deletions SystemServices/System.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,25 +366,6 @@
}
},
"methods": {
"cacheContains": {
"deprecated" : true,
"referenceUrl" : " https://rdkcentral.github.io/rdkservices/#/api/PersistentStorePlugin?id=getvalue",
"summary": "Checks if a key is present in the cache.",
"params": {
"type": "object",
"properties": {
"key": {
"$ref": "#/definitions/key"
}
},
"required": [
"key"
]
},
"result": {
"$ref": "#/common/result"
}
},
"clearLastDeepSleepReason":{
"summary": "Clears the last deep sleep reason.",
"result": {
Expand Down Expand Up @@ -485,39 +466,6 @@
]
}
},
"getCachedValue":{
"deprecated" : true,
"referenceUrl" : "https://rdkcentral.github.io/rdkservices/#/api/PersistentStorePlugin?id=getvalue",
"summary": "Gets the value of a key in the cache.",
"params": {
"type": "object",
"properties": {
"key": {
"$ref": "#/definitions/key"
}
},
"required": [
"key"
]
},
"result": {
"type": "object",
"properties": {
"sampleKey": {
"summary": "Value for the specified key name",
"type": "string",
"example": "4343.3434"
},
"success":{
"$ref": "#/common/success"
}
},
"required": [
"sampleKey",
"success"
]
}
},
"getCoreTemperature":{
"summary": "Returns the core temperature of the device. Not supported on all devices.",
"result": {
Expand Down Expand Up @@ -1550,25 +1498,6 @@
]
}
},
"removeCacheKey":{
"deprecated" : true,
"referenceUrl" : "https://rdkcentral.github.io/rdkservices/#/api/PersistentStorePlugin?id=deletekey",
"summary": "Removes the cache key.",
"params": {
"type":"object",
"properties": {
"key": {
"$ref": "#/definitions/key"
}
},
"required": [
"key"
]
},
"result": {
"$ref": "#/common/result"
}
},
"requestSystemUptime":{
"summary": "Returns the device uptime.",
"result": {
Expand Down Expand Up @@ -1606,31 +1535,6 @@
"$ref": "#/common/result"
}
},
"setCachedValue": {
"deprecated" : true,
"referenceUrl" : "https://rdkcentral.github.io/rdkservices/#/api/PersistentStorePlugin?id=setvalue",
"summary": "Sets the value for a key in the cache.",
"params": {
"type":"object",
"properties": {
"key": {
"$ref": "#/definitions/key"
},
"value":{
"summary": "The value to set",
"type": "number",
"example": "4343.3434"
}
},
"required": [
"key",
"value"
]
},
"result": {
"$ref": "#/common/result"
}
},
"setDeepSleepTimer": {
"summary": "Sets the deep sleep timeout period.",
"params": {
Expand Down
139 changes: 0 additions & 139 deletions SystemServices/SystemServices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,22 +346,8 @@ namespace WPEFramework {
*/
SystemServices::SystemServices()
: PluginHost::JSONRPC()
, m_cacheService(SYSTEM_SERVICE_SETTINGS_FILE)
{
SystemServices::_instance = this;
if (Utils::directoryExists(SYSTEM_SERVICE_SETTINGS_FILE))
{
std::cout << "File " << SYSTEM_SERVICE_SETTINGS_FILE << " detected as folder, deleting.." << std::endl;
if (rmdir(SYSTEM_SERVICE_SETTINGS_FILE) == 0)
{
cSettings stemp(SYSTEM_SERVICE_SETTINGS_FILE);
SystemServices::m_cacheService = stemp;
}
else
{
std::cout << "Unable to delete folder: " << SYSTEM_SERVICE_SETTINGS_FILE << std::endl;
}
}

//Updating the standard territory
m_strStandardTerritoryList = "ABW AFG AGO AIA ALA ALB AND ARE ARG ARM ASM ATA ATF ATG AUS AUT AZE BDI BEL BEN BES BFA BGD BGR BHR BHS BIH BLM BLR BLZ BMU BOL BRA BRB BRN BTN BVT BWA CAF CAN CCK CHE CHL CHN CIV CMR COD COG COK COL COM CPV CRI CUB Cuba CUW CXR CYM CYP CZE DEU DJI DMA DNK DOM DZA ECU EGY ERI ESH ESP EST ETH FIN FJI FLK FRA FRO FSM GAB GBR GEO GGY GHA GIB GIN GLP GMB GNB GNQ GRC GRD GRL GTM GUF GUM GUY HKG HMD HND HRV HTI HUN IDN IMN IND IOT IRL IRN IRQ ISL ISR ITA JAM JEY JOR JPN KAZ KEN KGZ KHM KIR KNA KOR KWT LAO LBN LBR LBY LCA LIE LKA LSO LTU LUX LVA MAC MAF MAR MCO MDA MDG MDV MEX MHL MKD MLI MLT MMR MNE MNG MNP MOZ MRT MSR MTQ MUS MWI MYS MYT NAM NCL NER NFK NGA NIC NIU NLD NOR NPL NRU NZL OMN PAK PAN PCN PER PHL PLW PNG POL PRI PRK PRT PRY PSE PYF QAT REU ROU RUS RWA SAU SDN SEN SGP SGS SHN SJM SLB SLE SLV SMR SOM SPM SRB SSD STP SUR SVK SVN SWE SWZ SXM SYC SYR TCA TCD TGO THA TJK TKL TKM TLS TON TTO TUN TUR TUV TWN TZA UGA UKR UMI URY USA UZB VAT VCT VEN VGB VIR VNM VUT WLF WSM YEM ZAF ZMB ZWE";
Expand Down Expand Up @@ -439,10 +425,6 @@ namespace WPEFramework {
registerMethod("getTimeZoneDST", &SystemServices::getTimeZoneDST, this);
registerMethod("getCoreTemperature", &SystemServices::getCoreTemperature,
this);
registerMethod("getCachedValue", &SystemServices::getCachedValue, this);
registerMethod("setCachedValue", &SystemServices::setCachedValue, this);
registerMethod("cacheContains", &SystemServices::cacheContains, this);
registerMethod("removeCacheKey", &SystemServices::removeCacheKey, this);
registerMethod("getPreviousRebootInfo",
&SystemServices::getPreviousRebootInfo, this);
registerMethod("getLastDeepSleepReason",
Expand Down Expand Up @@ -3029,127 +3011,6 @@ namespace WPEFramework {
returnResponse(resp);
}

/***
* @brief : To get cashed value .
* @param1[in] : {"params":{"key":"<string>"}}
* @param2[out] : {"result":{"<cachekey>":"<string>","success":<bool>}}
* @return : Core::<StatusCode>
*/
uint32_t SystemServices::getCachedValue(const JsonObject& parameters,
JsonObject& response)
{
bool retStat = false;
bool deprecated = true;
if (parameters.HasLabel("key")) {
std::string key = parameters["key"].String();
LOGWARN("key: '%s'\n", key.c_str());
if (key.length()) {
response[(key.c_str())] = (m_cacheService.getValue(key).String().empty()?
"" : m_cacheService.getValue(key).String());
retStat = true;
} else {
populateResponseWithError(SysSrv_UnSupportedFormat, response);
}
} else {
populateResponseWithError(SysSrv_MissingKeyValues, response);
}
response["deprecated"] = deprecated;
returnResponse(retStat);
}

/***
* @brief : To set cache value.
* @param1[in] : {"params":{"key":"<string>","value":<double>}}
* @param2[out] : {"jsonrpc":"2.0","id":3,"result":{"success":<bool>}}
* @return : Core::<StatusCode>
*/
uint32_t SystemServices::setCachedValue(const JsonObject& parameters,
JsonObject& response)
{
bool retStat = false;
bool deprecated = true;

if (parameters.HasLabel("key") && parameters.HasLabel("value")) {
std::string key = parameters["key"].String();
std::string value = parameters["value"].String();
LOGWARN("key: '%s' value: '%s'\n", key.c_str(), value.c_str());
if (key.length() && value.length()) {
if (m_cacheService.setValue(key, value)) {
retStat = true;
} else {
LOGERR("Accessing m_cacheService.setValue failed\n.");
populateResponseWithError(SysSrv_Unexpected, response);
}
} else {
populateResponseWithError(SysSrv_UnSupportedFormat, response);
}
} else {
populateResponseWithError(SysSrv_MissingKeyValues, response);
}
response["deprecated"] = deprecated;
returnResponse(retStat);
}

/***
* @brief : To check if key value present in cache.
* @param1[in] : {"params":{"key":"<string>"}}
* @param2[out] : {"jsonrpc":"2.0","id":3,"result":{"success":<bool>}}
* @return : Core::<StatusCode>
*/
uint32_t SystemServices::cacheContains(const JsonObject& parameters,
JsonObject& response)
{
bool retStat = false;
bool deprecated = true;
if (parameters.HasLabel("key")) {
std::string key = parameters["key"].String();
if (key.length()) {
if (m_cacheService.contains(key)) {
retStat = true;
} else {
LOGERR("Accessing m_cacheService.contains; no matching key '%s'\n.", key.c_str());
populateResponseWithError(SysSrv_KeyNotFound, response);
}
} else {
populateResponseWithError(SysSrv_UnSupportedFormat, response);
}
} else {
populateResponseWithError(SysSrv_MissingKeyValues, response);
}
response["deprecated"] = deprecated;
returnResponse(retStat);
}

/***
* @brief : To delete the key value present in cache.
* @param1[in] : {"params":{"key":"<string>"}}
* @param2[out] : {"jsonrpc":"2.0","id":3,"result":{"success":<bool>}}
* @return : Core::<StatusCode>
*/
uint32_t SystemServices::removeCacheKey(const JsonObject& parameters,
JsonObject& response)
{
bool retStat = false;
bool deprecated = true;
if (parameters.HasLabel("key")) {
std::string key = parameters["key"].String();
if (key.length()) {
if (m_cacheService.remove(key)) {
retStat = true;
} else {
LOGERR("Accessing m_cacheService.remove failed\n.");
populateResponseWithError(SysSrv_Unexpected, response);
}
} else {
populateResponseWithError(SysSrv_UnSupportedFormat, response);
}
} else {
populateResponseWithError(SysSrv_MissingKeyValues, response);
}
response["deprecated"] = deprecated;
returnResponse(retStat);
}

/***
* @brief : To get previous boot info.
* @param1[in] : {"params":{}}
Expand Down
5 changes: 0 additions & 5 deletions SystemServices/SystemServices.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ namespace WPEFramework {
typedef Core::JSON::ArrayType<JString> JStringArray;
typedef Core::JSON::Boolean JBool;
string m_stbVersionString;
cSettings m_cacheService;
static cSettings m_temp_settings;
#if defined(USE_IARMBUS) || defined(USE_IARM_BUS)
static IARM_Bus_SYSMgr_GetSystemStates_Param_t paramGetSysState;
Expand Down Expand Up @@ -226,10 +225,6 @@ namespace WPEFramework {
and getProperty functionalities are XRE/RTRemote dependent. */
bool setProperties(const JsonObject& propertyNames);
bool getProperties(const JsonObject& params, JsonObject& returnProperties);
uint32_t getCachedValue(const JsonObject& parameters, JsonObject& response);
uint32_t setCachedValue(const JsonObject& parameters, JsonObject& response);
uint32_t cacheContains(const JsonObject& parameters, JsonObject& response);
uint32_t removeCacheKey(const JsonObject& parameters, JsonObject& response);
uint32_t getMode(const JsonObject& parameters, JsonObject& response);
uint32_t updateFirmware(const JsonObject& parameters, JsonObject& response);
uint32_t setMode(const JsonObject& parameters, JsonObject& response);
Expand Down
Loading

0 comments on commit d520543

Please sign in to comment.