From: Ji-hoon Lee Date: Mon, 30 Sep 2024 16:19:54 +0000 (+0900) Subject: Return not-supported error if feature is not found X-Git-Tag: accepted/tizen/unified/20241004.041950~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24263d0caad8d84fda0e69a870ad33f1d5cec590;p=platform%2Fcore%2Fuifw%2Fmmi-framework.git Return not-supported error if feature is not found Change-Id: Iacde11f8edeb1ac6de531a5881c79688a2f9186b --- diff --git a/packaging/mmi.spec b/packaging/mmi.spec index 5d03fcd..9106ff8 100644 --- a/packaging/mmi.spec +++ b/packaging/mmi.spec @@ -9,6 +9,7 @@ Source1004: %{name}.manifest BuildRequires: meson BuildRequires: tidl +BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(glib-2.0) diff --git a/src/common/mmi-common.h b/src/common/mmi-common.h index 75ccd38..b360558 100644 --- a/src/common/mmi-common.h +++ b/src/common/mmi-common.h @@ -18,6 +18,8 @@ #ifndef __MMI_COMMON_H__ #define __MMI_COMMON_H__ +#include + #include "mmi-log.h" #ifdef __cplusplus @@ -26,6 +28,8 @@ extern "C" { #define MMI_API __attribute__ ((visibility("default"))) +#define MMI_FEATURE_PATH "http://tizen.org/feature/multimodal_interaction" + #ifdef __cplusplus } #endif diff --git a/src/mmi/meson.build b/src/mmi/meson.build index 5d35046..985db05 100644 --- a/src/mmi/meson.build +++ b/src/mmi/meson.build @@ -24,12 +24,14 @@ glib_dep = dependency('glib-2.0', method : 'pkg-config') gio_dep = dependency('gio-2.0', method : 'pkg-config') ecore_dep = dependency('ecore', method : 'pkg-config') xml_dep = dependency('libxml-2.0', method : 'pkg-config') +capi_system_info_dep = dependency('capi-system-info', method : 'pkg-config') mmi_deps = [ ecore_dep, glib_dep, gio_dep, - xml_dep + xml_dep, + capi_system_info_dep ] foreach platform_specific_dependency : mmi_platform_specific_dependencies diff --git a/src/mmi/mmi-attribute.cpp b/src/mmi/mmi-attribute.cpp index 22d8176..d93234b 100644 --- a/src/mmi/mmi-attribute.cpp +++ b/src/mmi/mmi-attribute.cpp @@ -21,6 +21,7 @@ #include #include "mmi-log.h" +#include "mmi-common.h" #include @@ -34,8 +35,41 @@ struct mmi_attribute_s { static constexpr size_t g_unit_size = sizeof(mmi_primitive_value_h); +static int g_feature_enabled = -1; + +static int mmi_get_feature_enabled() { + if (0 == g_feature_enabled) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } else if (-1 == g_feature_enabled) { + bool supported = false; + if (0 == system_info_get_platform_bool(MMI_FEATURE_PATH, &supported)) { + if (false == supported) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + g_feature_enabled = 0; + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; + } else { + //LCOV_EXCL_START + LOGE("[ERROR] Fail to get feature value"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + } + return 0; +} int mmi_attribute_create(mmi_primitive_value_h value, const char *name, mmi_attribute_h *attribute) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == value || nullptr == name || nullptr == attribute) { _E("[ERROR] Some parameters are null"); return MMI_ERROR_INVALID_PARAMETER; @@ -68,6 +102,10 @@ int mmi_attribute_create(mmi_primitive_value_h value, const char *name, mmi_att } int mmi_attribute_set_name(mmi_attribute_h attribute, const char *name) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == attribute || nullptr == name) { _E("[ERROR] Some parameters are null"); return MMI_ERROR_INVALID_PARAMETER; @@ -81,6 +119,10 @@ int mmi_attribute_set_name(mmi_attribute_h attribute, const char *name) { } int mmi_attribute_get_name(mmi_attribute_h attribute, char **name) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == attribute || nullptr == name) { _E("[ERROR] Some parameters are null"); return MMI_ERROR_INVALID_PARAMETER; @@ -98,6 +140,10 @@ int mmi_attribute_get_name(mmi_attribute_h attribute, char **name) { } int mmi_attribute_get_value(mmi_attribute_h attribute, mmi_primitive_value_h *value) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == attribute || nullptr == value) { _E("[ERROR] Some parameters are null"); return MMI_ERROR_INVALID_PARAMETER; @@ -114,6 +160,10 @@ int mmi_attribute_get_value(mmi_attribute_h attribute, mmi_primitive_value_h *va } int mmi_attribute_clone(mmi_attribute_h attribute, mmi_attribute_h *cloned) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == attribute || nullptr == cloned) { _E("[ERROR] Some parameters are null"); return MMI_ERROR_INVALID_PARAMETER; @@ -140,6 +190,10 @@ int mmi_attribute_clone(mmi_attribute_h attribute, mmi_attribute_h *cloned) { } int mmi_attribute_destroy(mmi_attribute_h attribute) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == attribute) { _E("[ERROR] Parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -157,6 +211,10 @@ int mmi_attribute_destroy(mmi_attribute_h attribute) { } int mmi_attribute_to_bytes(mmi_attribute_h attribute, unsigned char **bytes, size_t *length) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == attribute || nullptr == bytes || nullptr == length) { _E("[ERROR] Some parameters are null"); return MMI_ERROR_INVALID_PARAMETER; @@ -196,6 +254,10 @@ int mmi_attribute_to_bytes(mmi_attribute_h attribute, unsigned char **bytes, siz } int mmi_attribute_from_bytes(const unsigned char *bytes, size_t length, mmi_attribute_h *attribute) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == bytes || 0 == length || nullptr == attribute) { _E("[ERROR] Some parameters are null"); return MMI_ERROR_INVALID_PARAMETER; @@ -255,6 +317,10 @@ int mmi_attribute_from_bytes(const unsigned char *bytes, size_t length, mmi_attr } int mmi_attribute_create_string_array(const char *name, const char *strings[], size_t count, mmi_attribute_h *attribute) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == attribute || nullptr == name || nullptr == strings || 0 == count) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; diff --git a/src/mmi/mmi-data.cpp b/src/mmi/mmi-data.cpp index 1859925..5df558a 100644 --- a/src/mmi/mmi-data.cpp +++ b/src/mmi/mmi-data.cpp @@ -21,10 +21,40 @@ #include #include "mmi-log.h" +#include "mmi-common.h" #include #include +static int g_feature_enabled = -1; + +static int mmi_get_feature_enabled() { + if (0 == g_feature_enabled) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } else if (-1 == g_feature_enabled) { + bool supported = false; + if (0 == system_info_get_platform_bool(MMI_FEATURE_PATH, &supported)) { + if (false == supported) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + g_feature_enabled = 0; + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; + } else { + //LCOV_EXCL_START + LOGE("[ERROR] Fail to get feature value"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + } + return 0; +} struct mmi_data_timestamp_s { bool valid; @@ -62,6 +92,10 @@ static inline mmi_data_h *get_element_value_pointer_in_struct(mmi_data_h struct_ } int mmi_data_create_bool(bool value, mmi_data_h *data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -94,6 +128,10 @@ int mmi_data_create_bool(bool value, mmi_data_h *data) { } int mmi_data_create_int(int value, mmi_data_h *data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -127,6 +165,10 @@ int mmi_data_create_int(int value, mmi_data_h *data) { int mmi_data_create_float(float value, mmi_data_h *data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -159,6 +201,10 @@ int mmi_data_create_float(float value, mmi_data_h *data) { } int mmi_data_create_text(const char *value, mmi_data_h *data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == value) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -190,6 +236,10 @@ int mmi_data_create_text(const char *value, mmi_data_h *data) { } int mmi_data_create_audio(const void *ptr, size_t len, mmi_data_h *data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == ptr || 0 == len) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -222,6 +272,10 @@ int mmi_data_create_audio(const void *ptr, size_t len, mmi_data_h *data) { } int mmi_data_create_video(const void *ptr, size_t len, mmi_data_h *data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == ptr || 0 == len) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -254,6 +308,10 @@ int mmi_data_create_video(const void *ptr, size_t len, mmi_data_h *data) { } int mmi_data_create_user_identification(const void *ptr, size_t len, mmi_data_h *data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == ptr || 0 == len) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -286,6 +344,10 @@ int mmi_data_create_user_identification(const void *ptr, size_t len, mmi_data_h } int mmi_data_create_coordinate(int x, int y, mmi_data_h *data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -319,6 +381,10 @@ int mmi_data_create_coordinate(int x, int y, mmi_data_h *data) { } int mmi_data_create_bounding_box(int x, int y, int w, int h, mmi_data_h *data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -354,6 +420,10 @@ int mmi_data_create_bounding_box(int x, int y, int w, int h, mmi_data_h *data) { } int mmi_data_create_array(mmi_data_h *data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -377,6 +447,10 @@ int mmi_data_create_array(mmi_data_h *data) { } int mmi_data_add_array_element(mmi_data_h array, mmi_data_h element) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == array || nullptr == element) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -414,6 +488,10 @@ int mmi_data_add_array_element(mmi_data_h array, mmi_data_h element) { } int mmi_data_create_struct(mmi_data_h *struct_handle) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == struct_handle) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -437,6 +515,10 @@ int mmi_data_create_struct(mmi_data_h *struct_handle) { } int mmi_data_set_struct_element(mmi_data_h struct_handle, const char *name, mmi_data_h element) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == struct_handle || nullptr == name || nullptr == element) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -477,6 +559,10 @@ int mmi_data_set_struct_element(mmi_data_h struct_handle, const char *name, mmi_ } int mmi_data_get_type(mmi_data_h data, mmi_data_type_e *type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == type) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -488,6 +574,10 @@ int mmi_data_get_type(mmi_data_h data, mmi_data_type_e *type) { } int mmi_data_get_bool(mmi_data_h data, bool *value) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == value) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -505,6 +595,10 @@ int mmi_data_get_bool(mmi_data_h data, bool *value) { } int mmi_data_get_int(mmi_data_h data, int *value) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == value) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -521,6 +615,10 @@ int mmi_data_get_int(mmi_data_h data, int *value) { } int mmi_data_get_float(mmi_data_h data, float *value) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == value) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -537,6 +635,10 @@ int mmi_data_get_float(mmi_data_h data, float *value) { } int mmi_data_get_text(mmi_data_h data, const char **text) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == text) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -553,6 +655,10 @@ int mmi_data_get_text(mmi_data_h data, const char **text) { } int mmi_data_get_audio(mmi_data_h data, const void **ptr, size_t *len) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == ptr || nullptr == len) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -570,6 +676,10 @@ int mmi_data_get_audio(mmi_data_h data, const void **ptr, size_t *len) { } int mmi_data_get_video(mmi_data_h data, const void **ptr, size_t *len) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == ptr || nullptr == len) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -587,6 +697,10 @@ int mmi_data_get_video(mmi_data_h data, const void **ptr, size_t *len) { } int mmi_data_get_user_identification(mmi_data_h data, const void **ptr, size_t *len) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == ptr || nullptr == len) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -604,6 +718,10 @@ int mmi_data_get_user_identification(mmi_data_h data, const void **ptr, size_t * } int mmi_data_get_coordinate(mmi_data_h data, int *x, int *y) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == x || nullptr == y) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -627,6 +745,10 @@ int mmi_data_get_coordinate(mmi_data_h data, int *x, int *y) { } int mmi_data_get_bounding_box(mmi_data_h data, int *x, int *y, int *w, int *h) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == x || nullptr == y || nullptr == w || nullptr == h) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -652,6 +774,10 @@ int mmi_data_get_bounding_box(mmi_data_h data, int *x, int *y, int *w, int *h) { } int mmi_data_get_array_count(mmi_data_h array, size_t *count) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == array || nullptr == count) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -668,6 +794,10 @@ int mmi_data_get_array_count(mmi_data_h array, size_t *count) { } int mmi_data_get_array_element(mmi_data_h array, size_t index, mmi_data_h *element) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == array || nullptr == element) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -690,6 +820,10 @@ int mmi_data_get_array_element(mmi_data_h array, size_t index, mmi_data_h *eleme } int mmi_data_get_struct_element(mmi_data_h struct_handle, const char *name, mmi_data_h *element) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == struct_handle || nullptr == name || nullptr == element) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -728,6 +862,10 @@ int mmi_data_get_struct_element(mmi_data_h struct_handle, const char *name, mmi_ } int mmi_data_get_struct_count(mmi_data_h struct_handle, size_t *count) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == struct_handle || nullptr == count) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -744,6 +882,10 @@ int mmi_data_get_struct_count(mmi_data_h struct_handle, size_t *count) { } int mmi_data_get_struct_element_name(mmi_data_h struct_handle, size_t index, const char **string) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == struct_handle || nullptr == string) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -768,6 +910,10 @@ int mmi_data_get_struct_element_name(mmi_data_h struct_handle, size_t index, con int mmi_data_get_struct_element_value(mmi_data_h struct_handle, size_t index, mmi_data_h *element) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == struct_handle || nullptr == element) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -790,6 +936,10 @@ int mmi_data_get_struct_element_value(mmi_data_h struct_handle, size_t index, mm } int mmi_data_destroy(mmi_data_h data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -813,6 +963,10 @@ int mmi_data_destroy(mmi_data_h data) { } int mmi_data_to_bytes(mmi_data_h data, unsigned char **bytes, size_t *length) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == bytes || nullptr == length) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -888,6 +1042,10 @@ int mmi_data_to_bytes(mmi_data_h data, unsigned char **bytes, size_t *length) { } int mmi_data_from_bytes(unsigned char *bytes, size_t length, mmi_data_h *data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == data || nullptr == bytes || 0 == length) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; diff --git a/src/mmi/mmi-node-types.cpp b/src/mmi/mmi-node-types.cpp index dbb1af8..87993c5 100644 --- a/src/mmi/mmi-node-types.cpp +++ b/src/mmi/mmi-node-types.cpp @@ -21,8 +21,43 @@ #include "mmi-node-types.h" #include "mmi-log.h" +#include "mmi-common.h" + +static int g_feature_enabled = -1; + +static int mmi_get_feature_enabled() { + if (0 == g_feature_enabled) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } else if (-1 == g_feature_enabled) { + bool supported = false; + if (0 == system_info_get_platform_bool(MMI_FEATURE_PATH, &supported)) { + if (false == supported) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + g_feature_enabled = 0; + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; + } else { + //LCOV_EXCL_START + LOGE("[ERROR] Fail to get feature value"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + } + return 0; +} int mmi_node_create_source(mmi_node_source_type_e type, mmi_node_h *node) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { return MMI_ERROR_INVALID_PARAMETER; } @@ -37,6 +72,10 @@ int mmi_node_create_source(mmi_node_source_type_e type, mmi_node_h *node) { } int mmi_node_get_source_type(mmi_node_h node, mmi_node_source_type_e *type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == type || nullptr == node) { return MMI_ERROR_INVALID_PARAMETER; } @@ -45,6 +84,10 @@ int mmi_node_get_source_type(mmi_node_h node, mmi_node_source_type_e *type) { } int mmi_node_create_processor(mmi_node_processor_type_e type, mmi_node_h *node) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { return MMI_ERROR_INVALID_PARAMETER; } @@ -59,6 +102,10 @@ int mmi_node_create_processor(mmi_node_processor_type_e type, mmi_node_h *node) } int mmi_node_get_processor_type(mmi_node_h node, mmi_node_processor_type_e *type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node || nullptr == type) { return MMI_ERROR_INVALID_PARAMETER; } @@ -67,6 +114,10 @@ int mmi_node_get_processor_type(mmi_node_h node, mmi_node_processor_type_e *type } int mmi_node_create_logic(mmi_node_logic_type_e type, mmi_node_h *node) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { return MMI_ERROR_INVALID_PARAMETER; } @@ -81,6 +132,10 @@ int mmi_node_create_logic(mmi_node_logic_type_e type, mmi_node_h *node) { } int mmi_node_get_logic_type(mmi_node_h node, mmi_node_logic_type_e *type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { return MMI_ERROR_INVALID_PARAMETER; } @@ -89,6 +144,10 @@ int mmi_node_get_logic_type(mmi_node_h node, mmi_node_logic_type_e *type) { } int mmi_node_create_controller(mmi_node_controller_type_e type, mmi_node_h *node) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { return MMI_ERROR_INVALID_PARAMETER; } @@ -103,6 +162,10 @@ int mmi_node_create_controller(mmi_node_controller_type_e type, mmi_node_h *node } int mmi_node_get_controller_type(mmi_node_h node, mmi_node_controller_type_e *type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node || nullptr == type) { return MMI_ERROR_INVALID_PARAMETER; } @@ -111,6 +174,10 @@ int mmi_node_get_controller_type(mmi_node_h node, mmi_node_controller_type_e *ty } int mmi_node_create_action(mmi_node_action_type_e type, mmi_node_h *node) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { return MMI_ERROR_INVALID_PARAMETER; } @@ -125,6 +192,10 @@ int mmi_node_create_action(mmi_node_action_type_e type, mmi_node_h *node) { } int mmi_node_get_action_type(mmi_node_h node, mmi_node_action_type_e *type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node || nullptr == type) { return MMI_ERROR_INVALID_PARAMETER; } @@ -133,6 +204,10 @@ int mmi_node_get_action_type(mmi_node_h node, mmi_node_action_type_e *type) { } int mmi_node_create_custom(const char *custom_type_id, mmi_node_h *node) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { return MMI_ERROR_INVALID_PARAMETER; } @@ -148,6 +223,10 @@ int mmi_node_create_custom(const char *custom_type_id, mmi_node_h *node) { } int mmi_node_get_custom_type(mmi_node_h node, const char **custom_type_id) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node || nullptr == custom_type_id) { return MMI_ERROR_INVALID_PARAMETER; } diff --git a/src/mmi/mmi-node.cpp b/src/mmi/mmi-node.cpp index 1350036..53ed0a1 100644 --- a/src/mmi/mmi-node.cpp +++ b/src/mmi/mmi-node.cpp @@ -22,10 +22,45 @@ #include "mmi-plugin-storage.h" #include "mmi-log.h" +#include "mmi-common.h" #include +static int g_feature_enabled = -1; + +static int mmi_get_feature_enabled() { + if (0 == g_feature_enabled) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } else if (-1 == g_feature_enabled) { + bool supported = false; + if (0 == system_info_get_platform_bool(MMI_FEATURE_PATH, &supported)) { + if (false == supported) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + g_feature_enabled = 0; + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; + } else { + //LCOV_EXCL_START + LOGE("[ERROR] Fail to get feature value"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + } + return 0; +} + int mmi_node_add_port(mmi_node_h node, mmi_port_h port) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node || nullptr == port) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -55,6 +90,10 @@ int mmi_node_add_port(mmi_node_h node, mmi_port_h port) { // LCOV_EXCL_START int mmi_node_find_port(mmi_node_h node, mmi_port_type_e port_type, const char *port_name, mmi_port_h *port) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node || nullptr == port_name || nullptr == port) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -63,6 +102,10 @@ int mmi_node_find_port(mmi_node_h node, mmi_port_type_e port_type, const char *p } int mmi_node_link(mmi_node_h from_node, mmi_node_h to_node) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == from_node || nullptr == to_node) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -71,6 +114,10 @@ int mmi_node_link(mmi_node_h from_node, mmi_node_h to_node) { } int mmi_node_link_by_name(mmi_node_h from_node, const char *from_port_name, mmi_node_h to_node, const char *to_port_name) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == from_node || nullptr == from_port_name || nullptr == to_node || nullptr == to_port_name) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -80,6 +127,10 @@ int mmi_node_link_by_name(mmi_node_h from_node, const char *from_port_name, mmi_ // LCOV_EXCL_STOP int mmi_node_get_type(mmi_node_h node, mmi_node_type_e *type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node || nullptr == type) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -89,6 +140,10 @@ int mmi_node_get_type(mmi_node_h node, mmi_node_type_e *type) { } int mmi_node_get_port_count(mmi_node_h node, size_t *port_count) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node || nullptr == port_count) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -98,6 +153,10 @@ int mmi_node_get_port_count(mmi_node_h node, size_t *port_count) { } int mmi_node_get_port(mmi_node_h node, size_t index, mmi_port_h *port) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node || nullptr == port) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -111,6 +170,10 @@ int mmi_node_get_port(mmi_node_h node, size_t index, mmi_port_h *port) { } int mmi_node_get_callbacks(mmi_node_h node, mmi_node_callbacks_s *callbacks) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node || nullptr == callbacks) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -120,6 +183,10 @@ int mmi_node_get_callbacks(mmi_node_h node, mmi_node_callbacks_s *callbacks) { } int mmi_node_set_initialized_cb(mmi_node_h node, mmi_node_initialized_cb callback, void *user_data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -129,6 +196,10 @@ int mmi_node_set_initialized_cb(mmi_node_h node, mmi_node_initialized_cb callbac } int mmi_node_set_deinitialized_cb(mmi_node_h node, mmi_node_deinitialized_cb callback, void *user_data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -138,6 +209,10 @@ int mmi_node_set_deinitialized_cb(mmi_node_h node, mmi_node_deinitialized_cb cal } int mmi_node_set_attribute_set_cb(mmi_node_h node, mmi_node_attribute_set_cb callback, void *user_data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -147,6 +222,10 @@ int mmi_node_set_attribute_set_cb(mmi_node_h node, mmi_node_attribute_set_cb cal } int mmi_node_set_activated_cb(mmi_node_h node, mmi_node_activated_cb callback, void *user_data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -156,6 +235,10 @@ int mmi_node_set_activated_cb(mmi_node_h node, mmi_node_activated_cb callback, v } int mmi_node_set_deactivated_cb(mmi_node_h node, mmi_node_deactivated_cb callback, void *user_data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -165,6 +248,10 @@ int mmi_node_set_deactivated_cb(mmi_node_h node, mmi_node_deactivated_cb callbac } int mmi_node_set_signal_received_cb(mmi_node_h node, mmi_node_signal_received_cb callback, void *user_data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -174,6 +261,10 @@ int mmi_node_set_signal_received_cb(mmi_node_h node, mmi_node_signal_received_cb } int mmi_node_register(mmi_node_h node) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -299,6 +390,10 @@ int mmi_node_register(mmi_node_h node) { } int mmi_node_clone(mmi_node_h node, mmi_node_h *cloned) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node || nullptr == cloned) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -335,6 +430,10 @@ int mmi_node_clone(mmi_node_h node, mmi_node_h *cloned) { } int mmi_node_destroy(mmi_node_h node) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == node) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -349,8 +448,11 @@ int mmi_node_destroy(mmi_node_h node) { return MMI_ERROR_NONE; } -// LCOV_EXCL_START int mmi_node_instance_set_attribute(mmi_node_instance_h instance, mmi_attribute_h attribute) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (instance == NULL || attribute == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -358,6 +460,10 @@ int mmi_node_instance_set_attribute(mmi_node_instance_h instance, mmi_attribute_ } int mmi_node_instance_find_port_instance(mmi_node_instance_h node_instance, mmi_port_type_e port_type, const char *port_name, mmi_port_instance_h *port_instance) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (node_instance == NULL || port_name == NULL || port_instance == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -366,6 +472,10 @@ int mmi_node_instance_find_port_instance(mmi_node_instance_h node_instance, mmi_ } int mmi_node_instance_find_by_port_instance(mmi_port_instance_h port_instance, mmi_node_instance_h *node_instance) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (port_instance == NULL || node_instance == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -374,6 +484,10 @@ int mmi_node_instance_find_by_port_instance(mmi_port_instance_h port_instance, m } int mmi_node_instance_find_sibling_port_instance(mmi_port_instance_h instance, const char *port_name, mmi_port_instance_h *sibling) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (instance == NULL || port_name == NULL || sibling == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -385,6 +499,10 @@ int mmi_node_instance_find_sibling_port_instance(mmi_port_instance_h instance, c } int mmi_node_instance_emit_signal(mmi_node_instance_h instance, mmi_signal_h signal) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (instance == NULL || signal == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -392,9 +510,12 @@ int mmi_node_instance_emit_signal(mmi_node_instance_h instance, mmi_signal_h sig } int mmi_node_instance_update_pending_activation_result(mmi_node_instance_h instance, mmi_error_e result) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (instance == NULL) { return MMI_ERROR_INVALID_PARAMETER; } return MMI_ERROR_NONE; } -// LCOV_EXCL_STOP diff --git a/src/mmi/mmi-port.cpp b/src/mmi/mmi-port.cpp index 4c68de4..e7bc1ad 100644 --- a/src/mmi/mmi-port.cpp +++ b/src/mmi/mmi-port.cpp @@ -25,7 +25,41 @@ #include #include +static int g_feature_enabled = -1; + +static int mmi_get_feature_enabled() { + if (0 == g_feature_enabled) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } else if (-1 == g_feature_enabled) { + bool supported = false; + if (0 == system_info_get_platform_bool(MMI_FEATURE_PATH, &supported)) { + if (false == supported) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + g_feature_enabled = 0; + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; + } else { + //LCOV_EXCL_START + LOGE("[ERROR] Fail to get feature value"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + } + return 0; +} + MMI_API int mmi_port_create(mmi_port_h *port) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == port) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -44,6 +78,10 @@ MMI_API int mmi_port_create(mmi_port_h *port) { } MMI_API int mmi_port_get_name(mmi_port_h port, char **name, size_t *length) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == port || nullptr == name || nullptr == length) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -58,6 +96,10 @@ MMI_API int mmi_port_get_name(mmi_port_h port, char **name, size_t *length) { } MMI_API int mmi_port_get_type(mmi_port_h port, mmi_port_type_e *type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == port || nullptr == type) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -71,6 +113,10 @@ MMI_API int mmi_port_get_type(mmi_port_h port, mmi_port_type_e *type) { } MMI_API int mmi_port_get_data_type(mmi_port_h port, mmi_data_type_e *data_type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == port || nullptr == data_type) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -84,6 +130,10 @@ MMI_API int mmi_port_get_data_type(mmi_port_h port, mmi_data_type_e *data_type) } MMI_API int mmi_port_get_callbacks(mmi_port_h port, mmi_port_callbacks_s *callbacks) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == port || nullptr == callbacks) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -96,6 +146,10 @@ MMI_API int mmi_port_get_callbacks(mmi_port_h port, mmi_port_callbacks_s *callba } MMI_API int mmi_port_set_name(mmi_port_h port, const char *name) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == port || nullptr == name) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -109,6 +163,10 @@ MMI_API int mmi_port_set_name(mmi_port_h port, const char *name) { } MMI_API int mmi_port_set_type(mmi_port_h port, mmi_port_type_e type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == port) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -122,6 +180,10 @@ MMI_API int mmi_port_set_type(mmi_port_h port, mmi_port_type_e type) { } MMI_API int mmi_port_set_data_type(mmi_port_h port, mmi_data_type_e data_type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == port) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -134,8 +196,10 @@ MMI_API int mmi_port_set_data_type(mmi_port_h port, mmi_data_type_e data_type) { return MMI_ERROR_NONE; } -MMI_API int mmi_port_set_output_format_requested_cb(mmi_port_h port, mmi_port_output_format_requested_cb callback, void *user_data) -{ +MMI_API int mmi_port_set_output_format_requested_cb(mmi_port_h port, mmi_port_output_format_requested_cb callback, void *user_data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } if (nullptr == port) { LOGE("[ERROR] Port is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -148,8 +212,11 @@ MMI_API int mmi_port_set_output_format_requested_cb(mmi_port_h port, mmi_port_ou return MMI_ERROR_NONE; } -MMI_API int mmi_port_set_input_data_received_cb(mmi_port_h port, mmi_port_input_data_received_cb callback, void *user_data) -{ +MMI_API int mmi_port_set_input_data_received_cb(mmi_port_h port, mmi_port_input_data_received_cb callback, void *user_data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == port || nullptr == callback) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -163,6 +230,10 @@ MMI_API int mmi_port_set_input_data_received_cb(mmi_port_h port, mmi_port_input_ } MMI_API int mmi_port_clone(mmi_port_h port, mmi_port_h *cloned) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == port || nullptr == cloned) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -185,6 +256,10 @@ MMI_API int mmi_port_clone(mmi_port_h port, mmi_port_h *cloned) { } MMI_API int mmi_port_destroy(mmi_port_h port) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == port) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -197,6 +272,10 @@ MMI_API int mmi_port_destroy(mmi_port_h port) { // LCOV_EXCL_START MMI_API int mmi_port_instance_generate_output(mmi_port_instance_h instance, mmi_data_h data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == instance) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -214,14 +293,26 @@ MMI_API int mmi_port_instance_generate_output(mmi_port_instance_h instance, mmi_ } MMI_API int mmi_port_instance_request_auto_transform(mmi_port_instance_h instance, const char *from_format, const char *to_format) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + return MMI_ERROR_NONE; } MMI_API int mmi_port_instance_request_input_data_format(mmi_port_instance_h instance, const char *format) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + return MMI_ERROR_NONE; } MMI_API int mmi_port_instance_announce_output_data_format(mmi_port_instance_h instance, const char *format) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + return MMI_ERROR_NONE; } // LCOV_EXCL_STOP diff --git a/src/mmi/mmi-primitive-value.cpp b/src/mmi/mmi-primitive-value.cpp index 18681a0..ca06372 100644 --- a/src/mmi/mmi-primitive-value.cpp +++ b/src/mmi/mmi-primitive-value.cpp @@ -20,6 +20,7 @@ #include #include "mmi-log.h" +#include "mmi-common.h" struct mmi_primitive_value_s { @@ -30,6 +31,35 @@ struct mmi_primitive_value_s { static const size_t g_unit_size = sizeof(mmi_primitive_value_h); +static int g_feature_enabled = -1; + +static int mmi_get_feature_enabled() { + if (0 == g_feature_enabled) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } else if (-1 == g_feature_enabled) { + bool supported = false; + if (0 == system_info_get_platform_bool(MMI_FEATURE_PATH, &supported)) { + if (false == supported) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + g_feature_enabled = 0; + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; + } else { + //LCOV_EXCL_START + LOGE("[ERROR] Fail to get feature value"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + } + return 0; +} static inline size_t get_array_count(mmi_primitive_value_h array) { if (nullptr != array) { @@ -44,6 +74,10 @@ static inline mmi_primitive_value_h *get_element_pointer_in_array(mmi_primitive_ } int mmi_primitive_value_create_int(int data, mmi_primitive_value_h *handle) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -77,6 +111,10 @@ int mmi_primitive_value_create_int(int data, mmi_primitive_value_h *handle) { } int mmi_primitive_value_create_float(float data, mmi_primitive_value_h *handle) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -110,6 +148,10 @@ int mmi_primitive_value_create_float(float data, mmi_primitive_value_h *handle) } int mmi_primitive_value_create_string(const char *data, mmi_primitive_value_h *handle) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle || nullptr == data) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -134,6 +176,10 @@ int mmi_primitive_value_create_string(const char *data, mmi_primitive_value_h *h } int mmi_primitive_value_create_bool(bool data, mmi_primitive_value_h *handle) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -167,6 +213,10 @@ int mmi_primitive_value_create_bool(bool data, mmi_primitive_value_h *handle) { } int mmi_primitive_value_create_array(mmi_primitive_value_h *handle) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -191,6 +241,10 @@ int mmi_primitive_value_create_array(mmi_primitive_value_h *handle) { } int mmi_primitive_value_add_array_element(mmi_primitive_value_h array, mmi_primitive_value_h element) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == array || nullptr == element) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -231,6 +285,10 @@ int mmi_primitive_value_add_array_element(mmi_primitive_value_h array, mmi_primi } int mmi_primitive_value_get_type(mmi_primitive_value_h handle, mmi_primitive_value_type_e *type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle || nullptr == type) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -243,6 +301,10 @@ int mmi_primitive_value_get_type(mmi_primitive_value_h handle, mmi_primitive_val } int mmi_primitive_value_get_int(mmi_primitive_value_h handle, int *value) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle || nullptr == value) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -260,6 +322,10 @@ int mmi_primitive_value_get_int(mmi_primitive_value_h handle, int *value) { } int mmi_primitive_value_get_float(mmi_primitive_value_h handle, float *value) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle || nullptr == value) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -277,6 +343,10 @@ int mmi_primitive_value_get_float(mmi_primitive_value_h handle, float *value) { } int mmi_primitive_value_get_string(mmi_primitive_value_h handle, const char **string) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle || nullptr == string) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -294,6 +364,10 @@ int mmi_primitive_value_get_string(mmi_primitive_value_h handle, const char **st } int mmi_primitive_value_get_bool(mmi_primitive_value_h handle, bool *value) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle || nullptr == value) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -312,6 +386,10 @@ int mmi_primitive_value_get_bool(mmi_primitive_value_h handle, bool *value) { } int mmi_primitive_value_get_array_count(mmi_primitive_value_h array, size_t *count) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == array || nullptr == count) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -329,6 +407,10 @@ int mmi_primitive_value_get_array_count(mmi_primitive_value_h array, size_t *cou } int mmi_primitive_value_get_array_element(mmi_primitive_value_h array, size_t index, mmi_primitive_value_h *element) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == array || nullptr == element) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -352,6 +434,10 @@ int mmi_primitive_value_get_array_element(mmi_primitive_value_h array, size_t in } int mmi_primitive_value_clone(mmi_primitive_value_h handle, mmi_primitive_value_h *cloned) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle || nullptr == cloned) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -399,6 +485,10 @@ int mmi_primitive_value_clone(mmi_primitive_value_h handle, mmi_primitive_value_ } int mmi_primitive_value_destroy(mmi_primitive_value_h handle) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -422,8 +512,11 @@ int mmi_primitive_value_destroy(mmi_primitive_value_h handle) { return MMI_ERROR_NONE; } -int mmi_primitive_value_to_bytes(mmi_primitive_value_h handle, unsigned char **bytes, size_t *size) -{ +int mmi_primitive_value_to_bytes(mmi_primitive_value_h handle, unsigned char **bytes, size_t *size) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == handle || nullptr == bytes || nullptr == size) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; @@ -497,8 +590,11 @@ int mmi_primitive_value_to_bytes(mmi_primitive_value_h handle, unsigned char **b return MMI_ERROR_NONE; } -int mmi_primitive_value_from_bytes(unsigned char *bytes, size_t size, mmi_primitive_value_h *handle) -{ +int mmi_primitive_value_from_bytes(unsigned char *bytes, size_t size, mmi_primitive_value_h *handle) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == bytes || nullptr == handle) { _E("[ERROR] Some parameters are invalid"); return MMI_ERROR_INVALID_PARAMETER; diff --git a/src/mmi/mmi-signal.cpp b/src/mmi/mmi-signal.cpp index 3906f57..107dd2f 100644 --- a/src/mmi/mmi-signal.cpp +++ b/src/mmi/mmi-signal.cpp @@ -24,7 +24,41 @@ #include +static int g_feature_enabled = -1; + +static int mmi_get_feature_enabled() { + if (0 == g_feature_enabled) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } else if (-1 == g_feature_enabled) { + bool supported = false; + if (0 == system_info_get_platform_bool(MMI_FEATURE_PATH, &supported)) { + if (false == supported) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + g_feature_enabled = 0; + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; + } else { + //LCOV_EXCL_START + LOGE("[ERROR] Fail to get feature value"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + } + return 0; +} + MMI_API int mmi_signal_parameter_create(mmi_primitive_value_h value, const char *name, mmi_signal_parameter_h *signal_parameter) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (signal_parameter == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -45,6 +79,10 @@ MMI_API int mmi_signal_parameter_create(mmi_primitive_value_h value, const char } MMI_API int mmi_signal_parameter_get_name(mmi_signal_parameter_h signal_parameter, char **name) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (signal_parameter == NULL || name == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -53,6 +91,10 @@ MMI_API int mmi_signal_parameter_get_name(mmi_signal_parameter_h signal_paramete } MMI_API int mmi_signal_parameter_get_value(mmi_signal_parameter_h signal_parameter, mmi_primitive_value_h *value) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (signal_parameter == NULL || value == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -61,6 +103,10 @@ MMI_API int mmi_signal_parameter_get_value(mmi_signal_parameter_h signal_paramet } MMI_API int mmi_signal_parameter_clone(mmi_signal_parameter_h signal_parameter, mmi_signal_parameter_h *cloned) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (signal_parameter == NULL || cloned == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -75,6 +121,10 @@ MMI_API int mmi_signal_parameter_clone(mmi_signal_parameter_h signal_parameter, } MMI_API int mmi_signal_parameter_destroy(mmi_signal_parameter_h signal_parameter) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (signal_parameter == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -84,6 +134,10 @@ MMI_API int mmi_signal_parameter_destroy(mmi_signal_parameter_h signal_parameter } MMI_API int mmi_signal_create(const char *name, mmi_signal_h *handle) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (handle == NULL || name == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -103,6 +157,10 @@ MMI_API int mmi_signal_create(const char *name, mmi_signal_h *handle) { } MMI_API int mmi_signal_add_parameter(mmi_signal_h handle, mmi_signal_parameter_h parameter) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (handle == NULL || parameter == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -128,6 +186,10 @@ MMI_API int mmi_signal_add_parameter(mmi_signal_h handle, mmi_signal_parameter_h } MMI_API int mmi_signal_get_name(mmi_signal_h handle, char **name) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (handle == NULL || name == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -136,6 +198,10 @@ MMI_API int mmi_signal_get_name(mmi_signal_h handle, char **name) { } MMI_API int mmi_signal_get_parameter_count(mmi_signal_h handle, int *count) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (handle == NULL || count == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -144,6 +210,10 @@ MMI_API int mmi_signal_get_parameter_count(mmi_signal_h handle, int *count) { } MMI_API int mmi_signal_get_parameter(mmi_signal_h handle, int index, mmi_signal_parameter_h *parameter) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (handle == NULL || parameter == NULL) { return MMI_ERROR_INVALID_PARAMETER; } @@ -158,6 +228,10 @@ MMI_API int mmi_signal_get_parameter(mmi_signal_h handle, int index, mmi_signal_ } MMI_API int mmi_signal_destroy(mmi_signal_h handle) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (handle == NULL) { return MMI_ERROR_INVALID_PARAMETER; } diff --git a/src/mmi/mmi-workflow-instance.cpp b/src/mmi/mmi-workflow-instance.cpp index 8bcc601..e4ee009 100644 --- a/src/mmi/mmi-workflow-instance.cpp +++ b/src/mmi/mmi-workflow-instance.cpp @@ -37,7 +37,41 @@ using namespace mmi::communication; extern ClientManager g_mmi_client_manager; +static int g_feature_enabled = -1; + +static int mmi_get_feature_enabled() { + if (0 == g_feature_enabled) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } else if (-1 == g_feature_enabled) { + bool supported = false; + if (0 == system_info_get_platform_bool(MMI_FEATURE_PATH, &supported)) { + if (false == supported) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + g_feature_enabled = 0; + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; + } else { + //LCOV_EXCL_START + LOGE("[ERROR] Fail to get feature value"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + } + return 0; +} + MMI_API int mmi_standard_workflow_instance_create(mmi_standard_workflow_type_e type, mmi_workflow_instance_h *instance) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == instance) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -70,8 +104,11 @@ MMI_API int mmi_standard_workflow_instance_create(mmi_standard_workflow_type_e t return MMI_ERROR_NONE; } -MMI_API int mmi_custom_workflow_instance_create(mmi_workflow_h workflow, mmi_workflow_instance_h *instance) -{ +MMI_API int mmi_custom_workflow_instance_create(mmi_workflow_h workflow, mmi_workflow_instance_h *instance) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow || nullptr == instance) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -106,8 +143,11 @@ MMI_API int mmi_custom_workflow_instance_create(mmi_workflow_h workflow, mmi_wor return MMI_ERROR_NONE; } -// LCOV_EXCL_START MMI_API int mmi_workflow_instance_destroy(mmi_workflow_instance_h instance) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == instance) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -132,9 +172,12 @@ MMI_API int mmi_workflow_instance_destroy(mmi_workflow_instance_h instance) { return MMI_ERROR_NONE; } -// LCOV_EXCL_STOP MMI_API int mmi_workflow_instance_activate(mmi_workflow_instance_h instance) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == instance) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -153,8 +196,11 @@ MMI_API int mmi_workflow_instance_activate(mmi_workflow_instance_h instance) { return MMI_ERROR_NONE; } -// LCOV_EXCL_START MMI_API int mmi_workflow_instance_deactivate(mmi_workflow_instance_h instance) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == instance) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -172,9 +218,12 @@ MMI_API int mmi_workflow_instance_deactivate(mmi_workflow_instance_h instance) { return MMI_ERROR_NONE; } -// LCOV_EXCL_STOP MMI_API int mmi_workflow_instance_set_attribute(mmi_workflow_instance_h instance, mmi_attribute_h attribute) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == instance) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -195,6 +244,10 @@ MMI_API int mmi_workflow_instance_set_attribute(mmi_workflow_instance_h instance } MMI_API int mmi_workflow_instance_emit_signal(mmi_workflow_instance_h instance, mmi_signal_h signal) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == instance) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -215,6 +268,10 @@ MMI_API int mmi_workflow_instance_emit_signal(mmi_workflow_instance_h instance, } MMI_API int mmi_workflow_instance_feed_data(mmi_workflow_instance_h instance, const char *node_name, const char *port_name, mmi_data_h data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == instance || nullptr == node_name || nullptr == port_name) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -239,8 +296,11 @@ MMI_API int mmi_workflow_instance_feed_data(mmi_workflow_instance_h instance, co return MMI_ERROR_NONE; } -// LCOV_EXCL_START MMI_API int mmi_workflow_instance_set_output_cb(mmi_workflow_instance_h instance, const char *name, mmi_workflow_output_cb callback, void *user_data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == instance) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -261,9 +321,12 @@ MMI_API int mmi_workflow_instance_set_output_cb(mmi_workflow_instance_h instance return MMI_ERROR_NONE; } -// LCOV_EXCL_STOP MMI_API int mmi_workflow_instance_unset_output_cb(mmi_workflow_instance_h instance, mmi_workflow_output_cb callback) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == instance) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; diff --git a/src/mmi/mmi-workflow-script.cpp b/src/mmi/mmi-workflow-script.cpp index 34bb597..d65b9a2 100644 --- a/src/mmi/mmi-workflow-script.cpp +++ b/src/mmi/mmi-workflow-script.cpp @@ -26,7 +26,42 @@ #include #include +static int g_feature_enabled = -1; + +static int mmi_get_feature_enabled() { + if (0 == g_feature_enabled) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } else if (-1 == g_feature_enabled) { + bool supported = false; + if (0 == system_info_get_platform_bool(MMI_FEATURE_PATH, &supported)) { + if (false == supported) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + g_feature_enabled = 0; + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; + } else { + //LCOV_EXCL_START + LOGE("[ERROR] Fail to get feature value"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + } + return 0; +} + + MMI_API int mmi_workflow_create_from_script(const char *script, mmi_workflow_h *workflow) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (script == nullptr || workflow == nullptr) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -53,6 +88,10 @@ MMI_API int mmi_workflow_create_from_script(const char *script, mmi_workflow_h * MMI_API int mmi_workflow_create_from_script_file(const char *script_path, mmi_workflow_h *workflow) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (script_path == nullptr || workflow == nullptr) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -82,6 +121,10 @@ MMI_API int mmi_workflow_create_from_script_file(const char *script_path, mmi_wo } MMI_API int mmi_workflow_generate_script(mmi_workflow_h workflow, const char **script) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (workflow == nullptr || script == nullptr) { LOGE("[ERROR] Invalid parameter"); return MMI_ERROR_INVALID_PARAMETER; diff --git a/src/mmi/mmi-workflow.cpp b/src/mmi/mmi-workflow.cpp index b338db9..79bdd66 100644 --- a/src/mmi/mmi-workflow.cpp +++ b/src/mmi/mmi-workflow.cpp @@ -29,7 +29,41 @@ #include "mmi-common.h" #include "mmi-workflow-internal.h" +static int g_feature_enabled = -1; + +static int mmi_get_feature_enabled() { + if (0 == g_feature_enabled) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } else if (-1 == g_feature_enabled) { + bool supported = false; + if (0 == system_info_get_platform_bool(MMI_FEATURE_PATH, &supported)) { + if (false == supported) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + g_feature_enabled = 0; + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; + } else { + //LCOV_EXCL_START + LOGE("[ERROR] Fail to get feature value"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + } + return 0; +} + MMI_API int mmi_workflow_create(mmi_workflow_h *workflow) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -63,6 +97,10 @@ MMI_API int mmi_workflow_create(mmi_workflow_h *workflow) { } MMI_API int mmi_workflow_set_type(mmi_workflow_h workflow, mmi_standard_workflow_type_e type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -75,6 +113,10 @@ MMI_API int mmi_workflow_set_type(mmi_workflow_h workflow, mmi_standard_workflow } MMI_API int mmi_workflow_get_type(mmi_workflow_h workflow, mmi_standard_workflow_type_e *type) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow || nullptr == type) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -87,6 +129,10 @@ MMI_API int mmi_workflow_get_type(mmi_workflow_h workflow, mmi_standard_workflow } MMI_API int mmi_workflow_node_add(mmi_workflow_h workflow, const char *node_name, mmi_node_h node) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow || nullptr == node_name || nullptr == node) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -110,6 +156,10 @@ MMI_API int mmi_workflow_node_add(mmi_workflow_h workflow, const char *node_name MMI_API int mmi_workflow_link_nodes_by_names(mmi_workflow_h workflow, const char *from_node_name, const char *from_port_name, const char *to_node_name, const char *to_port_name) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -139,6 +189,10 @@ MMI_API int mmi_workflow_link_nodes_by_names(mmi_workflow_h workflow, } MMI_API int mmi_workflow_attribute_assign(mmi_workflow_h workflow, const char *attribute_name, const char *target_node_name, const char *target_attribute_name) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow || nullptr == attribute_name || nullptr == target_node_name || nullptr == target_attribute_name) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -169,6 +223,10 @@ MMI_API int mmi_workflow_attribute_assign(mmi_workflow_h workflow, const char *a } MMI_API int mmi_workflow_attribute_set_default_value(mmi_workflow_h workflow, mmi_attribute_h default_value) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow || nullptr == default_value) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -200,6 +258,10 @@ MMI_API int mmi_workflow_attribute_set_default_value(mmi_workflow_h workflow, mm } MMI_API int mmi_workflow_signal_assign(mmi_workflow_h workflow, const char *signal_name, const char *target_node_name, const char *target_signal_name) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow || nullptr == signal_name || nullptr == target_node_name || nullptr == target_signal_name) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -231,6 +293,10 @@ MMI_API int mmi_workflow_signal_assign(mmi_workflow_h workflow, const char *sign } MMI_API int mmi_workflow_output_assign(mmi_workflow_h workflow, const char *workflow_output, const char *out_node_name, const char *node_out_port_name) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow || nullptr == workflow_output || nullptr == out_node_name || nullptr == node_out_port_name) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -255,6 +321,10 @@ MMI_API int mmi_workflow_output_assign(mmi_workflow_h workflow, const char *work } MMI_API int mmi_workflow_output_assign_by_port(mmi_workflow_h workflow, const char *workflow_output, mmi_port_h port) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow || nullptr == workflow_output || nullptr == port) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -263,6 +333,10 @@ MMI_API int mmi_workflow_output_assign_by_port(mmi_workflow_h workflow, const ch } MMI_API int mmi_standard_workflow_register(mmi_workflow_h workflow) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -322,6 +396,10 @@ MMI_API int mmi_standard_workflow_register(mmi_workflow_h workflow) { } MMI_API int mmi_workflow_clone(mmi_workflow_h workflow, mmi_workflow_h *cloned) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow || nullptr == cloned) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; @@ -427,6 +505,10 @@ MMI_API int mmi_workflow_clone(mmi_workflow_h workflow, mmi_workflow_h *cloned) } MMI_API int mmi_workflow_destroy(mmi_workflow_h workflow) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (nullptr == workflow) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; diff --git a/src/mmi/mmi.cpp b/src/mmi/mmi.cpp index f6a1b07..08df609 100644 --- a/src/mmi/mmi.cpp +++ b/src/mmi/mmi.cpp @@ -67,8 +67,41 @@ ClientManager g_mmi_client_manager{ }; static bool g_initialized = false; +static int g_feature_enabled = -1; + +static int mmi_get_feature_enabled() { + if (0 == g_feature_enabled) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } else if (-1 == g_feature_enabled) { + bool supported = false; + if (0 == system_info_get_platform_bool(MMI_FEATURE_PATH, &supported)) { + if (false == supported) { + //LCOV_EXCL_START + LOGE("[ERROR] MMI feature NOT supported"); + g_feature_enabled = 0; + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; + } else { + //LCOV_EXCL_START + LOGE("[ERROR] Fail to get feature value"); + return MMI_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + } + return 0; +} MMI_API int mmi_initialize() { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (g_initialized) { return MMI_ERROR_OPERATION_FAILED; } @@ -80,6 +113,10 @@ MMI_API int mmi_initialize() { } MMI_API int mmi_deinitialize() { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (!g_initialized) { return MMI_ERROR_OPERATION_FAILED; } @@ -90,6 +127,10 @@ MMI_API int mmi_deinitialize() { } MMI_API int mmi_set_state_changed_cb(mmi_state_changed_cb callback, void *user_data) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (callback == nullptr) { return MMI_ERROR_INVALID_PARAMETER; } @@ -102,6 +143,10 @@ MMI_API int mmi_set_state_changed_cb(mmi_state_changed_cb callback, void *user_d } MMI_API int mmi_unset_state_changed_cb(mmi_state_changed_cb callback) { + if (0 != mmi_get_feature_enabled()) { + return MMI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (callback == nullptr) { return MMI_ERROR_INVALID_PARAMETER; }