Add aod image/icon APIs 03/223903/4
authorhyunho <hhstark.kang@samsung.com>
Wed, 5 Feb 2020 02:08:43 +0000 (11:08 +0900)
committerhyunho <hhstark.kang@samsung.com>
Wed, 5 Feb 2020 04:32:17 +0000 (13:32 +0900)
Change-Id: I0d379f3645146fc7beaa24b9bf46c6e01212defd
Signed-off-by: hyunho <hhstark.kang@samsung.com>
unittest/src/test-watchface-complication.cc
watchface-common/watchface-common-internal.h
watchface-common/watchface-util.cc
watchface-complication-provider/include/watchface-complication-provider-internal.h
watchface-complication-provider/watchface-complication-provider.cc
watchface-complication/include/watchface-complication-internal.h
watchface-complication/watchface-complication.cc

index b525671c4f569ef341186722189c03ae5b4fcdd5..0eef6f9d08a7fee6288ac7987e06f1c897790d54 100644 (file)
@@ -19,6 +19,7 @@
 #include <watchface-complication.h>
 #include <watchface-complication-internal.h>
 #include <watchface-complication-provider.h>
+#include <watchface-complication-provider-internal.h>
 
 #include "watchface-complication/complication.h"
 #include "mock/system_info_mock.h"
@@ -301,7 +302,8 @@ guint __fake_signal_subscribe_on_data_updated(GDBusConnection* connection,
     b.Add("__DATA_TYPE_KEY__", num_str);
     watchface_complication_provider_data_set_short_text(b.GetHandle(), "shorttext");
     watchface_complication_provider_data_set_title(b.GetHandle(), "title");
-    watchface_complication_provider_data_set_icon_path(b.GetHandle(), "data/icon.png");
+    watchface_complication_provider_data_set_icon_path_with_aod(b.GetHandle(),
+        "data/icon.png", "data/aod_icon.png");
 
     Bundle extra;
     extra.Add("extra_key", "extra_data");
@@ -381,8 +383,8 @@ guint __fake_signal_subscribe_on_data_updated(GDBusConnection* connection,
     b.Delete("__DATA_TYPE_KEY__");
     snprintf(num_str, sizeof(num_str), "%d", Image);
     b.Add("__DATA_TYPE_KEY__", num_str);
-    watchface_complication_provider_data_set_image_path(
-        b.GetHandle(), "data/img.png");
+    watchface_complication_provider_data_set_image_path_with_aod(
+        b.GetHandle(), "data/img.png", "data/aod_img.png");
     parameters = g_variant_new("(siis)", "org.tizen.gmock_comp_provider/test",
                           Image,
                           777,
@@ -410,7 +412,7 @@ void _complication_updated_cb_get_test(
   watchface_complication_type_e type;
   watchface_complication_data_get_type(data, &type);
   if (type == WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT) {
-    char *shorttext, *title, *icon_path, *extra, *sc_text;
+    char *shorttext, *title, *icon_path, *aod_icon_path, *extra, *sc_text;
     watchface_complication_data_get_short_text(data, &shorttext);
     EXPECT_STREQ(shorttext, "shorttext");
     free(shorttext);
@@ -423,6 +425,10 @@ void _complication_updated_cb_get_test(
     EXPECT_STREQ(icon_path, "data/icon.png");
     free(icon_path);
 
+    watchface_complication_data_get_aod_icon_path(data, &aod_icon_path);
+    EXPECT_STREQ(aod_icon_path, "data/aod_icon.png");
+    free(aod_icon_path);
+
     int ret = watchface_complication_data_get_extra_data(data, &extra);
     EXPECT_EQ(WATCHFACE_COMPLICATION_ERROR_NONE, ret);
     free(extra);
@@ -471,10 +477,14 @@ void _complication_updated_cb_get_test(
     EXPECT_EQ(diff / 3600, 19);
     watchface_complication_timeinfo_destroy(info);
   } else if (type == WATCHFACE_COMPLICATION_TYPE_IMAGE) {
-    char* value;
-    watchface_complication_data_get_image_path(data, &value);
-    EXPECT_STREQ(value, "data/img.png");
-    free(value);
+    char* image, *aod_image;
+    watchface_complication_data_get_image_path(data, &image);
+    EXPECT_STREQ(image, "data/img.png");
+    free(image);
+
+    watchface_complication_data_get_aod_image_path(data, &aod_image);
+    EXPECT_STREQ(aod_image, "data/aod_img.png");
+    free(aod_image);
   } else if (type == WATCHFACE_COMPLICATION_TYPE_RANGED_VALUE) {
     double cur, min, max;
     watchface_complication_data_get_ranged_value(data,
index eb333025180c6e32940e4b419498ee529e39e91b..0b56832cbabc12ebd9f1c2078680c4abdd5e37fb 100644 (file)
@@ -31,6 +31,7 @@
 #define SHORT_TEXT_KEY "__SHORT_TEXT_KEY__"
 #define LONG_TEXT_KEY "__LONG_TEXT_KEY__"
 #define ICON_KEY "__ICON_KEY__"
+#define AOD_ICON_KEY "__AOD_ICON_KEY__"
 #define TITLE_KEY "__TITLE_KEY__"
 #define TIME_KEY "__TIME_KEY__"
 #define TIME_ZONE_KEY "__TIME_ZONE_KEY__"
@@ -41,6 +42,7 @@
 #define RANGE_MAX_KEY "__MAX_KEY__"
 #define RANGE_MIN_KEY "__MIN_KEY__"
 #define IMAGE_KEY "__IMAGE_KEY__"
+#define AOD_IMAGE_KEY "__AOD_IMAGE_KEY__"
 #define DATA_TYPE_KEY "__DATA_TYPE_KEY__"
 #define EXTRA_DATA_KEY "__EXTRA_DATA_KEY__"
 #define SCREEN_READER_TEXT_KEY "__SCREEN_READER_TEXT_KEY__"
index 4493fd71a4934afcb240ad265f326a0f0fd81e7e..183cb426521db2c3e1ea4f59fcde3729c91f3d4c 100644 (file)
@@ -475,7 +475,7 @@ out:
   }
 
   int ConvertPathToAppPath(const char* appid, bundle* data) {
-    list<string> key_list {ICON_KEY, IMAGE_KEY};
+    list<string> key_list {ICON_KEY, IMAGE_KEY, AOD_ICON_KEY, AOD_IMAGE_KEY};
     for (auto& i : key_list) {
       char* path;
       int ret = bundle_get_str(data, i.c_str(), &path);
index b7f390bc2d5eeb2e3aabde23a723d1fbbccce145..f8babf1f2cca216c7351b5a3755b9796edd6b835 100644 (file)
@@ -49,6 +49,10 @@ extern "C" {
  */
 int watchface_complication_provider_data_set_type(bundle *shared_data,
                        watchface_complication_type_e type);
+int watchface_complication_provider_data_set_icon_path_with_aod(
+       bundle *shared_data, const char *icon_path, const char *aod_icon_path);
+int watchface_complication_provider_data_set_image_path_with_aod(
+       bundle *shared_data, const char *image_path, const char *aod_image_path);
 
 #ifdef __cplusplus
 }
index 8f94781c5906eb9fd673f4fa4357a84c16534872..12e8b1d4490e9aa1fc1cb4d93fd4686c5bd5504c 100644 (file)
@@ -391,6 +391,69 @@ extern "C" EXPORT_API int watchface_complication_provider_data_set_type(
   return _add_bundle_data(shared_data, DATA_TYPE_KEY, num_str);
 }
 
+extern "C" EXPORT_API int watchface_complication_provider_data_set_icon_path_with_aod(
+    bundle* shared_data, const char* icon_path, const char* aod_icon_path) {
+  int ret;
+  watchface_complication_type_e type;
+
+  if (!watchface_complication::util::CheckWatchFeatureEnabled())
+    return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+  if (shared_data == nullptr || icon_path == nullptr) {
+    LOGE("Invalid param");
+    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+  }
+
+  ret = _get_data_type(shared_data, &type);
+  if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
+      return ret;
+  if (type != WATCHFACE_COMPLICATION_TYPE_ICON &&
+      type != WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT &&
+      type != WATCHFACE_COMPLICATION_TYPE_LONG_TEXT &&
+      type != WATCHFACE_COMPLICATION_TYPE_TIME) {
+    LOGE("Invalid type, not allowed for this type !!");
+    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+  }
+
+  if (aod_icon_path != nullptr) {
+    ret = _add_bundle_data(shared_data, AOD_ICON_KEY, aod_icon_path);
+    if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
+      return ret;
+  }
+
+  return _add_bundle_data(shared_data, ICON_KEY, icon_path);
+}
+
+extern "C" EXPORT_API int watchface_complication_provider_data_set_image_path_with_aod(
+    bundle* shared_data, const char* image_path, const char* aod_image_path) {
+  int ret;
+  watchface_complication_type_e type;
+
+  if (!watchface_complication::util::CheckWatchFeatureEnabled())
+    return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+  if (shared_data == nullptr || image_path == nullptr) {
+    LOGE("Invalid param");
+    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+  }
+
+  ret = _get_data_type(shared_data, &type);
+  if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
+      return ret;
+  if (type != WATCHFACE_COMPLICATION_TYPE_IMAGE) {
+    LOGE("Invalid type, not allowed for this type !!");
+    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+  }
+
+  if (aod_image_path != nullptr) {
+    ret = _add_bundle_data(shared_data, AOD_IMAGE_KEY, aod_image_path);
+    if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
+      return ret;
+  }
+
+  return _add_bundle_data(shared_data, IMAGE_KEY, image_path);
+}
+
 extern "C" EXPORT_API int watchface_complication_provider_data_set_title(
     bundle* shared_data, const char* title) {
   int ret;
index ffc9d0acc3deef98a5838526869be85013107ee7..a704d018d89c1f91c425e28f878d10546458f156 100644 (file)
@@ -24,7 +24,12 @@ extern "C" {
 #endif
 
 int watchface_complication_get_default_data(const char *provider_id,
-    watchface_complication_type_e type, bundle **default_data);
+        watchface_complication_type_e type, bundle **default_data);
+int watchface_complication_data_get_aod_icon_path(const bundle *shared_data,
+        char **icon_path);
+int watchface_complication_data_get_aod_image_path(const bundle *shared_data,
+        char **image_path);
+
 #ifdef __cplusplus
 }
 #endif
index 72063cbc2a253f7950c67545d07c6f1232143f16..60a0157f3011695305937272e5cd9a300cc03b2a 100644 (file)
@@ -422,6 +422,32 @@ extern "C" EXPORT_API int watchface_complication_data_get_short_text(
   return __get_complication_data(data, SHORT_TEXT_KEY, short_text);
 }
 
+extern "C" EXPORT_API int watchface_complication_data_get_aod_icon_path(
+    const bundle* data, char** icon_path) {
+  if (!watchface_complication::util::CheckWatchFeatureEnabled())
+    return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+  if (data == nullptr || icon_path == nullptr) {
+    LOGE("Invalid param !!");
+    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+  }
+
+  return __get_complication_data(data, AOD_ICON_KEY, icon_path);
+}
+
+extern "C" EXPORT_API int watchface_complication_data_get_aod_image_path(
+    const bundle* data, char** image_path) {
+  if (!watchface_complication::util::CheckWatchFeatureEnabled())
+    return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+  if (data == nullptr || image_path == nullptr) {
+    LOGE("Invalid param !!");
+    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+  }
+
+  return __get_complication_data(data, AOD_IMAGE_KEY, image_path);
+}
+
 extern "C" EXPORT_API int watchface_complication_data_get_long_text(
     const bundle* data, char** long_text) {
   if (!watchface_complication::util::CheckWatchFeatureEnabled())