[SDL_tizen] bugfix App terminate 55/92855/3
authorDaeKwang Ryu <dkdk.ryu@samsung.com>
Wed, 19 Oct 2016 06:13:46 +0000 (15:13 +0900)
committerWonsik, Jung <sidein@samsung.com>
Thu, 20 Oct 2016 07:45:37 +0000 (16:45 +0900)
Before, we can't terminate SDL Apps with Tizen task manager.
So fix it.

Change-Id: Ida9974b75f6796dd711765d9f67011187cf2a14f

configure
configure.in
packaging/SDL2.spec
src/core/tizen/SDL_tizen.c

index 2fd13cf..9ce3689 100755 (executable)
--- a/configure
+++ b/configure
@@ -18944,8 +18944,8 @@ $as_echo_n "checking for Tizen support... " >&6; }
             test x$video_opengl_egl = xyes && \
             test x$video_opengles_v2 = xyes; then
             if $PKG_CONFIG --exists wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm; then
-                TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm`
-                TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm`
+                TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm aul`
+                TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm aul`
                 video_tizen=yes
             fi
         fi
index b41befc..26ce8f5 100644 (file)
@@ -1270,8 +1270,8 @@ CheckTizen()
             test x$video_opengl_egl = xyes && \
             test x$video_opengles_v2 = xyes; then
             if $PKG_CONFIG --exists wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm; then
-                TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm`
-                TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm`
+                TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm aul`
+                TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm aul`
                 video_tizen=yes
             fi
         fi
index 4e2496e..7f02f59 100755 (executable)
@@ -48,6 +48,7 @@ BuildRequires:  pkgconfig(capi-appfw-application)
 BuildRequires:  pkgconfig(capi-system-system-settings)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(ecore-imf)
+BuildRequires:  pkgconfig(aul)
 
 %if "%{profile}" == "mobile"
 BuildRequires:  Vulkan-LoaderAndValidationLayers
index 23390d1..6b711d1 100644 (file)
 #include <app_internal.h>
 #include <app_extension.h>
 #include <system_settings.h>
+#include <aul.h>
 
 static int tizen_appcore_initialized = 0;
 static appcore_context_h appcore_handle = NULL;
 static ui_app_lifecycle_callback_s event_callback = {0,};
 static app_event_handler_h handlers[5] = {NULL, };
 
+int _tizen_terminate_event_filter(void *userdata, SDL_Event * event);
+int _tizen_aul_status_changed_cb(int status, void *data);
+
 /* TODO  ::
  * Impplementation of serveral app core callback function for SDL Application and App Core
  * */
@@ -131,6 +135,7 @@ _tizen_app_low_battery(app_event_info_h event_info, void *user_data)
 {
     /*APP_EVENT_LOW_BATTERY*/
     SDL_Log("low battery");
+    return;
 }
 
 static void
@@ -139,11 +144,49 @@ _tizen_app_low_memory(app_event_info_h event_info, void *user_data)
     /*APP_EVENT_LOW_MEMORY*/
     SDL_Log("low memory");
     SDL_SendAppEvent(SDL_APP_LOWMEMORY);
+    return;
+}
+
+int
+_tizen_aul_status_changed_cb(int status, void *data)
+{
+    if (status == STATUS_DYING) {
+        SDL_Log(":: STATUS_DYING");
+        SDL_SendQuit();
+        SDL_SendAppEvent(SDL_APP_TERMINATING);
+
+        SDL_DelEventWatch(_tizen_terminate_event_filter, NULL);
+    }
+
+    return 1;
+}
+
+int
+_tizen_terminate_event_filter(void *userdata, SDL_Event * event)
+{
+    if (!event) {
+        SDL_Log("Event is NULL");
+        return -1;
+    }
+
+    switch(event->type) {
+    case SDL_APP_TERMINATING: {
+            aul_remove_status_local_cb(_tizen_aul_status_changed_cb, NULL);
+            SDL_tizen_app_exit();
+        }
+        break;
+    default:
+        break;
+    }
+
+    return 1;
 }
 
 int
 SDL_tizen_app_init(int argc, char *argv[])
 {
+    int aul_ret = 0;
+
     SDL_Log( "SDL Tizen App initialize");
     if (tizen_appcore_initialized) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Already initialized!");
@@ -156,7 +199,7 @@ SDL_tizen_app_init(int argc, char *argv[])
     }
 
     event_callback.create = _tizen_sdl_create;
-    event_callback.terminate = _tizen_sdl_terminate;
+//    event_callback.terminate = _tizen_sdl_terminate;
     event_callback.pause = _tizen_sdl_pause;
     event_callback.resume = _tizen_sdl_resume;
     event_callback.app_control = _tizen_sdl_control;
@@ -167,12 +210,22 @@ SDL_tizen_app_init(int argc, char *argv[])
     ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _tizen_app_lang_changed, NULL);
     ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, _tizen_app_region_changed, NULL);
 
+    aul_ret = aul_add_status_local_cb(_tizen_aul_status_changed_cb, NULL);
+    if (aul_ret == AUL_R_ERROR) {
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "AUL status changed callback setting is failed.");
+        return 0;
+    }
+
+    /* add event watch for SDL_APP_TERMINATING */
+    SDL_AddEventWatch(_tizen_terminate_event_filter, NULL);
+
     return ui_app_init(argc, argv, &event_callback, NULL, &appcore_handle);
 }
 
 void
 SDL_tizen_app_exit(void)
 {
+    SDL_Log("call ui_app_fini");
     ui_app_fini(appcore_handle);
 }
 #endif