Add new API for handling privacy privileges during application launch 77/120677/7
authorRafal Krypa <r.krypa@samsung.com>
Thu, 23 Mar 2017 16:33:12 +0000 (17:33 +0100)
committerRafal Krypa <r.krypa@samsung.com>
Fri, 31 Mar 2017 15:46:34 +0000 (17:46 +0200)
New public function security_manager_prepare_app_privacy() to be called
by launcher. It will check application policy, generate pop-up if necessary,\
wait for user answer, modify policy accordingly and trigger toast message
if application launch has been prohibited.
The caller (launcher) should abort application launching if this function
returns an error.

Change-Id: Ia4b901cc409ccd8d695da8b53a0223bdb54c0cde
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
src/client/client-security-manager.cpp
src/include/app-runtime.h
src/include/security-manager-types.h

index e838530e5c78349c44bc68b5a91df45040c72aac..3a62fef9f4527cf721a0ff1bd902fca54bfe80a7 100644 (file)
@@ -1572,3 +1572,18 @@ int security_manager_shm_open(const char *name, int oflag, mode_t mode, const ch
         return -1;
     });
 }
+
+SECURITY_MANAGER_API
+int security_manager_prepare_app_privacy(const char *app_name)
+{
+    using namespace SecurityManager;
+    return try_catch([&]() -> int {
+        if (app_name == nullptr) {
+            LogError("app_name is NULL");
+            return SECURITY_MANAGER_ERROR_INPUT_PARAM;
+        }
+
+        // TODO: stub implementation
+        return SECURITY_MANAGER_ERROR_UNKNOWN;
+    });
+}
index 6e1f03b3493b4861d6f87c00188c20902407355b..541b7c5216da5c8fc8788ce4f4c315653f452111 100644 (file)
@@ -219,6 +219,23 @@ int security_manager_app_has_privilege(const char *app_id, const char *privilege
  */
 int security_manager_shm_open(const char *name, int oflag, mode_t mode, const char *app_id);
 
+/**
+ * This function takes care of determining policy for privacy related privileges
+ * prior to application launching. It check current application policy, determine
+ * whether pop-up should be displayed to the user, get user response, modify policy
+ * accordingly and return verdict whether the app should be launched or not.
+ * This function is intended to be called by the launcher prior to launching the
+ * application.
+ *
+ * \param[in] app_id  Application identifier
+ * \return API return code or error code: it would be
+ * - SECURITY_MANAGER_SUCCESS on success, if policy allows application launching
+ * - SECURITY_MANAGER_ERROR_INPUT_PARAM when app_id is invalid,
+ * - SECURITY_MANAGER_ERROR_APP_LAUNCH_PROHIBITED when application launching has been prohibited,
+ * - SECURITY_MANAGER_ERROR_UNKNOWN on other errors.
+ */
+int security_manager_prepare_app_privacy(const char *app_id);
+
 #ifdef __cplusplus
 }
 #endif
index dfc331783843c9b2d7393e9b5dfa581388ffdf0d..54bff1a7443ffb15c45e810105daba5a95b8e24d 100644 (file)
@@ -52,6 +52,7 @@ enum lib_retcode {
     SECURITY_MANAGER_ERROR_NOT_INITIALIZED,
     SECURITY_MANAGER_ERROR_FILE_CREATE_FAILED,
     SECURITY_MANAGER_ERROR_FILE_DELETE_FAILED,
+    SECURITY_MANAGER_ERROR_APP_LAUNCH_PROHIBITED,
 };
 
 /*! \brief accesses types for application installation paths*/