From 50a5362271beb512a76d44b39d56e26774efe281 Mon Sep 17 00:00:00 2001 From: jusung son Date: Fri, 23 Mar 2018 10:14:49 +0900 Subject: [PATCH] Use aul api to run providers 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 --- packaging/libwatchface-complication.spec | 1 + watchface-complication/complication.cc | 33 ++++++++++++----------- watchface-complication/complication.h | 2 +- watchface-complication/include/watchface-common.h | 3 ++- watchface-complication/watchface-complication.cc | 3 +-- 5 files changed, 22 insertions(+), 20 deletions(-) mode change 100644 => 100755 watchface-complication/complication.h mode change 100644 => 100755 watchface-complication/include/watchface-common.h mode change 100644 => 100755 watchface-complication/watchface-complication.cc diff --git a/packaging/libwatchface-complication.spec b/packaging/libwatchface-complication.spec index fe15c57..6e48754 100755 --- a/packaging/libwatchface-complication.spec +++ b/packaging/libwatchface-complication.spec @@ -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. diff --git a/watchface-complication/complication.cc b/watchface-complication/complication.cc index e1f57cd..956b6a4 100755 --- a/watchface-complication/complication.cc +++ b/watchface-complication/complication.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -424,26 +425,25 @@ std::unique_ptr 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() { diff --git a/watchface-complication/complication.h b/watchface-complication/complication.h old mode 100644 new mode 100755 index ceb000d..b3aae16 --- a/watchface-complication/complication.h +++ b/watchface-complication/complication.h @@ -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 GetProviderList( ComplicationType type); diff --git a/watchface-complication/include/watchface-common.h b/watchface-complication/include/watchface-common.h old mode 100644 new mode 100755 index 1e9add5..2d796ff --- a/watchface-complication/include/watchface-common.h +++ b/watchface-complication/include/watchface-common.h @@ -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 { diff --git a/watchface-complication/watchface-complication.cc b/watchface-complication/watchface-complication.cc old mode 100644 new mode 100755 index 2bcac71..2c7510d --- a/watchface-complication/watchface-complication.cc +++ b/watchface-complication/watchface-complication.cc @@ -119,9 +119,8 @@ extern "C" EXPORT_API int complication_send_update_request( LOGI("update call!!"); auto sh = static_cast*>(handle); auto ptr = SharedHandle::Share(sh); - ptr.get()->SendDataUpdateRequest(); - return 0; + return ptr.get()->SendDataUpdateRequest(); } extern "C" EXPORT_API int complication_get_id(complication_h handle) { -- 2.7.4