Add an api to get current provider's event types 03/228403/1
authorhyunho <hhstark.kang@samsung.com>
Mon, 23 Mar 2020 01:36:48 +0000 (10:36 +0900)
committerhyunho <hhstark.kang@samsung.com>
Mon, 23 Mar 2020 01:36:48 +0000 (10:36 +0900)
watchface_complication_get_current_provider_events

Change-Id: Id612cc18c931f9407844bc34039f1dee087a003d
Signed-off-by: hyunho <hhstark.kang@samsung.com>
unittest/data/test.sql
unittest/src/test-watchface-complication-provider.cc
unittest/src/test-watchface-complication.cc
watchface-complication/complication.cc
watchface-complication/complication.hh
watchface-complication/include/watchface-complication-internal.h
watchface-complication/watchface-complication.cc

index 80063d918186d0a37667c708e61dae12e7d53059..6b7f7d288c9bf8e52308db51786aa843169245f9 100644 (file)
@@ -10,6 +10,7 @@ CREATE TABLE IF NOT EXISTS provider_support_types (
   provider_id  TEXT NOT NULL,
   support_type INTEGER DEFAULT 0,
   default_data TEXT NOT NULL,
+  UNIQUE (provider_id, support_type),
   FOREIGN KEY (provider_id) REFERENCES complication_provider(provider_id) ON DELETE CASCADE
 );
 CREATE TABLE IF NOT EXISTS provider_localized_info (
@@ -259,4 +260,26 @@ INSERT INTO provider_support_types (
   'org.tizen.gmock_comp_provider5/test',
   2,
   'test'
-);
\ No newline at end of file
+);
+
+INSERT INTO complication_provider (
+  pkgid, appid, provider_id, trusted, period) VALUES (
+  'org.tizen.gmock_comp_provider6',
+  'org.tizen.gmock_comp_provider6',
+  'org.tizen.gmock_comp_provider6/test',
+  1,
+  1
+);
+
+INSERT INTO provider_support_types (
+  provider_id, support_type, default_data) VALUES (
+  'org.tizen.gmock_comp_provider6/test',
+  2,
+  'test'
+);
+
+INSERT INTO provider_support_events (
+  provider_id, support_events) VALUES (
+  'org.tizen.gmock_comp_provider6/test',
+  6
+);
index 1fe0ca3fd9fe3ecd27dbe8bb302a7df0b5e9ea9b..5e4527f43606cafba1d77b80e84b228c0e9d8d48 100644 (file)
@@ -455,7 +455,7 @@ TEST_F(CWCP, watchface_complication_provider_foreach_info)
 
   ret = watchface_complication_provider_foreach_info(
           nullptr, __all_provider_foreach_cb, &count);
-  EXPECT_EQ(5, count);
+  EXPECT_EQ(6, count);
   EXPECT_EQ(WATCHFACE_COMPLICATION_ERROR_NONE, ret);
 
   ret = watchface_complication_provider_foreach_info(
index de4843ff395bfdda23ef08f79e70fd0954d993b6..8088730a816e9e4645d256fc74750412b21c16ea 100644 (file)
@@ -221,6 +221,24 @@ TEST_F(CWC, watchface_complication_get_current_type)
   EXPECT_EQ(cur_type, WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT);
 }
 
+TEST_F(CWC, watchface_complication_get_current_provider_events)
+{
+  int comp_id = 777;
+  int ret = watchface_complication_create(comp_id,
+    "org.tizen.gmock_comp_provider6/test",
+    WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
+    WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
+    WATCHFACE_COMPLICATION_EVENT_TAP|WATCHFACE_COMPLICATION_EVENT_DOUBLE_TAP,
+    &complication_);
+
+  int cur_types;
+  ret = watchface_complication_get_current_provider_events(complication_,
+      &cur_types);
+  EXPECT_EQ(WATCHFACE_COMPLICATION_ERROR_NONE, ret);
+  EXPECT_EQ(cur_types,
+      WATCHFACE_COMPLICATION_EVENT_TAP|WATCHFACE_COMPLICATION_EVENT_DOUBLE_TAP);
+}
+
 void _complication_updated_cb(
       int complication_id,
       const char* provider_id,
index e385fc339e0277d7fe16be83233a368243322415..67101d40631c751180d926c31a0b9f0fc8d1f468 100644 (file)
@@ -644,6 +644,10 @@ int Complication::GetCurType() const {
   return static_cast<int>(impl_->cur_type_);
 }
 
+int Complication::GetCurProviderEvents() const {
+  return DBManager::GetRequiredSupportEvents(impl_->cur_provider_id_);
+}
+
 const std::string& Complication::GetLabel() const {
   return impl_->name_;
 }
index 10a03c28468a849544aa0ddee549a22c26c4aa3f..4b1c78adeeab8617686529394bcc4b189d63ec4e 100755 (executable)
@@ -99,6 +99,7 @@ class EXPORT_API Complication : public IEditable
   std::string GetProviderId(const tizen_base::Bundle& candidate_data) const;
   int GetProviderType(const tizen_base::Bundle& candidate_data) const;
   int GetCurType() const;
+  int GetCurProviderEvents() const;
   int TouchLaunch(watchface_complication_event_type_e event_type);
   int ApplyAllowedList(
       std::list<std::unique_ptr<ProviderInfo>> allowed_list);
index fac7fef0dcfe87c2c8488dc9bb2f6eafc5f73ef2..d20fd21d91d9af8711f665900bbb1cd28aa7be50 100644 (file)
@@ -66,6 +66,8 @@ int watchface_complication_priority_list_get_nth(
 int watchface_complication_priority_list_apply(complication_h handle,
         complication_priority_list_h list_handle);
 int watchface_complication_priority_list_clear(complication_h handle);
+int watchface_complication_get_current_provider_events(
+        complication_h handle, int *current_provider_events);
 
 #ifdef __cplusplus
 }
index 077dcd4bf8629d7d53f964e86d555c7a47b01075..da1f9d585f0022c0c959b8e390be4f1a3433fa21 100644 (file)
@@ -373,6 +373,27 @@ extern "C" EXPORT_API int watchface_complication_get_current_type(
   return WATCHFACE_COMPLICATION_ERROR_NONE;
 }
 
+extern "C" EXPORT_API int watchface_complication_get_current_provider_events(
+    complication_h handle, int *current_provider_events) {
+  if (!watchface_complication::util::CheckWatchFeatureEnabled())
+    return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+  if (handle == nullptr || current_provider_events == nullptr)
+    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+
+  auto sh = static_cast<SharedHandle<WatchComplicationStub>*>(handle);
+  auto ptr = SharedHandle<WatchComplicationStub>::Share(sh);
+  if (ptr.get()->GetCurProviderId().empty())
+    return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
+
+  int ret = ptr.get()->GetCurProviderEvents();
+  if (ret < 0)
+    return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
+
+  *current_provider_events = ret;
+  return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
 extern "C" EXPORT_API int watchface_complication_data_get_type(
     const bundle* data, watchface_complication_type_e* type) {
   char* type_str = nullptr;