Modify service_app_add_event_handler function 40/298440/3
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 7 Sep 2023 04:12:57 +0000 (13:12 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 7 Sep 2023 04:19:11 +0000 (13:19 +0900)
To support timezone changed event, this patch modifies the function.

Change-Id: I5764c1b38572e6ff0c68c57fe5f0ef265530deeb
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/service_app_main.cc

index 42ebd46..981f95d 100644 (file)
@@ -75,7 +75,7 @@ int __on_error(app_error_e error, const char* function,
   return error;
 }
 
-constexpr int APP_EVENT_MAX = 7;
+constexpr int APP_EVENT_MAX = static_cast<int>(IAppCore::IEvent::Type::END);
 constexpr IAppCore::IEvent::Type __app_event_converter[APP_EVENT_MAX] = {
     [APP_EVENT_LOW_MEMORY] = IAppCore::IEvent::Type::LOW_MEMORY,
     [APP_EVENT_LOW_BATTERY] = IAppCore::IEvent::Type::LOW_BATTERY,
@@ -85,6 +85,9 @@ constexpr IAppCore::IEvent::Type __app_event_converter[APP_EVENT_MAX] = {
     [APP_EVENT_REGION_FORMAT_CHANGED] = IAppCore::IEvent::Type::REGION_CHANGE,
     [APP_EVENT_SUSPENDED_STATE_CHANGED] =
         IAppCore::IEvent::Type::SUSPENDED_STATE_CHANGE,
+    [APP_EVENT_UPDATE_REQUESTED] = IAppCore::IEvent::Type::UPDATE_REQUESTED,
+    [APP_EVENT_TIME_ZONE_CHANGED] =
+        IAppCore::IEvent::Type::TIME_ZONE_CHANGED,
 };
 
 class AppContext : public AppCoreBase {
@@ -279,7 +282,7 @@ extern "C" EXPORT_API int service_app_add_event_handler(
   }
 
   if (event_type < APP_EVENT_LOW_MEMORY ||
-      event_type > APP_EVENT_SUSPENDED_STATE_CHANGED ||
+      event_type > APP_EVENT_TIME_ZONE_CHANGED ||
       event_type == APP_EVENT_DEVICE_ORIENTATION_CHANGED) {
     return __on_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__,
         "invalid event type");
@@ -324,7 +327,7 @@ extern "C" EXPORT_API int service_app_remove_event_handler(
   auto type = (*eb)->GetType();
 
   if (type < IAppCore::IEvent::Type::LOW_MEMORY ||
-      type > IAppCore::IEvent::Type::SUSPENDED_STATE_CHANGE ||
+      type > IAppCore::IEvent::Type::TIME_ZONE_CHANGED ||
       type == IAppCore::IEvent::Type::DEVICE_ORIENTATION_CHANGED)
     return __on_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, nullptr);  // LCOV_EXCL_LINE