[SystemInfo] Throwing NOT_SUPPORTED_ERR added 44/127744/5
authorSzymon Jastrzebski <s.jastrzebsk@partner.samsung.com>
Fri, 19 May 2017 10:58:22 +0000 (12:58 +0200)
committerSzymon Jastrzebski <s.jastrzebsk@partner.samsung.com>
Fri, 19 May 2017 10:58:22 +0000 (12:58 +0200)
[Verification] TCT SystemInfo passed 100% (TM1, TW1, TV)
Signed-off-by: Szymon Jastrzebski <s.jastrzebsk@partner.samsung.com>
Change-Id: I18753fcf052b954dd3f88839db58616b137bfd3b

src/systeminfo/systeminfo_api.js

index 21bef45..38e48da 100644 (file)
@@ -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,