From 88bd2531ef7af65bfc236c980bf0bfec452c4c66 Mon Sep 17 00:00:00 2001 From: Szymon Jastrzebski Date: Fri, 19 May 2017 12:58:22 +0200 Subject: [PATCH] [SystemInfo] Throwing NOT_SUPPORTED_ERR added [Verification] TCT SystemInfo passed 100% (TM1, TW1, TV) Signed-off-by: Szymon Jastrzebski Change-Id: I18753fcf052b954dd3f88839db58616b137bfd3b --- src/systeminfo/systeminfo_api.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/systeminfo/systeminfo_api.js b/src/systeminfo/systeminfo_api.js index 21bef45..38e48da 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, { @@ -800,6 +811,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() { @@ -828,6 +848,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() { @@ -1339,6 +1369,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, -- 2.7.4