[SystemInfo] Throwing NOT_SUPPORTED_ERR added 02/130902/1
authorSzymon Jastrzebski <s.jastrzebsk@partner.samsung.com>
Fri, 19 May 2017 10:58:22 +0000 (12:58 +0200)
committerPiotr Kosko <p.kosko@samsung.com>
Wed, 24 May 2017 09:47:35 +0000 (11:47 +0200)
[Verification] TCT SystemInfo passed 100% (TM1, TW1, TV)
Signed-off-by: Szymon Jastrzebski <s.jastrzebsk@partner.samsung.com>
Change-Id: I30f56f7539be3baa59ec68fe75c357b4b26080e5

src/systeminfo/systeminfo_api.js

index e09c977d19818697ddc04a8837f94d69835d950c..2e5dc4fe7e3390f2d449d4b1439b34f620de3be7 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, {
@@ -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,