[systeminfo] - Change systemmanager privilege to telephony privilege
authorAndrzej Popowski <a.popowski@samsung.com>
Mon, 27 Apr 2015 11:45:46 +0000 (13:45 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Tue, 28 Apr 2015 13:19:36 +0000 (22:19 +0900)
Change-Id: Id7e01460bfbb359cc830208f39e34d61f2ad0fc7
Signed-off-by: Andrzej Popowski <a.popowski@samsung.com>
src/common/extension.h
src/systeminfo/systeminfo_api.js
src/utils/utils_api.js
src/utils/utils_instance.cc
src/utils/utils_instance.h

index 61f8348f45f0c64f1d1619ce75328382c443030f..bbecd616e05e4c2fb802c812b811c8ed43fc101e 100644 (file)
@@ -156,6 +156,21 @@ do { \
   } \
 } while (0)
 
+#define CHECK_BACKWARD_COMPABILITY_PRIVILEGE_ACCESS(current_priv, prev_priv, out) \
+do { \
+  auto ret = common::tools::CheckAccess(current_priv); \
+  auto ret2 = common::tools::CheckAccess(prev_priv); \
+\
+  if (!ret && ret2) { \
+    ret = ret2; \
+  } \
+\
+  if (!ret) { \
+    common::tools::ReportError(ret, out); \
+    return; \
+  } \
+} while (0)
+
 }  // namespace tools
 
 }  // namespace common
index 60903a0911524aa9b3d99580913cefa5d58a9c12..e836c08099eea351dcfa06fefdefe25a48e97b1d 100644 (file)
@@ -557,7 +557,8 @@ function SystemInfoCellularNetwork(data) {
         isFlightMode : {value: data.isFligthMode, writable: false, enumerable: true},
         imei : {
             get: function() {
-                xwalk.utils.checkPrivilegeAccess(_PRIVILEGE_TELEPHONY);
+                xwalk.utils.checkBackwardCompabilityPrivilegeAccess(_PRIVILEGE_TELEPHONY,
+                                                                    _PRIVILEGE_SYSTEM);
                 return data.imei;
             },
             set: function() {},
@@ -587,7 +588,8 @@ function SystemInfoSIM(data) {
         },
         msisdn : {
             get: function() {
-                xwalk.utils.checkPrivilegeAccess(_PRIVILEGE_TELEPHONY);
+                xwalk.utils.checkBackwardCompabilityPrivilegeAccess(_PRIVILEGE_TELEPHONY,
+                                                                    _PRIVILEGE_SYSTEM);
                 return data.msisdn;
             },
             set: function() {},
@@ -619,7 +621,8 @@ function SystemInfoSIM(data) {
         },
         msin : {
             get: function() {
-                xwalk.utils.checkPrivilegeAccess(_PRIVILEGE_TELEPHONY);
+                xwalk.utils.checkBackwardCompabilityPrivilegeAccess(_PRIVILEGE_TELEPHONY,
+                                                                    _PRIVILEGE_SYSTEM);
                 return data.msin;
             },
             set: function() {},
index d0df487708d0ae1146eb41a6ca363cde572a4709..145ad2aaa37a755797e37df0ee082bf7135770f4 100644 (file)
@@ -146,6 +146,17 @@ Utils.prototype.checkPrivilegeAccess = function(privilege) {
   }
 };
 
+Utils.prototype.checkBackwardCompabilityPrivilegeAccess = function(current_privilege, previous_privilege) {
+  var result = native_.callSync('Utils_checkBackwardPrivilegePrivilegeAccess', {
+    current_privilege : _toString(current_privilege),
+    previous_privilege : _toString(previous_privilege),
+  });
+
+  if (native_.isFailure(result)) {
+    throw native_.getErrorObject(result);
+  }
+};
+
 /////////////////////////////////////////////////////////////////////////////
 /** @constructor */
 var Type = function() {};
index 858bf3feebb1b775eae16ca93567076ffd105f5d..9eb198bd6fa7272341b88fd651957b610daf32e6 100644 (file)
@@ -18,6 +18,7 @@ UtilsInstance::UtilsInstance() {
   RegisterSyncHandler(c, std::bind(&UtilsInstance::x, this, _1, _2));
 
   REGISTER_SYNC("Utils_checkPrivilegeAccess", CheckPrivilegeAccess);
+  REGISTER_SYNC("Utils_checkBackwardCompabilityPrivilegeAccess", CheckBackwardCompabilityPrivilegeAccess);
 
 #undef REGISTER_SYNC
 #undef REGISTER_ASYNC
@@ -29,5 +30,14 @@ void UtilsInstance::CheckPrivilegeAccess(const picojson::value& args, picojson::
   ReportSuccess(out);
 }
 
+void UtilsInstance::CheckBackwardCompabilityPrivilegeAccess(const picojson::value& args,
+                                                            picojson::object& out) {
+  const auto& current_priv = args.get("current_privilege").to_str();
+  const auto& prev_priv = args.get("previous_privilege").to_str();
+
+  CHECK_BACKWARD_COMPABILITY_PRIVILEGE_ACCESS(current_priv, prev_priv, &out);
+  ReportSuccess(out);
+}
+
 }  // namespace utils
 }  // namespace extension
index c08332cca4a72aa8ffb0f2f5525cf15674b91a82..f97468cc00e08be5584ad035ace9a7bd435e6c15 100644 (file)
@@ -18,6 +18,7 @@ class UtilsInstance : public common::ParsedInstance {
 
  private:
   void CheckPrivilegeAccess(const picojson::value& args, picojson::object& out);
+  void CheckBackwardCompabilityPrivilegeAccess(const picojson::value& args, picojson::object& out);
 };
 }  // namespace utils
 }  // namespace extension