Use aul api to run providers 41/173641/1
authorjusung son <jusung07.son@samsung.com>
Fri, 23 Mar 2018 01:14:49 +0000 (10:14 +0900)
committerjusung son <jusung07.son@samsung.com>
Fri, 23 Mar 2018 01:17:55 +0000 (10:17 +0900)
Related changes:
[aul-1] https://review.tizen.org/gerrit/#/c/173013/
[amd] https://review.tizen.org/gerrit/#/c/173013/

Change-Id: Iaad0688c7de75620fa4d5cfc942a3811a80a441e
Signed-off-by: jusung son <jusung07.son@samsung.com>
packaging/libwatchface-complication.spec
watchface-complication/complication.cc
watchface-complication/complication.h [changed mode: 0644->0755]
watchface-complication/include/watchface-common.h [changed mode: 0644->0755]
watchface-complication/watchface-complication.cc [changed mode: 0644->0755]

index fe15c57..6e48754 100755 (executable)
@@ -26,6 +26,7 @@ BuildRequires: pkgconfig(pkgmgr-installer)
 %if 0%{?gcov:1}
 BuildRequires: lcov
 %endif
+Requires: amd-mod-complication
 
 %description
 API for creating a new watchface complication and managing it.
index e1f57cd..956b6a4 100755 (executable)
@@ -17,6 +17,7 @@
 #include <glib.h>
 #include <unistd.h>
 #include <aul.h>
+#include <aul_complication.h>
 #include <appsvc.h>
 #include <stdexcept>
 
@@ -424,26 +425,25 @@ std::unique_ptr<Bundle> Complication::Impl::GetDefault() {
   return std::move(ptr);
 }
 
-void Complication::SendDataUpdateRequest() {
+int Complication::SendDataUpdateRequest() {
   LOGI("emit signal comp_id %d, type %d",
       impl_->complication_id_, impl_->cur_type_);
   std::string provider_appid = impl_->GetProviderAppId();
   const char* context_data_raw = "";
-  bundle *arg_list = bundle_create();
-  if (arg_list == NULL)
-    std::runtime_error("bundle create failed");
-
-  appsvc_set_operation(arg_list, APPSVC_OPERATION_DEFAULT);
-  appsvc_set_appid(arg_list, provider_appid.c_str());
-  bundle_add_str(arg_list, "__OSP_LAUNCH_TYPE__", "datacontrol");
-  bundle_add_str(arg_list, AUL_K_CALLER_APPID,
-      ComplicationConnector::GetInst().GetAppId().c_str());
-  bundle_add_str(arg_list, AUL_K_CALLEE_APPID, provider_appid.c_str());
-  bundle_add_str(arg_list, AUL_K_DATA_CONTROL_TYPE, "CORE");
-
-  int pid = appsvc_run_service(arg_list, 0, NULL, NULL);
-  LOGI("Launch the provider app: %d, %s", pid, provider_appid.c_str());
-  bundle_free(arg_list);
+  int ret;
+
+  ret = aul_complication_update_request(ComplicationConnector::GetInst().GetAppId().c_str(),
+                provider_appid.c_str(), getuid());
+  LOGI("Launch the provider app: %d, %s", ret, provider_appid.c_str());
+
+  if (ret != AUL_R_OK) {
+    if (ret == AUL_R_EILLACC)
+      return COMPLICATION_ERROR_PERMISSION_DENIED;
+    else if (ret == AUL_R_EINVAL)
+      return COMPLICATION_ERROR_INVALID_PARAMETER;
+    else
+      return COMPLICATION_ERROR_IO_ERROR;
+  }
 
   if (impl_->context_data_ != nullptr)
     context_data_raw = impl_->context_data_->ToString();
@@ -461,6 +461,7 @@ void Complication::SendDataUpdateRequest() {
                   impl_->cur_type_,
                   context_data_raw));
   LOGI("emit signal done");
+  return COMPLICATION_ERROR_NONE;
 }
 
 const char* Complication::GetProviderIdKey() {
old mode 100644 (file)
new mode 100755 (executable)
index ceb000d..b3aae16
@@ -60,7 +60,7 @@ class EXPORT_API Complication : public IEditable
   void SetName(const std::string& name) override;
   void SetState(IEditable::EditableState state) override;
   IEditable::EditableState GetState() override;
-  void SendDataUpdateRequest();
+  int SendDataUpdateRequest();
   void SetShapeType(IEditable::EditableShapeType shape_type);
   std::list<std::string> GetProviderList(
                                          ComplicationType type);
old mode 100644 (file)
new mode 100755 (executable)
index 1e9add5..2d796ff
@@ -32,7 +32,8 @@ typedef enum _complication_error {
   COMPLICATION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,
   COMPLICATION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,
   COMPLICATION_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR,
-  COMPLICATION_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA
+  COMPLICATION_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA,
+  COMPLICATION_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED
 } complication_error;
 
 typedef enum _complication_type {
old mode 100644 (file)
new mode 100755 (executable)
index 2bcac71..2c7510d
@@ -119,9 +119,8 @@ extern "C" EXPORT_API int complication_send_update_request(
   LOGI("update call!!");
   auto sh = static_cast<SharedHandle<WatchComplicationStub>*>(handle);
   auto ptr = SharedHandle<WatchComplicationStub>::Share(sh);
-  ptr.get()->SendDataUpdateRequest();
 
-  return 0;
+  return ptr.get()->SendDataUpdateRequest();
 }
 
 extern "C" EXPORT_API int complication_get_id(complication_h handle) {