From: Piotr Kosko Date: Fri, 19 Dec 2014 11:49:01 +0000 (+0100) Subject: [Systeminfo] Fixes for tct test X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~752^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02cf6a3f12b0cb56b5e945c2d5e2b39574da30e7;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Systeminfo] Fixes for tct test Change-Id: I4664e23f9239bdbf263dbbce1f365f93b0a67f6b Signed-off-by: Piotr Kosko --- diff --git a/src/systeminfo/systeminfo-utils.cpp b/src/systeminfo/systeminfo-utils.cpp index e66f5dad..e76427db 100644 --- a/src/systeminfo/systeminfo-utils.cpp +++ b/src/systeminfo/systeminfo-utils.cpp @@ -1777,7 +1777,8 @@ void SysteminfoUtils::ReportDisplay(picojson::object& out) { if (SYSTEM_INFO_ERROR_NONE != system_info_get_value_int( SYSTEM_INFO_KEY_PHYSICAL_SCREEN_WIDTH, &physicalWidth)) { LOGE("Cannot get value of phisical screen width"); - throw UnknownException("Cannot get value of phisical screen width"); + //TODO uncomment when api would support this key + //throw UnknownException("Cannot get value of phisical screen width"); } out.insert(std::make_pair("physicalWidth", std::to_string(physicalWidth))); @@ -1785,7 +1786,8 @@ void SysteminfoUtils::ReportDisplay(picojson::object& out) { if (SYSTEM_INFO_ERROR_NONE != system_info_get_value_int( SYSTEM_INFO_KEY_PHYSICAL_SCREEN_HEIGHT, &physicalHeight)) { LOGE("Cannot get value of phisical screen height"); - throw UnknownException("Cannot get value of phisical screen height"); + //TODO uncomment when api would support this key + //throw UnknownException("Cannot get value of phisical screen height"); } out.insert(std::make_pair("physicalHeight", std::to_string(physicalHeight))); @@ -1947,6 +1949,7 @@ void SysteminfoUtils::ReportWifiNetwork(picojson::object& out) { std::string result_ssid; std::string result_ip_address; std::string result_ipv6_address; + std::string result_mac_address; double result_signal_strength = 0; connection_h connection_handle = nullptr; @@ -1964,6 +1967,18 @@ void SysteminfoUtils::ReportWifiNetwork(picojson::object& out) { connection_handle_ptr(connection_handle, &connection_destroy); // automatically release the memory + char* mac = NULL; + error = wifi_get_mac_address(&mac); + if(WIFI_ERROR_NONE == error) { + LOGD("macAddress fetched: %s", mac); + result_mac_address = mac; + free(mac); + } else { + std::string log_msg = "Failed to get mac address: " + std::to_string(error); + LOGE("%s", log_msg.c_str()); + throw UnknownException(log_msg.c_str()); + } + error = connection_get_type(connection_handle, &connection_type); if (CONNECTION_ERROR_NONE != error) { std::string log_msg = "Cannot get connection type: " + std::to_string(error); @@ -2020,6 +2035,7 @@ void SysteminfoUtils::ReportWifiNetwork(picojson::object& out) { out.insert(std::make_pair("ssid", result_ssid)); out.insert(std::make_pair("ipAddress", result_ip_address)); out.insert(std::make_pair("ipv6Address", result_ipv6_address)); + out.insert(std::make_pair("macAddress", result_mac_address)); out.insert(std::make_pair("signalStrength", std::to_string(result_signal_strength))); } @@ -2482,18 +2498,12 @@ static bool CheckStringCapability(const std::string& key, std::string* value) *value = SystemInfoDeviceCapability::GetProfile(); } else if (key == kTizenSystemDuid) { *value = SystemInfoDeviceCapability::GetDuid(); - } else if (key == kTizenFeatureInputKeyboardLayout || - key == kTizenFeatureNativeApiVersion || - key == kTizenSystemPlatformVersion || - key == kTizenSystemPlatformWebApiVersion || - key == kTizenSystemPlatformName) { + } else { try { *value = GetValueString(key.substr(strlen("http://")).c_str()); } catch (...){ return false; } - } else { - return false; } return true; } @@ -2612,18 +2622,12 @@ static bool CheckBoolCapability(const std::string& key, bool* bool_value) static bool CheckIntCapability(const std::string& key, std::string* value) { LOGD("Entered CheckIntCapability"); - if (key == kTizenFeatureMultitouchCount || - key == kTizenFeatureScreenBpp || - key == kTizenFeatureScreenDpi || - key == kTizenFeatureScreenHeight || - key == kTizenFeatureScreenWidth) { try { *value = std::to_string(GetValueInt(key.substr(strlen("http://")).c_str())); return true; } catch (...) { //empty for purpose - ignore that key was not found } - } return false; } @@ -2650,7 +2654,7 @@ picojson::value SystemInfoDeviceCapability::GetCapability(const std::string& key result_obj.insert(std::make_pair("value", value)); } else { LOGD("Value for given key was not found"); - throw UnknownException("Value for given key was not found"); + throw NotSupportedException("Value for given key was not found"); } result_obj.insert(std::make_pair("type", type)); diff --git a/src/systeminfo/systeminfo_api.js b/src/systeminfo/systeminfo_api.js index 3bcdc750..261a5f4c 100644 --- a/src/systeminfo/systeminfo_api.js +++ b/src/systeminfo/systeminfo_api.js @@ -67,7 +67,8 @@ var Common = function(){ }; Common.prototype.getTypeMismatch = function(msg) { - _getTypeMismatch(msg); + return _getException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + msg || 'Provided arguments are not valid.'); }; Common.prototype.throwTypeMismatch = function(msg) { @@ -75,7 +76,7 @@ var Common = function(){ }; Common.prototype.getInvalidValues = function(msg) { - return _getException('InvalidValuesError', + return _getException(tizen.WebAPIException.INVALID_VALUES_ERR, msg || 'There\'s a problem with input value.'); }; @@ -84,7 +85,7 @@ var Common = function(){ }; Common.prototype.getIOError = function (msg) { - return _getException('IOError', msg || 'Unexpected IO error.'); + return _getException(tizen.WebAPIException.IO_ERR, msg || 'Unexpected IO error.'); }; Common.prototype.throwIOError = function (msg) { @@ -100,7 +101,7 @@ var Common = function(){ }; Common.prototype.getNotFound = function (msg) { - return _getException('NotFoundError', msg || 'Not found.'); + return _getException(tizen.WebAPIException.NOT_FOUND_ERR, msg || 'Not found.'); }; Common.prototype.throwNotFound = function (msg) { @@ -108,7 +109,7 @@ var Common = function(){ }; Common.prototype.getUnknownError = function (msg) { - return _getException('UnknownError', msg || 'Unknown error.'); + return _getException(tizen.WebAPIException.UNKNOWN_ERR, msg || 'Unknown error.'); }; Common.prototype.throwUnknownError = function (msg) { @@ -777,6 +778,7 @@ function SystemInfoWifiNetwork(data) { ssid : {value: data.ssid, writable: false, enumerable: true}, ipAddress : {value: data.ipAddress, writable: false, enumerable: true}, ipv6Address : {value: data.ipv6Address, writable: false, enumerable: true}, + macAddress : {value: data.macAddress, writable: false, enumerable: true}, signalStrength : {value: Number(data.signalStrength), writable: false, enumerable: true} }); } @@ -822,7 +824,7 @@ function SystemInfoPeripheral(data) { //class SystemInfoMemory //////////////////////////////////////////////////// function SystemInfoMemory(data) { Object.defineProperties(this, { - state : {value: data.state, writable: false, enumerable: true} + status : {value: data.state, writable: false, enumerable: true} }); } @@ -978,13 +980,13 @@ function _systeminfoCpuListenerCallback(event) { for (var watchId in callbacks) { if (callbacks.hasOwnProperty(watchId)) { var listener = callbacks[watchId]; + var propObj = !listener.isArrayType ? + _createProperty(property, eventObj.result.array[0]) : + _createPropertyArray(property, eventObj.result); var executeCall = (T.isUndefined(listener.lowThreshold) || (propObj.load <= listener.lowThreshold)) || (T.isUndefined(listener.highThreshold) || (propObj.load >= listener.highThreshold)); - var propObj = !listener.isArrayType ? - _createProperty(property, eventObj.result.array[0]) : - _createPropertyArray(property, eventObj.result); if (executeCall) { listener.callback(propObj); } @@ -1016,13 +1018,13 @@ function _systeminfoDisplayListenerCallback(event) { for (var watchId in callbacks) { if (callbacks.hasOwnProperty(watchId)) { var listener = callbacks[watchId]; + var propObj = !listener.isArrayType ? + _createProperty(property, eventObj.result.array[0]) : + _createPropertyArray(property, eventObj.result); var executeCall = (T.isUndefined(listener.lowThreshold) || (propObj.brightness <= listener.lowThreshold)) || (T.isUndefined(listener.highThreshold) || (propObj.brightness >= listener.highThreshold)); - var propObj = !listener.isArrayType ? - _createProperty(property, eventObj.result.array[0]) : - _createPropertyArray(property, eventObj.result); if (executeCall) { listener.callback(propObj); } @@ -1258,7 +1260,7 @@ var _registerListener = function (property, listener, errorCallback) { 'SystemInfo_addPropertyValueChangeListener', {property: Converter.toString(property)}); fail = C.isFailure(result); - if (fail) { + if (C.isFailure(result)) { setTimeout(function() { C.callIfPossible(errorCallback, C.getErrorObject(result)); }, 0); @@ -1344,8 +1346,8 @@ var getListenerFunction = function (isArray) { isArrayType : isArray, highThreshold : !T.isNullOrUndefined(args.options) ? args.options.highThreshold : undefined, - lowThreshold : !T.isNullOrUndefined(args.options) ? - args.options.lowThreshold : undefined + lowThreshold : !T.isNullOrUndefined(args.options) ? + args.options.lowThreshold : undefined }; var watchId = _registerListener(args.property, listener, args.errorCallback); @@ -1392,12 +1394,13 @@ SystemInfo.prototype.getAvailableMemory = function() { SystemInfo.prototype.getCount = function() { var args = AV.validateMethod(arguments, [ { - name : 'key', - type : AV.Types.STRING + name : 'property', + type : AV.Types.ENUM, + values : T.getValues(SystemInfoPropertyId) } ]); - var result = _callSync('SystemInfo_getCount', {key: args.key}); + var result = _callSync('SystemInfo_getCount', {property: args.property}); if (C.isFailure(result)) { throw C.getErrorObject(result); } diff --git a/src/systeminfo/systeminfo_instance.cc b/src/systeminfo/systeminfo_instance.cc index 0a9a653d..cc404075 100644 --- a/src/systeminfo/systeminfo_instance.cc +++ b/src/systeminfo/systeminfo_instance.cc @@ -308,7 +308,8 @@ void SysteminfoInstance::AddPropertyValueChangeListener(const picojson::value& a SysteminfoUtils::RegisterDeviceOrientationListener(OnDeviceOrientationChangedCallback); } else if (property_name == kPropertyIdBuild) { LoggerW("BUILD property's value is a fixed value"); - throw NotSupportedException("BUILD property's value is a fixed value"); + //should be accepted, but no registration is needed + //throw NotSupportedException("BUILD property's value is a fixed value"); } else if (property_name == kPropertyIdLocale) { SysteminfoUtils::RegisterLocaleListener(OnLocaleChangedCallback); } else if (property_name == kPropertyIdNetwork) { @@ -363,13 +364,13 @@ void SysteminfoInstance::GetAvailableMemory(const picojson::value& args, picojso void SysteminfoInstance::GetCount(const picojson::value& args, picojson::object& out) { - const std::string& key = args.get("key").get(); - LoggerD("Getting capability with key: %s ", key.c_str()); + const std::string& property = args.get("property").get(); + LoggerD("Getting count of property with id: %s ", property.c_str()); picojson::value result = picojson::value(picojson::object()); picojson::object& result_obj = result.get(); result_obj.insert(std::make_pair("count", - static_cast(SysteminfoUtils::GetCount(key)) )); + static_cast(SysteminfoUtils::GetCount(property)) )); ReportSuccess(result, out); LoggerD("Success"); @@ -394,7 +395,8 @@ void SysteminfoInstance::RemovePropertyValueChangeListener(const picojson::value SysteminfoUtils::UnregisterDeviceOrientationListener(); } else if (property_name == kPropertyIdBuild) { LoggerW("BUILD property's value is a fixed value"); - throw NotSupportedException("BUILD property's value is a fixed value"); + //should be accepted, but no unregistration is needed + //throw NotSupportedException("BUILD property's value is a fixed value"); } else if (property_name == kPropertyIdLocale) { SysteminfoUtils::UnregisterLocaleListener(); } else if (property_name == kPropertyIdNetwork) {