Add default operation when create appcontrol
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 2 Aug 2018 08:52:17 +0000 (17:52 +0900)
committer장상윤/Tizen Platform Lab(SR)/Engineer/삼성전자 <jeremy.jang@samsung.com>
Thu, 2 Aug 2018 08:57:10 +0000 (17:57 +0900)
Change-Id: I8cf149ddb1ee14aae63d700db0d415b14b2edf71
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/client/client.cc

index adb46922f1e25f554c65963d3bcfc48d6ba5b0c2..43f4c1df102fb0151b84f43fab109499b7ed802d 100644 (file)
@@ -194,6 +194,12 @@ API int capmgr_app_control_create(capmgr_app_control_h* app_control) {
       delete control;
       return CAPMGR_ERROR_OUT_OF_MEMORY;
     }
+    int r = aul_svc_set_operation(control->b, AUL_SVC_OPERATION_DEFAULT);
+    if (r != AUL_SVC_RET_OK) {
+      bundle_free(control->b);
+      delete control;
+      return CAPMGR_ERROR_OUT_OF_MEMORY;
+    }
     *app_control = control;
   } catch (const std::bad_alloc& e) {
     LOG(ERROR) << e.what();
@@ -250,12 +256,8 @@ API int capmgr_app_control_get_operation(capmgr_app_control_h app_control,
 
   int r;
   const char* val = aul_svc_get_operation(app_control->b);
-  if (!val) {
-    r = aul_svc_set_operation(app_control->b, AUL_SVC_OPERATION_DEFAULT);
-    if (r != AUL_SVC_RET_OK)
-      return CAPMGR_ERROR_OUT_OF_MEMORY;
-    val = AUL_SVC_OPERATION_DEFAULT;
-  }
+  if (!val)
+    return CAPMGR_ERROR_INVALID_PARAMETER;
 
   *operation = strdup(val);
   if (*operation == nullptr)