From: Szymon Jastrzebski Date: Fri, 19 May 2017 10:58:22 +0000 (+0200) Subject: [SystemInfo] Throwing NOT_SUPPORTED_ERR added X-Git-Tag: submit/tizen_3.0/20170524.101153~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=68f4ee0e44acc108612a21b7252839f3165ff669;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [SystemInfo] Throwing NOT_SUPPORTED_ERR added [Verification] TCT SystemInfo passed 100% (TM1, TW1, TV) Signed-off-by: Szymon Jastrzebski Change-Id: I30f56f7539be3baa59ec68fe75c357b4b26080e5 --- diff --git a/src/systeminfo/systeminfo_api.js b/src/systeminfo/systeminfo_api.js index e09c977d..2e5dc4fe 100644 --- a/src/systeminfo/systeminfo_api.js +++ b/src/systeminfo/systeminfo_api.js @@ -46,6 +46,17 @@ var SystemInfoPropertyId = { ADS : 'ADS' }; +var SystemInfoPropertyIdToFeature = { + BATTERY : 'http://tizen.org/feature/battery', + CAMERA_FLASH : 'http://tizen.org/feature/camera.back.flash', + CELLULAR_NETWORK : 'http://tizen.org/feature/network.telephony', + DISPLAY : 'http://tizen.org/feature/screen', + ETHERNET_NETWORK : 'http://tizen.org/feature/network.ethernet', + SIM : 'http://tizen.org/feature/network.telephony', + NET_PROXY_NETWORK : 'http://tizen.org/feature/network.net_proxy', + WIFI_NETWORK : 'http://tizen.org/feature/network.wifi' +}; + //class SystemInfoDeviceCapability //////////////////////////////////////////////////// function SystemInfoDeviceCapability(data) { Object.defineProperties(this, { @@ -790,6 +801,15 @@ var _createPropertyArray = function (property, data) { return propertyArray; }; +var _checkPropertySupported = function(property){ + if (SystemInfoPropertyIdToFeature[property]) { + var supported = tizen.systeminfo.getCapability(SystemInfoPropertyIdToFeature[property]); + if (!supported) { + return false; + } + } + return true; +}; var getPropertyFunction = function(cppLabel, objectCreateFunction) { return function() { @@ -818,6 +838,16 @@ var getPropertyFunction = function(cppLabel, objectCreateFunction) { if (!propObject) { throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + args.property + ' is not supported.'); } + + if (_checkPropertySupported(args.property) === false) { + setTimeout(function() { + native_.callIfPossible(args.errorCallback, + new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR, + 'Property with id: ' + args.property + ' is not supported.')); + }, 0); + return; + } + var callback = function(result) { if (native_.isFailure(result)) { setTimeout(function() { @@ -1329,6 +1359,15 @@ var getListenerFunction = function (isArray) { } ]); + if (_checkPropertySupported(args.property) === false) { + setTimeout(function() { + native_.callIfPossible(args.errorCallback, + new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR, + 'Property with id: ' + args.property + ' is not supported.')); + }, 0); + return; + } + var listener = { callback : args.successCallback, isArrayType : isArray,