tizen 2.3 release tizen_2.3 submit/tizen_2.3/20150202.061310 tizen_2.3_release
authorjk7744.park <jk7744.park@samsung.com>
Sun, 1 Feb 2015 04:34:01 +0000 (13:34 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sun, 1 Feb 2015 04:34:01 +0000 (13:34 +0900)
64 files changed:
CMakeLists.txt
TC/unit/pkgname.h
agent/daemon-manager-launch-agent.c
am_daemon/amd_appinfo.c
am_daemon/amd_appinfo.h
am_daemon/amd_key.c
am_daemon/amd_key.h
am_daemon/amd_launch.c
am_daemon/amd_launch.h
am_daemon/amd_main.c
am_daemon/amd_request.c
am_daemon/amd_request.h
am_daemon/amd_status.c
am_daemon/amd_status.h
aul-mobile.manifest [deleted file]
aul.manifest [moved from aul-wearable.manifest with 91% similarity]
data/aul_mime.sh [deleted file]
data/aul_service.sh [deleted file]
data/aul_service_test.sh [deleted file]
data/config_splash.sh
data/create_default_service.sh [deleted file]
data/mida_db.sql [deleted file]
data/service/README [deleted file]
effect_img/type0_portrait.jpg [new file with mode: 0755]
effect_img/type1_portrait.jpg [new file with mode: 0755]
effect_img/type2_portrait.jpg [new file with mode: 0755]
effect_img/type3_portrait.jpg [new file with mode: 0755]
effect_img/type4_portrait.jpg [new file with mode: 0755]
include/SLP_AUL_PG.h [changed mode: 0755->0644]
include/app_signal.h
include/app_sock.h
include/aul.h
include/aul_service.h [deleted file]
include/aul_util.h
include/menu_db_util.h
include/mida.h [deleted file]
include/simple_util.h
launchpad_src/launchpad.c
launchpad_src/sigchild.h
legacy/preload.h
packaging/ac-mobile.service [deleted file]
packaging/ac.service [moved from packaging/ac-wearable.service with 84% similarity]
packaging/aul.spec
packaging/launchpad-preload-mobile.service [deleted file]
packaging/launchpad-preload.service [moved from packaging/launchpad-preload-wearable.service with 100% similarity]
packaging/process-pool-launchpad-preload-mobile.service [deleted file]
packaging/process-pool-launchpad-preload-wearable.service [deleted file]
process_pool/launchpad.c [deleted file]
process_pool/preload_list_for_process_pool.txt [deleted file]
process_pool/process_pool.c [deleted file]
process_pool/process_pool.h [deleted file]
src/app_signal.c
src/app_sock.c
src/aul_path.c [new file with mode: 0755]
src/launch.c
src/launch_with_result.c
src/mida.c [deleted file]
src/mime.c
src/pkginfo.c
src/runtime_info.c [new file with mode: 0755]
src/service.c
test/aul_dbus.h
test/aul_test.c
test/com.samsung.camera.service

index e5fb947..e83452e 100755 (executable)
@@ -22,12 +22,17 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 # Set required packages
 INCLUDE(FindPkgConfig)
 
-IF(DEVICE_PROFILE STREQUAL "wearable")
-pkg_check_modules(pkgs REQUIRED dlog ecore x11 libprivilege-control rua glib-2.0 ecore-x ecore-input evas vconf pkgmgr-info system-resource security-server deviced elementary libsystemd-daemon privacy-manager-client)
-ELSE()
-pkg_check_modules(pkgs REQUIRED dlog ecore x11 libprivilege-control rua glib-2.0 ecore-x ecore-input evas vconf pkgmgr-info security-server elementary libsystemd-daemon privacy-manager-client)
-ENDIF()
-pkg_check_modules(libpkgs REQUIRED dlog bundle dbus-glib-1 ail xdgmime libsmack ecore ecore-x)
+SET(pkgs_requires "dlog ecore x11 libprivilege-control rua glib-2.0 ecore-x ecore-input evas vconf pkgmgr-info libresourced security-server")
+SET(libpkgs_requires "dlog bundle dbus-glib-1 ail xdgmime libsmack ecore pkgmgr-info")
+
+IF(_APPFW_FEATURE_APP_CHECKER)
+       SET(pkgs_requires "${pkgs_requires} app-checker app-checker-server")
+       SET(libpkgs_requires "${libpkgs_requires} app-checker")
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_APP_CHECKER")
+ENDIF(_APPFW_FEATURE_APP_CHECKER)
+
+pkg_check_modules(pkgs REQUIRED ${pkgs_requires})
+pkg_check_modules(libpkgs REQUIRED ${libpkgs_requires})
 PKG_CHECK_MODULES(PKGS REQUIRED glib-2.0 gio-2.0 dlog bundle)
 
 FIND_LIBRARY(LIB_DL dl)
@@ -44,7 +49,6 @@ ENDFOREACH(flag)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/legacy)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/feature)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/launchpad_src)
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic")
@@ -57,7 +61,7 @@ SET(CMAKE_C_FLAGS_RELEASE "-O2")
 
 SET(CMAKE_SKIP_BUILD_RPATH true)
 
-# Get uname value to set 'TARGET' definition 
+# Get uname value to set 'TARGET' definition
 # TODO: Is this needed?
 FIND_PROGRAM(UNAME NAMES uname)
 EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
@@ -65,16 +69,63 @@ IF("${ARCH}" STREQUAL "arm")
        ADD_DEFINITIONS("-DTARGET")
        MESSAGE("add -DTARGET")
 ENDIF("${ARCH}" STREQUAL "arm")
-IF(DEVICE_PROFILE STREQUAL "wearable")
-       ADD_DEFINITIONS("-DWEARABLE_PROFILE")
-ELSEIF(DEVICE_PROFILE STREQUAL "mobile")
-       ADD_DEFINITIONS("-DMOBILE_PROFILE")
-ENDIF()
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DSHARE_PREFIX=\"/usr/share/aul\"")
-ADD_DEFINITIONS("-DPROCESS_POOL_ENABLE")
-ADD_DEFINITIONS("-DREMOVE_DB_ACCESS")
+IF(_APPFW_FEATURE_PROCESS_POOL)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_PROCESS_POOL")
+ENDIF(_APPFW_FEATURE_PROCESS_POOL)
+IF(_APPFW_FEATURE_PROCESS_POOL_COMMON)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_PROCESS_POOL_COMMON")
+ENDIF(_APPFW_FEATURE_PROCESS_POOL_COMMON)
+IF(_APPFW_FEATURE_PROCESS_POOL_HW_RENDERING)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_PROCESS_POOL_HW_RENDERING")
+ENDIF(_APPFW_FEATURE_PROCESS_POOL_HW_RENDERING)
+IF(_APPFW_FEATURE_MULTI_INSTANCE)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_MULTI_INSTANCE")
+ENDIF(_APPFW_FEATURE_MULTI_INSTANCE)
+IF(_APPFW_FEATURE_MULTI_WINDOW)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_MULTI_WINDOW")
+ENDIF(_APPFW_FEATURE_MULTI_WINDOW)
+IF(_APPFW_FEATURE_CHANGEABLE_COLOR)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_CHANGEABLE_COLOR")
+ENDIF(_APPFW_FEATURE_CHANGEABLE_COLOR)
+IF(_APPFW_FEATURE_CPU_BOOST)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_CPU_BOOST")
+ENDIF(_APPFW_FEATURE_CPU_BOOST)
+IF(_APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP")
+ENDIF(_APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP)
+IF(_APPFW_FEATURE_PRIORITY_CHANGE)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_PRIORITY_CHANGE")
+ENDIF(_APPFW_FEATURE_PRIORITY_CHANGE)
+IF(_APPFW_FEATURE_DATA_CONTROL)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_DATA_CONTROL")
+ENDIF(_APPFW_FEATURE_DATA_CONTROL)
+IF(_APPFW_FEATURE_DEBUG_LAUNCHPAD)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_DEBUG_LAUNCHPAD")
+ENDIF(_APPFW_FEATURE_DEBUG_LAUNCHPAD)
+IF(_APPFW_FEATURE_APP_CONTROL_LITE)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_APP_CONTROL_LITE")
+ENDIF(_APPFW_FEATURE_APP_CONTROL_LITE)
+IF(_APPFW_FEATURE_NATIVE_LAUNCHPAD)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_NATIVE_LAUNCHPAD")
+ENDIF(_APPFW_FEATURE_NATIVE_LAUNCHPAD)
+IF(_APPFW_FEATURE_WMS_CONNECTION_CHECK)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_WMS_CONNECTION_CHECK")
+ENDIF(_APPFW_FEATURE_WMS_CONNECTION_CHECK)
+IF(_APPFW_FEATURE_BG_PROCESS_LIMIT)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_BG_PROCESS_LIMIT")
+ENDIF(_APPFW_FEATURE_BG_PROCESS_LIMIT)
+IF(_APPFW_FEATURE_TTS_MODE)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_TTS_MODE")
+ENDIF(_APPFW_FEATURE_TTS_MODE)
+IF(_APPFW_FEATURE_ULTRA_POWER_SAVING_MODE)
+        ADD_DEFINITIONS("-D_APPFW_FEATURE_ULTRA_POWER_SAVING_MODE")
+ENDIF(_APPFW_FEATURE_ULTRA_POWER_SAVING_MODE)
+IF(_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS)
+        ADD_DEFINITIONS("-D_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS")
+ENDIF(_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS)
 
 # Linker flags
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
@@ -88,6 +139,11 @@ add_library(aul_mods STATIC
                src/simple_util.c
                )
 
+# launchpad_common (static library)
+ADD_LIBRARY(launchpad_common STATIC
+       launchpad_src/util_x.c
+       )
+
 # aul
 add_library(aul SHARED
                src/pkginfo.c
@@ -96,11 +152,12 @@ add_library(aul SHARED
                src/launch_with_result.c
                src/service.c
                src/mime.c
-               src/mida.c
                src/miregex.c
                src/app_signal.c
                src/key.c
                src/status.c
+               src/runtime_info.c
+               src/aul_path.c
                )
 target_link_libraries(aul aul_mods ${libpkgs_LDFLAGS})
 SET_TARGET_PROPERTIES(aul PROPERTIES SOVERSION ${VERSION_MAJOR})
@@ -110,27 +167,14 @@ SET_TARGET_PROPERTIES(aul PROPERTIES VERSION ${VERSION})
 SET(AVATAR_NAME "launchpad_preloading_preinitializing_daemon")
 add_executable(${AVATAR_NAME}
        launchpad_src/launchpad.c
-       launchpad_src/util_x.c
        )
 
 MESSAGE("       "${pkgs_LDFLAGS})
-target_link_libraries(${AVATAR_NAME} aul_mods aul ${pkgs_LDFLAGS} ${LIB_DL})
+target_link_libraries(${AVATAR_NAME} aul_mods launchpad_common aul ${pkgs_LDFLAGS} ${LIB_DL} "-pie")
 set_target_properties(${AVATAR_NAME}
                PROPERTIES SKIP_BUILD_RPATH true
                ) # remove rpath option that is automatically generated by cmake.
 
-# Process pool launchpad
-SET(PROCESS_POOL "process_pool_launchpad_preloading_preinitializing_daemon")
-ADD_EXECUTABLE(${PROCESS_POOL}
-       process_pool/launchpad.c
-       process_pool/process_pool.c
-       launchpad_src/util_x.c
-       )
-TARGET_LINK_LIBRARIES(${PROCESS_POOL} aul_mods aul ${pkgs_LDFLAGS} ${LIB_DL})
-SET_TARGET_PROPERTIES(${PROCESS_POOL}
-       PROPERTIES SKIP_BUILD_RPATH true
-       ) # remove rpath option that is automatically generated by cmake.
-
 add_executable(amd
                 am_daemon/amd_main.c
                am_daemon/amd_key.c
@@ -165,24 +209,32 @@ CONFIGURE_FILE(aul.pc.in aul.pc @ONLY)
 ### Install ###
 INSTALL(TARGETS aul DESTINATION lib COMPONENT RuntimeLibraries)
 INSTALL(TARGETS ${AVATAR_NAME} DESTINATION bin)
-INSTALL(TARGETS ${PROCESS_POOL} DESTINATION bin)
 INSTALL(TARGETS amd DESTINATION bin)
 
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul.h DESTINATION include/aul)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_service.h DESTINATION include/aul)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/SLP_AUL_PG.h DESTINATION include/aul)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/aul_service.sh DESTINATION bin)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/aul_service_test.sh DESTINATION bin)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/aul_mime.sh DESTINATION bin)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/config_splash.sh DESTINATION bin)
+IF (_APPFW_FEATURE_DEFAULT_FAKE_IMAGE)
+       ADD_DEFINITIONS("-D_APPFW_FEATURE_DEFAULT_FAKE_IMAGE")
+       INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/config_splash.sh DESTINATION bin)
+ENDIF(_APPFW_FEATURE_DEFAULT_FAKE_IMAGE)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/aul.pc DESTINATION lib/pkgconfig)
 
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/legacy/preload_list.txt DESTINATION /usr/share/aul )
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/process_pool/preload_list_for_process_pool.txt DESTINATION /usr/share/aul )
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/feature/preexec_list.txt DESTINATION /usr/share/aul )
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/mida_db.sql DESTINATION /usr/share/aul )
 INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/miregex DESTINATION /usr/share/aul )
-INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/service DESTINATION /usr/share/aul )
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/app_sock.h DESTINATION include/aul/launch)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/simple_util.h DESTINATION include/aul/launch)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/menu_db_util.h DESTINATION include/aul/launch)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/app_signal.h DESTINATION include/aul/launch)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_util.h DESTINATION include/aul/launch)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/access_control.h DESTINATION include/aul/launch)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/perf.h DESTINATION include/aul/launch)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/feature/preexec.h DESTINATION include/aul/launchpad)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/legacy/preload.h DESTINATION include/aul/launchpad)
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/launchpad_src/ DESTINATION include/aul/launchpad FILES_MATCHING PATTERN "*.h")
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libaul_mods.a DESTINATION lib)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblaunchpad_common.a DESTINATION lib)
 
 # test
 add_subdirectory(test)
+
index bd86d85..b5fcc27 100755 (executable)
@@ -20,7 +20,7 @@
  */
 #define MAX_LOCAL_BUFSZ        128
 
-#define EXIST_PKGNAME          "org.tizen.calculator"
+#define EXIST_PKGNAME          "com.samsung.calculator" 
 #define NO_EXIST_PKGNAME       "empty.fault.application"
 
 #define EXIST_FILENAME         "/usr/share/aul/preload_list.txt"
index 2978766..bc27fa9 100644 (file)
@@ -3,15 +3,9 @@
 #include <stdio.h>
 #include <stdarg.h>
 
-#ifdef WEARABLE_PROFILE
 #define DAEMON_MANAGER_NAME "com.samsung.DaemonManager"
 #define DAEMON_MANAGER_PATH "/com/samsung/DaemonManager"
 #define DAEMON_MANAGER_INTERFACE "com.samsung.DaemonManager"
-#else
-#define DAEMON_MANAGER_NAME "org.tizen.DaemonManager"
-#define DAEMON_MANAGER_PATH "/org/tizen/DaemonManager"
-#define DAEMON_MANAGER_INTERFACE "org.tizen.DaemonManager"
-#endif
 
 #define METHOD_RELEASED "Start"
 
index 9212227..842fbb6 100755 (executable)
@@ -36,9 +36,28 @@ enum _appinfo_idx {
        _AI_INDICATORDISP,
        _AI_EFFECTIMAGEPORT,
        _AI_EFFECTIMAGELAND,
+#ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
+       _AI_EFFECTTYPE,
+#endif
        _AI_STATUS,
+#ifdef _APPFW_FEATURE_PROCESS_POOL
        _AI_POOL,
+#endif
        _AI_COMPTYPE,
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+       _AI_MULTI_INSTANCE,
+       _AI_MULTI_INSTANCE_MAINID,
+       _AI_TOGGLE_ORDER,
+#endif
+#ifdef _APPFW_FEATURE_MULTI_WINDOW
+       _AI_MULTI_WINDOW,
+#endif
+#ifdef _APPFW_FEATURE_TTS_MODE
+       _AI_TTS,
+#endif
+#ifdef _APPFW_FEATURE_ULTRA_POWER_SAVING_MODE
+       _AI_UPS,
+#endif
        _AI_MAX,
 };
 #define _AI_START _AI_NAME /* start index */
@@ -64,9 +83,28 @@ static struct appinfo_t _appinfos[] = {
        [_AI_INDICATORDISP] = { "indicatordisplay", AIT_INDICATOR_DISP, },
        [_AI_EFFECTIMAGEPORT] = { "portaitimg", AIT_EFFECTIMAGEPORT, },
        [_AI_EFFECTIMAGELAND] = { "landscapeimg", AIT_EFFECTIMAGELAND, },
+#ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
+       [_AI_EFFECTTYPE] = { "EffectType", AIT_EFFECTTYPE, },
+#endif
        [_AI_STATUS] = { "status", AIT_STATUS, },
+#ifdef _APPFW_FEATURE_PROCESS_POOL
        [_AI_POOL] = { "ProcessPool", AIT_POOL, },
+#endif
        [_AI_COMPTYPE] = { "ComponentType", AIT_COMPTYPE, },
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+       [_AI_MULTI_INSTANCE] = { "multi-instance", AIT_MULTI_INSTANCE, },
+       [_AI_MULTI_INSTANCE_MAINID] = { "multi-instance-mainid", AIT_MULTI_INSTANCE_MAINID, },
+       [_AI_TOGGLE_ORDER] = { "toggleOrder", AIT_TOGGLE_ORDER, },
+#endif
+#ifdef _APPFW_FEATURE_MULTI_WINDOW
+       [_AI_MULTI_WINDOW] = { "multi-window", AIT_MULTI_WINDOW, },
+#endif
+#ifdef _APPFW_FEATURE_TTS_MODE
+       [_AI_TTS] = { "TTS", AIT_TTS, },
+#endif
+#ifdef _APPFW_FEATURE_ULTRA_POWER_SAVING_MODE
+       [_AI_UPS] = { "UPS", AIT_UPS, },
+#endif
 };
 
 struct appinfo {
@@ -75,7 +113,7 @@ struct appinfo {
 
 struct pkginfo {
        char *pkgid;
-       char *op;       
+       char *op;
 };
 
 int gles = 1;
@@ -90,8 +128,10 @@ static void _free_appinfo(gpointer data)
        if (!c)
                return;
 
-       for (i = 0; i < sizeof(c->val)/sizeof(c->val[0]); i++)
-               free(c->val[i]);
+       for (i = 0; i < sizeof(c->val)/sizeof(c->val[0]); i++) {
+               if(c->val[i] != NULL)
+                       free(c->val[i]);
+       }
 
        free(c);
 }
@@ -113,11 +153,21 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d
        char *exec;
        char *portraitimg;
        char *landscapeimg;
+#ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
+       char *effectimg_type;
+#endif
        char *type;
        char *appid;
        char *pkgid;
        char *component_type;
+       char *multi_mainid;
        bool multiple;
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+       bool multi_instance;
+#endif
+#ifdef _APPFW_FEATURE_MULTI_WINDOW
+       bool multi_window;
+#endif
        bool onboot;
        bool restart;
        pkgmgrinfo_app_hwacceleration hwacc;
@@ -127,7 +177,12 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d
        int ret = -1;
        bool taskmanage;
        bool preload;
+#ifdef _APPFW_FEATURE_PROCESS_POOL
        bool process_pool = 0;
+#endif
+       int support_mode = 0;
+
+       _D("__app_info_insert_handler");
 
        if (!handle) {
                _E("null app handle");
@@ -159,7 +214,12 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d
 
        c->val[_AI_NAME] = strdup(appid); //TODO :
 
-       pkgmgrinfo_appinfo_get_component(handle, &component);
+       ret = pkgmgrinfo_appinfo_get_component(handle, &component);
+       if (ret < 0) {
+               _E("fail to get component");
+               _free_appinfo(c);
+               return -1;
+       }
        if(component == PMINFO_UI_APP) {
                c->val[_AI_COMP] = strdup("ui"); //TODO :
 
@@ -223,13 +283,19 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d
                        else
                                c->val[_AI_EFFECTIMAGELAND] = NULL;
                }
+#ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
+               r = pkgmgrinfo_appinfo_get_effectimage_type(handle, &effectimg_type);
+               c->val[_AI_EFFECTTYPE] = strdup(effectimg_type);
+#endif
+
+#ifdef _APPFW_FEATURE_PROCESS_POOL
                r = pkgmgrinfo_appinfo_is_process_pool(handle, &process_pool);
                if (process_pool == false) {
                        c->val[_AI_POOL] = strdup("false");
                } else {
                        c->val[_AI_POOL] = strdup("true");
                }
-
+#endif
                r = pkgmgrinfo_appinfo_get_component_type(handle, &component_type);
                c->val[_AI_COMPTYPE] = strdup(component_type);
 
@@ -241,7 +307,28 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d
                r = pkgmgrinfo_appinfo_is_autorestart(handle, &restart);
                if(restart == true)
                        c->val[_AI_RESTART] = strdup("true");
-               else c->val[_AI_RESTART] = strdup("false");             
+               else c->val[_AI_RESTART] = strdup("false");
+
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+               r = pkgmgrinfo_appinfo_is_multi_instance(handle, &multi_instance);
+               if(multi_instance == true)
+                       c->val[_AI_MULTI_INSTANCE] = strdup("true");
+               else
+                       c->val[_AI_MULTI_INSTANCE] = strdup("false");
+
+               r = pkgmgrinfo_appinfo_get_multi_instance_mainid(handle, &multi_mainid);
+               c->val[_AI_MULTI_INSTANCE_MAINID] = strdup(multi_mainid);
+
+               // Toggle order
+               c->val[_AI_TOGGLE_ORDER] = strdup("0");
+#endif
+#ifdef _APPFW_FEATURE_MULTI_WINDOW
+               r = pkgmgrinfo_appinfo_is_multi_window(handle, &multi_window);
+               if((r == PMINFO_R_OK) && (multi_window == true))
+                       c->val[_AI_MULTI_WINDOW] = strdup("true");
+               else
+                       c->val[_AI_MULTI_WINDOW] = strdup("false");
+#endif
        } else {
                c->val[_AI_COMP] = strdup("svc");
 
@@ -277,12 +364,28 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d
                c->val[_AI_PERM] = strdup("normal");
        }
 
+       pkgmgrinfo_appinfo_get_support_mode(handle, &support_mode);
+#ifdef _APPFW_FEATURE_TTS_MODE
+       if(support_mode & PMINFO_MODE_PROP_SCREEN_READER) {
+               c->val[_AI_TTS] = strdup("true");
+       } else {
+               c->val[_AI_TTS] = strdup("false");
+       }
+#endif
+#ifdef _APPFW_FEATURE_ULTRA_POWER_SAVING_MODE
+       if(support_mode & PMINFO_MODE_PROP_ULTRA_POWER_SAVING) {
+               c->val[_AI_UPS] = strdup("true");
+       } else {
+               c->val[_AI_UPS] = strdup("false");
+       }
+#endif
+
        r = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
        c->val[_AI_PKGID] = strdup(pkgid);
 
        c->val[_AI_STATUS] = strdup("installed");
 
-       SECURE_LOGD("%s : %s : %s", c->val[_AI_FILE], c->val[_AI_COMP], c->val[_AI_TYPE]);
+       SECURE_LOGD("appinfo file:%s, comp:%s, type:%s", c->val[_AI_FILE], c->val[_AI_COMP], c->val[_AI_TYPE]);
 
        g_hash_table_insert(cf->tbl, c->val[_AI_FILE], c);
 
@@ -303,11 +406,11 @@ static int __app_info_delete_handler (const pkgmgrinfo_appinfo_h handle, void *d
 
 static int _read_pkg_info(struct appinfomgr *cf)
 {
-       int r;
+       int ret = pkgmgrinfo_appinfo_get_install_list(__app_info_insert_handler, cf);
 
-       r = pkgmgrinfo_appinfo_get_install_list(__app_info_insert_handler, cf);
+       assert(ret == PMINFO_R_OK);
 
-       return r;
+       return ret;
 }
 
 static struct appinfomgr *_init()
@@ -328,20 +431,30 @@ static struct appinfomgr *_init()
        return cf;
 }
 
-static int __amd_pkgmgrinfo_update_start_handler(pkgmgrinfo_appinfo_h handle, void *user_data)
+static gboolean __amd_pkgmgrinfo_start_handler (gpointer key, gpointer value, gpointer user_data)
 {
-       char *appid = NULL;
-       struct appinfomgr *cf = (struct appinfomgr *)user_data;
-       struct appinfo *c;
+       struct appinfo *c = value;
+       char *pkgid = (char *)user_data;
 
-       pkgmgrinfo_appinfo_get_appid(handle, &appid);
-       c = g_hash_table_lookup(cf->tbl, appid);
-       SECURE_LOGD("%s : %s", c->val[_AI_FILE], c->val[_AI_STATUS]);
-       free(c->val[_AI_STATUS]);
-       c->val[_AI_STATUS] = strdup("upgrading");
-       SECURE_LOGD("upgrading... (%s)", appid);
+       if (c != NULL && strcmp(c->val[_AI_PKGID], pkgid) == 0) {
+               free(c->val[_AI_STATUS]);
+               c->val[_AI_STATUS] = strdup("blocking");
+               SECURE_LOGD("pkgmgr working for this application(%s)", c->val[_AI_NAME]);
+       }
+       return TRUE;
+}
 
-       return 0;
+static gboolean __amd_pkgmgrinfo_fail_handler (gpointer key, gpointer value, gpointer user_data)
+{
+       struct appinfo *c = value;
+       char *pkgid = (char *)user_data;
+
+       if (c != NULL && strcmp(c->val[_AI_PKGID], pkgid) == 0) {
+               free(c->val[_AI_STATUS]);
+               c->val[_AI_STATUS] = strdup("installed");
+               SECURE_LOGD("pkgmgr fail(%s)", c->val[_AI_NAME]);
+       }
+       return TRUE;
 }
 
 static int __amd_pkgmgrinfo_install_end_handler(pkgmgrinfo_appinfo_h handle, void *user_data)
@@ -379,7 +492,8 @@ static int __amd_pkgmgrinfo_update_end_handler(pkgmgrinfo_appinfo_h handle, void
 
        pkgmgrinfo_appinfo_get_appid(handle, &appid);
        c = g_hash_table_lookup(cf->tbl, appid);
-       if (strncmp(c->val[_AI_STATUS], "restart", 7) == 0) {
+
+       if (c != NULL && strncmp(c->val[_AI_STATUS], "restart", 7) == 0) {
                __app_info_insert_handler(handle, user_data);
                __release_srv(appid);
        } else {
@@ -403,7 +517,7 @@ static gboolean __amd_pkgmgrinfo_uninstall_end_handler (gpointer key, gpointer v
 {
        struct appinfo *c = value;
        char *pkgid = (char *)user_data;
-       
+
        if (strcmp(c->val[_AI_PKGID], pkgid) == 0) {
                SECURE_LOGD("appid(%s), pkgid(%s)", c->val[_AI_NAME], pkgid);
                return TRUE;
@@ -430,29 +544,12 @@ static int __amd_pkgmgrinfo_status_cb(int req_id, const char *pkg_type,
                p->op = strdup(val);
                g_hash_table_insert(pkg_tbl, p->pkgid, p);
                if (strncmp(val, "install", 7) == 0) {
-                       
+
                }
-               else if (strncmp(val, "update", 6) == 0) {
-                       ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
-                       if (ret != PMINFO_R_OK)
-                               return -1;
-                       ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __amd_pkgmgrinfo_update_start_handler, user_data);
-                       if (ret != PMINFO_R_OK) {
-                               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-                               return -1;
-                       }
-                       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-               }
-               else if (strncmp(val, "uninstall", 9) == 0) {
-                       ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
-                       if (ret != PMINFO_R_OK)
-                               return -1;
-                       ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __amd_pkgmgrinfo_update_start_handler, user_data);
-                       if (ret != PMINFO_R_OK) {
-                               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-                               return -1;
-                       }
-                       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+               else if ((strncmp(val, "update", 6) == 0) || (strncmp(val, "uninstall", 9) == 0)) {
+                       g_hash_table_foreach(cf->tbl, __amd_pkgmgrinfo_start_handler, (gpointer)pkgid);
+                       _D("__amd_pkgmgrinfo_start_handler");
+                       ret = 0;
                }
        }
        else if (strncmp(key,"end", 3) == 0) {
@@ -490,7 +587,11 @@ static int __amd_pkgmgrinfo_status_cb(int req_id, const char *pkg_type,
                                }
                        }
                        else if (strncmp(val, "fail", 4) == 0) {
-
+                               if ((op && strncmp(op, "update", 6) == 0) || (op && strncmp(op, "uninstall", 9) ==  0) ) {
+                                       g_hash_table_foreach(cf->tbl, __amd_pkgmgrinfo_fail_handler, (gpointer)pkgid);
+                                       _D("__amd_pkgmgrinfo_fail_handler");
+                                       ret = 0;
+                               }
                        }
                        g_hash_table_remove(pkg_tbl, p->pkgid);
                        free(p->pkgid);
@@ -539,7 +640,7 @@ static void __amd_mmc_vconf_cb(keynode_t *key, void *data)
 {
        int status;
        struct appinfomgr *cf = (struct appinfomgr *)data;
-       int ret;
+       int ret = 0;
 
        status = vconf_keynode_get_int(key);
        if( status < 0 ) {
@@ -547,9 +648,15 @@ static void __amd_mmc_vconf_cb(keynode_t *key, void *data)
        }
 
        if(status == VCONFKEY_SYSMAN_MMC_REMOVED || status == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
-               pkgmgrinfo_appinfo_get_unmounted_list(__unmounted_list_cb, data);
+               ret = pkgmgrinfo_appinfo_get_unmounted_list(__unmounted_list_cb, data);
+               if (ret != PMINFO_R_OK){
+                       _E("pkgmgrinfo_appinfo_get_unmounted_list failed: %d", ret);
+               }
        } else if(status == VCONFKEY_SYSMAN_MMC_MOUNTED){
-               pkgmgrinfo_appinfo_get_mounted_list(__mounted_list_cb, data);
+               ret = pkgmgrinfo_appinfo_get_mounted_list(__mounted_list_cb, data);
+               if (ret != PMINFO_R_OK){
+                       _E("pkgmgrinfo_appinfo_get_mounted_list failed: %d", ret);
+               }
        }
 }
 
@@ -580,8 +687,10 @@ int appinfo_init(struct appinfomgr **cf)
        fclose(fp);
 
        _cf = _init();
-       if (!_cf)
+       if (!_cf) {
+               assert(_cf);
                return -1;
+       }
 
        r = _read_pkg_info(_cf);
        if (r != PMINFO_R_OK) {
@@ -589,6 +698,10 @@ int appinfo_init(struct appinfomgr **cf)
                return -1;
        }
 
+       r = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, __amd_mmc_vconf_cb, _cf);
+       if (r < 0)
+               _E("Unable to register vconf notification callback for VCONFKEY_SYSMAN_MMC_STATUS\n");
+
        int event_type = PMINFO_CLIENT_STATUS_UPGRADE | PMINFO_CLIENT_STATUS_UNINSTALL | PMINFO_CLIENT_STATUS_INSTALL;
        pkgmgrinfo_client *pc = NULL;
        pc = pkgmgrinfo_client_new(PMINFO_LISTENING);
@@ -634,7 +747,6 @@ const struct appinfo *appinfo_find(struct appinfomgr *cf, const char *filename)
 {
        if (!cf || !filename || !*filename) {
                errno = EINVAL;
-               _E("appinfo find: %s", strerror(errno));
                return NULL;
        }
 
@@ -647,7 +759,7 @@ const char *appinfo_get_value(const struct appinfo *c, enum appinfo_type type)
 
        if (!c) {
                errno = EINVAL;
-               _E("appinfo get value: %s", strerror(errno));
+               _E("appinfo get value: %s, %d", strerror(errno), type);
                return NULL;
        }
 
index 19d6ece..77bf6e6 100755 (executable)
@@ -20,9 +20,29 @@ enum appinfo_type {
        AIT_INDICATOR_DISP,
        AIT_EFFECTIMAGEPORT,
        AIT_EFFECTIMAGELAND,
+#ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
+       AIT_EFFECTTYPE,
+#endif
        AIT_STATUS,
+#ifdef _APPFW_FEATURE_PROCESS_POOL
        AIT_POOL,
+#endif
        AIT_COMPTYPE,
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+       AIT_MULTI_INSTANCE,
+       AIT_MULTI_INSTANCE_MAINID,
+       AIT_TOGGLE_ORDER,
+#endif
+#ifdef _APPFW_FEATURE_MULTI_WINDOW
+       AIT_MULTI_WINDOW,
+#endif
+#ifdef _APPFW_FEATURE_TTS_MODE
+       AIT_TTS,
+#endif
+#ifdef _APPFW_FEATURE_ULTRA_POWER_SAVING_MODE
+       AIT_UPS,
+#endif
+       AIT_MAX
 };
 
 int appinfo_init(struct appinfomgr **cf);
index 65fdee4..a64fe45 100755 (executable)
 #include <glib.h>
 
 #include "amd_config.h"
+#include "amd_key.h"
 #include "simple_util.h"
 #include "app_sock.h"
 #include "launch.h"
 
 static struct {
-       Evas_Object *win;
+       Ecore_X_Window win;
        Ecore_Event_Handler *key_up;
        Ecore_Event_Handler *key_down;
 } key_info = {
@@ -70,7 +71,7 @@ static Eina_Bool __key_release_cb(void *data, int type, void *event)
                bundle_add(kb, AUL_K_MULTI_KEY, ev->keyname);
                bundle_add(kb, AUL_K_MULTI_KEY_EVENT, AUL_V_KEY_RELEASED);
 
-               ret = app_send_cmd(*pid_data, APP_KEY_EVENT, kb);
+               ret = app_send_cmd_with_noreply(*pid_data, APP_KEY_EVENT, kb);
                if (ret < 0)
                        _E("app_send_cmd failed with error %d\n", ret);
 
@@ -104,7 +105,7 @@ static Eina_Bool __key_press_cb(void *data, int type, void *event)
                bundle_add(kb, AUL_K_MULTI_KEY, ev->keyname);
                bundle_add(kb, AUL_K_MULTI_KEY_EVENT, AUL_V_KEY_PRESSED);
 
-               ret = app_send_cmd(*pid_data, APP_KEY_EVENT, kb);
+               ret = app_send_cmd_with_noreply(*pid_data, APP_KEY_EVENT, kb);
                if (ret < 0)
                        _E("app_send_cmd failed with error %d\n", ret);
 
@@ -164,17 +165,26 @@ int _unregister_key_event(int pid)
        return 0;
 }
 
+Ecore_X_Window _input_window_get()
+{
+       return key_info.win;
+}
+
 int _key_init()
 {
-       key_info.win = ecore_x_window_input_new(0, 0, 0, 1, 1);
+       key_info.win = ecore_x_window_input_new(ecore_x_window_root_first_get(), 0, 0, 1, 1);
        if (!key_info.win) {
                _D("Failed to create hidden window");
        }
 
+       _D("_key_init, win : %x", key_info.win);
+
        ecore_x_icccm_title_set(key_info.win, "acdaemon,key,receiver");
        ecore_x_netwm_name_set(key_info.win, "acdaemon,key,receiver");
        ecore_x_netwm_pid_set(key_info.win, getpid());
 
+       ecore_x_window_show(key_info.win);
+
        utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_PLAYCD, SHARED_GRAB);
        utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_STOPCD, SHARED_GRAB);
        utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_PAUSECD, SHARED_GRAB);
index bcf8d2e..bee999e 100755 (executable)
 #ifndef __AUL_AMD_KEY_H_
 #define __AUL_AMD_KEY_H_
 
+#include <Ecore_X.h>
+
 int _key_init(void);
 int _register_key_event(int pid);
 int _unregister_key_event(int pid);
+Ecore_X_Window _input_window_get(void);
 
 #endif
 
index 2e3802d..5489773 100755 (executable)
@@ -30,6 +30,9 @@
 #include <bundle.h>
 #include <aul.h>
 #include <glib.h>
+#ifdef _APPFW_FEATURE_APP_CHECKER
+#include <app-checker-server.h>
+#endif
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/prctl.h>
+#include <sys/resource.h>
 #include <pkgmgr-info.h>
 #include <vconf.h>
-#ifdef WEARABLE_PROFILE
 #include <proc_stat.h>
-#endif
 #include <poll.h>
-#include <privacy_manager_client.h>
 
 #include "amd_config.h"
 #include "amd_launch.h"
 #include "amd_appinfo.h"
 #include "amd_status.h"
+#include "amd_key.h"
 #include "app_sock.h"
 #include "simple_util.h"
 #include "amd_cgutil.h"
@@ -60,9 +62,6 @@
 
 #include "access_control.h"
 
-#ifdef WEARABLE_PROFILE
-#include "dd-display.h"
-#endif
 
 #define TERM_WAIT_SEC 3
 #define INIT_PID 1
 #define HIDE_INDICATOR 0
 #define SHOW_INDICATOR 1
 
+#ifdef _APPFW_FEATURE_CPU_BOOST
+#define APP_BOOSTING_PERIOD 1500 //msec
+#endif
+
+static char *amd_cmdline;
+
 struct appinfomgr *_laf;
 struct cginfo *_lcg;
 
 DBusConnection *conn;
+guint grab_timer_id;
+
 
 #if 0
 /*Unused data structure. Will be removed*/
@@ -113,9 +120,11 @@ struct ktimer {
 static const char *atom_name = "_E_COMP_FAKE_LAUNCH_IMAGE"; // Atomic ID string
 static Ecore_X_Atom ATOM_IMAGE_EFFECT; //Atomic ID
 static void __amd_effect_image_file_set(char *image_file);
-static void __amd_send_message_to_e17(int screenmode, const char * indicator);
+static void __amd_send_message_to_e17(int screenmode, const char * indicator, int effect_type, int theme);
 static int __amd_change_min_cpulock_count(int value);
 static Eina_Bool __amd_restore_min_cpulock_count_cb(void *data);
+static void __set_reply_handler(int fd, int pid, int clifd, int cmd);
+static void __real_send(int clifd, int ret);
 
 static void _set_sdk_env(const char* appid, char* str) {
        char buf[MAX_LOCAL_BUFSZ];
@@ -198,7 +207,7 @@ static void _prepare_exec(const char *appid, bundle *kb)
 
        /* SET PRIVILEGES*/
         _D("appid : %s / pkg_type : %s / app_path : %s ", appid, pkg_type, app_path);
-       if ((ret = __set_access(appid, pkg_type, app_path)) < 0) {
+       if (strncmp(pkg_type, "wgt", 3) !=0 && (ret = __set_access(appid, pkg_type, app_path)) < 0) {
                 _D("fail to set privileges - check your package's credential : %d\n", ret);
                return;
        }
@@ -222,9 +231,6 @@ static void _prepare_exec(const char *appid, bundle *kb)
 
        /* SET ENVIROMENT*/
        _set_env(appid, kb, hwacc);
-
-       /* TODO: do security job */
-       /* TODO: setuid */
 }
 
 static int _add_cgroup(struct cginfo *cg, const char *group, int pid)
@@ -296,6 +302,121 @@ static void _do_exec(struct cginfo *cg, const char *cmd, const char *group, bund
        g_strfreev(argv);
 }
 
+static inline int __send_app_launch_signal(int launch_pid)
+{
+       DBusMessage *message;
+
+       if (conn == NULL)
+               return -1;
+
+       message = dbus_message_new_signal(AUL_DBUS_PATH,
+                                         AUL_DBUS_SIGNAL_INTERFACE,
+                                         AUL_DBUS_APPLAUNCH_SIGNAL);
+
+       if (dbus_message_append_args(message,
+                                    DBUS_TYPE_UINT32, &launch_pid,
+                                    DBUS_TYPE_INVALID) == FALSE) {
+               _E("Failed to load data error");
+               return -1;
+       }
+
+       if (dbus_connection_send(conn, message, NULL) == FALSE) {
+               _E("dbus send error");
+               return -1;
+       }
+
+       dbus_connection_flush(conn);
+       dbus_message_unref(message);
+
+       _D("send launch signal done\n");
+
+       return 0;
+}
+
+static int __send_watchdog_signal(int pid, int signal_num)
+{
+       DBusMessage *message;
+
+       if (conn == NULL)
+               return -1;
+
+       if (!_get_platform_ready()) {
+               _E("[Info]_get_platform_ready return false");
+               return -1;
+       }
+
+       if(_status_get_cooldown_status() == COOLDOWN_LIMIT) {
+               _E("[Info]cooldown status : LimitAction");
+               return -1;
+       }
+
+       message = dbus_message_new_signal(RESOURCED_PROC_OBJECT,
+                                         RESOURCED_PROC_INTERFACE,
+                                         RESOURCED_PROC_WATCHDOG_SIGNAL);
+
+       if (dbus_message_append_args(message,
+                                    DBUS_TYPE_INT32, &pid,
+                                    DBUS_TYPE_INT32, &signal_num,
+                                    DBUS_TYPE_INVALID) == FALSE) {
+               _E("Failed to load data error");
+               return -1;
+       }
+
+       if (dbus_connection_send(conn, message, NULL) == FALSE) {
+               _E("dbus send error");
+               return -1;
+       }
+
+       dbus_connection_flush(conn);
+       dbus_message_unref(message);
+
+       _D("send launch signal done\n");
+
+       return 0;
+}
+
+static int __check_cmdline(int ret)
+{
+       char *cmdline;
+       int wait_count;
+       int cmdline_changed = 0;
+       int cmdline_exist = 0;
+       int r;
+
+       if (ret <= 1)
+               return -1;
+
+       /* check normally was launched?*/
+       wait_count = 1;
+       do {
+               cmdline = __proc_get_cmdline_bypid(ret);
+               if (cmdline == NULL) {
+                       _E("error founded when being launched with %d", ret);
+
+               } else if (strcmp(cmdline, amd_cmdline)) {
+                       free(cmdline);
+                       cmdline_changed = 1;
+                       break;
+               } else {
+                       cmdline_exist = 1;
+                       free(cmdline);
+               }
+
+               _D("-- now wait to change cmdline --");
+               usleep(50 * 1000);      /* 50ms sleep*/
+               wait_count++;
+       } while (wait_count <= 20);     /* max 50*20ms will be sleep*/
+
+       if ((!cmdline_exist) && (!cmdline_changed)) {
+               return -1;
+       }
+
+       if (!cmdline_changed)
+               _E("process launched, but cmdline not changed");
+
+       return ret;
+}
+
 int service_start(struct cginfo *cg, const char *group, const char *cmd, bundle *kb)
 {
        int r;
@@ -311,6 +432,14 @@ int service_start(struct cginfo *cg, const char *group, const char *cmd, bundle
        switch (p) {
        case 0: /* child process */
                _D("start service");
+#ifdef _APPFW_FEATURE_PRIORITY_CHANGE
+               r = setpriority(PRIO_PROCESS, 0, 0);
+               if (r == -1)
+               {
+                       SECURE_LOGE("Setting process (%d) priority to 0 failed, errno: %d (%s)",
+                                       getpid(), errno, strerror(errno));
+               }
+#endif
                _do_exec(cg, cmd, group, kb);
                /* exec error */
 
@@ -322,7 +451,9 @@ int service_start(struct cginfo *cg, const char *group, const char *cmd, bundle
                break;
        default: /* parent process */
                _D("child process: %d", p);
-               r = p;
+               r = __check_cmdline(p);
+               if(r > 0)
+                       __send_app_launch_signal(r);
                break;
        }
 
@@ -334,6 +465,7 @@ int _start_srv(const struct appinfo *ai, bundle *kb)
        int r;
        const char *group;
        const char *cmd;
+       const char *pkgid;
 
        group = appinfo_get_filename(ai);
 
@@ -349,6 +481,10 @@ int _start_srv(const struct appinfo *ai, bundle *kb)
                return -1;
        }
 
+       pkgid = appinfo_get_value(ai, AIT_PKGID);
+       proc_cgroup_launch(PROC_CGROUP_SET_SERVICE_REQUEST, r, group, pkgid);
+       _status_add_app_info_list(group, cmd, NULL, r, -1);
+
        return 0;
 }
 
@@ -461,6 +597,8 @@ int service_stop(struct cginfo *cg, const char *group)
                return -1;
        }
 
+       _D("service_stop, group %s", group);
+
        return cgutil_group_foreach_pid(cg, CTRL_MGR, FILENAME(group),
                        _kill_pid_cb, cg);
 }
@@ -483,6 +621,8 @@ void service_release(const char *group)
 
                if (k->group && !strcmp(k->group, group))
                        d = l;
+               else
+                       d = NULL;
        }
 
        _del_list(d);
@@ -501,7 +641,7 @@ int _send_to_sigkill(int pid)
 
        return 0;
 }
-int _resume_app(int pid)
+int _resume_app(int pid, int clifd)
 {
        int dummy;
        int ret;
@@ -516,21 +656,32 @@ int _resume_app(int pid)
                        _send_to_sigkill(pid);
                        ret = -1;
                }
+               __real_send(clifd, ret);
        }
        _D("resume done\n");
+
+       if (ret > 0)
+               __set_reply_handler(ret, pid, clifd, APP_RESUME_BY_PID);
+
        return ret;
 }
 
-int _fake_launch_app(int cmd, int pid, bundle * kb)
+int _fake_launch_app(int cmd, int pid, bundle * kb, int clifd)
 {
        int datalen;
        int ret;
        bundle_raw *kb_data;
 
        bundle_encode(kb, &kb_data, &datalen);
-       if ((ret = __app_send_raw_with_delay_reply(pid, cmd, kb_data, datalen)) < 0)
+       if ((ret = __app_send_raw_with_delay_reply(pid, cmd, kb_data, datalen)) < 0) {
                _E("error request fake launch - error code = %d", ret);
+               __real_send(clifd, ret);
+       }
        free(kb_data);
+
+       if (ret > 0)
+               __set_reply_handler(ret, pid, clifd, cmd);
+
        return ret;
 }
 
@@ -650,13 +801,25 @@ static gboolean __recv_timeout_handler(gpointer data)
 
        close(fd);
 
-       if( r_info->cmd == APP_TERM_BY_PID ) {
+       switch (r_info->cmd) {
+       case APP_OPEN:
+       case APP_RESUME:
+       case APP_START:
+       case APP_START_RES:
+       case APP_START_ASYNC:
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+       case APP_START_MULTI_INSTANCE:
+#endif
+               __send_watchdog_signal(r_info->pid, SIGKILL);
+               break;
+       case APP_TERM_BY_PID:
                if (_send_to_sigkill(r_info->pid) < 0) {
                        _E("fail to killing - %d\n", r_info->pid);
                        __real_send(r_info->clifd, -1);
                        return -1;
                }
                __real_send(r_info->clifd, 0);
+               break;
        }
 
        g_source_remove_poll(r_info->src, r_info->gpollfd);
@@ -667,15 +830,41 @@ static gboolean __recv_timeout_handler(gpointer data)
        return FALSE;
 }
 
-_term_app(int pid, int clifd)
+static void __set_reply_handler(int fd, int pid, int clifd, int cmd)
 {
-       int dummy;
-       int ret;
-       int r;
        GPollFD *gpollfd;
        GSource *src;
        struct reply_info *r_info;
 
+       src = g_source_new(&funcs, sizeof(GSource));
+
+       gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+       gpollfd->events = POLLIN;
+       gpollfd->fd = fd;
+
+       r_info = malloc(sizeof(*r_info));
+       r_info->clifd = clifd;
+       r_info->pid = pid;
+       r_info->src = src;
+       r_info->gpollfd = gpollfd;
+       r_info->cmd = cmd;
+
+
+       r_info->timer_id = g_timeout_add(5000, __recv_timeout_handler, (gpointer) r_info);
+       g_source_add_poll(src, gpollfd);
+       g_source_set_callback(src, (GSourceFunc) __reply_handler,
+                       (gpointer) r_info, NULL);
+       g_source_set_priority(src, G_PRIORITY_DEFAULT);
+       g_source_attach(src, NULL);
+
+       _D("listen fd : %d, send fd : %d", fd, clifd);
+}
+
+int _term_app(int pid, int clifd)
+{
+       int dummy;
+       int ret;
+
        if ( (ret = __app_send_raw_with_delay_reply
            (pid, APP_TERM_BY_PID, (unsigned char *)&dummy, sizeof(int))) < 0) {
                _D("terminate packet send error - use SIGKILL");
@@ -687,60 +876,128 @@ _term_app(int pid, int clifd)
                __real_send(clifd, 0);
        }
        _D("term done\n");
-       if(ret > 0) {
-               src = g_source_new(&funcs, sizeof(GSource));
+       if (ret > 0)
+               __set_reply_handler(ret, pid, clifd, APP_TERM_BY_PID);
+
+       return 0;
+}
 
-               gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
-               gpollfd->events = POLLIN;
-               gpollfd->fd = ret;
+#include <dirent.h>
+#include <sqlite3.h>
+static int __launchpad_update_task_managed_field(const char* app_id, int task_managed)
+{
+       sqlite3 *db = NULL;
+       char *sqlite3_error_msg = NULL;
 
-               r_info = malloc(sizeof(*r_info));
-               r_info->clifd = clifd;
-               r_info->pid = pid;
-               r_info->src = src;
-               r_info->gpollfd = gpollfd;
-               r_info->cmd = APP_TERM_BY_PID;
+       if (sqlite3_open("/opt/dbspace/.pkgmgr_parser.db", &db) != SQLITE_OK) {
+           _E("sqlite3_open() failed! -> %s\n", sqlite3_errmsg(db));
+           return -1;
+       }
 
-               _D("listen fd : %d, send fd : %d", ret, clifd);
+       if (sqlite3_exec(db, "PRAGMA journal_mode = PERSIST", NULL, NULL, &sqlite3_error_msg) != SQLITE_OK) {
+           _E("sqlite3_exec(\"PRAGMA journal_mode = PERSIST\") failed! -> %s", sqlite3_error_msg);
+           sqlite3_free(sqlite3_error_msg);
+           sqlite3_close(db);
+           return -1;
+       }
 
-               r_info->timer_id = g_timeout_add(5000, __recv_timeout_handler, (gpointer) r_info);
-               g_source_add_poll(src, gpollfd);
-               g_source_set_callback(src, (GSourceFunc) __reply_handler,
-                               (gpointer) r_info, NULL);
-               g_source_set_priority(src, G_PRIORITY_DEFAULT);
-               r = g_source_attach(src, NULL);
+       if (sqlite3_exec(db, "BEGIN EXCLUSIVE", NULL, NULL, &sqlite3_error_msg) != SQLITE_OK) {
+               _E("sqlite3_exec(\"BEGIN EXCLUSIVE\") failed! -> %s", sqlite3_error_msg);
+           sqlite3_free(sqlite3_error_msg);
+               sqlite3_close(db);
+               return -1;
        }
-       return 0;
+
+       char query[1024] = {0, };
+       snprintf(query, 1024,"update package_app_info set app_taskmanage='%s' where app_id='%s'",
+               task_managed ? "true" : "false", app_id);
+
+       if (sqlite3_exec(db, query, NULL, NULL, &sqlite3_error_msg) != SQLITE_OK) {
+               _E("sqlite3_exec(\"%s\") failed! -> %s", query, sqlite3_error_msg);
+               sqlite3_free(sqlite3_error_msg);
+               return -1;
+       }
+
+       if (sqlite3_exec(db, "COMMIT", NULL, NULL, NULL) != SQLITE_OK) {
+               _E("sqlite3_exec(\"COMMIT\") failed!");
+               if (sqlite3_exec(db, "ROLLBACK", NULL, NULL, NULL) != SQLITE_OK) {
+                       _E("sqlite3_exec(\"ROLLBACK\") failed!");
+               }
+               sqlite3_close(db);
+               return -1;
+       }
+
+       sqlite3_close(db);
+
+return 0;
+}
+
+static void __pre_launching_processing(const char* app_id)
+{
+    const char* const PRE_LAUNCHING_LIST_DIR = "/opt/usr/etc/wrt_launchpad_daemon/pre_launching_list";
+
+    struct stat file_status;
+    if (stat(PRE_LAUNCHING_LIST_DIR, &file_status) == 0) {
+        if (S_ISDIR(file_status.st_mode)) {
+            int ret;
+            DIR *dir = NULL;
+            struct dirent entry, *result;
+
+            dir = opendir(PRE_LAUNCHING_LIST_DIR);
+
+            if (dir) {
+                for (ret = readdir_r(dir, &entry, &result);
+                     result != NULL && ret == 0;
+                     ret = readdir_r(dir, &entry, &result)) {
+                    if (strncmp(entry.d_name, ".", 2) == 0 ||
+                        strncmp(entry.d_name, "..", 3) == 0) {
+                        continue;
+                    }
+
+                    if (strcmp(entry.d_name, app_id) == 0)
+                    {
+                        __launchpad_update_task_managed_field(app_id, 1);
+                    }
+                }
+
+                closedir(dir);
+            }
+            else {
+                _E("opendir(\"%s\") failed!", PRE_LAUNCHING_LIST_DIR);
+            }
+        }
+    }
 }
 
 static int __nofork_processing(int cmd, int pid, bundle * kb, int clifd)
 {
        int ret = -1;
        int r;
-       GPollFD *gpollfd;
-       GSource *src;
-       struct reply_info *r_info;
        const char *operation;
 
        operation = bundle_get_val(kb, "__APP_SVC_OP_TYPE__");
 
-       if ( cmd == APP_OPEN ||
-               (operation != NULL && strncmp(operation, "http://tizen.org/appcontrol/operation/main", 512) == 0)){
+#ifdef _APPFW_FEATURE_CPU_BOOST
+       //TODO: CPU boosting for relaunching will be removed.
+       //Home screen requests CPU boosting on launching or relaunching during 200 msec.
+       if (cmd == APP_OPEN ||
+                       (operation != NULL && strncmp(operation, "http://tizen.org/appcontrol/operation/main", 512) == 0)) {
                char *arr[2];
                char val[32];
-               snprintf(val, sizeof(val), "%d", 800);
+               snprintf(val, sizeof(val), "%d", APP_BOOSTING_PERIOD);
                arr[0] = val;
                arr[1] = NULL;
                ret = invoke_dbus_method_sync(SYSTEM_BUS_NAME, SYSTEM_OBJECT_PATH,
-                                                               SYSTEM_INTERFACE_NAME, SYSTEM_METHOD_NAME, "i", arr);
+                               SYSTEM_INTERFACE_NAME, SYSTEM_METHOD_NAME, "i", arr);
                _D("%s-%s : %d", SYSTEM_INTERFACE_NAME, SYSTEM_METHOD_NAME, ret);
        }
-
+#endif
+       _D("__nofork_processing, cmd: %d, pid: %d", cmd, pid);
        switch (cmd) {
        case APP_OPEN:
        case APP_RESUME:
                _D("resume app's pid : %d\n", pid);
-               if ((ret = _resume_app(pid)) < 0)
+               if ((ret = _resume_app(pid, clifd)) < 0)
                        _E("__resume_app failed. error code = %d", ret);
                _D("resume app done");
                break;
@@ -748,37 +1005,16 @@ static int __nofork_processing(int cmd, int pid, bundle * kb, int clifd)
        case APP_START:
        case APP_START_RES:
        case APP_START_ASYNC:
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+       case APP_START_MULTI_INSTANCE:
+#endif
                _D("fake launch pid : %d\n", pid);
-               if ((ret = _fake_launch_app(cmd, pid, kb)) < 0)
+               if ((ret = _fake_launch_app(cmd, pid, kb, clifd)) < 0)
                        _E("fake_launch failed. error code = %d", ret);
                _D("fake launch done");
                break;
        }
 
-       if(ret > 0) {
-               src = g_source_new(&funcs, sizeof(GSource));
-
-               gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
-               gpollfd->events = POLLIN;
-               gpollfd->fd = ret;
-
-               r_info = malloc(sizeof(*r_info));
-               r_info->clifd = clifd;
-               r_info->pid = pid;
-               r_info->src = src;
-               r_info->gpollfd = gpollfd;
-               r_info->cmd = cmd;
-
-               _D("listen fd : %d, send fd : %d", ret, clifd);
-
-               r_info->timer_id = g_timeout_add(5200, __recv_timeout_handler, (gpointer) r_info);
-               g_source_add_poll(src, gpollfd);
-               g_source_set_callback(src, (GSourceFunc) __reply_handler,
-                               (gpointer) r_info, NULL);
-               g_source_set_priority(src, G_PRIORITY_DEFAULT);
-               r = g_source_attach(src, NULL);
-       }
-
        return ret;
 }
 
@@ -835,33 +1071,36 @@ static void __amd_effect_image_file_set(char *image_file)
 {
        Ecore_X_Window root_win;
        root_win = ecore_x_window_root_first_get();
+       SECURE_LOGD("path : %s", image_file);
        ecore_x_window_prop_string_set(root_win, ATOM_IMAGE_EFFECT,image_file);
 }
 
 
-static void __amd_send_message_to_e17(int screenmode, const char * indicator)
+static void __amd_send_message_to_e17(int screenmode, const char * indicator, int effect_type, int theme)
 {
        Ecore_X_Window root_win;
        int ret;
        root_win = ecore_x_window_root_first_get();
         _D("root win : %x",root_win);
-       int screen_orientation[5]={0,270,0,180,90};
+       int screen_orientation[5]={0,0,270,180,90};
        if (screenmode > 4 || screenmode < 0)
                screenmode=0;
 
        if (strncmp(indicator, "true", 4) == 0){
-               _D("[LAUNCHING EFFECT]: screen mode is %d, indicator show\n", screen_orientation[screenmode] );
+               _D("[LAUNCHING EFFECT]: screen mode(%d), effect type(%d), theme(%d), indicator show",
+                       screen_orientation[screenmode], effect_type, theme);
                ret = ecore_x_client_message32_send (root_win, ATOM_IMAGE_EFFECT,
-                       ECORE_X_EVENT_MASK_WINDOW_PROPERTY, 1,
+                       ECORE_X_EVENT_MASK_WINDOW_PROPERTY, effect_type,
                        screen_orientation[screenmode],
-                       SHOW_INDICATOR, 0, 0);
+                       SHOW_INDICATOR, theme, 0);
 
        }else{
-               _D("[LAUNCHING EFFECT]: screen mode is %d, indicator hide\n", screen_orientation[screenmode] );
+               _D("[LAUNCHING EFFECT]: screen mode(%d), effect type(%d), theme(%d), indicator show",
+                       screen_orientation[screenmode], effect_type, theme);
                ret = ecore_x_client_message32_send (root_win, ATOM_IMAGE_EFFECT,
-                       ECORE_X_EVENT_MASK_WINDOW_PROPERTY, 1,
+                       ECORE_X_EVENT_MASK_WINDOW_PROPERTY, effect_type,
                        screen_orientation[screenmode],
-                       HIDE_INDICATOR, 0, 0);
+                       HIDE_INDICATOR, theme, 0);
        }
        ecore_x_flush();
        _D("ecore_x_client_message32_send : %d",ret);
@@ -920,12 +1159,14 @@ int invoke_dbus_method_sync(const char *dest, const char *path,
                return -EBADMSG;
        }
 
-       dbus_message_iter_init_append(msg, &iter);
-       r = append_variant(&iter, sig, param);
-       if (r < 0) {
-               _E("append_variant error(%d)", r);
-               dbus_message_unref(msg);
-               return -EBADMSG;
+       if( param ) {
+               dbus_message_iter_init_append(msg, &iter);
+               r = append_variant(&iter, sig, param);
+               if (r < 0) {
+                       _E("append_variant error(%d)", r);
+                       dbus_message_unref(msg);
+                       return -EBADMSG;
+               }
        }
 
        dbus_error_init(&err);
@@ -949,9 +1190,225 @@ int invoke_dbus_method_sync(const char *dest, const char *path,
        return ret;
 }
 
+static gboolean __grab_timeout_handler(gpointer data)
+{
+       int pid = (int) data;
+
+       if(_input_window_get() != 0)
+               ecore_x_pointer_ungrab();
+       _D("pid(%d) ecore_x_pointer_ungrab", pid);
+
+       return FALSE;
+}
+
+static bool __check_ug_client_process_pool(const char *app_path)
+{
+       char sympath[MAX_PACKAGE_APP_PATH_SIZE] = {0,};
+       int ret;
+       bool func_ret = true;
+
+       if(!app_path) {
+               _E("invalid input param");
+               func_ret = false;
+               goto func_out;
+       }
+
+       if(strncmp(app_path, "/usr/ug/bin/", strlen("/usr/ug/bin")) != 0) {
+               func_ret = false;
+               goto func_out;
+       }
+
+       if(readlink(app_path, sympath, MAX_PACKAGE_APP_PATH_SIZE-1) == -1) {
+               _E("read app path link error(%d)", errno);
+               func_ret = false;
+               goto func_out;
+       }
+
+       if(strncmp(sympath, "/usr/bin/ug-client", strlen("/usr/bin/ug-client")) != 0) {
+               func_ret = false;
+       }
+
+func_out :
+       _D("ug process pool check result : %d", func_ret);
+       return func_ret;
+}
+
+#ifdef _APPFW_FEATURE_MULTI_WINDOW
+static void __add_multi_window_info(bundle* kb, const struct appinfo *ai, const char* callee_appid, const char* caller_appid)
+{
+       const struct appinfo *caller_ai;
+       const struct appinfo *callee_ai;
+       unsigned int layout = -1; // 0 : top of split window / 1 : bottom of split window
+       const char *caller = NULL;
+       Ecore_X_Window caller_win_id = 0;
+       const char *bundle_layout = NULL;
+       int is_open_via_multi = 0;
+       int startup_type = 2; //2 means callee will be displayed as split view
+       const char *caller_ai_multi_window = NULL;
+       const char *callee_ai_multi_window = NULL;
+       int ret = 0;
+       int multiwindow_enabled = 0;
+
+       /* check multi window is enabled or not */
+       ret = vconf_get_bool(VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED, &multiwindow_enabled);
+       if((ret != VCONF_OK) || (multiwindow_enabled == 0)) {
+               _D("multiwindow is disabled");
+               return;
+       }
+
+       SECURE_LOGD("callee appid : %s / caller_appid : %s", callee_appid, caller_appid);
+
+       /* check whether caller & callee ui app support multi window or not */
+       caller_ai = appinfo_find(_laf, caller_appid);
+       if(caller_ai == NULL) {
+               _D("no caller appinfo");
+               return;
+       }
+       caller_ai_multi_window = appinfo_get_value(caller_ai, AIT_MULTI_WINDOW);
+       if((caller_ai_multi_window == NULL) || (strcmp(caller_ai_multi_window, "true") != 0)) {
+               _D("caller app does not support multi window");
+               return;
+       }
+       callee_ai = appinfo_find(_laf, callee_appid);
+       if(callee_ai == NULL) {
+               _D("no callee appinfo");
+               return;
+       }
+       callee_ai_multi_window = appinfo_get_value(callee_ai, AIT_MULTI_WINDOW);
+       if((callee_ai_multi_window == NULL) || (strcmp(callee_ai_multi_window, "true") != 0)) {
+               _D("callee app does not support multi window");
+               return;
+       }
+
+       /* check aul_forwad_app case */
+       if((caller_appid) && (strcmp(caller_appid, "org.tizen.app-selector") == 0)) {
+               _D("forward app case");
+               return;
+       }
+
+       /* get multi window layout value */
+       caller = bundle_get_val(kb, "__APP_SVC_K_WIN_ID__");
+       if(caller) {
+               caller_win_id = atoi(caller);
+       } else {
+               _D("caller win id is null");
+               return;
+       }
+       if(caller_win_id == 0) {
+               _D("caller id is 0");
+               return;
+       }
+
+       if( ecore_x_window_prop_card32_get(caller_win_id,
+               ECORE_X_ATOM_E_WINDOW_DESKTOP_LAYOUT, &layout, 1 ) != -1 )
+       {
+               if(layout == 0 || layout == 1) {
+                       _D("layout : %d", layout);
+               } else {
+                       _W("x_window__prop_get layout value error : %d", layout);
+                       return;
+               }
+       } else {
+               layout = -1;
+       }
+
+       do {
+               const char *operation = NULL;
+               operation = bundle_get_val(kb, "__APP_SVC_OP_TYPE__");
+               if(operation == NULL) {
+                       _D("operation is null");
+                       break;
+               }
+
+               if(strcmp(operation,"http://tizen.org/appcontrol/operation/view") == 0) {
+                       int open_via_multi = 0;
+                       ret = vconf_get_bool(VCONFKEY_SETAPPL_OPEN_VIA_MULTI, &open_via_multi);
+                       _D("open_via_multi : %d", open_via_multi);
+                       if((ret == VCONF_OK) && (open_via_multi == 1)) {
+                               is_open_via_multi = 1;
+                               /* callee window should not be transient for caller window under "open in multi window" mode */
+                               if(caller) {
+                                       if(bundle_del(kb, "__APP_SVC_K_WIN_ID__") == -1) {
+                                               _D("failed to remove window id of bundle (errno : %d)", errno);
+                                       }
+                               }
+                               break;
+                       }
+               }
+       } while (0);
+
+       if(is_open_via_multi) {
+               if(layout == 1)
+                       layout = 0;
+               else
+                       layout = 1;
+
+               _D("open via multi scenario. reverted layout id is %d", layout);
+       } else {
+               /* multi window support app need be launched with full view
+               when app is launched from multi window support app with full view. */
+               if(layout == -1) {
+                       startup_type = 0;
+               }
+       }
+
+       char tmp_layout[128];
+       char tmp_startup[128];
+
+       snprintf(tmp_layout, 128, "%d", layout);
+       snprintf(tmp_startup, 128, "%d", startup_type);
+
+       if(bundle_add(kb, "window_layout_id", tmp_layout) != 0) {
+               _W("winow layout id bundle add error");
+       }
+       if(bundle_add(kb, "window_startup_type", tmp_startup) != 0) {
+               _W("winow startup type bundle add error");
+       }
+
+       SECURE_LOGD("window startup type(%d) and layout id(%d) is added", startup_type, layout);
+
+       return;
+}
+#endif
+
+int __check_mode(const struct appinfo *ai)
+{
+#ifdef _APPFW_FEATURE_TTS_MODE
+       int tts_mode = 0;
+       const char *tts_support = NULL;
+#endif
+#ifdef _APPFW_FEATURE_ULTRA_POWER_SAVING_MODE
+       int ups_mode = 0;
+       const char *ups_support = NULL;
+#endif
+
+#ifdef _APPFW_FEATURE_TTS_MODE
+       vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &tts_mode);
+       if(tts_mode) {
+               tts_support = appinfo_get_value(ai, AIT_TTS);
+               _D("tts : %d %s", tts_mode, tts_support);
+               if(strncmp(tts_support, "false", 5) == 0)
+                       return -1;
+       }
+#endif
+
+#ifdef _APPFW_FEATURE_ULTRA_POWER_SAVING_MODE
+       vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &ups_mode);
+       if(ups_mode == SETTING_PSMODE_WEARABLE) {
+               ups_support = appinfo_get_value(ai, AIT_UPS);
+               _D("ups : %d %s", ups_mode, ups_support);
+               if(strncmp(ups_support, "false", 5) == 0)
+                       return -1;
+       }
+#endif
+
+       return 0;
+}
+
 int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_uid, int fd)
 {
        const struct appinfo *ai;
+       const struct appinfo *caller_ai;
        int ret = -1;
        const char *multiple = NULL;
        const char *app_path = NULL;
@@ -959,27 +1416,36 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
        const char *component_type = NULL;
        int pid = -1;
        char tmp_pid[MAX_PID_STR_BUFSZ];
-       const char *hwacc;
        const char *permission;
        const char *pkgid;
-       const char *taskmanage;
        const char *preload;
        const char *pkg_status;
        const char *operation;
+       const char *fake_effect;
        char caller_appid[256];
        char* caller = NULL;
+       char* curr_caller = NULL;
+       char* old_caller = NULL;
        pkgmgrinfo_cert_compare_result_type_e compare_result;
        int delay_reply = 0;
        int pad_pid = LAUNCHPAD_PID;
        int status = -1;
        int r = -1;
        char trm_buf[MAX_PACKAGE_STR_SIZE];
-       bool consented = true;
 
        int effect_mode = 0;
-#ifdef WEARABLE_PROFILE
+#ifdef _APPFW_FEATURE_WMS_CONNECTION_CHECK
        int wmanager_connected = 0;
 #endif
+       char *caller_component_type = NULL;
+
+       if (appid == NULL || kb == NULL
+               || caller_pid < 0 || caller_uid < 0 || fd < 0) {
+               _D("invalid parameter");
+               if (fd >= 0)
+                       __real_send(fd, -1);
+               return -1;
+       }
 
        snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", caller_pid);
        bundle_add(kb, AUL_K_CALLER_PID, tmp_pid);
@@ -996,20 +1462,29 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
        } else {
                bundle_add(kb, AUL_K_CALLER_APPID, caller);
        }
-       SECURE_LOGD("caller : %s", bundle_get_val(kb,AUL_K_CALLER_APPID));
-
+       curr_caller = bundle_get_val(kb,AUL_K_CALLER_APPID);
+       SECURE_LOGD("caller : %s", curr_caller);
+
+#ifdef _APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP
+       // Add the appid into bundle to distinguish between Contacts and Phone.
+       if (strncmp(appid, "org.tizen.contacts", strlen("org.tizen.contacts")) == 0
+               || strncmp(appid, "org.tizen.phone", strlen("org.tizen.phone")) == 0)
+       {
+               bundle_add(kb, AUL_K_INTERNAL_APPID, appid);
+               SECURE_LOGD("Add the appid[%s] into bundle to distinguish between Contacts and Phone.", appid);
+       }
+#endif
        ai = appinfo_find(_laf, appid);
-
        if(ai == NULL) {
                _D("no appinfo");
                __real_send(fd, -1);
                return -1;
        } else {
                pkg_status = appinfo_get_value(ai, AIT_STATUS);
-               if(pkg_status && strncmp(pkg_status, "upgrading", 9) == 0 ) {
-                       _D("upgrading");
-                       __real_send(fd, -1);
-                       return -1;
+               if(pkg_status && (strncmp(pkg_status, "blocking", 8) == 0 || strncmp(pkg_status, "restart", 7) == 0) ) {
+                       _D("blocking");
+                       __real_send(fd, -EREJECTED);
+                       return -EREJECTED;
                } else if(pkg_status && strncmp(pkg_status, "unmounted", 9) == 0 ) {
                        _D("unmounted");
                        __real_send(fd, -1);
@@ -1017,53 +1492,105 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                }
        }
 
-       pkgid = appinfo_get_value(ai, AIT_PKGID);
-
-       if(bundle_get_val(kb, AUL_K_PRIVACY_APPID)){
-               bundle_del(kb, AUL_K_PRIVACY_APPID);
-       } else {
-               privacy_manager_client_check_user_consented(pkgid, &consented);
-
-               _D("consented : %d", consented);
-
-               if(consented == false && bundle_get_val(kb, AUL_K_SDK) == NULL) {
-                       _D("appid : %s", appid);
-                       bundle_add(kb, AUL_K_PRIVACY_APPID, appid);
-                       appid = PRIVACY_POPUP;
-                       bundle_del(kb, AUL_K_PKG_NAME);
-                       bundle_add(kb, AUL_K_PKG_NAME, appid);
-                       ai = appinfo_find(_laf, appid);
-               }
-       }
-
        app_path = appinfo_get_value(ai, AIT_EXEC);
        pkg_type = appinfo_get_value(ai, AIT_TYPE);
        permission = appinfo_get_value(ai, AIT_PERM);
        pkgid = appinfo_get_value(ai, AIT_PKGID);
        component_type = appinfo_get_value(ai, AIT_COMPTYPE);
 
+       operation = bundle_get_val(kb, "__APP_SVC_OP_TYPE__");
+       caller_ai = appinfo_find(_laf, curr_caller);
+
        if(permission && strncmp(permission, "signature", 9) == 0 ) {
-               if(caller_uid != 0 && (cmd == APP_START || cmd == APP_START_RES || cmd == APP_START_ASYNC)){
-                       const struct appinfo *caller_ai;
-                       caller_ai = appinfo_find(_laf, caller_appid);
+               if(caller_uid != 0 && (cmd == APP_START
+                                       || cmd == APP_START_RES
+                                       || cmd == APP_START_ASYNC
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+                                       || cmd == APP_START_MULTI_INSTANCE
+#endif
+                                       ))
+               {
                        preload = appinfo_get_value(caller_ai, AIT_PRELOAD);
                        if( preload && strncmp(preload, "true", 4) != 0 ) {
                                pkgmgrinfo_pkginfo_compare_app_cert_info(caller_appid, appid, &compare_result);
                                if(compare_result != PMINFO_CERT_COMPARE_MATCH) {
                                        pid = -EILLEGALACCESS;
-                                       __real_send(fd, pid);
+                                       if(cmd == APP_START_ASYNC)
+                                               close(fd);
+                                       else
+                                               __real_send(fd, pid);
                                        return pid;
                                }
                        }
                }
        }
 
+       if(__check_mode(ai) < 0) {
+               pid = -EREJECTED;
+               if(cmd == APP_START_ASYNC)
+                       close(fd);
+               else
+                       __real_send(fd, pid);
+               return pid;
+       }
+
        pkgmgrinfo_client_request_enable_external_pkg(pkgid);
 
        if (component_type && strncmp(component_type, "uiapp", 5) == 0) {
+
+#ifdef _APPFW_FEATURE_MULTI_WINDOW
+               if((cmd != APP_RESUME) && (cmd != APP_OPEN)) {
+                       __add_multi_window_info(kb, ai, (const char*) appid, (const char*)bundle_get_val(kb,AUL_K_CALLER_APPID));
+               }
+#endif
                multiple = appinfo_get_value(ai, AIT_MULTI);
                if (!multiple || strncmp(multiple, "false", 5) == 0) {
                        pid = _status_app_is_running_v2(appid);
+               } else if (operation != NULL && strncmp(operation, "http://tizen.org/appcontrol/operation/view", 512) == 0){
+                       old_caller = _status_get_caller_by_appid(appid);
+                       if(old_caller && curr_caller) {
+                               if(strncmp(old_caller, curr_caller, MAX_PACKAGE_STR_SIZE) == 0) {
+                                       pid = _status_app_is_running_v2(appid);
+                               }
+                       }
+               }
+
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+               char app_path_link[512] = {0,};
+               const char *caller_app_path = NULL;
+               char caller_app_path_link[512] = {0,};
+
+               caller_app_path = appinfo_get_value(caller_ai, AIT_EXEC);
+
+               SECURE_LOGD("callee path(%s) caller path(%s)", app_path, caller_app_path);
+
+               readlink(app_path, app_path_link, 512);
+               readlink(caller_app_path, caller_app_path_link, 512);
+
+               SECURE_LOGD("callee link(%s) caller link(%s)", app_path_link, caller_app_path_link);
+
+               if(strncmp(app_path_link, "/usr/bin/ug-client", 512) == 0) {
+                       if (strcmp(caller, "org.tizen.app-selector") == 0){
+                               pid = atoi(bundle_get_val(kb,AUL_K_ORG_CALLER_PID));
+                               bundle_add(kb, "__AUL_UG_EXEC__", app_path);
+                               SECURE_LOGD("app_path : %s , ug id(%s)", app_path, bundle_get_val(kb, "__AUL_UG_ID__"));
+                       } else if(strncmp(caller_app_path_link, "/usr/bin/ug-client", 512) == 0) {
+                               __real_send(fd, -EUGLOCAL_LAUNCH);
+                               return -1;
+                       }
+               }
+#endif
+
+               if(curr_caller) {
+                       caller_component_type = appinfo_get_value(caller_ai, AIT_COMPTYPE);
+                       if (caller_component_type && strncmp(caller_component_type, "uiapp", 5) == 0) {
+                               Ecore_X_Window in_win;
+                               in_win = _input_window_get();
+                               if(in_win) {
+                                       ret = ecore_x_pointer_grab(in_win);
+                                       _D("win(%x) ecore_x_pointer_grab(%d)", in_win, ret);
+                               }
+                       }
                }
 
                status = _status_get_app_info_status(pid);
@@ -1072,9 +1599,10 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                                SECURE_LOGD("caller process & callee process is same.[%s:%d]", appid, pid);
                                pid = -ELOCALLAUNCH_ID;
                        } else {
-#ifdef WEARABLE_PROFILE
+                               if(strncmp(pkg_type, "wgt", 3) == 0) {
+                                       __pre_launching_processing(appid);
+                               }
                                proc_group_change_status(PROC_CGROUP_SET_RESUME_REQUEST, pid, appid);
-#endif
                                if ((ret = __nofork_processing(cmd, pid, kb, fd)) < 0) {
                                        pid = ret;
                                } else {
@@ -1087,25 +1615,22 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                                if (r == -1)
                                        _D("send SIGKILL: %s", strerror(errno));
                        }
-                       hwacc = appinfo_get_value(ai, AIT_HWACC);
-                       bundle_add(kb, AUL_K_HWACC, hwacc);
-                       taskmanage = appinfo_get_value(ai, AIT_TASKMANAGE);
-                       bundle_add(kb, AUL_K_TASKMANAGE, taskmanage);
-                       operation = bundle_get_val(kb, "__APP_SVC_OP_TYPE__");
-
-                       if ( cmd == APP_OPEN ||
-                               (operation != NULL && strncmp(operation, "http://tizen.org/appcontrol/operation/main", 512) == 0) ||
-                               (caller != NULL && strcmp(caller, "com.samsung.wnotification2") == 0) ){
+                       fake_effect = bundle_get_val(kb, "__FAKE_EFFECT__");
+
+#ifdef _APPFW_FEATURE_CPU_BOOST
+                       if (cmd == APP_OPEN || operation != NULL ||
+                               (caller != NULL && strcmp(caller, "org.tizen.wnotification2") == 0) ||
+                               (caller != NULL && strcmp(caller, "org.tizen.wnotiboard-popup") == 0)) {
                                char *arr[2];
                                char val[32];
-                               snprintf(val, sizeof(val), "%d", 1200);
+                               snprintf(val, sizeof(val), "%d", APP_BOOSTING_PERIOD);
                                arr[0] = val;
                                arr[1] = NULL;
                                ret = invoke_dbus_method_sync(SYSTEM_BUS_NAME, SYSTEM_OBJECT_PATH,
-                                                               SYSTEM_INTERFACE_NAME, SYSTEM_METHOD_NAME, "i", arr);
+                                               SYSTEM_INTERFACE_NAME, SYSTEM_METHOD_NAME, "i", arr);
                                _D("%s-%s : %d", SYSTEM_INTERFACE_NAME, SYSTEM_METHOD_NAME, ret);
                        }
-
+#endif
                        /*
                         *      effect_mode = 0
                         *              default mode : fake effect off, 1.6 MHZ off
@@ -1118,63 +1643,189 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                         *
                         */
                        vconf_get_int(AMD_EFFECT_IMAGE_ENABLE, &effect_mode);
-#ifdef WEARABLE_PROFILE
+#ifdef _APPFW_FEATURE_WMS_CONNECTION_CHECK
                        vconf_get_bool(VCONFKEY_WMS_WMANAGER_CONNECTED, &wmanager_connected);
+#endif
                        //_D("*******[effect_mode] Mode : %d\n ", effect_mode );
 
-                       if ( ( cmd == APP_OPEN || (operation != NULL && strncmp(operation, "http://tizen.org/appcontrol/operation/main", 512) == 0) )
-                               && (effect_mode == 1 || effect_mode == 2) && wmanager_connected == true){
-#else
-                       if ( ( cmd == APP_OPEN || (operation != NULL && strncmp(operation, "http://tizen.org/appcontrol/operation/main", 512) == 0) )
-                               && (effect_mode == 1 || effect_mode == 2)){
+                       if ( ( cmd == APP_OPEN ||
+                               ( (operation != NULL && strncmp(operation, "http://tizen.org/appcontrol/operation/main", 512) == 0)
+                               && !(fake_effect != NULL && strncmp(fake_effect, "OFF", 3) == 0) )
+                               ) && (effect_mode == 1 || effect_mode == 2)
+#ifdef _APPFW_FEATURE_WMS_CONNECTION_CHECK
+                               && wmanager_connected == true
 #endif
+                               ){
                                char image_filename[256] = {0,};
+                               char xml_filename[256] = {0,};
                                const char *portraitimg = NULL;
+                               const char *landscapeimg = NULL;
+#ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
+                               char *effectimg_type = NULL;
+#endif
                                const char *indicator = NULL;
+                               int screen_mode = 0;
                                bool rotate_allowed = false;
+                               int file_type = 1;
+                               int theme = 0;
 
+                               //vconf_get_int(PHONE_ORIENTATION_MODE, &screen_mode);
+                               screen_mode = invoke_dbus_method_sync(ROTATION_BUS_NAME, ROTATION_OBJECT_PATH,
+                                                               ROTATION_INTERFACE_NAME, ROTATION_METHOD_NAME, "i", NULL);
+                               _D("%s-%s : %d", ROTATION_INTERFACE_NAME, ROTATION_METHOD_NAME, screen_mode);
                                vconf_get_bool(PHONE_ROTATE_LOCK, &rotate_allowed); /*TODO: use vconf_notify_key_changed()*/
                                portraitimg = appinfo_get_value(ai, AIT_EFFECTIMAGEPORT);
+                               landscapeimg = appinfo_get_value(ai, AIT_EFFECTIMAGELAND);
+#ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
+                               effectimg_type = appinfo_get_value(ai, AIT_EFFECTTYPE);
+#endif
                                indicator = appinfo_get_value(ai, AIT_INDICATOR_DISP);
                                /*Currently we assume apps supporting launching effect supports portrait mode*/
-                               if (portraitimg){
-                                       snprintf(image_filename, 255, "%s", portraitimg);
-                                       if (access(image_filename, R_OK) == 0){
-                                               __amd_effect_image_file_set("/usr/share/splash_images/type0_portrait.bmp");
-                                               __amd_send_message_to_e17(0, indicator);
+                               if (indicator && portraitimg) {
+                                       if (rotate_allowed == false) {
+                                               screen_mode = 1;
+                                       }
+                                       if ((screen_mode == 2 || screen_mode == 4) && (rotate_allowed == true)) {
+                                               /*if there is no landscape image, that means app supports only portrait mode.*/
+                                               if (landscapeimg) {
+                                                       snprintf(image_filename, 255, "%s", landscapeimg);
+                                               }
+                                       } else {
+                                               snprintf(image_filename, 255, "%s", portraitimg);
+                                       }
+                                       if (access(image_filename, R_OK) == 0) {
+#ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
+                                               if(strncmp(effectimg_type, "edj-dark", strlen(effectimg_type)) == 0) {
+                                                       file_type = 0;
+                                                       theme = 0;
+                                               } else if (strncmp(effectimg_type, "edj-light", strlen(effectimg_type)) == 0) {
+                                                       file_type = 0;
+                                                       theme = 1;
+                                               } else if (strncmp(effectimg_type, "edj-default", strlen(effectimg_type)) == 0) {
+                                                       file_type = 0;
+                                                       theme = 2;
+                                               } else {
+                                                       file_type = 1;
+                                                       theme = 0;
+                                               }
+
+                                               do {
+                                                       if (file_type == 1)
+                                                               break;
+                                                       r = snprintf(xml_filename, 255, "/usr/apps/%s/shared/res/tables/%s_ChangeableColorInfo.xml", pkgid, pkgid);
+                                                       if (access(xml_filename, R_OK) == 0) {
+                                                               //snprintf(image_filename, 255, "%s:%s", image_filename, xml_filename);
+                                                               strcat(image_filename, ":");
+                                                               strcat(image_filename, xml_filename);
+                                                               break;
+                                                       }
+                                                       r = snprintf(xml_filename, 255, "/opt/usr/apps/%s/shared/res/tables/%s_ChangeableColorInfo.xml", pkgid, pkgid);
+                                                       if (access(xml_filename, R_OK) == 0) {
+                                                               //snprintf(image_filename, 255, "%s:%s", image_filename, xml_filename);
+                                                               strcat(image_filename, ":");
+                                                               strcat(image_filename, xml_filename);
+                                                               break;
+                                                       }
+                                               } while(0);
+#endif
+#ifndef _APPFW_FEATURE_DEFAULT_FAKE_IMAGE
+                                               __amd_effect_image_file_set(image_filename);
+#else
+                                               if(file_type == 1) {
+                                                       __amd_effect_image_file_set("/usr/share/splash_images/type0_portrait.bmp");
+                                               } else {
+                                                       __amd_effect_image_file_set(image_filename);
+                                               }
+#endif
+                                               __amd_send_message_to_e17(screen_mode, indicator, file_type, theme);
                                        }
                                }
                        }
 
-                       bundle_add(kb, AUL_K_EXEC, app_path);
-                       bundle_add(kb, AUL_K_PACKAGETYPE, pkg_type);
-                       if(bundle_get_type(kb, AUL_K_SDK) != BUNDLE_TYPE_NONE) {
+#ifdef _APPFW_FEATURE_DEBUG_LAUNCHPAD
+                       if (bundle_get_type(kb, AUL_K_SDK) != BUNDLE_TYPE_NONE) {
                                pad_pid = DEBUG_LAUNCHPAD_PID;
-                       } else if(strncmp(pkg_type, "wgt", 3) == 0) {
+                       } else if (strncmp(pkg_type, "wgt", 3) == 0) {
                                pad_pid = WEB_LAUNCHPAD_PID;
                        }
-#ifdef PROCESS_POOL_ENABLE
+#else
+                       if (strncmp(pkg_type, "wgt", 3) == 0) {
+                               pad_pid = WEB_LAUNCHPAD_PID;
+                       }
+#endif
+#ifdef _APPFW_FEATURE_NATIVE_LAUNCHPAD
+                       else if (strncmp(pkg_type, "tpk", 3) == 0) {
+                char native_sock[UNIX_PATH_MAX] = { 0, };
+                snprintf(native_sock, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pad_pid);
+                               if (access(native_sock, F_OK) != 0) {
+                                       _D("Sending to native launchpad because native launchpad is not initialized.");
+                               } else {
+                                   pad_pid = NATIVE_LAUNCHPAD_PID;
+                }
+                       }
+#endif
+#ifdef _APPFW_FEATURE_PROCESS_POOL
                        else {
                                const char *process_pool = appinfo_get_value(ai, AIT_POOL);
-                               _D("process_pool: %s\n", process_pool);
+                               _D("process_pool: %s", process_pool);
+
+                               const char *hwacc = appinfo_get_value(ai, AIT_HWACC);
+                               _D("h/w acceleration: %s", hwacc);
+
+                               SECURE_LOGD("appid: %s", appid);
 
-                               if (strncmp(process_pool, "true", 4) == 0)
+                               if (strncmp(process_pool, "true", strlen("true")) == 0)
                                {
+ #ifndef _APPFW_FEATURE_PROCESS_POOL_COMMON
+                                       if (strncmp(hwacc, "USE", strlen("USE")) != 0)
+                                       {
+                                               _D("Sending to process-pool launchpad (type1).");
+                                               bundle_add(kb, AUL_K_LAUNCHPAD_TYPE, "1"); //sw rendering
+                                               pad_pid = PROCESS_POOL_LAUNCHPAD_PID;
+                                       }
+                                       else
+                                       {
+  #ifndef _APPFW_FEATURE_PROCESS_POOL_HW_RENDERING
+                                               _D("Sending to legacy launchpad because launchpad type2 is not supported.");
+  #else
+                                               _D("Sending to process-pool launchpad (type2).");
+                                               bundle_add(kb, AUL_K_LAUNCHPAD_TYPE, "2"); //hw rendering
+                                               pad_pid = PROCESS_POOL_LAUNCHPAD_PID;
+  #endif
+                                       }
+ #else //_APPFW_FEATURE_PROCESS_POOL_COMMON
+                                       _D("Sending to process-pool launchpad (combine mode).");
+                                       bundle_add(kb, AUL_K_LAUNCHPAD_TYPE, "1");
                                        pad_pid = PROCESS_POOL_LAUNCHPAD_PID;
+ #endif //_APPFW_FEATURE_PROCESS_POOL_COMMON
+
+                                       char pad_sock[UNIX_PATH_MAX] = { 0, };
+                                       snprintf(pad_sock, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pad_pid);
+                                       if (access(pad_sock, F_OK) != 0)
+                                       {
+                                               _D("Sending to legacy launchpad because process-pool launchpad is not initialized.");
+                                               pad_pid = LAUNCHPAD_PID;
+                                       }
                                }
                        }
-#endif
+#endif //_APPFW_FEATURE_PROCESS_POOL
 
+                       __set_appinfo_for_launchpad(ai, kb);
                        pid = app_send_cmd(pad_pid, cmd, kb);
-                       if(pid == -3) {
+                       if(pid == AUL_R_ECOMM) {
                                pid = -ENOLAUNCHPAD;
                        }
                        //_add_cgroup(_lcg, appid, pid);
-#ifdef WEARABLE_PROFILE
-                       proc_group_change_status(PROC_CGROUP_SET_LAUNCH_REQUEST, pid, appid);
+                       proc_cgroup_launch(PROC_CGROUP_SET_LAUNCH_REQUEST, pid, appid, pkgid);
                        snprintf(trm_buf, MAX_PACKAGE_STR_SIZE, "appinfo_launch:%s[PID]%d", appid, pid);
                        __trm_app_info_send_socket(trm_buf);
-#endif
+               }
+               if(pid < 0) {
+                       if(_input_window_get() != 0)
+                               ecore_x_pointer_ungrab();
+                       _D("pid(%d) ecore_x_pointer_ungrab", pid);
+               } else {
+                       grab_timer_id = g_timeout_add(1000, __grab_timeout_handler, pid);
                }
        }
        else if (component_type && strncmp(component_type, "svcapp", 6) == 0) {
@@ -1184,9 +1835,22 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                                pid = ret;
                        }
                } else if (cmd != APP_RESUME) {
+#ifdef _APPFW_FEATURE_DEBUG_LAUNCHPAD
+                       if (bundle_get_type(kb, AUL_K_SDK) != BUNDLE_TYPE_NONE) {
+                               _D("The svcapp(%s) is launched by debug-launchpad", appid);
+                               __set_appinfo_for_launchpad(ai, kb);
+                               pid = app_send_cmd(DEBUG_LAUNCHPAD_PID, cmd, kb);
+                               if (pid == AUL_R_ECOMM) {
+                                       pid = -ENOLAUNCHPAD;
+                               }
+                               proc_cgroup_launch(PROC_CGROUP_SET_LAUNCH_REQUEST, pid, appid, pkgid);
+                       } else {
+                               pid = service_start(_lcg, appid, app_path, kb);
+                               proc_cgroup_launch(PROC_CGROUP_SET_SERVICE_REQUEST, pid, appid, pkgid);
+                       }
+#else
                        pid = service_start(_lcg, appid, app_path, kb);
-#ifdef WEARABLE_PROFILE
-                       proc_group_change_status(PROC_CGROUP_SET_SERVICE_REQUEST, pid, appid);
+                       proc_cgroup_launch(PROC_CGROUP_SET_SERVICE_REQUEST, pid, appid, pkgid);
 #endif
                }
        } else {
@@ -1201,26 +1865,56 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
        }
 
        if(pid > 0) {
-               _status_add_app_info_list(appid, app_path, pid, pad_pid);
-       }
+#ifdef _APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP
+               // Add the appid into bundle to distinguish between Contacts and Phone.
+               if (strncmp(appid, "org.tizen.phone", strlen("org.tizen.phone")) == 0)
+                       _status_add_app_info_list("org.tizen.contacts", app_path, curr_caller, pid, pad_pid);
+               else
+#endif
+                       _status_add_app_info_list(appid, app_path, curr_caller, pid, pad_pid);
 
-#ifdef WEARABLE_PROFILE
-       display_lock_state(LCD_OFF, STAY_CUR_STATE, 1000);
+#ifdef _APPFW_FEATURE_APP_CHECKER
+               ret = ac_server_check_launch_privilege(appid, appinfo_get_value(ai, AIT_TYPE), pid);
+               return ret != AC_R_ERROR ? pid : -1;
 #endif
+       }
 
        return pid;
 }
 
+int __e17_status_handler(int pid, int status, void *data)
+{
+       if( status == 0 || status == 3) {
+               _D("pid(%d) status(%d)", pid, status);
+               if(_input_window_get() != 0)
+                       ecore_x_pointer_ungrab();
+               g_source_remove(grab_timer_id);
+       }
+
+       return 0;
+}
 
 int _launch_init(struct amdmgr* amd)
 {
+       int ret = 0;
+
+       _D("_launch_init");
+
+       amd_cmdline = __proc_get_cmdline_bypid(getpid());
+
        _laf = amd->af;
        _lcg = amd->cg;
+
        conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
        if (!conn) {
                _E("dbus_bus_get error");
                return -EBADMSG;
        }
+
+       ret = aul_listen_e17_status_signal(__e17_status_handler, NULL);
+
+       _D("ret : %d", ret);
+
        return 0;
 }
 
@@ -1229,4 +1923,10 @@ void _set_atom_effect(void)
        ATOM_IMAGE_EFFECT = ecore_x_atom_get(atom_name);
 }
 
-
+void __set_appinfo_for_launchpad(const struct appinfo *ai, bundle *kb) {
+       _D("Add hwacc, taskmanage, app_path and pkg_type into bundle for sending those to launchpad.");
+       bundle_add(kb, AUL_K_HWACC, appinfo_get_value(ai, AIT_HWACC));
+       bundle_add(kb, AUL_K_TASKMANAGE, appinfo_get_value(ai, AIT_TASKMANAGE));
+       bundle_add(kb, AUL_K_EXEC, appinfo_get_value(ai, AIT_EXEC));
+       bundle_add(kb, AUL_K_PACKAGETYPE, appinfo_get_value(ai, AIT_TYPE));
+}
index 4d67357..9cde936 100755 (executable)
 #ifndef __AUL_AMD_LAUNCH_H_
 #define __AUL_AMD_LAUNCH_H_
 
+#ifndef _APPFW_FEATURE_PROCESS_POOL
+ #ifdef _APPFW_FEATURE_PROCESS_POOL_COMMON
+ #error _APPFW_FEATURE_PROCESS_POOL should be defined !!
+ #else
+  #ifdef _APPFW_FEATURE_PROCESS_POOL_HW_RENDERING
+  #error _APPFW_FEATURE_PROCESS_POOL should be defined !!
+  #endif
+ #endif
+#endif
+
+#include <glib.h>
 #include <bundle.h>
 #include "aul_util.h"
 #include "amd_appinfo.h"
 
 int _send_to_sigkill(int pid);
-int _resume_app(int pid);
+int _resume_app(int pid, int clifd);
 int _term_app(int pid, int clifd);
-int _fake_launch_app(int cmd, int pid, bundle * kb);
+int _fake_launch_app(int cmd, int pid, bundle * kb, int clifd);
 int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_uid, int fd);
 void service_release(const char *group);
 int _start_srv(const struct appinfo *ai, bundle *kb);
 
 int _launch_init(struct amdmgr* amd);
 void _set_atom_effect(void);
-
+void __set_appinfo_for_launchpad(const struct appinfo *ai, bundle *kb);
+gboolean _get_platform_ready(void);
 
 #endif /* __AUL_AMD_LAUNCH_H_ */
index 6248a0d..f182bfe 100755 (executable)
 #include <Evas.h>
 #include <aul.h>
 #include <vconf.h>
-#include <ail.h>
+#ifdef _APPFW_FEATURE_APP_CHECKER
+#include <app-checker-server.h>
+#endif
 #include <glib.h>
+#include <sys/resource.h>
+#include <assert.h>
+#include <pkgmgr-info.h>
+#include <proc_stat.h>
 
 #include "amd_config.h"
 #include "simple_util.h"
 #include "aul_util.h"
+#include "app_sock.h"
 #include "amd_appinfo.h"
 #include "amd_cgutil.h"
 #include "amd_key.h"
 #  define AGENT_PATH "/usr/bin/daemon-manager-release-agent"
 #endif
 
+#ifdef _APPFW_FEATURE_BG_PROCESS_LIMIT
+typedef struct _r_app_info_t{
+       char pkg_name[MAX_PACKAGE_STR_SIZE];
+       int pid;
+} r_app_info_t;
+
+GSList *r_app_info_list = NULL;
+#endif
+
+gboolean platform_ready = false;
+
 #define WINDOW_READY   "/tmp/.wm_ready"
 
 typedef struct _window_watch {
@@ -61,15 +79,197 @@ typedef struct _window_watch {
 } _window_watch_t;
 static _window_watch_t *win_info_t = NULL;
 
+#ifdef _APPFW_FEATURE_BG_PROCESS_LIMIT
+static void __vconf_cb(keynode_t *key, void *data);
+#endif
 static int __app_dead_handler(int pid, void *data);
 static int __init();
 
 extern int _status_init(struct amdmgr* amd);
 
+static int __send_to_sigkill(int pid)
+{
+       int pgid;
+
+       _D("__send_to_sigkill, pid: %d", pid);
+
+       pgid = getpgid(pid);
+       if (pgid <= 1)
+               return -1;
+
+       if (killpg(pgid, SIGKILL) < 0)
+               return -1;
+
+       return 0;
+}
+
+#ifdef _APPFW_FEATURE_BG_PROCESS_LIMIT
+static int __kill_bg_apps(int limit)
+{
+       int len;
+       int i;
+       int n;
+       r_app_info_t *info_t = NULL;
+       GSList *iter = NULL;
+
+       len = g_slist_length(r_app_info_list);
+
+       n = len - limit;
+
+       if (n<=0) return 0;
+
+       for ( i=0, iter = r_app_info_list; i<n ; i++) {
+               info_t = (r_app_info_t *)iter->data;
+               //__send_to_sigkill(info_t->pid);
+               proc_group_change_status(PROC_CGROUP_SET_TERMINATE_REQUEST, info_t->pid, NULL);
+               _term_app(info_t->pid, 0);
+               iter = g_slist_next(iter);
+               r_app_info_list = g_slist_remove(r_app_info_list, info_t);
+               free(info_t);
+       }
+
+       return 0;
+}
+
+static int __remove_item_running_list(int pid)
+{
+       r_app_info_t *info_t = NULL;
+       GSList *iter = NULL;
+
+       for (iter = r_app_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (r_app_info_t *)iter->data;
+               if(pid == info_t->pid) {
+                       r_app_info_list = g_slist_remove(r_app_info_list, info_t);
+                       free(info_t);
+                       break;
+               }
+       }
+       return 0;
+}
+
+gboolean __add_item_running_list(gpointer user_data)
+{
+
+       bool taskmanage;
+       pkgmgrinfo_appinfo_h handle = NULL;
+       int ret = 0;
+       r_app_info_t *info_t = NULL;
+       GSList *iter = NULL;
+       int found = 0;
+       int limit;
+
+       item_pkt_t *item  = (item_pkt_t *)user_data;
+       if (item == NULL) {
+               return false;
+       }
+
+       char* appid = item->appid;
+       int pid = item->pid;
+
+       SECURE_LOGD("__add_item_running_list pid: %d", pid);
+
+       if (vconf_get_int(VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS, &limit) != 0){
+               _E("Unable to get VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS\n");
+       }
+
+       if (appid == NULL) {
+               return false;
+       } else if (strncmp(appid, "org.tizen.cluster-home", 24) == 0) {
+               if(limit>0) __kill_bg_apps(limit-1);
+               return false;
+       }
+
+       SECURE_LOGD("__add_item_running_list appid: %s", appid);
+
+       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (ret != PMINFO_R_OK) {
+               _E("pkgmgrinfo_pkginfo_get_pkginfo with %s failed", appid);
+               return false;
+       }
+
+       ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
+       if (ret != PMINFO_R_OK) {
+               _E("pkgmgrinfo_appinfo_is_taskmanage failed");
+               goto END;
+       }
+
+       if (taskmanage == false)
+               goto END;
+
+       for (iter = r_app_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (r_app_info_t *)iter->data;
+               if(pid == info_t->pid) {
+                       found = 1;
+                       r_app_info_list = g_slist_remove(r_app_info_list, info_t);
+                       r_app_info_list = g_slist_append(r_app_info_list, info_t);
+                       break;
+               }
+       }
+
+       if(found == 0) {
+               info_t = malloc(sizeof(r_app_info_t));
+               strncpy(info_t->pkg_name, appid, MAX_PACKAGE_STR_SIZE-1);
+               info_t->pid = pid;
+               r_app_info_list = g_slist_append(r_app_info_list, info_t);
+       }
+
+       for (iter = r_app_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (r_app_info_t *)iter->data;
+       }
+
+       if(limit>0) __kill_bg_apps(limit);
+
+       for (iter = r_app_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (r_app_info_t *)iter->data;
+       }
+
+END:
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
+       free(item);
+       return false;
+}
+
+static void __vconf_cb(keynode_t *key, void *data)
+{
+       int limit;
+       const char *name;
+
+       name = vconf_keynode_get_name(key);
+       if( name == NULL ) {
+               return;
+       }else if ( strcmp(name, VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS) == 0){
+               limit = vconf_keynode_get_int(key);
+               if(limit>0) __kill_bg_apps(limit);
+       }
+}
+#endif
+
 static int __app_dead_handler(int pid, void *data)
 {
+       char trm_buf[MAX_PACKAGE_STR_SIZE];
+       char buf[MAX_LOCAL_BUFSZ];
+
+       _I("__app_dead_handler, pid: %d", pid);
+
+       if(pid <= 0)
+               return 0;
+
        _unregister_key_event(pid);
+#ifdef _APPFW_FEATURE_BG_PROCESS_LIMIT
+       __remove_item_running_list(pid);
+#endif
        _status_remove_app_info_list(pid);
+       snprintf(trm_buf, MAX_PACKAGE_STR_SIZE, "appinfo_terminated:[PID]%d", pid);
+       __trm_app_info_send_socket(trm_buf);
+
+       snprintf(buf, MAX_LOCAL_BUFSZ, "%s/%d", AUL_SOCK_PREFIX, pid);
+       unlink(buf);
+
        return 0;
 }
 
@@ -86,10 +286,16 @@ static void __start_cb(void *user_data,
 
        if (r == 1 && strncmp(componet, "svcapp", 6) == 0)
        {
-               const char *pkgid = appinfo_get_value(ai, AIT_PKGID);
-               _D("start service - %s", pkgid);
-
-               _start_srv(ai, NULL);
+               const char *appid = appinfo_get_value(ai, AIT_NAME);
+               if (_status_app_is_running(appid) < 0)
+               {
+                       _I("start service (on-boot) - %s", appid);
+                       _start_srv(ai, NULL);
+               }
+               else
+               {
+                       _E("service: %s is already running", appid);
+               }
        }
 }
 
@@ -98,10 +304,29 @@ static void _start_services(struct amdmgr *amd)
        appinfo_foreach(amd->af, __start_cb, amd);
 }
 
+gboolean _get_platform_ready()
+{
+       return platform_ready;
+}
+
+static gboolean __platform_ready_handler(gpointer data)
+{
+       _E("[Info]__platform_ready_handler");
+       platform_ready = true;
+
+       return FALSE;
+}
+
 static int __booting_done_handler(int pid, void *data)
 {
+       guint timer_id;
+
+       _E("[Info]__booting_done_handler, pid: %d", pid);
+
        _start_services((struct amdmgr*)data);
 
+       timer_id = g_timeout_add(60000, __platform_ready_handler, NULL);
+
        return 0;
 }
 
@@ -115,6 +340,8 @@ static gboolean _check_window_ready(void)
 
 static void __window_init(void)
 {
+       _D("_window_init");
+
        ecore_x_init(NULL);
        _set_atom_effect();
 #ifndef __i386__
@@ -160,6 +387,8 @@ static Eina_Bool _window_cb(void *data, Ecore_Fd_Handler * fd_handler)
 
 static void _register_window_init(void)
 {
+       _D("_register_window_init");
+
        win_info_t = malloc(sizeof(_window_watch_t));
        if (!win_info_t) {
                _E("Unable to allocate memory. don't init widow\n");
@@ -182,30 +411,54 @@ static void _window_init(void)
 static int __init()
 {
        struct amdmgr amd;
+       int ret = 0;
 
        ecore_init();
        evas_init();
        ecore_event_init();
 
-       appinfo_init(&amd.af);
-       cgutil_create(MOUNT_PATH, AGENT_PATH, &amd.cg);
-       _requset_init(&amd);
+       _D("ecore init done\n");
+
+       ret = appinfo_init(&amd.af);
+       assert(ret == 0);
+
+       ret = cgutil_create(MOUNT_PATH, AGENT_PATH, &amd.cg);
+       assert(ret == 0);
+
+       ret = _request_init(&amd);
+       assert(ret == 0);
+
        _launch_init(&amd);
        _status_init(&amd);
        _window_init();
 
-       aul_listen_app_dead_signal(__app_dead_handler, NULL);
+       _D("AMD init done\n");
 
+#ifdef _APPFW_FEATURE_BG_PROCESS_LIMIT
+       if (vconf_notify_key_changed(VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS, __vconf_cb, NULL) != 0) {
+               _E("Unable to register callback for VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS\n");
+       }
+#endif
+
+       aul_listen_app_dead_signal(__app_dead_handler, NULL);
        aul_listen_booting_done_signal(__booting_done_handler, &amd);
 
+#ifdef _APPFW_FEATURE_PRIORITY_CHANGE
+       int res = setpriority(PRIO_PROCESS, 0, -12);
+       if (res == -1)
+       {
+               SECURE_LOGE("Setting process (%d) priority to -12 failed, errno: %d (%s)",
+                               getpid(), errno, strerror(errno));
+       }
+#endif
        return 0;
 }
 
 gboolean  __amd_ready(gpointer user_data)
 {
-       int handle;
+       _D("AMD ready\n");
 
-       handle = creat("/tmp/amd_ready", S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+       int handle = creat("/tmp/amd_ready", S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
        if (handle != -1)
                close(handle);
 
@@ -214,7 +467,17 @@ gboolean  __amd_ready(gpointer user_data)
 
 int main(int argc, char *argv[])
 {
+       _D("AMD main()\n");
+
+#ifdef _APPFW_FEATURE_APP_CHECKER
+       if (ac_server_initialize() != AC_R_OK){
+               _E("ac_server_initialize failed!\n");
+               assert(0);
+               return -1;
+       }
+#endif
        if (__init() != 0){
+               assert(0);
                _E("AMD Initialization failed!\n");
                return -1;
        }
index 9b8927e..04f270a 100755 (executable)
 #include <glib.h>
 #include <bundle.h>
 #include <rua.h>
-#ifdef WEARABLE_PROFILE
 #include <proc_stat.h>
-#endif
 #include <security-server.h>
+#include <vconf.h>
 
 #include "amd_config.h"
 #include "simple_util.h"
 #include "app_sock.h"
+#include "app_signal.h"
 #include "aul_util.h"
 #include "amd_request.h"
 #include "amd_key.h"
 #include "amd_cgutil.h"
 #include "amd_status.h"
 
+#include <pkgmgr-info.h>
 
 #define INHOUSE_UID     5000
 
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+#define METADATA_MULTI_INSTANCE                "http://developer.samsung.com/tizen/metadata/multiinstance"
+#endif
+
 struct appinfomgr *_raf;
 struct cginfo *_rcg;
+static DBusConnection *bus = NULL;
+char *home_appid = NULL;
+
 
 static int __send_result_to_client(int fd, int res);
 static gboolean __request_handler(gpointer data);
 
 static int __send_result_to_client(int fd, int res)
 {
+       _D("__send_result_to_client, res: %d", fd, res);
+
        if (send(fd, &res, sizeof(int), MSG_NOSIGNAL) < 0) {
-               if (errno == EPIPE)
+               if (errno == EPIPE) {
                        _E("send failed due to EPIPE.\n");
+               }
+
                _E("send fail to client");
        }
        close(fd);
@@ -69,6 +81,9 @@ static int __send_result_to_client(int fd, int res)
 
 static void __real_send(int clifd, int ret)
 {
+       if(clifd <= 0) {
+               return;
+       }
        if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
                if (errno == EPIPE) {
                        _E("send failed due to EPIPE.\n");
@@ -110,15 +125,19 @@ static int __foward_cmd(int cmd, bundle *kb, int cr_pid)
        int res;
 
        if ((pid = __get_caller_pid(kb)) < 0)
-                       return AUL_R_ERROR;
+       {
+               return AUL_R_ERROR;
+       }
 
        pgid = getpgid(cr_pid);
        if(pgid > 0) {
                snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", pgid);
-               bundle_del(kb,AUL_K_CALLEE_PID);
+               bundle_del(kb, AUL_K_CALLEE_PID);
                bundle_add(kb, AUL_K_CALLEE_PID, tmp_pid);
        }
 
+       _D("__forward_cmd: %d %d", cr_pid, pgid);
+
        bundle_encode(kb, &kb_data, &datalen);
        if ((res = __app_send_raw_with_noreply(pid, cmd, kb_data, datalen)) < 0)
                res = AUL_R_ERROR;
@@ -148,19 +167,18 @@ static int __app_process_by_pid(int cmd,
                _E("invalid pid");
                return -1;
        }
-#ifdef WEARABLE_PROFILE
        if (cmd == APP_RESUME_BY_PID)
                proc_group_change_status(PROC_CGROUP_SET_RESUME_REQUEST, pid, NULL);
        else
                proc_group_change_status(PROC_CGROUP_SET_TERMINATE_REQUEST, pid, NULL);
-#endif
 
+       _D("__app_process_by_pid, cmd: %d, pid: %d, ", cmd, pid);
        switch (cmd) {
        case APP_RESUME_BY_PID:
-               ret = _resume_app(pid);
-               __real_send(clifd, ret);
+               ret = _resume_app(pid, clifd);
                break;
        case APP_TERM_BY_PID:
+       case APP_TERM_BY_PID_WITHOUT_RESTART:
                ret = _term_app(pid, clifd);
                break;
        case APP_KILL_BY_PID:
@@ -169,10 +187,17 @@ static int __app_process_by_pid(int cmd,
                __real_send(clifd, ret);
                break;
        case APP_TERM_REQ_BY_PID:
-               if ((ret = __app_send_raw(pid, APP_TERM_REQ_BY_PID, (unsigned char *)&dummy, sizeof(int))) < 0) {
+               if ((ret = __app_send_raw(pid, cmd, (unsigned char *)&dummy, sizeof(int))) < 0) {
+                       _D("terminate req packet send error");
+               }
+               __real_send(clifd, ret);
+               break;
+       case APP_TERM_BY_PID_ASYNC:
+               if ((ret = __app_send_raw_with_noreply(pid, cmd, (unsigned char *)&dummy, sizeof(int))) < 0) {
                        _D("terminate req packet send error");
                }
                __real_send(clifd, ret);
+               break;
        }
 
        return ret;
@@ -194,6 +219,15 @@ static gboolean __add_history_handler(gpointer user_data)
        kb = bundle_decode(pkt->data, pkt->len);
        appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
 
+#ifdef _APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP
+       // When the Phone is executed, the Contacts is shown on task manager.
+       int need_free = 0;
+       if (strncmp(appid, "org.tizen.phone", strlen("org.tizen.phone")) == 0)
+       {
+               appid = strndup("org.tizen.contacts", strlen("org.tizen.contacts"));
+               need_free = 1;
+       }
+#endif
        ai = (struct appinfo *)appinfo_find(_raf, appid);
        app_path = (char *)appinfo_get_value(ai, AIT_EXEC);
 
@@ -216,6 +250,11 @@ static gboolean __add_history_handler(gpointer user_data)
                bundle_free(kb);
        free(pkt);
 
+#ifdef _APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP
+       if (need_free)
+               free(appid);
+#endif
+
        return FALSE;
 }
 
@@ -296,6 +335,136 @@ int __release_srv(const char *filename)
        return 0;
 }
 
+static inline int __send_home_launch_signal(int pid)
+{
+       DBusMessage *message;
+
+       if (bus == NULL)
+               return -1;
+
+       message = dbus_message_new_signal(AUL_DBUS_PATH,
+                                         AUL_DBUS_SIGNAL_INTERFACE,
+                                         AUL_DBUS_HOMELAUNCH_SIGNAL);
+
+       if (dbus_message_append_args(message,
+                                    DBUS_TYPE_UINT32, &pid,
+                                    DBUS_TYPE_INVALID) == FALSE) {
+               _E("Failed to load data error");
+               return -1;
+       }
+
+       if (dbus_connection_send(bus, message, NULL) == FALSE) {
+               _E("dbus send error");
+               return -1;
+       }
+
+       dbus_connection_flush(bus);
+       dbus_message_unref(message);
+
+       _D("send dead signal done\n");
+
+       return 0;
+}
+
+static inline int __send_app_termination_signal(int dead_pid)
+{
+       DBusMessage *message;
+
+       if (bus == NULL)
+               return -1;
+
+       message = dbus_message_new_signal(AUL_DBUS_PATH,
+                                         AUL_DBUS_SIGNAL_INTERFACE,
+                                         AUL_DBUS_APPDEAD_SIGNAL);
+
+       if (dbus_message_append_args(message,
+                                    DBUS_TYPE_UINT32, &dead_pid,
+                                    DBUS_TYPE_INVALID) == FALSE) {
+               _E("Failed to load data error");
+               return -1;
+       }
+
+       if (dbus_connection_send(bus, message, NULL) == FALSE) {
+               _E("dbus send error");
+               return -1;
+       }
+
+       dbus_connection_flush(bus);
+       dbus_message_unref(message);
+
+       _D("send dead signal done\n");
+
+       return 0;
+}
+
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+static char* __get_metadata_value(const char *appid, const char *metadata_key)
+{
+       int ret = 0;
+       pkgmgrinfo_appinfo_h handle;
+       char *metadata_value = NULL;
+       char *multi_appid = NULL;
+
+       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (ret != PMINFO_R_OK)
+               return NULL;
+
+       ret = pkgmgrinfo_appinfo_get_metadata_value(handle, metadata_key, &metadata_value);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
+               return NULL;
+       }
+
+       multi_appid = strdup(metadata_value);
+
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
+       return multi_appid;
+}
+
+static const char* __check_target_appid(const struct appinfo* ai, const char *appid, const char *multi_appid)
+{
+       const char* target = NULL;
+
+       // Both apps are running
+       if (_status_app_is_running(appid) != -1 && _status_app_is_running(multi_appid) != -1) {
+               const char* toggle = appinfo_get_value(ai, AIT_TOGGLE_ORDER);
+               int order = atoi(toggle);
+
+               _D("launch a multi-instance app with toggle mode: %d", order);
+               switch (order) {
+                       case 0:
+                               target = multi_appid;
+                               appinfo_set_value(ai, AIT_TOGGLE_ORDER, "1");
+                               break;
+
+                       case 1:
+                               target = appid;
+                               appinfo_set_value(ai, AIT_TOGGLE_ORDER, "0");
+                               break;
+
+                       default:
+                               break;
+               }
+       } else {
+               // Main app is running
+               if (_status_app_is_running(appid) != -1) {
+                       _D("Send a request to the running main appid: %s", appid);
+                       target = appid;
+                       // Sub app is running
+               } else if (_status_app_is_running(multi_appid) != -1) {
+                       _D("Send a request to the running sub appid: %s", multi_appid);
+                       target = multi_appid;
+               } else {
+                       _D("Both apps are not running, launch a main app - %s", appid);
+                       target = appid;
+               }
+       }
+
+       return target;
+}
+#endif
+
 static gboolean __request_handler(gpointer data)
 {
        GPollFD *gpollfd = (GPollFD *) data;
@@ -307,18 +476,19 @@ static gboolean __request_handler(gpointer data)
        int ret = -1;
        int free_pkt = 1;
        char *appid;
-       /*char *app_path;
-       char *tmp_pid;*/
+       char *term_pid = NULL;
        int pid;
        bundle *kb = NULL;
        const struct appinfo *ai;
        const char *pkg_status;
+       item_pkt_t *item;
 
        if ((pkt = __app_recv_raw(fd, &clifd, &cr)) == NULL) {
                _E("recv error");
                return FALSE;
        }
 
+       _D("__request_handler: %d", pkt->cmd);
        switch (pkt->cmd) {
                case APP_OPEN:
                case APP_RESUME:
@@ -333,10 +503,55 @@ static gboolean __request_handler(gpointer data)
                        } else {
                                kb = bundle_decode(pkt->data, pkt->len);
                                appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
+
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+                               // Check the multi-instance app
+                               ai = appinfo_find(_raf, appid);
+                               if (ai == NULL) {
+                                       _E("no appinfo");
+                                       __real_send(clifd, -1);
+                                       ret = -1;
+                               } else {
+                                       const char* multi = appinfo_get_value(ai, AIT_MULTI_INSTANCE);
+                                       if( multi && strncmp(multi, "true", strlen("true")) == 0 ) {
+
+                                               char* multi_appid =__get_metadata_value(appid, METADATA_MULTI_INSTANCE);
+                                               if (multi_appid != NULL)
+                                               {
+                                                       _D("Multi-instance main: %s, sub: %s", appid, multi_appid);
+
+                                                       const char* target_appid = __check_target_appid(ai, appid, multi_appid);
+
+                                                       _D("launch a target appid: - %s", target_appid);
+                                                       ret = _start_app(target_appid, kb, pkt->cmd, cr.pid, cr.uid, clifd);
+                                               } else {
+                                                       _D("No multi-instance app information, launch a main appid: - %s", appid);
+                                                       ret = _start_app(appid, kb, pkt->cmd, cr.pid, cr.uid, clifd);
+                                               }
+
+                                               free(multi_appid);
+                                       }
+                                       else
+                                       {
+                                               _D("launch a single-instance appid: %s", appid);
+                                               ret = _start_app(appid, kb, pkt->cmd, cr.pid, cr.uid, clifd);
+                                       }
+                               }
+#else
                                ret = _start_app(appid, kb, pkt->cmd, cr.pid, cr.uid, clifd);
+#endif
 
-                               if(ret > 0) {
+                               if(ret > 0 && bundle_get_type(kb, AUL_K_PRELAUCHING) == BUNDLE_TYPE_NONE) {
+                                       item = calloc(1, sizeof(item_pkt_t));
+                                       item->pid = ret;
+                                       strncpy(item->appid, appid, 511);
                                        free_pkt = 0;
+
+                                       if (home_appid && strncmp(appid, home_appid, strlen(appid)) == 0)
+                                               __send_home_launch_signal(ret);
+#ifdef _APPFW_FEATURE_BG_PROCESS_LIMIT
+                                       __add_item_running_list(item);
+#endif
                                        g_timeout_add(1000, __add_history_handler, pkt);
                                }
 
@@ -344,6 +559,40 @@ static gboolean __request_handler(gpointer data)
                                        bundle_free(kb), kb = NULL;
                        }
                        break;
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+               case APP_START_MULTI_INSTANCE:
+                       ret = security_server_check_privilege_by_sockfd(clifd, "aul::launch", "x");
+                       if(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
+                               _E("launch request has been denied by smack");
+                               ret = -EILLEGALACCESS;
+                               __real_send(clifd, ret);
+                       } else {
+                               kb = bundle_decode(pkt->data, pkt->len);
+                               appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
+
+                               _D("launch a multi-instance appid: %s", appid);
+                               ret = _start_app(appid, kb, pkt->cmd, cr.pid, cr.uid, clifd);
+                       }
+
+                       if(ret > 0) {
+                               item = calloc(1, sizeof(item_pkt_t));
+                               item->pid = ret;
+                               strncpy(item->appid, appid, 511);
+                               free_pkt = 0;
+
+                               if (home_appid && strncmp(appid, home_appid, strlen(appid)) == 0)
+                                       __send_home_launch_signal(ret);
+#ifdef _APPFW_FEATURE_BG_PROCESS_LIMIT
+                               __add_item_running_list(item);
+#endif
+                               g_timeout_add(1000, __add_history_handler, pkt);
+                       }
+
+                       if (kb != NULL)
+                               bundle_free(kb), kb = NULL;
+
+                       break;
+#endif
                case APP_RESULT:
                case APP_CANCEL:
                        kb = bundle_decode(pkt->data, pkt->len);
@@ -357,6 +606,26 @@ static gboolean __request_handler(gpointer data)
                        appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
                        ret = __app_process_by_pid(pkt->cmd, appid, &cr, clifd);
                        break;
+               case APP_TERM_BY_PID_WITHOUT_RESTART:
+               case APP_TERM_BY_PID_ASYNC:
+                       ret = security_server_check_privilege_by_sockfd(clifd, "aul::terminate", "x");
+                       if(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
+                               _E("terminate request has been denied by smack");
+                               ret = -EILLEGALACCESS;
+                               __real_send(clifd, ret);
+                       } else {
+                               kb = bundle_decode(pkt->data, pkt->len);
+                               term_pid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
+                               appid = _status_app_get_appid_bypid(atoi(term_pid));
+                               ai = appinfo_find(_raf, appid);
+                               if(ai) {
+                                       appinfo_set_value(ai, AIT_STATUS, "norestart");
+                                       ret = __app_process_by_pid(pkt->cmd, term_pid, &cr, clifd);
+                               } else {
+                                       ret = -1;
+                               }
+                       }
+                       break;
                case APP_TERM_BY_PID:
                case APP_KILL_BY_PID:
                        ret = security_server_check_privilege_by_sockfd(clifd, "aul::terminate", "x");
@@ -373,6 +642,9 @@ static gboolean __request_handler(gpointer data)
                case APP_RUNNING_INFO:
                        _status_send_running_appinfo_v2(clifd);
                        break;
+               case APP_RUNNING_INFO_MEMORY:
+                       _status_send_running_appinfo(clifd);
+                       break;
                case APP_IS_RUNNING:
                        appid = malloc(MAX_PACKAGE_STR_SIZE);
                        strncpy(appid, (const char*)pkt->data, MAX_PACKAGE_STR_SIZE-1);
@@ -382,10 +654,15 @@ static gboolean __request_handler(gpointer data)
                        free(appid);
                        break;
                case APP_GET_APPID_BYPID:
-                       memcpy(&pid, pkt->data, pkt->len);
+                       memcpy(&pid, pkt->data, sizeof(int));
                        ret = _status_get_appid_bypid(clifd, pid);
                        _D("APP_GET_APPID_BYPID : %d : %d", pid, ret);
                        break;
+               case APP_GET_PKGID_BYPID:
+                       memcpy(&pid, pkt->data, sizeof(int));
+                       ret = _status_get_pkgid_bypid(clifd, pid);
+                       _D("APP_GET_PKGID_BYPID : %d : %d", pid, ret);
+                       break;
                case APP_KEY_RESERVE:
                        ret = _register_key_event(cr.pid);
                        __send_result_to_client(clifd, ret);
@@ -408,11 +685,11 @@ static gboolean __request_handler(gpointer data)
                        break;
                case APP_RELEASED:
                        appid = malloc(MAX_PACKAGE_STR_SIZE);
-                       strncpy(appid, (const char*)pkt->data, MAX_PACKAGE_STR_SIZE-1);
+                       strncpy(appid, (const char*)&pkt->data[1], MAX_PACKAGE_STR_SIZE-1);
                        ai = appinfo_find(_raf, appid);
                        pkg_status = appinfo_get_value(ai, AIT_STATUS);
-                       _D("pkg_status : %s", pkg_status);
-                       if(pkg_status && strncmp(pkg_status, "upgrading", 9) == 0) {
+                       SECURE_LOGD("appid(%s) pkg_status(%s)", appid, pkg_status);
+                       if(pkg_status && strncmp(pkg_status, "blocking", 8) == 0) {
                                appinfo_set_value(ai, AIT_STATUS, "restart");
                        } else if (pkg_status && strncmp(pkg_status, "norestart", 9) == 0) {
                                appinfo_set_value(ai, AIT_STATUS, "installed");
@@ -420,6 +697,10 @@ static gboolean __request_handler(gpointer data)
                                ret = __release_srv(appid);
                        }
                        __send_result_to_client(clifd, ret);
+                       ret = _status_app_is_running(appid);
+                       SECURE_LOGI("appid(%s) dead pid(%d)", appid, ret);
+                       if(ret > 0)
+                               __send_app_termination_signal(ret);
                        free(appid);
                        break;
                case APP_RUNNING_LIST_UPDATE:
@@ -481,12 +762,28 @@ static GSourceFuncs funcs = {
        .finalize = NULL
 };
 
-int _requset_init(struct amdmgr *amd)
+static void __home_appid_vconf_cb(keynode_t *key, void *data)
+{
+       char *tmpstr;
+
+       tmpstr = vconf_keynode_get_str(key);
+       if (tmpstr == NULL) {
+               return;
+       }
+
+       if (home_appid) {
+               free(home_appid);
+       }
+       home_appid = strdup(tmpstr);
+}
+
+int _request_init(struct amdmgr *amd)
 {
        int fd;
        int r;
        GPollFD *gpollfd;
        GSource *src;
+       DBusError error;
 
        fd = __create_server_sock(AUL_UTIL_PID);
        src = g_source_new(&funcs, sizeof(GSource));
@@ -503,7 +800,7 @@ int _requset_init(struct amdmgr *amd)
        r = g_source_attach(src, NULL);
        if (r  == 0)
        {
-               /* TODO: error handle*/
+               _E("fail to attach the source : %d", r);
                return -1;
        }
 
@@ -515,6 +812,13 @@ int _requset_init(struct amdmgr *amd)
 
        _D("rua_clear_history : %d", r);
 
+       dbus_error_init(&error);
+       bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
+       home_appid = vconf_get_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME);
+       if (vconf_notify_key_changed(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, __home_appid_vconf_cb, NULL) != 0) {
+               _E("Unable to register callback for VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME\n");
+       }
+
        return 0;
 }
 
index 3353c7e..ca409b1 100755 (executable)
@@ -23,7 +23,7 @@
 #ifndef __AUL_AMD_REQUEST_H_
 #define __AUL_AMD_REQUEST_H_
 
-int _requset_init(struct amdmgr *amd);
+int _request_init(struct amdmgr *amd);
 
 
 
index 3143962..904c3ba 100755 (executable)
 #include <aul.h>
 #include <string.h>
 #include <Ecore.h>
+#include <proc_stat.h>
+#include <pkgmgr-info.h>
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+#include <Ecore_X.h>
+#include <vconf/vconf.h>
+#endif
 
 #include "amd_config.h"
 #include "amd_status.h"
 #include "menu_db_util.h"
 
 GSList *app_status_info_list = NULL;
-
 struct appinfomgr *_saf = NULL;
 
-int _status_add_app_info_list(char *appid, char *app_path, int pid, int pad_pid)
+GHashTable *cooldown_tbl;
+
+GHashTable *cooldown_black_tbl;
+
+char *cooldown_list[] = {
+};
+
+char *cooldown_black_list[] = {
+};
+
+int cooldown_status = 0;
+
+#define WHITE_LIST_COUNT 0
+#define BLACK_LIST_COUNT 0
+
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+#define LCD_ON "LCDOn"
+#define LCD_OFF        "LCDOff"
+#define PROC_SIZE      256
+#define WAKE_UP_GESTURE_CLOCK          1
+#endif
+
+int _status_add_app_info_list(char *appid, char *app_path, const char *caller, int pid, int pad_pid)
 {
        GSList *iter = NULL;
        app_status_info_t *info_t = NULL;
@@ -52,8 +79,12 @@ int _status_add_app_info_list(char *appid, char *app_path, int pid, int pad_pid)
        }
 
        info_t = malloc(sizeof(app_status_info_t));
+       memset(info_t, 0, sizeof(app_status_info_t));
+
        strncpy(info_t->appid, appid, MAX_PACKAGE_STR_SIZE-1);
        strncpy(info_t->app_path, app_path, MAX_PACKAGE_APP_PATH_SIZE-1);
+       if(caller)
+               strncpy(info_t->caller, caller, MAX_PACKAGE_STR_SIZE-1);
        info_t->status = STATUS_LAUNCHING;
        info_t->pid = pid;
        info_t->pad_pid = pad_pid;
@@ -183,6 +214,22 @@ char* _status_app_get_appid_bypid(int pid)
        return NULL;
 }
 
+char* _status_get_caller_by_appid(const char *appid)
+{
+       GSList *iter = NULL;
+       app_status_info_t *info_t = NULL;
+
+       for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (app_status_info_t *)iter->data;
+               if( strncmp(appid, info_t->appid, MAX_PACKAGE_STR_SIZE-1) == 0) {
+                       return info_t->caller;
+               }
+       }
+
+       return NULL;
+}
+
 int _status_send_running_appinfo(int fd)
 {
        GSList *iter = NULL;
@@ -355,11 +402,11 @@ int _status_get_appid_bypid(int fd, int pid)
 
        memset(pkt, 0, AUL_SOCK_MAXBUFF);
 
-       pkt->cmd = APP_GET_APPID_BYPID_ERROR;
+       pkt->cmd = APP_GET_INFO_ERROR;
 
        if (__get_pkgname_bypid(pid, (char *)pkt->data, MAX_PACKAGE_STR_SIZE) == 0) {
                SECURE_LOGD("appid for %d is %s", pid, pkt->data);
-               pkt->cmd = APP_GET_APPID_BYPID_OK;
+               pkt->cmd = APP_GET_INFO_OK;
                goto out;
        }
        /* support app launched by shell script*/
@@ -370,7 +417,77 @@ int _status_get_appid_bypid(int fd, int pid)
 
        _D("second change pgid = %d, pid = %d", pgid, pid);
        if (__get_pkgname_bypid(pgid, (char *)pkt->data, MAX_PACKAGE_STR_SIZE) == 0)
-               pkt->cmd = APP_GET_APPID_BYPID_OK;
+               pkt->cmd = APP_GET_INFO_OK;
+
+ out:
+       pkt->len = strlen((char *)pkt->data) + 1;
+
+       if ((len = send(fd, pkt, pkt->len + 8, 0)) != pkt->len + 8) {
+               if (errno == EPIPE)
+                       _E("send failed due to EPIPE.\n");
+               _E("send fail to client");
+       }
+
+       if(pkt)
+               free(pkt);
+
+       close(fd);
+
+       return 0;
+}
+
+static int __get_pkgid_bypid(int pid, char *pkgid, int len)
+{
+       char *cmdline;
+       app_info_from_db *menu_info;
+
+       cmdline = __proc_get_cmdline_bypid(pid);
+       if (cmdline == NULL)
+               return -1;
+
+       if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL) {
+               free(cmdline);
+               return -1;
+       } else
+               snprintf(pkgid, len, "%s", _get_pkgid(menu_info));
+
+       free(cmdline);
+       _free_app_info_from_db(menu_info);
+
+       return 0;
+}
+
+int _status_get_pkgid_bypid(int fd, int pid)
+{
+       app_pkt_t *pkt = NULL;
+       int len;
+       int pgid;
+
+       pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+       if(!pkt) {
+               _E("malloc fail");
+               close(fd);
+               return 0;
+       }
+
+       memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+       pkt->cmd = APP_GET_INFO_ERROR;
+
+       if (__get_pkgid_bypid(pid, (char *)pkt->data, MAX_PACKAGE_STR_SIZE) == 0) {
+               SECURE_LOGD("appid for %d is %s", pid, pkt->data);
+               pkt->cmd = APP_GET_INFO_OK;
+               goto out;
+       }
+       /* support app launched by shell script*/
+       _D("second chance");
+       pgid = getpgid(pid);
+       if (pgid <= 1)
+               goto out;
+
+       _D("second change pgid = %d, pid = %d", pgid, pid);
+       if (__get_pkgid_bypid(pgid, (char *)pkt->data, MAX_PACKAGE_STR_SIZE) == 0)
+               pkt->cmd = APP_GET_INFO_OK;
 
  out:
        pkt->len = strlen((char *)pkt->data) + 1;
@@ -389,11 +506,223 @@ int _status_get_appid_bypid(int fd, int pid)
        return 0;
 }
 
+static void __app_info_iter_limit_cb(void *user_data, const char *appid, const struct appinfo *ai)
+{
+       if(!g_hash_table_lookup(cooldown_tbl, appid)) {
+               appinfo_set_value(ai, AIT_STATUS, "blocking");
+       }
+}
+
+static void __app_info_iter_waring_cb(void *user_data, const char *appid, const struct appinfo *ai)
+{
+       if(g_hash_table_lookup(cooldown_black_tbl, appid)) {
+               appinfo_set_value(ai, AIT_STATUS, "blocking");
+       }
+}
+
+static void __app_info_iter_release_cb(void *user_data, const char *appid, const struct appinfo *ai)
+{
+       const char *component = NULL;
+       int onboot = 0;
+       int restart = 0;
+
+       if(!g_hash_table_lookup(cooldown_tbl, appid)) {
+               component = appinfo_get_value(ai, AIT_COMPTYPE);
+               onboot = appinfo_get_boolean(ai, AIT_ONBOOT);
+               restart = appinfo_get_boolean(ai, AIT_RESTART);
+               if (onboot == 1 && restart == 1 && strncmp(component, "svcapp", 6) == 0)
+               {
+                       if (_status_app_is_running(appid) < 0)
+                       {
+                               _I("start service (cooldown release) - %s", appid);
+                               _start_srv(ai, NULL);
+                       }
+                       else
+                       {
+                               _E("service: %s is already running", appid);
+                       }
+               }
+               appinfo_set_value(ai, AIT_STATUS, "installed");
+       }
+}
+
+
+
+static int __cooldown_cb(const char* status, void *data)
+{
+       GSList *iter = NULL;
+       app_status_info_t *info_t = NULL;
+       int ret;
+       int dummy;
+
+       _I("__cooldown_cb, status: %s", status);
+
+       if(strncmp(status, "LimitAction", 11) == 0) {
+               appinfo_foreach(_saf, __app_info_iter_limit_cb, NULL);
+               for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+               {
+                       info_t = (app_status_info_t *)iter->data;
+                       if(!g_hash_table_lookup(cooldown_tbl, info_t->appid)) {
+                               proc_group_change_status(PROC_CGROUP_SET_TERMINATE_REQUEST, info_t->pid, NULL);
+                               ret = __app_send_raw_with_noreply(info_t->pid, APP_TERM_BY_PID_ASYNC, (unsigned char *)&dummy, sizeof(int) );
+                       }
+               }
+               cooldown_status = COOLDOWN_LIMIT;
+       } else if(strncmp(status, "WarningAction", 13) == 0) {
+               appinfo_foreach(_saf, __app_info_iter_waring_cb, NULL);
+               for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+               {
+                       info_t = (app_status_info_t *)iter->data;
+                       if(g_hash_table_lookup(cooldown_black_tbl, info_t->appid)) {
+                               proc_group_change_status(PROC_CGROUP_SET_TERMINATE_REQUEST, info_t->pid, NULL);
+                               ret = __app_send_raw_with_noreply(info_t->pid, APP_TERM_BY_PID_ASYNC, (unsigned char *)&dummy, sizeof(int) );
+                       }
+               }
+               cooldown_status = COOLDOWN_WARNING;
+       } else if (strncmp(status, "Release", 7) == 0){
+               appinfo_foreach(_saf, __app_info_iter_release_cb, NULL);
+               cooldown_status = COOLDOWN_RELEASE;
+       }
+
+       return 0;
+}
+
+int _status_get_cooldown_status(void)
+{
+       return cooldown_status;
+}
+
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+static int __lcd_status_cb(const char *lcd_status, void *data)
+{
+       int gesture = -1;
+       Ecore_X_Window win;
+       int pid = 0;
+       bundle *kb = NULL;
+       char proc_file[PROC_SIZE] = {0, };
+       static int paused_pid = 0;
+
+       // Check the wake-up gesture is a clock or not.
+       // 0: Off, 1: Clock, 2: Last viewed screen
+       if (vconf_get_int(VCONFKEY_WMS_WAKEUP_BY_GESTURE_SETTING, &gesture) < 0) {
+               _E("Failed to get VCONFKEY_WMS_WAKEUP_BY_GESTURE_SETTING");
+               return 0;
+       }
+
+       if (gesture == WAKE_UP_GESTURE_CLOCK) {
+               SECURE_LOGD("Skip when wake-up gesture is a Clock.");
+               return 0;
+       }
+
+       // Get the topmost app
+       win = ecore_x_window_focus_get();
+       if (ecore_x_netwm_pid_get(win, &pid) != 1) {
+               _E("Can't get pid for focus x window (%x)", win);
+               return 0;
+       }
+       SECURE_LOGD("The topmost app's pid is %d.", pid);
+
+       // Pause or Resume the app when the lcd becomes On/Off
+       if (lcd_status && (strncmp(lcd_status, LCD_OFF, strlen(LCD_OFF)) == 0)) {
+               SECURE_LOGD("LCD status becomes Off. Pause the topmose app, %d", pid);
+               paused_pid = pid;
+               kb = bundle_create();
+               app_send_cmd_with_noreply(pid, APP_PAUSE_LCD_OFF, kb);
+       }
+       else if (lcd_status && (strncmp(lcd_status, LCD_ON, strlen(LCD_ON)) == 0)) {
+               if (paused_pid != pid) {
+                       SECURE_LOGE("The topmost app(%d) is different with the paused app(%d).", pid, paused_pid);
+               }
+
+               // Check whether the paused app is running or Not
+               snprintf(proc_file, PROC_SIZE, "/proc/%d/cmdline", paused_pid);
+               if (access(proc_file, F_OK) != 0) {
+                       SECURE_LOGE("paused app(%d) seems to be killed.", paused_pid);
+                       if (paused_pid != pid) {
+                               paused_pid = pid;
+                       } else {
+                               return 0;
+                       }
+               }
+
+               SECURE_LOGD("LCD status becomes On. Resume the paused app, %d", paused_pid);
+               kb = bundle_create();
+               app_send_cmd_with_noreply(paused_pid, APP_RESUME_LCD_ON, kb);
+       }
+       else {
+               _E("Invalid input param for lcd_status.");
+       }
+
+       bundle_free(kb);
+       return 0;
+}
+#endif
+
+static int __app_info_handler (const pkgmgrinfo_appinfo_h handle, void *data)
+{
+       char *tmp_appid;
+       char *appid;
+
+       pkgmgrinfo_appinfo_get_appid(handle, &tmp_appid);
+
+       appid = strdup(tmp_appid);
+
+       g_hash_table_insert(cooldown_tbl, appid, appid);
+
+       SECURE_LOGD("white_list : %s", appid);
+
+       return 0;
+}
+
+static int __blacklist_app_info_handler (const pkgmgrinfo_appinfo_h handle, void *data)
+{
+       char *tmp_appid;
+       char *appid;
+
+       pkgmgrinfo_appinfo_get_appid(handle, &tmp_appid);
+
+       appid = strdup(tmp_appid);
+
+       g_hash_table_insert(cooldown_black_tbl, appid, appid);
+
+       SECURE_LOGD("white_list : %s", appid);
+
+       return 0;
+}
 
 int _status_init(struct amdmgr* amd)
 {
+       int i;
+       pkgmgrinfo_appinfo_h handle = NULL;
+
        _saf = amd->af;
 
+       aul_listen_cooldown_signal(__cooldown_cb, NULL);
+
+       cooldown_tbl = g_hash_table_new(g_str_hash, g_str_equal);
+       for(i = 0; i < WHITE_LIST_COUNT; i++) {
+               SECURE_LOGD("pkgid %s", cooldown_list[i]);
+               if (pkgmgrinfo_pkginfo_get_pkginfo(cooldown_list[i], &handle) == PMINFO_R_OK){
+                       pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, __app_info_handler, NULL);
+                       pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __app_info_handler, NULL);
+                       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+               }
+       }
+
+       cooldown_black_tbl = g_hash_table_new(g_str_hash, g_str_equal);
+       for(i = 0; i < BLACK_LIST_COUNT; i++) {
+               SECURE_LOGD("pkgid %s", cooldown_black_list[i]);
+               if (pkgmgrinfo_pkginfo_get_pkginfo(cooldown_black_list[i], &handle) == PMINFO_R_OK){
+                       pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, __blacklist_app_info_handler, NULL);
+                       pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __blacklist_app_info_handler, NULL);
+                       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+               }
+       }
+
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+       // Register callback for LCD On/Off
+       aul_listen_lcd_status_signal(__lcd_status_cb, NULL);
+#endif
        return 0;
 }
 
index 157d749..d8fa74f 100755 (executable)
@@ -21,7 +21,7 @@
 
 
 
-int _status_add_app_info_list(char *appid, char *app_path, int pid, int pad_pid);
+int _status_add_app_info_list(char *appid, char *app_path,const char *caller, int pid, int pad_pid);
 int _status_update_app_info_list(int pid, int status);
 int _status_remove_app_info_list(int pid);
 int _status_get_app_info_status(int pid);
@@ -30,7 +30,9 @@ int _status_send_running_appinfo(int fd);
 int _status_app_is_running_v2(char *appid);
 int _status_send_running_appinfo_v2(int fd);
 int _status_get_appid_bypid(int fd, int pid);
-
+int _status_get_pkgid_bypid(int fd, int pid);
+char* _status_get_caller_by_appid(const char *appid);
+int _status_get_cooldown_status(void);
 
 
 
@@ -41,7 +43,13 @@ typedef struct _item_pkt_t {
        char appid[512];
 } item_pkt_t;
 
+#ifdef _APPFW_FEATURE_BG_PROCESS_LIMIT
 gboolean __add_item_running_list(gpointer user_data);
+#endif
 
-
+enum cooldown_status_val {
+       COOLDOWN_RELEASE,
+       COOLDOWN_WARNING,
+       COOLDOWN_LIMIT,
+};
 
diff --git a/aul-mobile.manifest b/aul-mobile.manifest
deleted file mode 100644 (file)
index 08d812c..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<manifest>
-       <define>
-               <domain name="aul"/>
-               <request>
-                       <smack request="aul::launch" type="x"/>
-                       <smack request="aul::terminate" type="x"/>
-                       <smack request="security-server::api-privilege-by-pid" type="w"/>
-                       <smack request="deviced::display" type="rw"/>
-               </request>
-               <provide>
-                       <label name="aul::db"/>
-                       <label name="aul::launch"/>
-                       <label name="aul::terminate"/>
-               </provide>
-       </define>
-       <assign>
-               <filesystem path="/usr/lib/libaul.so.0" label="_"/>
-               <filesystem path="/usr/lib/libaul.so.0.1.0" label="_"/>
-               <filesystem path="/usr/lib/systemd/system/ac.service" label="_" exec_label="none" />
-               <filesystem path="/usr/lib/systemd/system/launchpad-preload@.service" label="_" exec_label="none" />
-               <filesystem path="/usr/lib/systemd/system/graphical.target.wants/ac.service" label="_" exec_label="none" />
-               <filesystem path="/usr/lib/systemd/system/graphical.target.wants/launchpad-preload@app.service" label="_" exec_label="none" />
-       </assign>
-       <request>
-               <domain name="aul"/>
-       </request>
-</manifest>
similarity index 91%
rename from aul-wearable.manifest
rename to aul.manifest
index 0bf756f..979caa3 100644 (file)
@@ -5,7 +5,6 @@
                        <smack request="aul::launch" type="x"/>
                        <smack request="aul::terminate" type="x"/>
                        <smack request="security-server::api-privilege-by-pid" type="w"/>
-                       <smack request="deviced::display" type="rw"/>
                </request>
                <provide>
                        <label name="aul::db"/>
diff --git a/data/aul_mime.sh b/data/aul_mime.sh
deleted file mode 100755 (executable)
index 80a7153..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-usage()
-{
-       echo "----------------------------------------------------------"
-       echo "aul_mime.sh package_name mimetype1 mimetype2 ... mimetypeN"
-       echo "----------------------------------------------------------"
-}
-
-if [ -z $1 ] 
-then
-       echo "package name is NULL"
-       usage
-       exit
-fi
-
-if [ -z $2 ] 
-then
-       echo "mimetype is NULL"
-       usage
-       exit
-fi
-
-pkg=$1
-shift
-while [ "$*" != "" ]
-do
-       sqlite3 /opt/dbspace/.mida.db "insert into mida(pkg_name,mime_type) values ('$pkg','$1')"
-       shift
-done
diff --git a/data/aul_service.sh b/data/aul_service.sh
deleted file mode 100755 (executable)
index bae3153..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-usage()
-{
-       echo "--------------------------------------------------------------------------"
-       echo "aul_services.sh package_name service_name1 service_name2 ... service_nameN"
-       echo "--------------------------------------------------------------------------"
-}
-
-if [ -z $1 ] 
-then
-       echo "package name is NULL"
-       usage
-       exit
-fi
-
-if [ -z $2 ] 
-then
-       echo "service name is NULL"
-       usage
-       exit
-fi
-
-pkg=$1
-shift
-while [ "$*" != "" ]
-do
-       sqlite3 /opt/dbspace/.mida.db "insert into svc(pkg_name,svc_name) values ('$pkg','$1')"
-       shift
-done
diff --git a/data/aul_service_test.sh b/data/aul_service_test.sh
deleted file mode 100755 (executable)
index 31add47..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-usage()
-{
-       echo "---------------------------------"
-       echo "aul_service_test.sh service_name"
-       echo "---------------------------------"
-}
-
-if [ -z $1 ] 
-then
-       echo "service name is NULL"
-       usage
-       exit
-fi
-
-sqlite3 /opt/dbspace/.mida.db "insert into system_svc(svc_name) values ('$1')"
index 8b13789..2aab49d 100755 (executable)
@@ -1 +1,27 @@
 
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type1/landscape.jpg' where app_id = 'com.samsung.calendar'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type1/landscape.jpg' where app_id = 'com.samsung.myfile'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type1/landscape.jpg' where app_id = 'com.samsung.clock'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type1/landscape.jpg' where app_id = 'com.samsung.contacts'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type1/landscape.jpg' where app_id = 'com.samsung.voicerecorder'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type1/landscape.jpg' where app_id = 'com.samsung.message'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type1/landscape.jpg' where app_id = 'com.samsung.calculator'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type1/landscape.jpg' where app_id = 'com.samsung.call'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type1/landscape.jpg' where app_id = 'com.samsung.nfc-app'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type1/landscape.jpg' where app_id = 'com.samsung.gallery'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type1/landscape.jpg' where app_id = 'com.samsung.video-player'"
+
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' where app_id = 'com.samsung.dailybriefing-accuweather'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' where app_id = 'com.samsung.dailybriefing-yfinance'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type2/portrait.jpg' where app_id = 'com.samsung.dailybriefing-ynews'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type1/portrait.jpg' where app_id = 'com.samsung.music-player'"
+
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type2/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type2/landscape.jpg' where app_id = 'com.samsung.setting'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type2/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type2/landscape.jpg' where app_id = 'com.samsung.smartsearch'"
+
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type2/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type2/landscape.jpg' where app_id = 'com.samsung.email'"
+#sqlite3 /opt/dbspace/.pkgmgr_parser.db "update package_app_info set app_portraitimg = '/usr/share/splash_images/type2/portrait.jpg' , app_landscapeimg = '/usr/share/splash_images/type2/landscape.jpg' where app_id = 'com.samsung.helloworld'"
+
+
+
+
diff --git a/data/create_default_service.sh b/data/create_default_service.sh
deleted file mode 100755 (executable)
index d59541f..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-mkdir -p $OUTDIR
-pushd $OUTDIR
-
-mkdir -p contact/cmds
-mkdir -p contact/apps
-
-echo 0 > contact/cmds/create
-echo 0 > contact/cmds/view
-echo 0 > contact/cmds/edit
-echo 1 > contact/cmds/search
-echo "" > contact/apps/com.samsung.contacts
-
-mkdir -p calendar/cmds
-mkdir -p calendar/apps
-
-echo 0 > calendar/cmds/create
-echo 0 > calendar/cmds/view
-echo "" > calendar/apps/com.samsung.efl-calendar
-
-mkdir -p memo/cmds
-mkdir -p memo/apps
-
-echo 0 > memo/cmds/create
-echo 0 > memo/cmds/view
-echo "" > memo/apps/com.samsung.memo
-
-mkdir -p email/cmds
-mkdir -p email/apps
-
-echo 0 > email/cmds/create
-echo 0 > email/cmds/view
-echo "" > email/apps/com.samsung.email
-
-mkdir -p message/cmds
-mkdir -p message/apps
-
-echo 0 > message/cmds/create
-echo 0 > message/cmds/view
-echo "" > message/apps/com.samsung.message
-
-mkdir -p camera/cmds
-mkdir -p camera/apps
-
-echo 1 > camera/cmds/take_picture
-echo 1 > camera/cmds/rec_video
-echo 1 > camera/cmds/read_barcode
-echo "" > camera/apps/com.samsung.camera-app
-
-mkdir -p voice_record/cmds
-mkdir -p voice_record/apps
-
-echo 1 > voice_record/cmds/rec_voice
-echo "" > voice_record/apps/com.samsung.voicerecorder
-
-mkdir -p file_browser/cmds
-mkdir -p file_browser/apps
-
-echo 0 > file_browser/cmds/browse
-echo "" > file_browser/apps/com.samsung.myfile
-
-mkdir -p map/cmds
-mkdir -p map/apps
-
-echo 0 > map/cmds/show_place
-echo 0 > map/cmds/route_path
-
-mkdir -p alarm/cmds
-mkdir -p alarm/apps
-
-echo 0 > alarm/cmds/create
-echo "" > alarm/apps/com.samsung.alarm
-
-mkdir -p search/cmds
-mkdir -p search/apps
-
-echo 1 > search/cmds/search
-echo "" > search/apps/com.samsung.smartsearch
-
-mkdir -p voice_call/cmds
-mkdir -p voice_call/apps
-
-echo 0 > voice_call/cmds/mtcall
-echo 0 > voice_call/cmds/mocall
-echo "" > voice_call/apps/com.samsung.voice-call-ui
-
-mkdir -p video_call/cmds
-mkdir -p video_call/apps
-
-echo 0 > video_call/cmds/mtcall
-echo 0 > video_call/cmds/mocall
-echo "" > video_call/apps/com.samsung.vtmain
-
-popd 
-
-sync
-
diff --git a/data/mida_db.sql b/data/mida_db.sql
deleted file mode 100644 (file)
index 6fdaf1e..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-PRAGMA journal_mode = PERSIST;
-
-CREATE TABLE IF NOT EXISTS mida ( 
-       id INTEGER PRIMARY KEY, 
-       pkg_name TEXT, 
-       mime_type TEXT UNIQUE NOT NULL
-);
-
-CREATE TABLE IF NOT EXISTS svc ( 
-       id INTEGER PRIMARY KEY, 
-       pkg_name TEXT, 
-       svc_name TEXT UNIQUE NOT NULL
-);
-
-DROP TABLE IF EXISTS system_svc;
-
-CREATE TABLE IF NOT EXISTS system_svc ( 
-       id INTEGER PRIMARY KEY, 
-       svc_name TEXT UNIQUE NOT NULL
-);
-
-
-INSERT INTO system_svc(svc_name) VALUES ("create_alarm");
-INSERT INTO system_svc(svc_name) VALUES ("open_calendar");
-INSERT INTO system_svc(svc_name) VALUES ("create_event");
-INSERT INTO system_svc(svc_name) VALUES ("view_event");
-INSERT INTO system_svc(svc_name) VALUES ("take_picture");
-INSERT INTO system_svc(svc_name) VALUES ("record_video");
-INSERT INTO system_svc(svc_name) VALUES ("read_barcode");
-INSERT INTO system_svc(svc_name) VALUES ("search_contact");
-INSERT INTO system_svc(svc_name) VALUES ("create_email");
-INSERT INTO system_svc(svc_name) VALUES ("view_email");
-INSERT INTO system_svc(svc_name) VALUES ("browse_file");
-INSERT INTO system_svc(svc_name) VALUES ("create_memo");
-INSERT INTO system_svc(svc_name) VALUES ("view_memo");
-INSERT INTO system_svc(svc_name) VALUES ("create_message");
-INSERT INTO system_svc(svc_name) VALUES ("view_message");
-INSERT INTO system_svc(svc_name) VALUES ("search");
-INSERT INTO system_svc(svc_name) VALUES ("make_videocall");
-INSERT INTO system_svc(svc_name) VALUES ("make_voicecall");
-INSERT INTO system_svc(svc_name) VALUES ("record_voice");
-INSERT INTO system_svc(svc_name) VALUES ("play_music");
-INSERT INTO system_svc(svc_name) VALUES ("browse_web");
-INSERT INTO system_svc(svc_name) VALUES ("update_facebook");
-INSERT INTO system_svc(svc_name) VALUES ("update_twitter");
-INSERT INTO system_svc(svc_name) VALUES ("open_ebook");
-
diff --git a/data/service/README b/data/service/README
deleted file mode 100644 (file)
index 0be6f7c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-system service directory
diff --git a/effect_img/type0_portrait.jpg b/effect_img/type0_portrait.jpg
new file mode 100755 (executable)
index 0000000..8ff5727
Binary files /dev/null and b/effect_img/type0_portrait.jpg differ
diff --git a/effect_img/type1_portrait.jpg b/effect_img/type1_portrait.jpg
new file mode 100755 (executable)
index 0000000..4d8257e
Binary files /dev/null and b/effect_img/type1_portrait.jpg differ
diff --git a/effect_img/type2_portrait.jpg b/effect_img/type2_portrait.jpg
new file mode 100755 (executable)
index 0000000..3ae9b7b
Binary files /dev/null and b/effect_img/type2_portrait.jpg differ
diff --git a/effect_img/type3_portrait.jpg b/effect_img/type3_portrait.jpg
new file mode 100755 (executable)
index 0000000..5d5e3f9
Binary files /dev/null and b/effect_img/type3_portrait.jpg differ
diff --git a/effect_img/type4_portrait.jpg b/effect_img/type4_portrait.jpg
new file mode 100755 (executable)
index 0000000..3f3b97f
Binary files /dev/null and b/effect_img/type4_portrait.jpg differ
old mode 100755 (executable)
new mode 100644 (file)
index 37072c7..624c463
@@ -99,7 +99,7 @@ Caller application
 - The second parameter(bundle) give dictionary style's arguments to launched(callee) application.
 
 @code
-// the package name of this app is a "org.tizen.caller"
+// the package name of this app is a "com.samsung.caller"
 #include <aul.h>
 #include <bundle.h>
 void launch_func()
@@ -109,7 +109,7 @@ void launch_func()
        bundle_add(kb, "key1", "val1");
        bundle_add(kb, "key2", "val2");
        bundle_add(kb, "key3", "val3");
-       aul_launch_app("org.tizen.callee",kb);
+       aul_launch_app("com.samsung.callee",kb);
        bundle_free(kb);
 }
 @endcode
@@ -120,11 +120,11 @@ void launch_func()
 - If the application is not running, the application will be launched.
 
 @code
-// the package name of this app is a "org.tizen.caller"
+// the package name of this app is a "com.samsung.caller"
 #include <aul.h>
 void resume_func()
 {
-       aul_open_app("org.tizen.callee");
+       aul_open_app("com.samsung.callee");
 }
 @endcode
 
@@ -279,7 +279,7 @@ int main (int argc, char **argv)
 
 int main (int argc, char **argv)
 {
-       if(aul_app_is_running("org.tizen.app2"))
+       if(aul_app_is_running("com.samsung.app2"))
                printf("application is running");
 }
 @endcode
@@ -304,108 +304,7 @@ void set_dead_handler_func()
 @endcode
 @}
 
-@defgroup AUL_Use_Cases3 Launch Based on Mime Type
-@ingroup AUL_Use_Cases
-@{
-<h2 class="pg"> High Level APIs - launch based on mime type(filename, URI) </h2>
-
-- These AUL functions are used to launch the default application associated with the specified MIME extension. In addition, AUL provides functions to set/get the default application (package name) associated with a MIME type and functions to retrieve the MIME type associated with a specific file.
-
-- AUL launch default application associated with filename or url(or content)
-
-- AUL automatically launch "application selection popup" when AUL doesn't find default application.\n
-  App-Selector(application selection popup) shows list of application to process the file(or content).\n
-  User can select application from the list and open file with the application.\n
-  User can determine whether the selected application is set as default application or not.\n
-  If App-Selector doesn't find any application to process the file, App-Selector will show "Cannot get mimetype" or "Cannot find default application".
-
-@code
-// the package name of this app is a "org.tizen.caller"
-#include <aul.h>
-void func1(char* filename)
-{
-       aul_open_file(filename);
-}
-
-void func2(char* content)
-{
-       aul_open_content(content);
-}
-
-int main (int argc, char **argv)
-{
-       // launch the application to process 3gp.3gp file
-       func1("/opt/media/Videos/3gp.3gp");
-       // launch the application to process "http://www.samsung.com"
-       func2("http://www.samsung.com");
-}
-@endcode
-
-- We support primitive APIs for MIME operation
-       - aul_get_mime_from_content
-       - aul_get_mime_from_file
-       - aul_get_defapp_from_mime
-       - aul_set_defapp_with_mime
-
-This is example to launch MIME default applications using primitive APIs
-
-@code
-// the package name of this app is a "org.tizen.caller"
-
-#include <aul.h>
-#include <bundle.h>
-
-int main (int argc, char **argv)
-{
-       int ret;
-       char mimetype[128];
-       char defapp[128];
-       bundle *kb;
-
-       // get MIME type of "3gp.3gp"
-       if( aul_get_mime_from_file("3gp.3gp",mimetype,sizeof(mimetype)) <0)
-               return -1;
-       printf("3gp.3gp's mime type is %s",mimetype);
-
-       // get default application of the mimetype
-       if( aul_get_defapp_from_mime(mimetype,defapp,sizeof(defapp)) < 0)
-               return -1;
-       printf("%s types default application is %s\n", mimetype, defapp);
-
-       // Launch the default application with specific mime key
-       kb = bundle_create();
-       bundle_add(kb, AUL_K_MIME_TYPE, mimetype);
-       bundle_add(kb, AUL_K_MIME_CONTENT, "3gp.3gp");
-       aul_launch_app(defapp, kb);
-       bundle_free(kb);
-}
-@endcode
-
-
-- In callee, if you want to process specific MIME type
-  First, you must add mimetype field at desktop file
-  Second, you must process special key "AUL_K_MIME_TYPE", "AUL_K_MIME_CONTENT"
-
-@code
-// the package name of this app is a "org.tizen.callee"
-#include <aul.h>
-#include <bundle.h>
-
-// AppCore Reset Handler
-static int app_reset(bundle *b, void *data)
-{
-       char* mime_type;
-
-       mime_type = bundle_get_val(b, AUL_K_MIME_TYPE);
-       if (!mime_type)
-               return 0;
-       else
-               process_mime(mime_type, bundle_get_val(AUL_K_MIME_CONTENT));
-}
-@endcode
-@}
-
-@defgroup AUL_Use_Cases4 Launch Based on Service Name and Command
+@defgroup AUL_Use_Cases3 Launch Based on Service Name and Command
 @ingroup AUL_Use_Cases
 @{
 <h2 class="pg"> High Level APIs - launch based on service name and command </h2>
@@ -418,7 +317,7 @@ static int app_reset(bundle *b, void *data)
 - the API is asynchronous.(non-blocking API)
 
 @code
-// the package name of this app is a "org.tizen.caller"
+// the package name of this app is a "com.samsung.caller"
 #include <aul.h>
 #include <bundle.h>
 void cb_func( bundle* kb, int reserved, void* data)
@@ -446,7 +345,7 @@ void service_launch_func()
 
 @code
 // Callee application
-// the package name of this app is a "org.tizen.callee"
+// the package name of this app is a "com.samsung.callee"
 
 #include <aul.h>
 #include <bundle.h>
index 67ce1d6..112a9e4 100755 (executable)
  */
 
 
-#ifndef __APP_DBUS_H__
-#define __APP_DBUS_H__
+#ifndef __APP_SIGNAL_H__
+#define __APP_SIGNAL_H__
 
-#include <glib.h>
 #include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
 
 #define AUL_DBUS_PATH "/aul/dbus_handler"
-#ifdef WEARABLE_PROFILE
 #define AUL_DBUS_SIGNAL_INTERFACE "com.samsung.aul.signal"
-#else
-#define AUL_DBUS_SIGNAL_INTERFACE "org.tizen.aul.signal"
-#endif
 #define AUL_DBUS_APPDEAD_SIGNAL        "app_dead"
 #define AUL_DBUS_APPLAUNCH_SIGNAL      "app_launch"
 #define AUL_DBUS_HOMELAUNCH_SIGNAL     "home_launch"
 
+#ifdef _APPFW_FEATURE_CPU_BOOST
 #define SYSTEM_BUS_NAME       "org.tizen.system.deviced"
-
 #define SYSTEM_OBJECT_PATH    "/Org/Tizen/System/DeviceD/PmQos"
 #define SYSTEM_INTERFACE_NAME "org.tizen.system.deviced.PmQos"
 #define SYSTEM_METHOD_NAME    "AppLaunch"
+#endif
 
 #define SYSTEM_PATH_CORE       "/Org/Tizen/System/DeviceD/Core"
 #define SYSTEM_INTERFACE_CORE  "org.tizen.system.deviced.core"
 
 #define SYSTEM_SIGNAL_BOOTING_DONE             "BootingDone"
 
+#define SYSTEM_PATH_SYSNOTI            "/Org/Tizen/System/DeviceD/SysNoti"
+#define SYSTEM_INTERFACE_SYSNOTI       "org.tizen.system.deviced.SysNoti"
+
+#define SYSTEM_SIGNAL_COOLDOWN_CHANGED         "CoolDownChanged"
+
+#define RESOURCED_PATH_CORE            "/Org/Tizen/ResourceD/Process"
+#define RESOURCED_INTERFACE_CORE       "org.tizen.resourced.process"
+
+#define RESOURCED_SIGNAL_PROCESS_STATUS                "ProcStatus"
+
+#define ROTATION_BUS_NAME       "org.tizen.system.coord"
+#define ROTATION_OBJECT_PATH    "/Org/Tizen/System/Coord/Rotation"
+#define ROTATION_INTERFACE_NAME "org.tizen.system.coord.rotation"
+#define ROTATION_METHOD_NAME    "Degree"
+
+#define RESOURCED_PROC_OBJECT          "/Org/Tizen/ResourceD/Process"
+#define RESOURCED_PROC_INTERFACE       "org.tizen.resourced.process"
+#define RESOURCED_PROC_METHOD          "ProcExclude"
+
+#define RESOURCED_PROC_WATCHDOG_SIGNAL "ProcWatchdog"
+
+#define PROC_TYPE_EXCLUDE              "exclude"
+#define PROC_TYPE_INCLUDE              "include"
+#define PROC_TYPE_WAKEUP               "wakeup"
+
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+#define DEVICED_PATH_DISPLAY   "/Org/Tizen/System/DeviceD/Display"
+#define DEVICED_INTERFACE_DISPLAY      "org.tizen.system.deviced.display"
+
+#define DEVICED_SIGNAL_LCD_ON                  "LCDOn"
+#define DEVICED_SIGNAL_LCD_OFF         "LCDOff"
+#endif
 #endif
index 86324c9..1664001 100755 (executable)
@@ -34,17 +34,20 @@ enum app_cmd {
        APP_RESUME,
        APP_RESUME_BY_PID,
        APP_TERM_BY_PID,
+       APP_TERM_BY_PID_WITHOUT_RESTART,
        APP_RESULT,
        APP_START_RES,
        APP_CANCEL,
        APP_KILL_BY_PID,
        APP_ADD_HISTORY,
        APP_RUNNING_INFO,
+       APP_RUNNING_INFO_MEMORY,
        APP_RUNNING_INFO_RESULT,
        APP_IS_RUNNING,
        APP_GET_APPID_BYPID,
-       APP_GET_APPID_BYPID_OK,
-       APP_GET_APPID_BYPID_ERROR,
+       APP_GET_PKGID_BYPID,
+       APP_GET_INFO_OK,
+       APP_GET_INFO_ERROR,
        APP_KEY_EVENT,
        APP_KEY_RESERVE,
        APP_KEY_RELEASE,
@@ -52,19 +55,39 @@ enum app_cmd {
        APP_RELEASED,
        APP_RUNNING_LIST_UPDATE,
        APP_TERM_REQ_BY_PID,
-       APP_START_ASYNC
+       APP_START_ASYNC,
+       APP_TERM_BY_PID_ASYNC,
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+       APP_START_MULTI_INSTANCE,
+#endif
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+       APP_PAUSE_LCD_OFF,
+       APP_RESUME_LCD_ON,
+#endif
 };
 
 #define AUL_SOCK_PREFIX "/tmp/alaunch"
 #define AUL_SOCK_MAXBUFF 65535
 #define LAUNCHPAD_PID -1
 #define WEB_LAUNCHPAD_PID -3
+#ifdef _APPFW_FEATURE_DEBUG_LAUNCHPAD
 #define DEBUG_LAUNCHPAD_PID -4
+#endif
+#ifdef _APPFW_FEATURE_PROCESS_POOL
 #define PROCESS_POOL_LAUNCHPAD_PID -5
+#endif
+#ifdef _APPFW_FEATURE_NATIVE_LAUNCHPAD
+#define NATIVE_LAUNCHPAD_PID -6
+#endif
 #define ELOCALLAUNCH_ID 128
 #define EILLEGALACCESS 127
 #define ETERMINATING 126
 #define ENOLAUNCHPAD 125
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+#define EUGLOCAL_LAUNCH 124
+#endif
+#define EREJECTED 123
+
 
 typedef struct _app_pkt_t {
        int cmd;
index ef7353d..48bc10d 100755 (executable)
@@ -70,6 +70,11 @@ extern "C" {
  * @brief Return values in AUL.
  */
 typedef enum _aul_return_val {
+       AUL_R_EREJECTED = -14,  /**< App disable for mode*/
+       AUL_R_ENOAPP = -13,             /**< Failed to find app ID or pkg ID */
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+       AUL_R_UG_LOCAL = -12,
+#endif
        AUL_R_EHIDDENFORGUEST = -11,    /**< App hidden for guest mode */
        AUL_R_ENOLAUNCHPAD = -10,       /**< no launchpad */
        AUL_R_ETERMINATING = -9,        /**< application terminating */
@@ -123,7 +128,11 @@ enum app_status {
 typedef enum _aul_type{
        AUL_START,
        AUL_RESUME,
-       AUL_TERMINATE
+       AUL_TERMINATE,
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+       AUL_PAUSE_LCD_OFF,
+       AUL_RESUME_LCD_ON,
+#endif
 }aul_type;
 
 /** AUL internal private key */
@@ -180,9 +189,6 @@ typedef enum _aul_type{
 /** AUL public key - To support Media key */
 #define AUL_K_MULTI_KEY_EVENT  "__AUL_MULTI_KEY_EVENT__"
 
-/** AUL public bundle value */
-#define AUL_K_PRIVACY_APPID            "__AUL_PRIVACY_APPID__"
-
 /** AUL public bundle value - To support Media key*/
 #define AUL_V_KEY_PRESSED      "__AUL_KEY_PRESSED__"
 /** AUL public bundle value - To support Media key*/
@@ -204,9 +210,21 @@ typedef enum _aul_type{
 #define AUL_K_APPID            "__AUL_APPID__"
 /** AUL internal private key */
 #define AUL_K_PID              "__AUL_PID__"
+/** AUL internal private key */
+#define AUL_K_PRELAUCHING      "__AUL_PRELAUCHING__"
 
-#define PRIVACY_POPUP "tizenprv00.privacy-popup"
+#ifdef _APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP
+/** AUL internal private key - To distinguish between Contacts and Phone */
+#define AUL_K_INTERNAL_APPID   "__AUL_INTERNAL_APPID__"
+#endif
+
+#ifdef _APPFW_FEATURE_PROCESS_POOL
+#define AUL_K_LAUNCHPAD_TYPE   "__AUL_LAUNCHPAD_TYPE__"
+#endif
 
+#ifdef _APPFW_FEATURE_DATA_CONTROL
+#define AUL_K_DATA_CONTROL_TYPE   "__AUL_DATA_CONTROL_TYPE__"
+#endif
 
 /**
  * @brief      This is callback function for aul_launch_init
@@ -440,7 +458,7 @@ int aul_launch_local(bundle *b);
  * @return     callee's pid if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invaild package name
- * @retval     AUL_R_ECOM      - internal AUL IPC error
+ * @retval     AUL_R_ECOMM     - internal AUL IPC error
  * @retval     AUL_R_ERROR     - general error
  *
  * @pre
@@ -459,6 +477,7 @@ int aul_launch_local(bundle *b);
  *     b = bundle_create();
  *     bundle_add(b,"type","SIM");
  *     aul_launch_app("org.tizen.contact",b);
+ *     iuu
  * }
  *
  * @endcode
@@ -485,7 +504,7 @@ int aul_launch_app(const char *appid, bundle *kb);
  * @return     callee's pid if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invaild package name
- * @retval     AUL_R_ECOM      - internal AUL IPC error
+ * @retval     AUL_R_ECOMM     - internal AUL IPC error
  * @retval     AUL_R_ERROR     - general error
  *
  * @pre
@@ -529,7 +548,7 @@ int aul_open_app(const char *appid);
  * @return     callee's pid if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invaild package name
- * @retval     AUL_R_ECOM      - internal AUL IPC error
+ * @retval     AUL_R_ECOMM     - internal AUL IPC error
  * @retval     AUL_R_ERROR     - general error
  *
  * @pre
@@ -577,7 +596,7 @@ int aul_resume_app(const char *appid);
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invaild pid
- * @retval     AUL_R_ECOM      - internal AUL IPC error
+ * @retval     AUL_R_ECOMM     - internal AUL IPC error
  * @retval     AUL_R_ERROR     - general error (include application is not running)
  * @warning    This API need to require root or inhouse permisssion \n
  *             If you have not the permission, this API return AUL_R_ERROR. \n
@@ -625,7 +644,7 @@ int aul_resume_pid(int pid);
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invaild pid
- * @retval     AUL_R_ECOM      - internal AUL IPC error
+ * @retval     AUL_R_ECOMM     - internal AUL IPC error
  * @retval     AUL_R_ERROR     - general error
  * @warning    This API need to require root or inhouse permisssion. \n
  *
@@ -655,6 +674,9 @@ int aul_resume_pid(int pid);
  *     If you have not the permission, this API return AUL_R_ERROR. \n
 */
 int aul_terminate_pid(int pid);
+int aul_terminate_pid_without_restart(int pid);
+int aul_terminate_pid_async(int pid);
+
 
 /** @} */
 
@@ -775,6 +797,22 @@ int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
 
 /**
  * @par Description:
+ *     This API use to get running application list from the proc file system.
+ *     This API call iter_fn with each aul_app_info of running apps when running application is found.
+ *
+ * @param[in]  iter_fn         iterator function
+ * @param[in]  data            user-supplied data for iter_fn
+ * @return     0 if success, negative value(<0) if fail
+ * @retval     AUL_R_OK        - success
+ * @retval     AUL_R_ERROR     - internal error
+ */
+int aul_get_running_app_info_from_proc(aul_app_info_iter_fn iter_fn, void *data);
+
+int aul_get_running_app_info_from_memory(aul_app_info_iter_fn iter_fn, void *data);
+
+
+/**
+ * @par Description:
  *     This API get application package name by pid
  * @par Purpose:
  *     If you want to get package name of running application, use this API
@@ -851,6 +889,8 @@ int aul_app_get_pkgname_bypid(int pid, char *pkgname, int len);
 */
 int aul_app_get_appid_bypid(int pid, char *appid, int len);
 
+int aul_app_get_pkgid_bypid(int pid, char *pkgid, int len);
+
 
 /** @} */
 
@@ -877,222 +917,6 @@ int aul_app_get_appid_bypid(int pid, char *appid, int len);
 
 /**
  * @par Description:
- *     This API launch application associated with given filename
- * @par Purpose:
- *      This API is for caller.
- *     This API launch application based on mime type.
- *     This API find mime_type associated with file name,
- *     and then find default app associated with found mime_type
- *     and then launch the app with filename argument.
- * @par Typical use case:
- *     You can launch application to process given filename.
- *     That is, Even if you don't know the specific application's pkgname,
- *     you can launch the applicaiton processing given filename .
- *     For example, If you want to process image file, you can simply launch image viewer.
- *     At that time, you can use this APIs like aul_open_file("myimage.jpg");
- *
- * @param[in]  filename        filename
- * @return     callee's pid or 0 if success, negative value if fail\n
- *              (when no found default app, return 0)
- * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invalid argument(filename)
- * @retval     AUL_R_ECOM      - internal AUL IPC error
- * @retval     AUL_R_ERROR     - general error
- *
- * @pre
- *     None
- * @post
- *     None
- * @see
- *     None
- * @code
- * #include <aul.h>
- *
- * int view_image_file(char *filename)
- * {
- *      aul_open_file(filename);
- * }
- *
- * @endcode
- * @remark
- *     None
- *
- */
-int aul_open_file(const char* filename);
-
-/**
- * @par Description:
- *     This API launch application associated with given specific mimetype
- * @par Purpose:
- *      This API is for caller.
- *     This API launch application based on mime type like aul_open_file API.
- *     But, This API don't find mime_type associated with file name.
- *     This API use mimetype given by user. By using given mimetype, find default application.
- *     and then launch the app with filename argument.
- * @par Typical use case:
- *     Some files cannot extract exact mimetype automatically.
- *     For example, To know mime type of files with DRM lock, first we should unlock DRM file.
- *     In this case, You can use this API.
- *     First, unlock DRM file, and extract mimetype from unlock file by using aul_get_mime_from_file,
- *     and then, use this API with DRM file and extracted mime type.
- *
- * @param[in]  filename        filename
- * @param[in]  mimetype        specific mimetype
- * @return     callee's pid or 0 if success, negative value if fail\n
- *              (when no found default app, return 0)
- * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invalid argument(filename,mimetype)
- * @retval     AUL_R_ECOM      - internal AUL IPC error
- * @retval     AUL_R_ERROR     - general error
- *
- * @pre
- *     None
- * @post
- *     None
- * @see
- *     aul_open_file, aul_get_mime_from_file
- * @code
- * #include <aul.h>
- *
- * int view_drm_image_file(char *drm_filename)
- * {
- *     char* mimetype;
- *     // you must implement this function
- *     mimetype = get_mimetype_from_drmfile(drm_filename);
- *
- *      aul_open_file_with_mimetype(drm_filename,mimetype);
- * }
- *
- * @endcode
- * @remark
- *     None
- */
-int aul_open_file_with_mimetype(const char *filename, const char *mimetype);
-
-/**
- * @par Description:
- *     This API launch application associated with content like "http://www.samsung.com"
- * @par Purpose:
- *      This API is for caller.
- *     This API launch application based on mime type.
- *     This API find mime_type associated with content,
- *     and then find default app associated with found mime_type,
- *     and then launch the app with content argument.
- * @par Typical use case:
- *     You can launch application to process given content.
- *     That is, Even if you don't know the specific application's pkgname,
- *     you can launch the applicaiton processing given content.
- *     For example, If you want to process URL "http://www.samsung.com",
- *     you can simply launch browser.
- *     At that time, you can use this APIs like aul_open_content("http://www.samsung.com");
- *
- * @param[in]   content                content
- * @return     callee's pid or 0 if success, negative value if fail\n
- *              (when no found default app, return 0)
- * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invalid argument(content)
- * @retval     AUL_R_ECOM      - internal AUL IPC error
- * @retval     AUL_R_ERROR     - general error or no found mimetype
- *
- * @pre
- *     None
- * @post
- *     None
- * @see
- *     None
- * @code
- * #include <aul.h>
- *
- * int view_url(char *url)
- * {
- *      aul_open_content(url);
- * }
- *
- * @endcode
- * @remark
- *     None
- *
- */
-int aul_open_content(const char* content);
-
-/**
- * @par Description:
- *      This API get the default application(appid) associated with MIME type
- * @par Purpose:
- *     This API use to get default application associteted with mimetype
- *     In general, Setting Application need this API.
- * @par Typical use case:
- *     Setting Application show mapping of default application / mimetype
- *
- * @param[in]  mimetype        a mime type
- * @param[out] defapp          a application appid of the app
- * @param[in]  len             length of defapp
- * @return     0 if success, negative value if fail
- * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invalid argument(mimetype)
- * @retval     AUL_R_ERROR     - general error or no found mimetype
- *
- * @pre
- *     None
- * @post
- *     None
- * @see
- *     aul_set_defapp_with_mime
- * @code
- * #include <aul.h>
- *
- * void get_text_html_defapp()
- * {
- *     char appname[255];
- *     aul_get_defapp_from_mime("text/html",appname,sizeof(appname));
- * }
- *
- * @endcode
- * @remark
- *     None
- *
- */
-int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len);
-
-/**
- * @par Description:
- *      This API set the default application(appid) associated with MIME type
- * @par Purpose:
- *     This API use to change default application associteted with mimetype
- *     In general, Setting Application or Installer need this API.
- * @par Typical use case:
- *     Default Application associated with mimetype can be changed by Setting Application or installer
- *     So, application to process specific mimetype can be substituted.
- *
- * @param[in]  mimetype        a mime type
- * @param[in]  defapp          a application appid of the app to be set
- * @return     0 if success, negative value if fail
- * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invalid argument(mimetype)
- * @retval     AUL_R_ERROR     - general error
- *
- * @pre
- *     None
- * @post
- *     None
- * @see
- *     aul_get_defapp_from_mime
- * @code
- * #include <aul.h>
- *
- * void set_text_html_defapp()
- * {
- *     aul_set_defapp_with_mime("text/html","org.tizen.browser");
- * }
- *
- * @endcode
- * @remark
- *     None
-*/
-int aul_set_defapp_with_mime(const char *mimetype, const char *defapp);
-
-/**
- * @par Description:
  *     This API get the mimetype associated with filename
  * @par Purpose:
  *     This API use to get mimetype associteted with given filename
@@ -1291,19 +1115,6 @@ int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
  */
 int aul_get_mime_description(const char *mimetype, char *desc, int len);
 
-/************************************************************************************************/
-/* Example of aul_open_content or aul_open_file                                                        */
-/* voice call , browser , docview , image viewer , audio player, video player                   */
-/*                                                                                              */
-/* voice call - aul_open_content("callto://011-1111-1111");                                     */
-/* browser -    aul_open_content("http://www.naver.com");                                       */
-/*         -    aul_open_file("/opt/share/index.html");                                         */
-/* docview -    aul_open_file("/opt/share/word.pdf");                                           */
-/* image view - aul_open_file("/opt/share/image.jpg");                                          */
-/* audio play - aul_open_file("/opt/share/audio.mp3");                                          */
-/* video play - aul_open_file("/opt/share/video.mpg");                                          */
-/************************************************************************************************/
-
 /** @} */
 
 /**
@@ -1340,62 +1151,6 @@ typedef void (*aul_service_res_fn)(bundle *b, int reserved, void *user_data);
 
 /**
  * @par Description:
- *     This API launch application based on service.
- * @par Purpose:
- *      This API is for caller.
- *     This API launch application based on service name.
- *     This API find default application associated with service name.
- *     and then launch the application with given bundle.
- * @par Typical use case:
- *     You can launch application provided the service if you know service name.
- *     That is, even if you don't know the specific application's pkgname,
- *     you can launch the applicaiton by requesting the service.
- *     For example, If you want to take a picture in your app, you can simply launch camera application.
- *     At that time, you can use this API like aul_open_service(TAKE_PICTURE_SVC,..);
- *
- *
- * @param[in]   svcname         service name to launch as callee
- * @param[in]   b               bundle to be passed to callee
- * @param[in]   cbfunc          result callback function
- * @param[in]   data            user-supplied data passed to callback function
- * @return      callee's pid if success, negative value(<0) if fail
- * @retval      AUL_R_OK        - success
- * @retval      AUL_R_EINVAL    - invaild service name
- * @retval      AUL_R_ENOINIT   - you must initilize aul library with aul_launch_init
- * @retval      AUL_R_ECOM      - internal AUL IPC error
- * @retval      AUL_R_ERROR     - general error
- *
- * @pre
- *     None
- * @post
- *     None
- * @see
- *     None
- * @code
- * #include <aul.h>
- * #include <aul_service.h>
- * #include <bundle.h>
- *
- * void res_func(bundle *b, int reserved, void *user_data)
- * {
- *     // process result bundle
- * }
- *
- * int create_camera_view()
- * {
- *      aul_open_service(TAKE_PICTURE_SVC, NULL, res_func, NULL);
- * }
- *
- * @endcode
- * @remark
- *     This API can wait result (asynchronous).
- *     To see kinds of default service provided by platform, see "aul_service.h" header file
- *
- */
-int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc, void *data);
-
-/**
- * @par Description:
  *     This API create service result bundle based on bundle received in reset event.
  * @par Purpose:
  *     This API use to create result bundle to send it to caller.
@@ -1408,7 +1163,7 @@ int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc,
  * @param[out]  outb            bundle to use for returning result
  * @return      0 if success, negative value(<0) if fail
  * @retval      AUL_R_OK        - success
- * @retval      AUL_R_EINVAL    - inb is not bundle created by aul_open_service
+ * @retval      AUL_R_EINVAL    - inb is not bundle
  * @retval      AUL_R_ERROR     - general error
  *
  * @pre
@@ -1490,85 +1245,6 @@ int aul_send_service_result(bundle *b);
 
 /**
  * @par Description:
- *     This API set the default application(appid) associated with service name
- * @par Purpose:
- *     This API use to change default application associteted with service name
- *     In general, Setting Application needs this API.
- * @par Typical use case:
- *     Default Application associated with service name can be changed by Setting Application
- *     So, Inhouse service application can be substituted by 3rd party service application
- *
- * @param[in]  svcname         service string like "create_contact"
- * @param[in]  defapp          default application like "org.tizen.contact"
- * @return     0 if success, negative value if fail
- * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invalid argument(content)
- * @retval     AUL_R_ERROR     - general error
- *
- * @pre
- *     None
- * @post
- *     None
- * @see
- *     aul_get_defapp_for_service
- * @code
- * #include <aul.h>
- * #include <aul_service.h>
- *
- * void set_camera_service_defapp()
- * {
- *     aul_set_defapp_for_service(TAKE_PICTURE_SVC,"org.tizen.camera");
- * }
- *
- * @endcode
- * @remark
- *     None
- *
- */
-int aul_set_defapp_for_service(const char *svcname, const char *defapp);
-
-/**
- * @par Description:
- *     This API get the application appid associated with given service name
- * @par Purpose:
- *     This API use to get default application associteted with service name
- *     In general, Setting Application need this API.
- * @par Typical use case:
- *     Setting Application show mapping of default application/ service
- *
- * @param[in]  svcname         service string like "create_contact"
- * @param[out] defapp          default application
- * @param[in]  len             length of defapp
- * @return     0 if success, negative value if fail
- * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invalid argument(content)
- * @retval     AUL_R_ERROR     - general error
- *
- * @pre
- *     None
- * @post
- *     None
- * @see
- *     aul_set_defapp_for_service
- * @code
- * #include <aul.h>
- * #include <aul_service.h>
- *
- * void get_camera_service_defapp()
- * {
- *     char appname[255];
- *     aul_get_defapp_for_service(TAKE_PICTURE_SVC,appname,sizeof(appname));
- * }
- *
- * @endcode
- * @remark
- *     None
- *
- */
-int aul_get_defapp_for_service(const char *svcname, char *defapp, int len);
-
-/**
- * @par Description:
  *     This API sets callback fuction that will be called when applications die.
  * @par Purpose:
  *     This API's purpose is to listen the application dead event.
@@ -1647,6 +1323,27 @@ int aul_listen_app_dead_signal(int (*func) (int, void *), void *data);
  */
 int aul_listen_app_launch_signal(int (*func) (int, void *), void *data);
 
+int aul_listen_booting_done_signal(int (*func) (int, void *), void *data);
+
+int aul_listen_cooldown_signal(int (*func) (const char *, void *), void *data);
+
+const char *aul_get_app_external_root_path(void);
+const char *aul_get_app_root_path(void);
+const char *aul_get_app_data_path(void);
+const char *aul_get_app_cache_path(void);
+const char *aul_get_app_resource_path(void);
+const char *aul_get_app_shared_data_path(void);
+const char *aul_get_app_shared_resource_path(void);
+const char *aul_get_app_shared_trusted_path(void);
+const char *aul_get_app_external_data_path(void);
+const char *aul_get_app_external_cache_path(void);
+const char *aul_get_app_external_shared_data_path(void);
+const char *aul_get_app_specific_path(void);
+const char *aul_get_app_external_specific_path(void);
+int aul_get_app_shared_data_path_by_appid(const char *app_id, char **path);
+int aul_get_app_shared_resource_path_by_appid(const char *app_id, char **path);
+int aul_get_app_shared_trusted_path_by_appid(const char *app_id, char **path);
+int aul_get_app_external_shared_data_path_by_appid(const char *app_id, char **path);
 
 typedef int (*subapp_fn)(void *data);
 
@@ -1656,15 +1353,45 @@ int aul_is_subapp(void);
 int aul_add_caller_cb(int pid,  void (*caller_cb) (int, void *), void *data);
 int aul_remove_caller_cb(int pid);
 
+#ifdef _APPFW_FEATURE_PROCESS_POOL
 void aul_set_preinit_window(void *evas_object);
-void* aul_get_preinit_window(void);
+void* aul_get_preinit_window(const char *win_name);
+
+void aul_set_preinit_background(void *evas_object);
+void* aul_get_preinit_background(void);
+
+void aul_set_preinit_conformant(void *evas_object);
+void* aul_get_preinit_conformant(void);
+#endif
 
 void aul_set_preinit_appid(const char *appid);
 
 int aul_launch_app_async(const char *appid, bundle *kb);
 
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+int aul_launch_app_for_multi_instance(const char *appid, bundle *kb);
+#endif
+
+int aul_update_freezer_status(int pid, const char* type);
+
 int aul_status_update(int status);
 
+int aul_get_app_allocated_memory(void);
+
+long long aul_get_app_running_time(void);
+
+int aul_listen_e17_status_signal(int (*func) (int, int, void *), void *data);
+
+#ifdef _APPFW_FEATURE_DATA_CONTROL
+typedef int (*data_control_provider_handler_fn) (bundle *b, int request_id, void *data);
+int aul_set_data_control_provider_cb(data_control_provider_handler_fn handler);
+int aul_unset_data_control_provider_cb(void);
+#endif
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+int aul_call_ug_result_callback(bundle *kb, int is_cancel, int id);
+#endif
+
+int aul_get_support_legacy_lifecycle(void);
 
 /** @} */
 
diff --git a/include/aul_service.h b/include/aul_service.h
deleted file mode 100755 (executable)
index f34e650..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *  aul
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-/**
- * @addtogroup aul_service
- * @{
- */
-
-/** alarm app_service, 1 svc */
-#define CREATE_ALARM_SVC               "create_alarm"
-
-/** calendar app_service , 3 svc */
-#define OPEN_CALENDAR_SVC              "open_calendar"
-#define CREATE_EVENT_SVC               "create_event"
-#define VIEW_EVENT_SVC                 "view_event"
-
-/** camera app_service , 3 svc */
-#define TAKE_PICTURE_SVC               "take_picture"  /* have result*/
-#define RECORD_VIDEO_SVC               "record_video"  /* have result*/
-#define READ_BARCODE_SVC               "read_barcode"  /* have result*/
-
-/** contact app_service , 1 svs */
-#define SEARCH_CONTACT_SVC             "search_contact"
-
-/** email app_service , 2 svc */
-#define CREATE_EMAIL_SVC               "create_email"
-#define VIEW_EMAIL_SVC                 "view_email"
-
-/** file browser app_service, 1 svc */
-#define BROWSE_FILE_SVC                        "browse_file"
-
-/** memo app_service , 2 svc */
-#define CREATE_MEMO_SVC                        "create_memo"
-#define VIEW_MEMO_SVC                  "view_memo"
-
-/** message(sms,mms) app_service , 2 svc */
-#define CREATE_MESSAGE_SVC             "create_message"
-#define VIEW_MESSAGE_SVC               "view_message"
-
-/** search app_service, 1 svc */
-#define SEARCH_SVC                     "search"
-
-/** video call app_service, 1 svc */
-#define MAKE_VIDEOCALL_SVC             "make_videocall"
-
-/** voice call app_service, 1 svc */
-#define MAKE_VOICECALL_SVC             "make_voicecall"
-
-/** voice record app_service, 1 svc */
-#define RECORD_VOICE_SVC               "record_voice"  /* have result*/
-
-/** music player app_service, 1 svc */
-#define PLAY_MUSIC_SVC                 "play_music"
-
-/** web browser app_service, 1 svc */
-#define BROWSE_WEB_SVC                 "browse_web"
-
-/** facebook app_service, 1 svc */
-#define UPDATE_FACEBOOK_SVC    "update_facebook"
-
-/** twitter app_service, 1 svc */
-#define UPDATE_TWITTER_SVC             "update_twitter"
-
-/** ebook app_service, 1 svc */
-#define OPEN_EBOOK_SVC                 "open_ebook"
index d6f300d..f93e518 100755 (executable)
@@ -32,6 +32,7 @@
 typedef struct _app_status_info_t{
        char appid[MAX_PACKAGE_STR_SIZE];
        char app_path[MAX_PACKAGE_APP_PATH_SIZE];
+       char caller[MAX_PACKAGE_STR_SIZE];
        int status;
        int pid;
        int pad_pid;
index e80b068..0624542 100755 (executable)
@@ -52,6 +52,7 @@ typedef struct {
        char *pkg_type;         /* x_slp_packagetype */
        char *hwacc;            /* hwacceleration */
        char *taskmanage;       /* taskmanage */
+       char *pkg_id;
 } app_info_from_db;
 
 static inline char *_get_pkgname(app_info_from_db *menu_info)
@@ -59,6 +60,11 @@ static inline char *_get_pkgname(app_info_from_db *menu_info)
        return menu_info ? menu_info->pkg_name : NULL;
 }
 
+static inline char *_get_pkgid(app_info_from_db *menu_info)
+{
+       return menu_info ? menu_info->pkg_id : NULL;
+}
+
 static inline char *_get_app_path(app_info_from_db *menu_info)
 {
        int i = 0;
@@ -105,8 +111,14 @@ static inline void _free_app_info_from_db(app_info_from_db *menu_info)
                        free(menu_info->app_path);
                if (menu_info->original_app_path != NULL)
                        free(menu_info->original_app_path);
+               if (menu_info->pkg_type != NULL)
+                       free(menu_info->pkg_type);
                if (menu_info->hwacc != NULL)
                        free(menu_info->hwacc);
+               if (menu_info->taskmanage != NULL)
+                       free(menu_info->taskmanage);
+               if (menu_info->pkg_id != NULL)
+                       free(menu_info->pkg_id);
                free(menu_info);
        }
 }
@@ -168,6 +180,7 @@ static inline ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *use
 {
        app_info_from_db *menu_info = (app_info_from_db *)user_data;
        char *package;
+       char *pkgid;
        ail_cb_ret_e ret = AIL_CB_RET_CONTINUE;
 
        if (!menu_info)
@@ -179,6 +192,11 @@ static inline ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *use
                ret = AIL_CB_RET_CANCEL;
        }
 
+       ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_PKGID_STR, &pkgid);
+       if (pkgid) {
+               menu_info->pkg_id = strdup(pkgid);
+       }
+
        return ret;
 }
 
diff --git a/include/mida.h b/include/mida.h
deleted file mode 100755 (executable)
index 271f951..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *  aul
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-#ifndef __MIDA_H__
-#define __MIDA_H__
-
-#include <sqlite3.h>
-#include <time.h>
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int mida_clear(void);
-int mida_delete_with_pkgname(const char *pkg_name);
-int mida_delete_with_mimetype(const char *mime_type);
-int mida_add_app(const char *mime_type, const char *pkg_name);
-char *mida_get_app(const char *mime_type);
-
-int svc_clear(void);
-int svc_delete_with_pkgname(const char *pkg_name);
-int svc_delete_with_svcname(const char *svc_name);
-int svc_add_app(const char *svc_name, const char *pkg_name);
-char *svc_get_app(const char *svc_name);
-
-int is_supported_svc(const char *svc_name);
-#ifdef __cplusplus
-}
-#endif
-#endif                         /*__MIDA_H__ */
-
index 657392a..89993ad 100755 (executable)
@@ -46,6 +46,8 @@
 #define _E(fmt, arg...) LOGE(fmt, ##arg)
 #define _D(fmt, arg...) LOGD(fmt, ##arg)
 #define _W(fmt, arg...) LOGW(fmt, ##arg)
+#define _I(fmt, arg...) LOGI(fmt, ##arg)
+
 
 #define retvm_if(expr, val, fmt, arg...) do { \
        if (expr) { \
index 71a24dd..10f3b3b 100755 (executable)
@@ -37,6 +37,7 @@
 #include <poll.h>
 #include <sys/prctl.h>
 #include <malloc.h>
+#include <sys/resource.h>
 
 #include "app_sock.h"
 #include "aul.h"
@@ -132,14 +133,11 @@ _static_ int __prepare_exec(const char *pkg_name,
        __preexec_run(menu_info->pkg_type, pkg_name, app_path);
 
        /* SET PRIVILEGES*/
-       if(bundle_get_val(kb, AUL_K_PRIVACY_APPID) == NULL) {
-                _D("pkg_name : %s / pkg_type : %s / app_path : %s ", pkg_name, menu_info->pkg_type, app_path);
-               if ((ret = __set_access(pkg_name, menu_info->pkg_type, app_path)) < 0) {
-                        _D("fail to set privileges - check your package's credential : %d\n", ret);
-                       return -1;
-               }
+       SECURE_LOGD("pkg_name : %s / pkg_type : %s / app_path : %s ", pkg_name, menu_info->pkg_type, app_path);
+       if ((ret = __set_access(pkg_name, menu_info->pkg_type, app_path)) < 0) {
+                _D("fail to set privileges - check your package's credential : %d\n", ret);
+               return -1;
        }
-
        /* SET DUMPABLE - for coredump*/
        prctl(PR_SET_DUMPABLE, 1);
 
@@ -191,6 +189,14 @@ _static_ int __normal_fork_exec(int argc, char **argv)
 {
        _D("start real fork and exec\n");
 
+#ifdef _APPFW_FEATURE_PRIORITY_CHANGE
+       int res = setpriority(PRIO_PROCESS, 0, 0);
+       if (res == -1)
+       {
+               SECURE_LOGE("Setting process (%d) priority to 0 failed, errno: %d (%s)",
+                               getpid(), errno, strerror(errno));
+       }
+#endif
        if (execv(argv[0], argv) < 0) { /* Flawfinder: ignore */
                if (errno == EACCES)
                        _E("such a file is no executable - %s", argv[0]);
@@ -333,7 +339,15 @@ _static_ void __modify_bundle(bundle * kb, int caller_pid,
        bundle_del(kb, AUL_K_TASKMANAGE);
 
        /* Parse app_path to retrieve default bundle*/
-       if (cmd == APP_START || cmd == APP_START_RES || cmd == APP_START_ASYNC || cmd == APP_OPEN || cmd == APP_RESUME) {
+       if (cmd == APP_START
+               || cmd == APP_START_RES
+               || cmd == APP_START_ASYNC
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+               || cmd == APP_START_MULTI_INSTANCE
+#endif
+               || cmd == APP_OPEN
+               || cmd == APP_RESUME
+               ) {
                char *ptr;
                char exe[MAX_PATH_LEN];
                int flag;
@@ -739,8 +753,7 @@ _static_ int __launchpad_pre_init(int argc, char **argv)
 
        __preload_init(argc, argv);
 
-       /* preexec is not used */
-       //__preexec_init(argc, argv);
+//     __preexec_init(argc, argv);
 
        return fd;
 }
@@ -781,6 +794,14 @@ int main(int argc, char **argv)
        pfds[0].events = POLLIN;
        pfds[0].revents = 0;
 
+#ifdef _APPFW_FEATURE_PRIORITY_CHANGE
+       int res = setpriority(PRIO_PROCESS, 0, -12);
+       if (res == -1)
+       {
+               SECURE_LOGE("Setting process (%d) priority to -12 failed, errno: %d (%s)",
+                               getpid(), errno, strerror(errno));
+       }
+#endif
        while (1) {
                if (poll(pfds, POLLFD_MAX, -1) < 0)
                        continue;
index bb65707..9b5c6b3 100755 (executable)
@@ -117,18 +117,17 @@ static inline int __send_app_launch_signal(int launch_pid)
 static int __sigchild_action(void *data)
 {
        pid_t dead_pid;
-       char buf[MAX_LOCAL_BUFSZ];
+       int ret;
 
        dead_pid = (pid_t) data;
+       _I("dead_pid(%d)", dead_pid);
        if (dead_pid <= 0)
                goto end;
 
-       __send_app_dead_signal(dead_pid);
+       ret = __send_app_dead_signal(dead_pid);
 
-       snprintf(buf, MAX_LOCAL_BUFSZ, "%s/%d", AUL_SOCK_PREFIX, dead_pid);
-       unlink(buf);
+       _I("__send_app_dead_signal(%d)", ret);
 
-       __socket_garbage_collector();
  end:
        return 0;
 }
@@ -140,7 +139,7 @@ static void __launchpad_sig_child(int signo, siginfo_t *info, void *data)
        pid_t child_pgid;
 
        child_pgid = getpgid(info->si_pid);
-       _D("dead_pid = %d pgid = %d", info->si_pid, child_pgid);
+       _I("dead_pid = %d pgid = %d", info->si_pid, child_pgid);
 
        while ((child_pid = waitpid(-1, &status, WNOHANG)) > 0) {
                if (child_pid == child_pgid)
@@ -148,6 +147,8 @@ static void __launchpad_sig_child(int signo, siginfo_t *info, void *data)
                __sigchild_action((void *)child_pid);
        }
 
+       _I("after __sigchild_action");
+
        return;
 }
 
@@ -187,7 +188,7 @@ static inline int __signal_set_sigchld(void)
                dbus_error_free(&error);
                return -1;
        }
-       /* TODO: if process stop mechanism is included, 
+       /* TODO: if process stop mechanism is included,
        should be modified (SA_NOCLDSTOP)*/
        act.sa_handler = NULL;
        act.sa_sigaction = __launchpad_sig_child;
index c5896f1..f9f719b 100755 (executable)
@@ -24,9 +24,6 @@
 
 #include <dlfcn.h>
 #define PRELOAD_FILE SHARE_PREFIX"/preload_list.txt"
-#ifdef PROCESS_POOL_ENABLE
-#define PROCESS_POOL_PRELOAD_FILE SHARE_PREFIX"/preload_list_for_process_pool.txt"
-#endif
 
 #define EFL_PREINIT_FUNC       "elm_quicklaunch_init"
 #define EFL_SHUTDOWN_FUNC      "elm_quicklaunch_shutdown"
@@ -83,90 +80,6 @@ static inline void __preload_init(int argc, char **argv)
        preload_initialized = 1;
 }
 
-#ifdef PROCESS_POOL_ENABLE
-static int g_dlopen_size = 5;
-static int g_dlopen_count = 0;
-static void** g_dlopen_handle_list = NULL;
-
-static inline int __preload_save_dlopen_handle(void *handle)
-{
-    if (!handle) {
-        return 1;
-    }
-    if (g_dlopen_count == g_dlopen_size || !g_dlopen_handle_list) {
-        void** tmp =
-            realloc(g_dlopen_handle_list, 2 * g_dlopen_size * sizeof(void *));
-        if (NULL == tmp) {
-            _E("out of memory\n");
-            dlclose(handle);
-            return 1;
-        }
-        g_dlopen_size *= 2;
-        g_dlopen_handle_list = tmp;
-    }
-    g_dlopen_handle_list[g_dlopen_count++] = handle;
-    return 0;
-}
-
-static inline void __preload_fini_for_process_pool(void)
-{
-    int i = 0;
-    if (!g_dlopen_handle_list) {
-        return;
-    }
-    for (i = 0; i < g_dlopen_count; ++i)
-    {
-        void *handle = g_dlopen_handle_list[i];
-        if (handle) {
-            if (0 != dlclose(handle)) {
-                _E("dlclose failed\n");
-            }
-        }
-    }
-    free(g_dlopen_handle_list);
-    g_dlopen_handle_list = NULL;
-    g_dlopen_size = 5;
-    g_dlopen_count = 0;
-}
-
-static inline void __preload_init_for_process_pool(void)
-{
-    if (atexit(__preload_fini_for_process_pool) != 0) {
-        _E("Cannot register atexit callback. Libraries will not be unloaded");
-    }
-
-       void *handle = NULL;
-       char soname[MAX_LOCAL_BUFSZ] = { 0, };
-       FILE *preload_list = NULL;
-
-       preload_list = fopen(PROCESS_POOL_PRELOAD_FILE, "rt");
-       if (preload_list == NULL) {
-               _E("no preload\n");
-               return;
-       }
-
-       while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) > 0) {
-        size_t len = strnlen(soname, MAX_LOCAL_BUFSZ);
-        if (len > 0) {
-            soname[len - 1] = '\0';
-        }
-               handle = dlopen((const char *) soname, RTLD_NOW);
-               if (handle == NULL) {
-            _E("dlopen(\"%s\") was failed!", soname);
-            continue;
-        }
-
-        if (__preload_save_dlopen_handle(handle) != 0) {
-            _E("Cannot save handle, no more preloads");
-            break;
-        }
-        _D("preload %s# - handle : %x\n", soname, handle);
-       }
-
-       fclose(preload_list);
-}
-#endif
-
 static inline int preinit_init()
 {
        if (dl_einit != NULL)
@@ -201,15 +114,22 @@ static inline void __preload_exec(int argc, char **argv)
 {
        void *handle = NULL;
        int (*dl_main) (int, char **);
+       char *error = NULL;
 
        if (!preload_initialized)
                return;
 
        handle = dlopen(argv[0], RTLD_LAZY | RTLD_GLOBAL);
        if (handle == NULL) {
+               _E("dlopen(\"%s\") failed", argv[0]);
+               if ((error = dlerror()) != NULL) {
+                       _E("dlopen error: %s", error);
+               }
                return;
        }
 
+       dlerror();
+
        dl_main = dlsym(handle, "main");
        if (dl_main != NULL) {
                if (__change_cmdline(argv[0]) < 0) {
@@ -217,9 +137,23 @@ static inline void __preload_exec(int argc, char **argv)
                        dlclose(handle);
                        return;
                }
+
+#ifdef _APPFW_FEATURE_PRIORITY_CHANGE
+               int res = setpriority(PRIO_PROCESS, 0, 0);
+               if (res == -1)
+               {
+                       SECURE_LOGE("Setting process (%d) priority to 0 failed, errno: %d (%s)",
+                                       getpid(), errno, strerror(errno));
+               }
+#endif
                dl_main(argc, argv);
        } else {
                _E("dlsym not founded. bad preloaded app - check fpie pie");
+               if ((error = dlerror()) != NULL) {
+                       _E("dlsym error: %s", error);
+               }
+               dlclose(handle);
+               return;
        }
 
        exit(0);
diff --git a/packaging/ac-mobile.service b/packaging/ac-mobile.service
deleted file mode 100644 (file)
index 519fc1b..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-[Unit]
-Description=Start the Access Control server
-After=dbus.service vconf-setup.service
-
-[Service]
-EnvironmentFile=/run/tizen-mobile-ui
-ExecStartPre=-/bin/mkdir /tmp/alaunch
-ExecStartPre=/bin/chmod 1777 /tmp/alaunch
-ExecStartPre=/usr/bin/chsmack -a '*' /tmp/alaunch
-ExecStart=/usr/bin/amd
-TimeoutStopSec=3s
-Restart=always
-RestartSec=0
-
-[Install]
-WantedBy=multi-user.target
similarity index 84%
rename from packaging/ac-wearable.service
rename to packaging/ac.service
index 7305e98..22fe171 100644 (file)
@@ -6,10 +6,8 @@ After=dbus.service vconf-setup.service
 EnvironmentFile=/run/tizen-mobile-env
 ExecStartPre=-/bin/mkdir /tmp/alaunch
 ExecStartPre=/bin/chmod 1777 /tmp/alaunch
+ExecStartPre=/usr/bin/chsmack -a "*" /tmp/alaunch
 ExecStart=/usr/bin/amd
-TimeoutStopSec=3s
-Restart=always
-RestartSec=0
 
 [Install]
 WantedBy=multi-user.target
index f659e4a..0b7ea00 100644 (file)
@@ -1,17 +1,12 @@
 Name:       aul
 Summary:    App utility library
-Version:    0.0.321
-Release:    1
-VCS:        magnolia/framework/appfw/aul-1#aul-1_0.0.258-131-g360ea8ecae0545dedf08f426497538e15a3e5cd3
+Version:    0.2.3.0
+Release:    6
 Group:      System/Libraries
 License:    Apache License, Version 2.0
 Source0:    %{name}-%{version}.tar.gz
-Source101:  ac-wearable.service
-Source102:  launchpad-preload-wearable.service
-Source103:  process-pool-launchpad-preload-wearable.service
-Source104:  ac-mobile.service
-Source105:  launchpad-preload-mobile.service
-Source106:  process-pool-launchpad-preload-mobile.service
+Source101:  ac.service
+Source102:  launchpad-preload.service
 
 Requires(post): /sbin/ldconfig
 Requires(post): /usr/bin/systemctl
@@ -29,6 +24,8 @@ BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(ail)
 BuildRequires:  xdgmime-devel, pkgconfig(xdgmime)
 BuildRequires:  pkgconfig(libprivilege-control)
+BuildRequires:  pkgconfig(app-checker)
+BuildRequires:  pkgconfig(app-checker-server)
 BuildRequires:  pkgconfig(rua)
 BuildRequires:  pkgconfig(ecore-x)
 BuildRequires:  pkgconfig(ecore-input)
@@ -36,16 +33,42 @@ BuildRequires:  pkgconfig(utilX)
 BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(pkgmgr-info)
 BuildRequires:  pkgconfig(libsmack)
-BuildRequires: pkgconfig(app2sd)
+#BuildRequires:  pkgconfig(system-resource)
+BuildRequires:  pkgconfig(libresourced)
 BuildRequires:  pkgconfig(security-server)
-%if %{_repository} == "wearable"
-BuildRequires:  pkgconfig(system-resource)
-BuildRequires:  pkgconfig(deviced)
+
+%define feature_appfw_integrated_contact_phone 1
+%define feature_appfw_multi_instance 1
+%define feature_appfw_process_pool 1
+%define keepstatic 1
+%if "%{?tizen_profile_name}" == "wearable"
+%define appfw_feature_process_pool_common 1
+%define appfw_feature_hw_rendering 0
+%elseif "%{?tizen_profile_name}" == "mobile"
+%define appfw_feature_process_pool_common 0
+%define appfw_feature_hw_rendering 1
+%endif
+%define appfw_feature_priority_change 1
+%define appfw_feature_default_fake_image 0
+%define appfw_feature_data_control 1
+%define appfw_feature_debug_launchpad 1
+%define appfw_feature_app_control_lite 0
+%define appfw_feature_native_launchpad 0
+%if "%{?tizen_profile_name}" == "wearable"
+%define appfw_feature_bg_process_limit 0
+%define appfw_feature_app_checker 0
+%define appfw_feature_tts_mode 1
+%elseif "%{?tizen_profile_name}" == "mobile"
+%define appfw_feature_bg_process_limit 1
+%define appfw_feature_app_checker 1
+%define appfw_feature_tts_mode 0
+%endif
+%define appfw_feature_ultra_power_saving_mode 0
+%if "%{?tizen_profile_name}" == "wearable"
+%define appfw_feature_visibility_check_by_lcd_status 1
+%elseif "%{?tizen_profile_name}" == "mobile"
+%define appfw_feature_visibility_check_by_lcd_status 0
 %endif
-BuildRequires:  pkgconfig(libsystemd-daemon)
-BuildRequires:  pkgconfig(elementary)
-BuildRequires:  pkgconfig(eina)
-BuildRequires:  pkgconfig(privacy-manager-client)
 
 %description
 Application utility library
@@ -64,17 +87,83 @@ Application utility library (devel)
 
 %build
 %if 0%{?sec_build_binary_debug_enable}
-export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
-export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
-export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
 %endif
-cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
-%if %{_repository} == "wearable"
-        -DDEVICE_PROFILE=wearable
-%else if %{_repository} == "mobile"
-        -DDEVICE_PROFILE=mobile
+%if 0%{?feature_appfw_process_pool}
+_APPFW_FEATURE_PROCESS_POOL=ON
+ %if 0%{?appfw_feature_process_pool_common}
+ _APPFW_FEATURE_PROCESS_POOL_COMMON=ON
+ %else
+  %if 0%{?appfw_feature_hw_rendering}
+  _APPFW_FEATURE_PROCESS_POOL_HW_RENDERING=ON
+  %endif
+ %endif
+%endif
+%if 0%{?feature_appfw_multi_instance}
+_APPFW_FEATURE_MULTI_INSTANCE=ON
+%endif
+%if 0%{?feature_appfw_integrated_contact_phone}
+_APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP=ON
+%endif
+%if 0%{?appfw_feature_priority_change}
+_APPFW_FEATURE_PRIORITY_CHANGE=ON
+%endif
+%if 0%{?appfw_feature_default_fake_image}
+_APPFW_FEATURE_DEFAULT_FAKE_IMAGE=ON
+%endif
+%if 0%{?appfw_feature_data_control}
+_APPFW_FEATURE_DATA_CONTROL=ON
+%endif
+%if 0%{?appfw_feature_debug_launchpad}
+_APPFW_FEATURE_DEBUG_LAUNCHPAD=ON
+%endif
+%if 0%{?appfw_feature_app_control_lite}
+_APPFW_FEATURE_APP_CONTROL_LITE=ON
+%endif
+%if 0%{?appfw_feature_native_launchpad}
+_APPFW_FEATURE_NATIVE_LAUNCHPAD=ON
+%endif
+%if 0%{?appfw_feature_bg_process_limit}
+_APPFW_FEATURE_BG_PROCESS_LIMIT=ON
+%endif
+%if 0%{?appfw_feature_app_checker}
+_APPFW_FEATURE_APP_CHECKER=ON
+%endif
+%if 0%{?appfw_feature_tts_mode}
+_APPFW_FEATURE_TTS_MODE=ON
+%endif
+%if 0%{?appfw_feature_ultra_power_saving_mode}
+_APPFW_FEATURE_ULTRA_POWER_SAVING_MODE=ON
+%endif
+%if 0%{?appfw_feature_visibility_check_by_lcd_status}
+_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS=ON
 %endif
 
+cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+       -D_APPFW_FEATURE_PROCESS_POOL:BOOL=${_APPFW_FEATURE_PROCESS_POOL} \
+       -D_APPFW_FEATURE_PROCESS_POOL_COMMON:BOOL=${_APPFW_FEATURE_PROCESS_POOL_COMMON} \
+       -D_APPFW_FEATURE_PROCESS_POOL_HW_RENDERING:BOOL=${_APPFW_FEATURE_PROCESS_POOL_HW_RENDERING} \
+       -D_APPFW_FEATURE_MULTI_INSTANCE:BOOL=${_APPFW_FEATURE_MULTI_INSTANCE} \
+       -D_APPFW_FEATURE_MULTI_WINDOW:BOOL=${_APPFW_FEATURE_MULTI_WINDOW} \
+       -D_APPFW_FEATURE_CHANGEABLE_COLOR:BOOL=${_APPFW_FEATURE_CHANGEABLE_COLOR} \
+       -D_APPFW_FEATURE_CPU_BOOST:BOOL=${_APPFW_FEATURE_CPU_BOOST} \
+       -D_APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP:BOOL=${_APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP} \
+       -D_APPFW_FEATURE_PRIORITY_CHANGE:BOOL=${_APPFW_FEATURE_PRIORITY_CHANGE} \
+       -D_APPFW_FEATURE_DEFAULT_FAKE_IMAGE:BOOL=${_APPFW_FEATURE_DEFAULT_FAKE_IMAGE} \
+       -D_APPFW_FEATURE_DATA_CONTROL:BOOL=${_APPFW_FEATURE_DATA_CONTROL} \
+       -D_APPFW_FEATURE_DEBUG_LAUNCHPAD:BOOL=${_APPFW_FEATURE_DEBUG_LAUNCHPAD} \
+       -D_APPFW_FEATURE_APP_CONTROL_LITE:BOOL=${_APPFW_FEATURE_APP_CONTROL_LITE} \
+       -D_APPFW_FEATURE_NATIVE_LAUNCHPAD:BOOL=${_APPFW_FEATURE_NATIVE_LAUNCHPAD} \
+       -D_APPFW_FEATURE_WMS_CONNECTION_CHECK:BOOL=${_APPFW_FEATURE_WMS_CONNECTION_CHECK} \
+       -D_APPFW_FEATURE_BG_PROCESS_LIMIT:BOOL=${_APPFW_FEATURE_BG_PROCESS_LIMIT} \
+       -D_APPFW_FEATURE_APP_CHECKER:BOOL=${_APPFW_FEATURE_APP_CHECKER} \
+       -D_APPFW_FEATURE_TTS_MODE:BOOL=${_APPFW_FEATURE_TTS_MODE} \
+       -D_APPFW_FEATURE_ULTRA_POWER_SAVING_MODE:BOOL=${_APPFW_FEATURE_ULTRA_POWER_SAVING_MODE} \
+       -D_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS:BOOL=${_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS} \
+       .
+
 make %{?jobs:-j%jobs}
 
 %install
@@ -82,28 +171,15 @@ rm -rf %{buildroot}
 %make_install
 
 mkdir -p %{buildroot}/opt/dbspace
-sqlite3 %{buildroot}/opt/dbspace/.mida.db < %{buildroot}/usr/share/aul/mida_db.sql
-rm -rf %{buildroot}/usr/share/aul/mida_db.sql
+%if 0%{?appfw_feature_default_fake_image}
 mkdir -p %{buildroot}/usr/share/splash_images
 cp -raf effect_img/* %{buildroot}/usr/share/splash_images
-
+%endif
 mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
-%if %{_repository} == "wearable"
 install -m0644 %SOURCE101 %{buildroot}%{_libdir}/systemd/system/ac.service
 ln -s ../ac.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/ac.service
 install -m0644 %SOURCE102 %{buildroot}%{_libdir}/systemd/system/launchpad-preload.service
 ln -s ../launchpad-preload.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/launchpad-preload.service
-install -m0644 %SOURCE103 %{buildroot}%{_libdir}/systemd/system/process-pool-launchpad-preload.service
-ln -s ../process-pool-launchpad-preload.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/process-pool-launchpad-preload.service
-%else if %{_repository} == "mobile"
-install -m0644 %SOURCE104 %{buildroot}%{_libdir}/systemd/system/ac.service
-ln -s ../ac.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/ac.service
-install -m0644 %SOURCE105 %{buildroot}%{_libdir}/systemd/system/launchpad-preload.service
-ln -s ../launchpad-preload.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/launchpad-preload.service
-install -m0644 %SOURCE106 %{buildroot}%{_libdir}/systemd/system/process-pool-launchpad-preload.service
-ln -s ../process-pool-launchpad-preload.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/process-pool-launchpad-preload.service
-%endif
-
 mkdir -p %{buildroot}/usr/share/license
 cp LICENSE %{buildroot}/usr/share/license/%{name}
 
@@ -113,30 +189,22 @@ vconftool set -t int db/setting/effect_image 1 -f -s system::vconf_inhouse
 
 
 %files
-%if %{_repository} == "wearable"
-%manifest aul-wearable.manifest
-%else
-%manifest aul-mobile.manifest
-%endif
+%manifest aul.manifest
 %attr(0644,root,root) %{_libdir}/libaul.so.0
 %attr(0644,root,root) %{_libdir}/libaul.so.0.1.0
-%attr(0755,root,root) %{_bindir}/aul_service.sh
-%attr(0755,root,root) %{_bindir}/aul_service_test.sh
+%if 0%{?appfw_feature_default_fake_image}
 %attr(0755,root,root) %{_bindir}/config_splash.sh
-%config(noreplace) %attr(0644,root,app) /opt/dbspace/.mida.db
-%config(noreplace) %attr(0644,root,app) /opt/dbspace/.mida.db-journal
-%attr(0755,root,root) %{_bindir}/aul_mime.sh
+%endif
 %{_bindir}/aul_test
 %{_bindir}/launch_app
 %{_bindir}/open_app
 /usr/share/aul/miregex/*
-/usr/share/aul/service/*
 /usr/share/aul/preload_list.txt
-/usr/share/aul/preload_list_for_process_pool.txt
 /usr/share/aul/preexec_list.txt
+%if 0%{?appfw_feature_default_fake_image}
 /usr/share/splash_images/*
+%endif
 %{_bindir}/launchpad_preloading_preinitializing_daemon
-%{_bindir}/process_pool_launchpad_preloading_preinitializing_daemon
 %{_bindir}/amd
 %{_bindir}/daemon-manager-release-agent
 %{_bindir}/daemon-manager-launch-agent
@@ -144,11 +212,12 @@ vconftool set -t int db/setting/effect_image 1 -f -s system::vconf_inhouse
 %{_libdir}/systemd/system/multi-user.target.wants/ac.service
 %{_libdir}/systemd/system/launchpad-preload.service
 %{_libdir}/systemd/system/multi-user.target.wants/launchpad-preload.service
-%{_libdir}/systemd/system/process-pool-launchpad-preload.service
-%{_libdir}/systemd/system/multi-user.target.wants/process-pool-launchpad-preload.service
 /usr/share/license/%{name}
 
 %files devel
-/usr/include/aul/*.h
+%{_includedir}/aul/*.h
+%{_includedir}/aul/launch/*.h
+%{_includedir}/aul/launchpad/*.h
 %{_libdir}/*.so
+%{_libdir}/*.a
 %{_libdir}/pkgconfig/*.pc
diff --git a/packaging/launchpad-preload-mobile.service b/packaging/launchpad-preload-mobile.service
deleted file mode 100644 (file)
index f5a0dd8..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-[Unit]
-Description=Start the Access Control server
-After=dbus.service vconf-setup.service ac.service
-
-[Service]
-EnvironmentFile=/run/tizen-mobile-ui
-ExecStart=/usr/bin/launchpad_preloading_preinitializing_daemon "                                                                                                                                                                                                         "
-TimeoutStopSec=3s
-Restart=always
-RestartSec=0
-
-[Install]
-WantedBy=multi-user.target
diff --git a/packaging/process-pool-launchpad-preload-mobile.service b/packaging/process-pool-launchpad-preload-mobile.service
deleted file mode 100644 (file)
index 90f1abd..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=Start the Access Control server
-After=dbus.service vconf-setup.service ac.service
-
-[Service]
-EnvironmentFile=/run/tizen-mobile-ui
-ExecStart=/usr/bin/process_pool_launchpad_preloading_preinitializing_daemon "                                                                                                                                                                                                         "
-
-[Install]
-WantedBy=multi-user.target
diff --git a/packaging/process-pool-launchpad-preload-wearable.service b/packaging/process-pool-launchpad-preload-wearable.service
deleted file mode 100644 (file)
index d4e68f6..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=Start the Access Control server
-After=dbus.service vconf-setup.service ac.service
-
-[Service]
-EnvironmentFile=/run/tizen-mobile-env
-ExecStart=/usr/bin/process_pool_launchpad_preloading_preinitializing_daemon "                                                                                                                                                                                                         "
-
-[Install]
-WantedBy=multi-user.target
diff --git a/process_pool/launchpad.c b/process_pool/launchpad.c
deleted file mode 100755 (executable)
index 00b6fad..0000000
+++ /dev/null
@@ -1,1211 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <dlfcn.h>
-#include <X11/Xlib.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <poll.h>
-#include <sys/prctl.h>
-#include <malloc.h>
-
-#include "app_sock.h"
-#include "aul.h"
-
-#include "config.h"
-
-#include "menu_db_util.h"
-#include "simple_util.h"
-#include "access_control.h"
-#include "preload.h"
-#include "preexec.h"
-#include "perf.h"
-#include "sigchild.h"
-#include "aul_util.h"
-
-#include "heap_dbg.h"
-
-#include "util_x.h"
-
-#include "gl.h"
-
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sqlite3.h>
-
-#include "process_pool.h"
-#include <Elementary.h>
-#include <Ecore.h>
-
-#define _static_ static inline
-#define SQLITE_FLUSH_MAX       (1048576)       /* (1024*1024) */
-#define AUL_POLL_CNT           15
-#define AUL_PR_NAME                    16
-
-#define EXEC_DUMMY_EXPIRED 5
-#define DIFF(a,b) (((a)>(b))?(a)-(b):(b)-(a))
-#define LOWEST_PRIO 20
-#define DUMMY_NONE 0
-
-static char *launchpad_cmdline;
-static char *__appid = NULL;
-static int initialized = 0;
-static int candidate_pid = DUMMY_NONE;
-static int candidate_fd         = -1;
-static int last_dummy_exec_time = 0;
-const char* const HOME = "HOME";
-const char* const APP_HOME_PATH = "/opt/home/app";
-const char* const ROOT_HOME_PATH = "/opt/home/root";
-
-_static_ void __set_env(app_info_from_db * menu_info, bundle * kb);
-_static_ int __prepare_exec(const char *pkg_name,
-                               const char *app_path, app_info_from_db * menu_info,
-                               bundle * kb);
-_static_ int __fake_launch_app(int cmd, int pid, bundle * kb);
-_static_ char **__create_argc_argv(bundle * kb, int *margc);
-_static_ int __normal_fork_exec(int argc, char **argv);
-_static_ void __real_launch(const char *app_path, bundle * kb);
-_static_ int __candidate_process_real_launch(int dummy_client_fd, app_pkt_t* pkt);
-static inline int __parser(const char *arg, char *out, int out_size);
-_static_ void __modify_bundle(bundle * kb, int caller_pid,
-                               app_info_from_db * menu_info, int cmd);
-_static_ int __child_raise_win_by_x(int pid, void *priv);
-_static_ int __raise_win_by_x(int pid);
-_static_ int __send_to_sigkill(int pid);
-_static_ int __term_app(int pid);
-_static_ int __resume_app(int pid);
-_static_ int __real_send(int clifd, int ret);
-_static_ void __send_result_to_caller(int clifd, int ret);
-_static_ void __prepare_candidate_process(int main_fd, int pool_fd, int client_fd);
-_static_ void __launchpad_main_loop(int main_fd, int pool_fd);
-_static_ int __launchpad_pre_init(int argc, char **argv);
-_static_ int __launchpad_post_init();
-
-extern ail_error_e ail_db_close(void);
-
-
-static app_info_from_db *_get_app_info_from_bundle_by_pkgname(
-                                                       const char *pkgname, bundle *kb);
-
-
-_static_ void __set_env(app_info_from_db * menu_info, bundle * kb)
-{
-       const char *str;
-
-       setenv("PKG_NAME", _get_pkgname(menu_info), 1);
-
-       USE_ENGINE("gl")
-
-       str = bundle_get_val(kb, AUL_K_STARTTIME);
-       if (str != NULL)
-               setenv("APP_START_TIME", str, 1);
-
-       if (menu_info->hwacc != NULL)
-               setenv("HWACC", menu_info->hwacc, 1);
-       if (menu_info->taskmanage != NULL)
-               setenv("TASKMANAGE", menu_info->taskmanage, 1);
-}
-
-_static_ int __prepare_exec(const char *pkg_name,
-                               const char *app_path, app_info_from_db * menu_info,
-                               bundle * kb)
-{
-       char *file_name;
-       char process_name[AUL_PR_NAME];
-       int ret;
-
-       /* Set new session ID & new process group ID*/
-       /* In linux, child can set new session ID without check permission */
-       /* TODO : should be add to check permission in the kernel*/
-       setsid();
-
-       __preexec_run(menu_info->pkg_type, pkg_name, app_path);
-
-       /* SET PRIVILEGES*/
-       SECURE_LOGD("pkg_name : %s / pkg_type : %s / app_path : %s ", pkg_name, menu_info->pkg_type, app_path);
-       if ((ret = __set_access(pkg_name, menu_info->pkg_type, app_path)) < 0) {
-                _D("fail to set privileges - check your package's credential : %d\n", ret);
-               return -1;
-       }
-       /* SET DUMPABLE - for coredump*/
-       prctl(PR_SET_DUMPABLE, 1);
-
-       /* SET PROCESS NAME*/
-       if (app_path == NULL) {
-               _D("app_path should not be NULL - check menu db");
-               return -1;
-       }
-       file_name = strrchr(app_path, '/') + 1;
-       if (file_name == NULL) {
-               _D("can't locate file name to execute");
-               return -1;
-       }
-       memset(process_name, '\0', AUL_PR_NAME);
-       snprintf(process_name, AUL_PR_NAME, "%s", file_name);
-       prctl(PR_SET_NAME, process_name);
-
-       /* SET ENVIROMENT*/
-       __set_env(menu_info, kb);
-
-       return 0;
-}
-
-_static_ int __fake_launch_app(int cmd, int pid, bundle * kb)
-{
-       int datalen;
-       int ret;
-       bundle_raw *kb_data;
-
-       bundle_encode(kb, &kb_data, &datalen);
-       if ((ret = __app_send_raw(pid, cmd, kb_data, datalen)) < 0)
-               _E("error request fake launch - error code = %d", ret);
-       free(kb_data);
-       return ret;
-}
-
-_static_ char **__create_argc_argv(bundle * kb, int *margc)
-{
-       char **argv;
-       int argc;
-
-       argc = bundle_export_to_argv(kb, &argv);
-
-       *margc = argc;
-       return argv;
-}
-
-_static_ int __normal_fork_exec(int argc, char **argv)
-{
-       _D("start real fork and exec\n");
-
-       if (execv(argv[0], argv) < 0) { /* Flawfinder: ignore */
-               if (errno == EACCES)
-                       _E("such a file is no executable - %s", argv[0]);
-               else
-                       _E("unknown executable error - %s", argv[0]);
-               return -1;
-       }
-       /* never reach*/
-       return 0;
-}
-
-_static_ void __real_launch(const char *app_path, bundle * kb)
-{
-       int app_argc;
-       char **app_argv;
-       int i;
-
-       app_argv = __create_argc_argv(kb, &app_argc);
-       app_argv[0] = strdup(app_path);
-
-       for (i = 0; i < app_argc; i++) {
-               if( (i%2) == 1)
-                       continue;
-               SECURE_LOGD("input argument %d : %s##", i, app_argv[i]);
-       }
-
-       PERF("setup argument done");
-
-       /* Temporary log: launch time checking */
-       LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:launchpad:done]", app_path);
-
-       __preload_exec(app_argc, app_argv);
-
-       __normal_fork_exec(app_argc, app_argv);
-}
-
-_static_ int __candidate_process_real_launch(int dummy_client_fd, app_pkt_t* pkt)
-{
-       return __send_pkt_raw_data(dummy_client_fd, pkt);
-}
-
-/*
- * Parsing original app path to retrieve default bundle
- *
- * -1 : Invalid sequence
- * -2 : Buffer overflow
- *
- */
-static inline int __parser(const char *arg, char *out, int out_size)
-{
-       register int i;
-       int state = 1;
-       char *start_out = out;
-
-       if (arg == NULL || out == NULL) {
-               /* Handles null buffer*/
-               return 0;
-       }
-
-       for (i = 0; out_size > 1; i++) {
-               switch (state) {
-               case 1:
-                       switch (arg[i]) {
-                       case ' ':
-                       case '\t':
-                               state = 5;
-                               break;
-                       case '\0':
-                               state = 7;
-                               break;
-                       case '\"':
-                               state = 2;
-                               break;
-                       case '\\':
-                               state = 4;
-                               break;
-                       default:
-                               *out = arg[i];
-                               out++;
-                               out_size--;
-                               break;
-                       }
-                       break;
-               case 2: /* escape start*/
-                       switch (arg[i]) {
-                       case '\0':
-                               state = 6;
-                               break;
-                       case '\"':
-                               state = 1;
-                               break;
-                       default:
-                               *out = arg[i];
-                               out++;
-                               out_size--;
-                               break;
-                       }
-                       break;
-               case 4: /* character escape*/
-                       if (arg[i] == '\0') {
-                               state = 6;
-                       } else {
-                               *out = arg[i];
-                               out++;
-                               out_size--;
-                               state = 1;
-                       }
-                       break;
-               case 5: /* token*/
-                       if (out != start_out) {
-                               *out = '\0';
-                               out_size--;
-                               return i;
-                       }
-                       i--;
-                       state = 1;
-                       break;
-               case 6:
-                       return -1;      /* error*/
-               case 7: /* terminate*/
-                       *out = '\0';
-                       out_size--;
-                       return 0;
-               default:
-                       state = 6;
-                       break;  /* error*/
-               }
-       }
-
-       if (out_size == 1) {
-               *out = '\0';
-       }
-       /* Buffer overflow*/
-       return -2;
-}
-
-_static_ void __modify_bundle(bundle * kb, int caller_pid,
-                               app_info_from_db * menu_info, int cmd)
-{
-       bundle_del(kb, AUL_K_PKG_NAME);
-       bundle_del(kb, AUL_K_EXEC);
-       bundle_del(kb, AUL_K_PACKAGETYPE);
-       bundle_del(kb, AUL_K_HWACC);
-       bundle_del(kb, AUL_K_TASKMANAGE);
-
-       /* Parse app_path to retrieve default bundle*/
-       if (cmd == APP_START || cmd == APP_START_RES || cmd == APP_START_ASYNC || cmd == APP_OPEN || cmd == APP_RESUME) {
-               char *ptr;
-               char exe[MAX_PATH_LEN];
-               int flag;
-
-               ptr = _get_original_app_path(menu_info);
-
-               flag = __parser(ptr, exe, sizeof(exe));
-               if (flag > 0) {
-                       char key[256];
-                       char value[256];
-
-                       ptr += flag;
-                       SECURE_LOGD("parsing app_path: EXEC - %s\n", exe);
-
-                       do {
-                               flag = __parser(ptr, key, sizeof(key));
-                               if (flag <= 0)
-                                       break;
-                               ptr += flag;
-
-                               flag = __parser(ptr, value, sizeof(value));
-                               if (flag < 0)
-                                       break;
-                               ptr += flag;
-
-                               /*bundle_del(kb, key);*/
-                               bundle_add(kb, key, value);
-                       } while (flag > 0);
-               } else if (flag == 0) {
-                       _D("parsing app_path: No arguments\n");
-               } else {
-                       _D("parsing app_path: Invalid argument\n");
-               }
-       }
-}
-
-_static_ int __child_raise_win_by_x(int pid, void *priv)
-{
-       return x_util_raise_win(pid);
-}
-
-_static_ int __raise_win_by_x(int pid)
-{
-       int pgid;
-       if (x_util_raise_win(pid) == 0)
-               return 0;
-
-       /* support app launched by shell script*/
-       pgid = getpgid(pid);
-       _D("X raise failed. try to find first child & raise it - c:%d p:%d\n",
-          pgid, pid);
-
-       if (pgid <= 1)
-               return -1;
-       if (__proc_iter_pgid(pgid, __child_raise_win_by_x, NULL) < 0)
-               return -1;
-
-       return 0;
-}
-
-_static_ int __send_to_sigkill(int pid)
-{
-       int pgid;
-
-       pgid = getpgid(pid);
-       if (pgid <= 1)
-               return -1;
-
-       if (killpg(pgid, SIGKILL) < 0)
-               return -1;
-
-       return 0;
-}
-
-_static_ int __term_app(int pid)
-{
-       int dummy;
-       if (__app_send_raw
-               (pid, APP_TERM_BY_PID, (unsigned char *)&dummy, sizeof(int)) < 0) {
-               _D("terminate packet send error - use SIGKILL");
-               if (__send_to_sigkill(pid) < 0) {
-                       _E("fail to killing - %d\n", pid);
-                       return -1;
-               }
-       }
-       _D("term done\n");
-       return 0;
-}
-
-_static_ int __resume_app(int pid)
-{
-       int dummy;
-       int ret;
-       if ((ret =
-                __app_send_raw(pid, APP_RESUME_BY_PID, (unsigned char *)&dummy,
-                               sizeof(int))) < 0) {
-               if (ret == -EAGAIN)
-                       _E("resume packet timeout error");
-               else {
-                       _D("resume packet send error - use raise win");
-                       if (__raise_win_by_x(pid) < 0) {
-                               _E("raise failed - %d resume fail\n", pid);
-                               _E("we will term the app - %d\n", pid);
-                               __send_to_sigkill(pid);
-                               ret = -1;
-                       } else
-                               ret = 0;
-               }
-       }
-       _D("resume done\n");
-       return ret;
-}
-
-static int __get_caller_pid(bundle *kb)
-{
-       const char *pid_str;
-       int pid;
-
-       pid_str = bundle_get_val(kb, AUL_K_ORG_CALLER_PID);
-       if(pid_str)
-               goto end;
-
-       pid_str = bundle_get_val(kb, AUL_K_CALLER_PID);
-       if (pid_str == NULL)
-               return -1;
-
-end:
-       pid = atoi(pid_str);
-       if (pid <= 1)
-               return -1;
-
-       return pid;
-}
-
-_static_ int __foward_cmd(int cmd, bundle *kb, int cr_pid)
-{
-       int pid;
-       char tmp_pid[MAX_PID_STR_BUFSZ];
-       int datalen;
-       bundle_raw *kb_data;
-       int res;
-
-       if ((pid = __get_caller_pid(kb)) < 0)
-                       return AUL_R_ERROR;
-
-       snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", cr_pid);
-
-       bundle_add(kb, AUL_K_CALLEE_PID, tmp_pid);
-
-       bundle_encode(kb, &kb_data, &datalen);
-       if ((res = __app_send_raw_with_noreply(pid, cmd, kb_data, datalen)) < 0)
-               res = AUL_R_ERROR;
-
-       free(kb_data);
-
-       return res;
-}
-
-_static_ int __real_send(int clifd, int ret)
-{
-       if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
-               if (errno == EPIPE) {
-                       _E("send failed due to EPIPE.\n");
-                       close(clifd);
-                       return -1;
-               }
-               _E("send fail to client");
-       }
-
-       close(clifd);
-       return 0;
-}
-
-_static_ void __send_result_to_caller(int clifd, int ret)
-{
-       char *cmdline;
-       int wait_count;
-       int cmdline_changed = 0;
-       int cmdline_exist = 0;
-       int r;
-
-       if (clifd == -1)
-               return;
-
-       if (ret <= 1) {
-               __real_send(clifd, ret);
-               return;
-       }
-       /* check normally was launched?*/
-       wait_count = 1;
-       do {
-               cmdline = __proc_get_cmdline_bypid(ret);
-               if (cmdline == NULL) {
-                       _E("error founded when being launched with %d", ret);
-
-               } else if (strcmp(cmdline, launchpad_cmdline)) {
-                       free(cmdline);
-                       cmdline_changed = 1;
-                       break;
-               } else {
-                       cmdline_exist = 1;
-                       free(cmdline);
-               }
-
-               _D("-- now wait to change cmdline --");
-               usleep(50 * 1000);      /* 50ms sleep*/
-               wait_count++;
-       } while (wait_count <= 20);     /* max 50*20ms will be sleep*/
-
-       if ((!cmdline_exist) && (!cmdline_changed)) {
-               __real_send(clifd, -1); /* abnormally launched*/
-               return;
-       }
-
-       if (!cmdline_changed)
-               _E("process launched, but cmdline not changed");
-
-       if(__real_send(clifd, ret) < 0) {
-               r = kill(ret, SIGKILL);
-               if (r == -1)
-                       _E("send SIGKILL: %s", strerror(errno));
-       }
-
-       return;
-}
-
-_static_ int __candidate_process_prepare_exec(const char *pkg_name,
-                                                       const char *app_path, app_info_from_db *menu_info,
-                                                       bundle *kb)
-{
-       const char *file_name = NULL;
-       char process_name[AUL_PR_NAME] = { 0, };
-       int ret = 0;
-
-       /* SET PRIVILEGES*/
-       SECURE_LOGD("[candidata] pkg_name : %s / pkg_type : %s / app_path : %s ", pkg_name, menu_info->pkg_type, app_path);
-       if ((ret = __set_access(pkg_name, menu_info->pkg_type, app_path)) < 0) {
-               _D("fail to set privileges - check your package's credential : %d\n", ret);
-               return -1;
-       }
-
-       //XXX: Check CAP_MAC_ADMIN
-#if 0
-       /* SET INHERIT BIT FOR CAP_MAC_ADMIN TO WHOLE THREAD */
-       EXECUTE_ON_WHOLE_THREAD(__set_inherit_bit_for_CAP_MAC_ADMIN, SIGUSR1);
-#endif
-
-       /* SET PROCESS NAME*/
-       if (app_path == NULL) {
-               _D("app_path should not be NULL - check menu db");
-               return -1;
-       }
-
-       file_name = strrchr(app_path, '/') + 1;
-       if (file_name == NULL) {
-               _D("can't locate file name to execute");
-               return -1;
-       }
-       memset(process_name, '\0', AUL_PR_NAME);
-       snprintf(process_name, AUL_PR_NAME, "%s", file_name);
-       prctl(PR_SET_NAME, process_name);
-
-       /* SET ENVIROMENT*/
-       __set_env(menu_info, kb);
-
-       return 0;
-}
-
-static bundle *_s_bundle = NULL;
-static void __at_exit_to_release_bundle()
-{
-       if (_s_bundle) {
-               bundle_free(_s_bundle);
-               _s_bundle = NULL;
-       }
-}
-
-static void __release_appid_at_exit(void)
-{
-       if (__appid != NULL) {
-               free(__appid);
-       }
-}
-
-_static_ void __candidate_process_launchpad_main_loop(app_pkt_t* pkt, char* out_app_path, int* out_argc, char ***out_argv)
-{
-       bundle *kb = NULL;
-       app_info_from_db *menu_info = NULL;
-
-       const char *pkg_name = NULL;
-       const char *app_path = NULL;
-
-       kb = bundle_decode(pkt->data, pkt->len);
-       if (!kb) {
-               _E("bundle decode error");
-               exit(-1);
-       }
-
-       if (_s_bundle != NULL) {
-               bundle_free(_s_bundle);
-       }
-       _s_bundle = kb;
-       atexit(__at_exit_to_release_bundle);
-
-       pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME);
-       SECURE_LOGD("pkg name : %s", pkg_name);
-
-       menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb);
-       if (menu_info == NULL) {
-               _D("such pkg no found");
-               exit(-1);
-       }
-
-       app_path = _get_app_path(menu_info);
-       if (app_path == NULL) {
-               _E("app_path is NULL");
-               exit(-1);
-       }
-
-       if (app_path[0] != '/') {
-               _E("app_path is not absolute path");
-               exit(-1);
-       }
-
-       __modify_bundle(kb, /*cr.pid - unused parameter*/ 0, menu_info, pkt->cmd);
-       pkg_name = _get_pkgname(menu_info);
-       SECURE_LOGD("pkg name : %s", pkg_name);
-
-       __appid = strdup(pkg_name);
-       aul_set_preinit_appid(__appid);
-       atexit(__release_appid_at_exit);
-
-       __candidate_process_prepare_exec(pkg_name, app_path, menu_info, kb);
-
-       if (out_app_path != NULL && out_argc != NULL && out_argv != NULL)
-       {
-               int i;
-
-               sprintf(out_app_path, "%s", app_path);
-
-               *out_argv = __create_argc_argv(kb, out_argc);
-               (*out_argv)[0] = out_app_path;
-
-               for (i = 0; i < *out_argc; i++)
-               {
-                       SECURE_LOGD("input argument %d : %s##", i, (*out_argv)[i]);
-               }
-       }
-       else
-       {
-               exit(-1);
-       }
-
-       if (menu_info != NULL) {
-               _free_app_info_from_db(menu_info);
-       }
-}
-
-static Eina_Bool __candidate_proces_fd_handler(void* data, Ecore_Fd_Handler *handler)
-{
-       int fd = ecore_main_fd_handler_fd_get(handler);
-
-       if (fd == -1)
-       {
-               _D("[candidate] ECORE_FD_GET");
-               exit(-1);
-       }
-
-       if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR))
-       {
-               _D("[candidate] ECORE_FD_ERROR");
-               close(fd);
-               exit(-1);
-       }
-
-       if (ecore_main_fd_handler_active_get(handler, ECORE_FD_READ))
-       {
-               _D("[candidate] ECORE_FD_READ");
-               {
-                       app_pkt_t* pkt = (app_pkt_t*) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
-                       memset(pkt, 0, AUL_SOCK_MAXBUFF);
-
-                       int recv_ret = recv(fd, pkt, AUL_SOCK_MAXBUFF, 0);
-                       close(fd);
-                       if (recv_ret == -1)
-                       {
-                               _D("[condidate] recv error!");
-                               free(pkt);
-                               exit(-1);
-                       }
-                       _D("[candidate] recv_ret: %d, pkt->len: %d", recv_ret, pkt->len);
-
-                       ecore_main_fd_handler_del(handler);
-                       __candidate_process_launchpad_main_loop(pkt, g_argv[0], &g_argc, &g_argv);
-                       SECURE_LOGD("[candidate] real app argv[0]: %s, real app argc: %d", g_argv[0], g_argc);
-                       free(pkt);
-               }
-               ecore_main_loop_quit();
-               _D("[candidate] ecore main loop quit");
-       }
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-_static_ void __prepare_candidate_process(int main_fd, int pool_fd, int client_fd)
-{
-       int pid;
-
-       last_dummy_exec_time = time(NULL);
-
-       pid = fork();
-
-       if (pid == 0) // child
-       {
-               setpriority(PRIO_PROCESS, 0, LOWEST_PRIO);
-               _D("[candidate] Another candidate process was forked.");
-
-               //temp - this requires some optimization.
-               sleep(1);
-               _D("sleeping 1 sec...");
-
-               /* Set new session ID & new process group ID*/
-               /* In linux, child can set new session ID without check permission */
-               /* TODO : should be add to check permission in the kernel*/
-               setsid();
-
-               if (main_fd != -1)
-               {
-                       close(main_fd);
-               }
-
-               if (pool_fd != -1)
-               {
-                       close(pool_fd);
-               }
-
-               if (client_fd != -1)
-               {
-                       close(client_fd);
-               }
-
-               __signal_unset_sigchld();
-               __signal_fini();
-
-               /* SET PR_SET_KEEPCAPS */
-               if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
-                       _E("prctl(PR_SET_KEEPCAPS) failed.");
-               }
-
-               /* SET DUMPABLE - for coredump*/
-               prctl(PR_SET_DUMPABLE, 1);
-               {
-                       int client_fd = __connect_candidate_process();
-                       if (client_fd == -1)
-                       {
-                               _D("Connecting to candidate process was failed.");
-                               exit(-1);
-                       }
-
-                       // Temporarily change HOME path to app
-                       // This change is needed for getting elementary profile
-                       // /opt/home/app/.elementary/config/mobile/base.cfg
-                       setenv(HOME, APP_HOME_PATH, 1);
-                       _D("[candidate] elm_init()");
-                       elm_init(g_argc, g_argv);
-                       setenv(HOME, ROOT_HOME_PATH, 1);
-
-                       Evas_Object *eo = elm_win_add(NULL, "package_name", ELM_WIN_BASIC);
-                       aul_set_preinit_window(eo);
-
-                       Ecore_Fd_Handler* fd_handler = ecore_main_fd_handler_add(client_fd,
-                                                                                  (Ecore_Fd_Handler_Flags)(ECORE_FD_READ|ECORE_FD_ERROR),
-                                                                                  __candidate_proces_fd_handler, NULL, NULL, NULL);
-                       if (fd_handler == NULL)
-                       {
-                               _D("fd_handler is NULL");
-                               exit(-1);
-                       }
-
-                       setpriority(PRIO_PROCESS, 0, 0);
-
-                       _D("[candidate] ecore main loop begin");
-                       ecore_main_loop_begin();
-
-                       void *handle = NULL;
-                       int (*dl_main) (int, char **);
-
-                       SECURE_LOGD("[candidate] Launch real application (%s)", g_argv[0]);
-                       handle = dlopen(g_argv[0], RTLD_LAZY | RTLD_GLOBAL);
-                       if (handle == NULL)
-                       {
-                               _E("dlopen failed (%s).", dlerror());
-                               exit(-1);
-                       }
-                       dlerror();
-
-                       dl_main = dlsym(handle, "main");
-                       if (dl_main != NULL)
-                       {
-                               dl_main(g_argc, g_argv);
-                       }
-                       else
-                       {
-                               _E("dlsym not founded. bad preloaded app - check fpie pie");
-                       }
-
-                       exit(0);
-               }
-       }
-}
-
-static app_info_from_db *_get_app_info_from_bundle_by_pkgname(
-                                                       const char *pkgname, bundle *kb)
-{
-       app_info_from_db *menu_info;
-
-       menu_info = calloc(1, sizeof(app_info_from_db));
-       if (menu_info == NULL) {
-               return NULL;
-       }
-
-       menu_info->pkg_name = strdup(pkgname);
-       menu_info->app_path = strdup(bundle_get_val(kb, AUL_K_EXEC));
-       if (menu_info->app_path != NULL)
-               menu_info->original_app_path = strdup(menu_info->app_path);
-       menu_info->pkg_type = strdup(bundle_get_val(kb, AUL_K_PACKAGETYPE));
-       menu_info->hwacc = strdup(bundle_get_val(kb, AUL_K_HWACC));
-       menu_info->taskmanage = strdup(bundle_get_val(kb, AUL_K_TASKMANAGE));
-
-       if (!_get_app_path(menu_info)) {
-               _free_app_info_from_db(menu_info);
-               return NULL;
-       }
-
-       return menu_info;
-}
-
-_static_ void __launchpad_main_loop(int main_fd, int pool_fd)
-{
-       bundle *kb = NULL;
-       app_pkt_t *pkt = NULL;
-       app_info_from_db *menu_info = NULL;
-
-       const char *pkg_name = NULL;
-       const char *app_path = NULL;
-       int pid = -1;
-       int clifd = -1;
-       struct ucred cr;
-       int is_real_launch = 0;
-
-       char sock_path[UNIX_PATH_MAX] = {0,};
-
-       pkt = __app_recv_raw(main_fd, &clifd, &cr);
-       if (!pkt) {
-               _D("packet is NULL");
-               goto end;
-       }
-
-       kb = bundle_decode(pkt->data, pkt->len);
-       if (!kb) {
-               _D("bundle decode error");
-               goto end;
-       }
-
-       INIT_PERF(kb);
-       PERF("packet processing start");
-
-       pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME);
-       SECURE_LOGD("pkg name : %s\n", pkg_name);
-
-       menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb);
-       if (menu_info == NULL) {
-               _D("such pkg no found");
-               goto end;
-       }
-
-       app_path = _get_app_path(menu_info);
-       if(app_path == NULL) {
-               _E("app_path is NULL");
-               goto end;
-       }
-       if (app_path[0] != '/') {
-               _D("app_path is not absolute path");
-               goto end;
-       }
-
-       __modify_bundle(kb, cr.pid, menu_info, pkt->cmd);
-       pkg_name = _get_pkgname(menu_info);
-
-       PERF("get package information & modify bundle done");
-
-       if (candidate_pid != DUMMY_NONE)
-       {
-               snprintf(sock_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, candidate_pid);
-               unlink(sock_path);
-
-               __candidate_process_real_launch(candidate_fd, pkt);
-               _D("Request real launch to candidate_process.");
-
-               pid = candidate_pid;
-               is_real_launch = 1;
-               close(candidate_fd);
-
-               candidate_pid = DUMMY_NONE;
-               candidate_fd  = -1;
-
-               /* Temporary log: launch time checking */
-               //LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:launchpad:done]", app_path);
-
-               __prepare_candidate_process(main_fd, pool_fd, clifd);
-
-               SECURE_LOGD("Prepare candidate process, pid: %d, bin path: %s\n", pid, app_path);
-       }
-       else
-       {
-               pid = fork();
-
-               if (pid == 0)
-               {
-                       PERF("fork done");
-                       _E("lock up test log(no error) : fork done");
-
-                       close(clifd);
-                       close(main_fd);
-                       __signal_unset_sigchld();
-                       __signal_fini();
-
-                       snprintf(sock_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, getpid());
-                       unlink(sock_path);
-
-                       PERF("prepare exec - first done");
-                       _E("lock up test log(no error) : prepare exec - first done");
-
-                       if (__prepare_exec(pkg_name, app_path,
-                                                          menu_info, kb) < 0)
-                       {
-                               SECURE_LOGE("preparing work fail to launch - "
-                                  "can not launch %s\n", pkg_name);
-                               exit(-1);
-                       }
-
-                       PERF("prepare exec - second done");
-                       _E("lock up test log(no error) : prepare exec - second done");
-
-                       __real_launch(app_path, kb);
-
-                       exit(-1);
-               }
-               _D("==> real launch pid : %d %s\n", pid, app_path);
-               is_real_launch = 1;
-       }
-
- end:
-       __send_result_to_caller(clifd, pid);
-
-       if (pid > 0) {
-               if (is_real_launch) {
-                       /*TODO: retry*/
-                       __signal_block_sigchld();
-                       __send_app_launch_signal(pid);
-                       __signal_unblock_sigchld();
-               }
-       }
-
-       if (menu_info != NULL)
-               _free_app_info_from_db(menu_info);
-
-       if (kb != NULL)
-               bundle_free(kb);
-       if (pkt != NULL)
-               free(pkt);
-
-       /* Active Flusing for Daemon */
-       if (initialized > AUL_POLL_CNT) {
-               sqlite3_release_memory(SQLITE_FLUSH_MAX);
-               malloc_trim(0);
-               initialized = 1;
-       }
-
-}
-
-_static_ int __launchpad_pre_init(int argc, char **argv)
-{
-       int fd;
-
-       /* signal init*/
-       __signal_init();
-
-       /* get my(launchpad) command line*/
-       launchpad_cmdline = __proc_get_cmdline_bypid(getpid());
-       if (launchpad_cmdline == NULL) {
-               _E("launchpad cmdline fail to get");
-               return -1;
-       }
-       _D("launchpad cmdline = %s", launchpad_cmdline);
-
-       /* create launchpad sock */
-       fd = __create_server_sock(PROCESS_POOL_LAUNCHPAD_PID);
-       if (fd < 0) {
-               _E("server sock error");
-               return -1;
-       }
-
-       __preload_init(argc, argv);
-
-       __preload_init_for_process_pool();
-
-       __preexec_init(argc, argv);
-
-       return fd;
-}
-
-_static_ int __launchpad_post_init()
-{
-       /* Setting this as a global variable to keep track
-       of launchpad poll cnt */
-       /* static int initialized = 0;*/
-
-       if (initialized) {
-               initialized++;
-               return 0;
-       }
-
-       if (__signal_set_sigchld() < 0)
-               return -1;
-
-       initialized++;
-
-       return 0;
-}
-
-int main(int argc, char **argv)
-{
-       enum {
-               LAUNCH_PAD = 0,
-               POOL_SERVER,
-               DUMMY_PROCESS,
-               POLLFD_MAX
-       };
-       int pool_fd = -1;
-       int main_fd;
-       struct pollfd pfds[POLLFD_MAX];
-       int i;
-
-       memset(pfds, 0x00, sizeof(pfds));
-
-       /* init without concerning X & EFL*/
-       main_fd = __launchpad_pre_init(argc, argv);
-       if (main_fd < 0) {
-               _E("launchpad pre init failed");
-               exit(-1);
-       }
-
-       pfds[LAUNCH_PAD].fd      = main_fd;
-       pfds[LAUNCH_PAD].events  = POLLIN;
-       pfds[LAUNCH_PAD].revents = 0;
-
-       pool_fd = __create_candidate_process();
-       if (pool_fd == -1)
-       {
-               _E("Error creationg pool server!");
-               goto exit_main;
-       }
-
-       pfds[POOL_SERVER].fd      = pool_fd;
-       pfds[POOL_SERVER].events  = POLLIN;
-       pfds[POOL_SERVER].revents = 0;
-
-       while (1) {
-               if (candidate_pid == DUMMY_NONE)
-               {
-                       pfds[DUMMY_PROCESS].fd          = -1;
-                       pfds[DUMMY_PROCESS].events  = 0;
-                       pfds[DUMMY_PROCESS].revents = 0;
-
-                       if (DIFF(last_dummy_exec_time, time(NULL)) > EXEC_DUMMY_EXPIRED)
-                       {
-                               __prepare_candidate_process(main_fd, pool_fd, -1);
-                       }
-               }
-
-               if (poll(pfds, POLLFD_MAX, -1) < 0)
-                       continue;
-
-               _D("pfds[LAUNCH_PAD].revents    : 0x%x", pfds[LAUNCH_PAD].revents) ;
-               _D("pfds[POOL_SERVER].revents   : 0x%x", pfds[POOL_SERVER].revents) ;
-               _D("pfds[DUMMY_PROCESS].revents : 0x%x", pfds[DUMMY_PROCESS].revents) ;
-
-               /* init with concerning X & EFL (because of booting
-               * sequence problem)*/
-               if (__launchpad_post_init() < 0)
-               {
-                       _E("launcpad post init failed");
-                       goto exit_main;
-               }
-
-               if ((pfds[LAUNCH_PAD].revents & POLLIN) != 0)
-               {
-                       _D("pfds[LAUNCH_PAD].revents & POLLIN");
-                       __launchpad_main_loop(pfds[LAUNCH_PAD].fd, pfds[POOL_SERVER].fd);
-               }
-
-               if ((pfds[POOL_SERVER].revents & POLLIN) != 0)
-               {
-                       int server_fd, client_fd, client_pid;
-
-                       server_fd = pfds[POOL_SERVER].fd;
-
-                       _D("pfds[POOL_SERVER].revents & POLLIN");
-
-                       if (candidate_pid == DUMMY_NONE)
-                       {
-                               __accept_candidate_process(server_fd, &client_fd, &client_pid);
-
-                               candidate_pid = client_pid;
-                               candidate_fd  = client_fd;
-
-                               pfds[DUMMY_PROCESS].fd     = candidate_fd;
-                               pfds[DUMMY_PROCESS].events = POLLIN|POLLHUP;
-                               pfds[DUMMY_PROCESS].revents = 0;
-
-                               _D("Dummy process was connected! (pid:%d)", candidate_pid);
-                       }
-                       else
-                       {
-                               __refuse_candidate_process(server_fd);
-
-                               _E("Refused dummy process connection!");
-                       }
-               }
-
-               if ((pfds[DUMMY_PROCESS].revents & (POLLHUP|POLLNVAL)) != 0)
-               {
-                       _D("pfds[DUMMY_PROCESS].revents & (POLLHUP|POLLNVAL) (pid:%d)", candidate_pid);
-
-                       if (pfds[DUMMY_PROCESS].fd > -1)
-                       {
-                               close(pfds[DUMMY_PROCESS].fd);
-                       }
-
-                       candidate_pid = DUMMY_NONE;
-                       candidate_fd = -1;
-
-                       pfds[DUMMY_PROCESS].fd          = -1;
-                       pfds[DUMMY_PROCESS].events  = 0;
-                       pfds[DUMMY_PROCESS].revents = 0;
-               }
-       }
-
-       return 0;
-
-exit_main:
-       if (main_fd != -1)
-       {
-               close(main_fd);
-       }
-
-       if (pool_fd != -1)
-       {
-               close(pool_fd);
-       }
-
-       return -1;
-}
-
diff --git a/process_pool/preload_list_for_process_pool.txt b/process_pool/preload_list_for_process_pool.txt
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/process_pool/process_pool.c b/process_pool/process_pool.c
deleted file mode 100644 (file)
index 3a09680..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <unistd.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <linux/un.h>
-#include <errno.h>
-#include <stdio.h>
-#include <systemd/sd-daemon.h>
-
-#include "process_pool.h"
-#include "simple_util.h"
-
-#define TMP_PATH "/tmp"
-#define PROCESS_POOL_SERVER "core_process_pool_server"
-#define MAX_PENDING_CONNECTIONS 10
-#define CONNECT_RETRY_TIME 100 * 1000
-#define CONNECT_RETRY_COUNT 3
-
-int __create_candidate_process(void)
-{
-    struct sockaddr_un addr;
-    int fd = -1;
-    int listen_fds=0;
-    int i;
-
-    _D("[dummy] process pool");
-
-    memset(&addr, 0x00, sizeof(struct sockaddr_un));
-    addr.sun_family = AF_UNIX;
-    snprintf(addr.sun_path, UNIX_PATH_MAX, "%s/%s", TMP_PATH, PROCESS_POOL_SERVER);
-
-    listen_fds = sd_listen_fds(0);
-    if (listen_fds < 0)
-    {
-        _E("invalid systemd environment");
-        return -1;
-    }
-    else if (listen_fds > 0)
-    {
-        for (i = 0; i < listen_fds; i++)
-        {
-            fd = SD_LISTEN_FDS_START  + i;
-            if (sd_is_socket_unix(fd, SOCK_STREAM, 1, addr.sun_path, 0))
-                return fd;
-        }
-        _E("socket not found: %s", addr.sun_path);
-        return -1;
-    }
-
-    fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
-
-    if (fd < 0)
-    {
-        _E("socket error");
-        goto err_create_process_pool_server;
-    }
-
-    unlink(addr.sun_path);
-
-    _D("bind to %s", addr.sun_path);
-    if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0)
-    {
-        _E("bind error");
-        goto err_create_process_pool_server;
-    }
-
-    _D("chmod to %s", addr.sun_path);
-    if (chmod(addr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0)
-    {
-        _E("chmod error");
-        goto err_create_process_pool_server;
-    }
-
-    _D("listen to %s", addr.sun_path);
-    if (listen(fd, MAX_PENDING_CONNECTIONS) == -1)
-    {
-        _E("listen error");
-        goto err_create_process_pool_server;
-    }
-
-    _D("__create_process_pool_server done : %d", fd);
-    return fd;
-
-
-err_create_process_pool_server:
-
-    if (fd != -1)
-    {
-        close(fd);
-    }
-
-    return -1;
-}
-
-
-int __connect_candidate_process(void)
-{
-    struct sockaddr_un addr;
-    int fd = -1;
-    int retry = CONNECT_RETRY_COUNT;
-    int send_ret = -1;
-    int client_pid = getpid();
-
-    memset(&addr, 0x00, sizeof(struct sockaddr_un));
-
-    fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
-
-    if (fd < 0)
-    {
-        _E("socket error");
-
-        goto err_connect_process_pool_server;
-    }
-
-    addr.sun_family = AF_UNIX;
-    snprintf(addr.sun_path, UNIX_PATH_MAX, "%s/%s", TMP_PATH, PROCESS_POOL_SERVER);
-
-
-    _D("connect to %s", addr.sun_path);
-    while (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0)
-    {
-        if (errno != ETIMEDOUT || retry <= 0)
-        {
-            _E("connect error : %d", errno);
-
-            goto err_connect_process_pool_server;
-        }
-
-        usleep(CONNECT_RETRY_TIME);
-        retry--;
-        _D("re-connect to %s (%d)", addr.sun_path, retry);
-    }
-
-    send_ret = send(fd, &client_pid, sizeof(client_pid), 0);
-    _D("send(%d) : %d", client_pid, send_ret);
-
-    if (send_ret == -1)
-    {
-        _E("send error");
-
-        goto err_connect_process_pool_server;
-    }
-
-    _D("__connect_process_pool_server done : %d", fd);
-    return fd;
-
-err_connect_process_pool_server:
-
-    if (fd != -1)
-    {
-        close(fd);
-    }
-
-    return -1;
-}
-
-
-int __accept_candidate_process(int server_fd, int* out_client_fd, int* out_client_pid)
-{
-    int client_fd = -1, client_pid = 0, recv_ret = 0;
-
-    if (server_fd == -1 || out_client_fd == NULL || out_client_pid == NULL)
-    {
-        _E("arguments error!");
-
-        goto err__accept_dummy_process;
-    }
-
-    client_fd = accept(server_fd, NULL, NULL);
-
-    if (client_fd == -1)
-    {
-        _E("accept error!");
-
-        goto err__accept_dummy_process;
-    }
-
-    recv_ret = recv(client_fd, &client_pid, sizeof(client_pid), MSG_WAITALL);
-
-    if (recv_ret == -1)
-    {
-        _E("recv error!");
-
-        goto err__accept_dummy_process;
-    }
-
-    *out_client_fd = client_fd;
-    *out_client_pid = client_pid;
-
-    return *out_client_fd;
-
-err__accept_dummy_process:
-
-    if (client_fd != -1)
-    {
-        close(client_fd);
-    }
-
-    return -1;
-}
-
-void __refuse_candidate_process(int server_fd)
-{
-    int client_fd = -1;
-
-    if (server_fd == -1)
-    {
-        _E("arguments error!");
-
-        goto err__refuse_dummy_process;
-    }
-
-    client_fd = accept(server_fd, NULL, NULL);
-
-    if (client_fd == -1)
-    {
-        _E("accept error!");
-
-        goto err__refuse_dummy_process;;
-    }
-
-    close(client_fd);
-    _D("refuse connection!");
-
-err__refuse_dummy_process:
-    return;
-}
-
-
-int __send_pkt_raw_data(int client_fd, app_pkt_t* pkt)
-{
-    int send_ret = 0;
-    int pkt_size = 0;
-
-    if (client_fd == -1 || pkt == NULL)
-    {
-        _E("arguments error!");
-
-        goto err__send_pkt_raw_data;
-    }
-
-    pkt_size = sizeof(pkt->cmd) + sizeof(pkt->len) + pkt->len;
-
-    send_ret = send(client_fd, pkt, pkt_size, 0);
-    _D("send(%d) : %d / %d", client_fd, send_ret, pkt_size);
-
-    if (send_ret == -1)
-    {
-        _E("send error!");
-
-        goto err__send_pkt_raw_data;
-    }
-    else if (send_ret != pkt_size)
-    {
-        _E("send byte fail!");
-
-        goto err__send_pkt_raw_data;
-    }
-
-    return 0;
-
-err__send_pkt_raw_data:
-
-    return -1;
-}
-
diff --git a/process_pool/process_pool.h b/process_pool/process_pool.h
deleted file mode 100644 (file)
index 38b6893..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __PROCESS_POOL_H_
-#define __PROCESS_POOL_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif //__cplusplus
-
-#include <app_sock.h>
-
-int  __create_candidate_process(void);
-int  __connect_candidate_process(void);
-int  __accept_candidate_process(int server_fd, int* out_client_fd, int* out_client_pid);
-void __refuse_candidate_process(int server_fd);
-int  __send_pkt_raw_data(int client_fd, app_pkt_t* pkt);
-
-#ifdef __cplusplus
-}
-#endif //__cplusplus
-
-#endif //__PROCESS_POOL_H_
index 0cab910..49bdf65 100755 (executable)
 
 
 #include <stdio.h>
+
 #include "app_signal.h"
 #include "aul_api.h"
 #include "simple_util.h"
 #include "aul.h"
 
+
 static int (*_app_dead_handler) (int pid, void *data);
 static void *_app_dead_data;
 
@@ -35,6 +37,17 @@ static void *_app_launch_data;
 static int (*_booting_done_handler) (int pid, void *data);
 static void *_booting_done_data;
 
+static int (*_status_handler) (int pid, int status, void *data);
+static void *_status_data;
+
+static int (*_cooldown_handler) (const char *cooldown_status, void *data);
+static void *_cooldown_data;
+
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+static int (*_lcd_status_handler) (const char *lcd_status, void *data);
+static void *_lcd_status_data;
+#endif
+
 static DBusConnection *bus;
 static int app_dbus_signal_handler_initialized = 0;
 
@@ -44,7 +57,9 @@ __app_dbus_signal_filter(DBusConnection *conn, DBusMessage *message,
 {
        const char *sender;
        const char *interface;
+       const char *cooldown_status;
        int pid;
+       int status;
 
        DBusError error;
        dbus_error_init(&error);
@@ -53,11 +68,11 @@ __app_dbus_signal_filter(DBusConnection *conn, DBusMessage *message,
        if (sender == NULL)
                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
-       if (dbus_bus_get_unix_user(conn, sender, &error) != 0) {
+       /*if (dbus_bus_get_unix_user(conn, sender, &error) != 0) {
                _E("reject by security issue - no allowed sender\n");
                dbus_error_free(&error);
                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-       }
+       }*/
 
        interface = dbus_message_get_interface(message);
        if (interface == NULL) {
@@ -89,7 +104,38 @@ __app_dbus_signal_filter(DBusConnection *conn, DBusMessage *message,
          message, interface, SYSTEM_SIGNAL_BOOTING_DONE)) {
                if (_booting_done_handler)
                        _booting_done_handler(pid, _booting_done_data);
+       } else if (dbus_message_is_signal(
+         message, interface, RESOURCED_SIGNAL_PROCESS_STATUS)) {
+               if (dbus_message_get_args(message, &error, DBUS_TYPE_INT32,&status,
+                       DBUS_TYPE_INT32,&pid, DBUS_TYPE_INVALID) == FALSE) {
+                       _E("Failed to get data: %s", error.message);
+                       dbus_error_free(&error);
+                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               }
+               if (_status_handler)
+                       _status_handler(pid, status, _status_data);
+       } else if (dbus_message_is_signal(
+         message, interface, SYSTEM_SIGNAL_COOLDOWN_CHANGED)) {
+               if (dbus_message_get_args(message, &error, DBUS_TYPE_STRING, &cooldown_status,
+                       DBUS_TYPE_INVALID) == FALSE) {
+                       _E("Failed to get data: %s", error.message);
+                       dbus_error_free(&error);
+                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               }
+               if (_cooldown_handler)
+                       _cooldown_handler(cooldown_status, _cooldown_data);
+       }
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+       else if (dbus_message_is_signal(
+         message, interface, DEVICED_SIGNAL_LCD_ON)) {
+               if (_lcd_status_handler)
+                       _lcd_status_handler(DEVICED_SIGNAL_LCD_ON, _lcd_status_data);
+       } else if (dbus_message_is_signal(
+         message, interface, DEVICED_SIGNAL_LCD_OFF)) {
+               if (_lcd_status_handler)
+                       _lcd_status_handler(DEVICED_SIGNAL_LCD_OFF, _lcd_status_data);
        }
+#endif
 
        return DBUS_HANDLER_RESULT_HANDLED;
 }
@@ -133,8 +179,10 @@ int __app_dbus_signal_handler_init_with_param(const char* path, const char* inte
        }
 
        if (dbus_connection_add_filter(bus, 
-               __app_dbus_signal_filter, NULL, NULL) == FALSE)
+               __app_dbus_signal_filter, NULL, NULL) == FALSE) {
+               _E("add filter fail");
                return -1;
+       }
 
        _D("app signal initialized");
 
@@ -240,3 +288,111 @@ SLPAPI int aul_listen_booting_done_signal(int (*func) (int, void *), void *data)
 
 }
 
+SLPAPI int aul_listen_cooldown_signal(int (*func) (const char *, void *), void *data)
+{
+       if (func) {
+               if (__app_dbus_signal_handler_init_with_param(SYSTEM_PATH_SYSNOTI, SYSTEM_INTERFACE_SYSNOTI) < 0) {
+                       _E("error app signal init");
+                       return AUL_R_ERROR;
+               }
+       } else if (_cooldown_handler == NULL) {
+               if (__app_dbus_signal_handler_fini_with_param(SYSTEM_PATH_SYSNOTI, SYSTEM_INTERFACE_SYSNOTI) < 0) {
+                       _E("error app signal fini");
+                       return AUL_R_ERROR;
+               }
+       }
+       _cooldown_handler = func;
+       _cooldown_data = data;
+
+       return AUL_R_OK;
+
+}
+
+SLPAPI int aul_listen_e17_status_signal(int (*func) (int, int, void *), void *data)
+{
+       if (func) {
+               if (__app_dbus_signal_handler_init_with_param(RESOURCED_PATH_CORE, RESOURCED_INTERFACE_CORE) < 0) {
+                       _E("error app signal init");
+                       return AUL_R_ERROR;
+               }
+       }
+       _status_handler = func;
+       _status_data = data;
+
+       return AUL_R_OK;
+}
+
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+SLPAPI int aul_listen_lcd_status_signal(int (*func) (const char *, void *), void *data)
+{
+       if (func) {
+               if (__app_dbus_signal_handler_init_with_param(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY) < 0) {
+                       _E("error app signal init");
+                       return AUL_R_ERROR;
+               }
+       }
+       _lcd_status_handler = func;
+       _lcd_status_data = data;
+
+       return AUL_R_OK;
+}
+#endif
+
+SLPAPI int aul_update_freezer_status(int pid, const char* type)
+{
+       DBusError err;
+       DBusConnection* conn = NULL;
+       DBusMessage* msg = NULL;
+       dbus_uint32_t serial = 0;
+
+       int ret = -1;
+
+       dbus_error_init(&err);
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+       if (!conn) {
+               _E("Fail to dbus_bus_get : %s", err.message);
+               return -1;
+       }
+
+       msg = dbus_message_new_signal(RESOURCED_PROC_OBJECT,
+                       RESOURCED_PROC_INTERFACE,
+                       RESOURCED_PROC_METHOD);
+       if (!msg) {
+               _E("Could not create DBus Message.");
+               ret = -1;
+               goto end;
+       }
+
+       if (!dbus_message_append_args(msg,
+                       DBUS_TYPE_STRING, &type,
+                       DBUS_TYPE_INT32, &pid,
+                       DBUS_TYPE_INVALID)) {
+               _E("Failed to append a D-Bus Message.");
+               ret = -1;
+       }
+
+       _D("Send a freezer signal pid: %d, type: %s", pid, type);
+
+       if (!dbus_connection_send(conn, msg, &serial)) {
+               _E("Failed to send a D-Bus Message.");
+               ret = -1;
+       }
+
+       dbus_connection_flush(conn);
+
+end:
+       dbus_error_free(&err);
+
+       if (msg) {
+               dbus_message_unref(msg);
+       }
+
+       if (conn) {
+               dbus_connection_unref(conn);
+       }
+
+       return ret;
+
+}
+
index 69cc3d2..6f5e932 100755 (executable)
@@ -66,11 +66,11 @@ int __create_server_sock(int pid)
                if (errno == EINVAL) {
                        fd = socket(AF_UNIX, SOCK_STREAM, 0);
                        if (fd < 0) {
-                               _E("second chance - socket create error");
+                               _E("second chance - socket create error: %d", errno);
                                return -1;
                        }
                } else {
-                       _E("socket error");
+                       _E("socket error: %d", errno);
                        return -1;
                }
        }
@@ -103,7 +103,7 @@ int __create_server_sock(int pid)
        }
 
        if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
-               _E("bind error");
+               _E("bind error: %d", errno);
                close(fd);
                return -1;
        }
@@ -118,7 +118,7 @@ int __create_server_sock(int pid)
        __set_sock_option(fd, 0);
 
        if (listen(fd, 128) == -1) {
-               _E("listen error");
+               _E("listen error: %d", errno);
                close(fd);
                return -1;
        }
@@ -149,17 +149,17 @@ int __create_client_sock(int pid)
        int retry = 2;
        int ret = -1;
 
-       fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);    
+       fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
        /*  support above version 2.6.27*/
        if (fd < 0) {
                if (errno == EINVAL) {
                        fd = socket(AF_UNIX, SOCK_STREAM, 0);
                        if (fd < 0) {
-                               _E("second chance - socket create error");
+                               _E("second chance - socket create error: %d", errno);
                                return -1;
                        }
                } else {
-                       _E("socket error");
+                       _E("socket error: %d", errno);
                        return -1;
                }
        }
@@ -170,7 +170,7 @@ int __create_client_sock(int pid)
        ret = __connect_client_sock(fd, (struct sockaddr *)&saddr, sizeof(saddr),
                        100 * 1000);
        if (ret < -1) {
-               _E("maybe peer not launched or peer daed\n");
+               _E("cannot connect the client socket: %d", errno);
                if (retry > 0) {
                        usleep((1+2*(2-retry))*100 * 1000);
                        retry--;
@@ -204,7 +204,8 @@ static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t
        error = 0;
        if ((ret = connect(fd, (struct sockaddr *)saptr, salen)) < 0) {
                if (errno != EAGAIN && errno != EINPROGRESS) {
-                       fcntl(fd, F_SETFL, flags);      
+                       _E("connect error: %d", errno);
+                       fcntl(fd, F_SETFL, flags);
                        return (-2);
                }
        }
@@ -219,8 +220,9 @@ static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t
        timeout.tv_sec = 0;
        timeout.tv_usec = nsec;
 
-       if ((ret = select(fd + 1, &readfds, &writefds, NULL, 
+       if ((ret = select(fd + 1, &readfds, &writefds, NULL,
                        nsec ? &timeout : NULL)) == 0) {
+               _E("select timeout");
                close(fd);      /* timeout */
                errno = ETIMEDOUT;
                return (-1);
@@ -262,8 +264,10 @@ int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
        _D("pid(%d) : cmd(%d)", pid, cmd);
 
        fd = __create_client_sock(pid);
-       if (fd < 0)
+       if (fd < 0) {
+               _E("cannot create a client socket: %d", fd);
                return -ECOMM;
+       }
 
        /* aul_app_is_running timeout : 25sec */
        if(cmd == APP_IS_RUNNING) {
@@ -291,7 +295,7 @@ int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
                        while (len != datalen + 8) {
                                ret = send(fd, &pkt->data[len-8], datalen + 8 - len, 0);
                                if (ret < 0) {
-                                       _E("second sendto() failed - %d %d (errno %d)", ret, datalen + 8, errno);
+                                       _E("second send() failed - %d %d (errno: %d)", ret, datalen + 8, errno);
                                        if (errno == EPIPE) {
                                                _E("pid:%d, fd:%d\n", pid, fd);
                                        }
@@ -303,7 +307,7 @@ int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
                                        return -ECOMM;
                                }
                                len += ret;
-                               _D("sendto() len - %d %d", len, datalen + 8);
+                               _D("send() len - %d %d", len, datalen + 8);
                        }
                } else {
                        if (errno == EPIPE) {
@@ -314,6 +318,8 @@ int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
                                free(pkt);
                                pkt = NULL;
                        }
+
+                       _E("send() failed: %d %s", errno, strerror(errno));
                        return -ECOMM;
                }
        }
@@ -496,7 +502,7 @@ app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr)
        if ((*clifd = accept(fd, (struct sockaddr *)&aul_addr,
                             (socklen_t *) &sun_size)) == -1) {
                if (errno != EINTR)
-                       _E("accept error");
+                       _E("accept error: %d", errno);
                return NULL;
        }
 
@@ -519,9 +525,11 @@ app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr)
  retry_recv:
        /* receive single packet from socket */
        len = recv(*clifd, pkt, AUL_SOCK_MAXBUFF, 0);
-       if (len < 0)
+       if (len < 0) {
+               _E("recv error: %d", errno);
                if (errno == EINTR)
                        goto retry_recv;
+       }
 
        if (len < 8) {
                _E("recv error %d %d", len, pkt->len);
@@ -530,10 +538,10 @@ app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr)
                return NULL;
        }
 
-       while( len != (pkt->len + 8) ) {
+       while( len < (pkt->len + 8) ) {
                ret = recv(*clifd, &pkt->data[len-8], AUL_SOCK_MAXBUFF, 0);
                if (ret < 0) {
-                       _E("recv error %d %d", len, pkt->len);
+                       _E("recv error: %d %d %d", errno, len, pkt->len);
                        free(pkt);
                        close(*clifd);
                        return NULL;
@@ -569,7 +577,7 @@ app_pkt_t *__app_send_cmd_with_result(int pid, int cmd, unsigned char *kb_data,
        }
 
        if ((len = send(fd, pkt, datalen + 8, 0)) != datalen + 8) {
-               _E("sendto() failed - %d", len);
+               _E("send() failed: %d len: %d", errno, len);
                if (errno == EPIPE) {
                        _E("pid:%d, fd:%d\n", pid, fd);
                }
@@ -591,7 +599,7 @@ retry_recv:
                } else if (errno == EINTR) {
                        goto retry_recv;
                } else {
-                       _E("recv error %s\n", strerror(errno));
+                       _E("recv error %d %s", errno, strerror(errno));
                        free(pkt);
                        close(fd);
                        return NULL;
diff --git a/src/aul_path.c b/src/aul_path.c
new file mode 100755 (executable)
index 0000000..85cb4fa
--- /dev/null
@@ -0,0 +1,371 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <unistd.h>
+#include <linux/limits.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include <pkgmgr-info.h>
+
+#include "aul_api.h"
+#include "aul_util.h"
+#include "simple_util.h"
+#include "aul.h"
+
+#define _MAX_PACKAGE_ID_LEN 256
+#define _MAX_BASE_PATH_LEN 512
+
+static const char _EXTERNAL_APP_SPECIFIC_PATH[] = "/opt/storage/sdcard/apps/";
+static const char _APP_SPECIFIC_PATH[] = "/opt/usr/apps/";
+
+static const char _DATA_DIR[] = "data/";
+static const char _CACHE_DIR[] = "cache/";
+static const char _RESOURCE_DIR[] = "res/";
+static const char _SHARED_DATA_DIR[] = "shared/data/";
+static const char _SHARED_TRUSTED_DIR[] = "shared/trusted/";
+static const char _SHARED_RESOURCE_DIR[] = "shared/res/";
+
+static int __get_pkgid_by_appid(char *pkgid, int pkgid_len, const char *appid)
+{
+       pkgmgrinfo_appinfo_h handle = NULL;
+       char *tmp_pkgid = NULL;
+
+       // get pkginfo handle
+       int err = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (err != PMINFO_R_OK)
+       {
+               _E("Failed to get app info. (err:%d)", err);
+               return AUL_R_ENOAPP;
+       }
+
+       // get and set pkgid
+       err = pkgmgrinfo_appinfo_get_pkgid(handle, &tmp_pkgid);
+       if (err != PMINFO_R_OK)
+       {
+               _E("Failed to get pkgid. (err:%d)", err);
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
+               return AUL_R_ENOAPP;
+       }
+
+       strncat(pkgid, tmp_pkgid, pkgid_len);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
+       return AUL_R_OK;
+}
+
+static int __get_pkgid(char* pkgid, int pkgid_len)
+{
+       char appid[_MAX_PACKAGE_ID_LEN] = {0,};
+
+       // get appid
+       int err = aul_app_get_appid_bypid(getpid(), appid, _MAX_PACKAGE_ID_LEN - 1);
+       if (err != AUL_R_OK)
+       {
+               _E("Failed to get appid. (err:%d)", err);
+               return err;
+       }
+
+       return __get_pkgid_by_appid(pkgid, pkgid_len, appid);
+}
+
+static int __get_root_path(char *root_path, int root_path_len, bool external)
+{
+       static char pkgid[_MAX_PACKAGE_ID_LEN] = {0,};
+       const char *specific_path = external ? _EXTERNAL_APP_SPECIFIC_PATH : _APP_SPECIFIC_PATH;
+
+       if (pkgid[0] == '\0')
+       {
+               int err = __get_pkgid(pkgid, _MAX_PACKAGE_ID_LEN - 1);
+               if (err != AUL_R_OK)
+               {
+                       return err;
+               }
+       }
+       {
+               int specific_path_len = strlen(specific_path);
+               int pkgid_len = strlen(pkgid);
+               int total_len = specific_path_len + pkgid_len + 1;
+
+               if (total_len > root_path_len)
+               {
+                       _E("Assert: path length %d is too long", total_len);
+                       assert(false);
+               }
+
+               strncat(root_path, specific_path, specific_path_len);
+               strncat(root_path + specific_path_len, pkgid, pkgid_len);
+               root_path[specific_path_len + pkgid_len] = '/';
+       }
+
+       return AUL_R_OK;
+}
+
+static int __get_path(char *path, int path_len, const char *dir_name, bool external)
+{
+       if (dir_name == NULL)
+       {
+               _E("Assert: dir name is NULL!");
+               assert(false);
+       }
+       {
+               const char *root_path = external ? aul_get_app_external_root_path() : aul_get_app_root_path();
+               if (root_path == NULL)
+               {
+                       return AUL_R_ERROR;
+               }
+               else
+               {
+                       int dir_name_len = strlen(dir_name);
+                       int root_path_len = strlen(root_path);
+                       int total_len = root_path_len + dir_name_len;
+
+                       if (total_len > path_len)
+                       {
+                               _E("Assert: path length %d is too long", total_len);
+                               assert(false);
+                       }
+
+                       strncpy(path, root_path, root_path_len);
+                       strncpy(path + root_path_len, dir_name, dir_name_len);
+               }
+       }
+
+       return AUL_R_OK;
+}
+
+static int __get_path_by_appid(char **path, const char *appid, const char *dir_name, bool external)
+{
+       if (dir_name == NULL)
+       {
+               _E("Assert: dir name is NULL!");
+               assert(false);
+       }
+
+       if (path == NULL || appid == NULL)
+       {
+               return AUL_R_EINVAL;
+       }
+
+       {
+               char pkgid[_MAX_PACKAGE_ID_LEN] = {0,};
+               int err = __get_pkgid_by_appid(pkgid, _MAX_PACKAGE_ID_LEN - 1, appid);
+               if (err != AUL_R_OK)
+               {
+                       return err;
+               }
+               {
+                       const char *specific_path = external ? _EXTERNAL_APP_SPECIFIC_PATH : _APP_SPECIFIC_PATH;
+                       int specific_path_len = strlen(specific_path);
+                       int pkgid_len = strlen(pkgid);
+                       int dir_name_len = strlen(dir_name);
+                       int total_len = specific_path_len + pkgid_len + 1 + dir_name_len;
+
+                       if (total_len > _MAX_BASE_PATH_LEN - 1)
+                       {
+                               _E("Assert: path length %d is too long", total_len);
+                               assert(false);
+                       }
+
+                       *path = (char *)calloc(total_len + 1, sizeof(char));
+                       if (*path == NULL)
+                       {
+                               return AUL_R_ERROR;
+                       }
+
+                       snprintf(*path, total_len + 1, "%s%s/%s", specific_path, pkgid, dir_name);
+               }
+       }
+
+       return AUL_R_OK;
+}
+
+SLPAPI const char *aul_get_app_external_root_path(void)
+{
+       static char external_root_path[_MAX_BASE_PATH_LEN] = {0,};
+       if (external_root_path[0] == '\0')
+       {
+               if (__get_root_path(external_root_path, _MAX_BASE_PATH_LEN - 1, true) != AUL_R_OK)
+               {
+                       return NULL;
+               }
+       }
+       return external_root_path;
+}
+
+SLPAPI const char *aul_get_app_root_path(void)
+{
+       static char root_path[_MAX_BASE_PATH_LEN] = {0,};
+       if (root_path[0] == '\0')
+       {
+               if (__get_root_path(root_path, _MAX_BASE_PATH_LEN - 1, false) != AUL_R_OK)
+               {
+                       return NULL;
+               }
+       }
+       return root_path;
+}
+
+SLPAPI const char *aul_get_app_data_path(void)
+{
+       static char data_path[_MAX_BASE_PATH_LEN] = {0,};
+       if (data_path[0] == '\0')
+       {
+               if (__get_path(data_path, _MAX_BASE_PATH_LEN - 1, _DATA_DIR, false) != AUL_R_OK)
+               {
+                       return NULL;
+               }
+       }
+       return data_path;
+}
+
+SLPAPI const char *aul_get_app_cache_path(void)
+{
+       static char cache_path[_MAX_BASE_PATH_LEN] = {0,};
+       if (cache_path[0] == '\0')
+       {
+               if (__get_path(cache_path, _MAX_BASE_PATH_LEN - 1, _CACHE_DIR, false) != AUL_R_OK)
+               {
+                       return NULL;
+               }
+       }
+       return cache_path;
+}
+
+SLPAPI const char *aul_get_app_resource_path(void)
+{
+       static char resource_path[_MAX_BASE_PATH_LEN] = {0,};
+       if (resource_path[0] == '\0')
+       {
+               if (__get_path(resource_path, _MAX_BASE_PATH_LEN - 1, _RESOURCE_DIR, false) != AUL_R_OK)
+               {
+                       return NULL;
+               }
+       }
+       return resource_path;
+}
+
+SLPAPI const char *aul_get_app_shared_data_path(void)
+{
+       static char shared_data_path[_MAX_BASE_PATH_LEN] = {0,};
+       if (shared_data_path[0] == '\0')
+       {
+               if (__get_path(shared_data_path, _MAX_BASE_PATH_LEN - 1, _SHARED_DATA_DIR, false) != AUL_R_OK)
+               {
+                       return NULL;
+               }
+       }
+       return shared_data_path;
+}
+
+SLPAPI const char *aul_get_app_shared_resource_path(void)
+{
+       static char shared_resource_path[_MAX_BASE_PATH_LEN] = {0,};
+       if (shared_resource_path[0] == '\0')
+       {
+               if (__get_path(shared_resource_path, _MAX_BASE_PATH_LEN - 1, _SHARED_RESOURCE_DIR, false) != AUL_R_OK)
+               {
+                       return NULL;
+               }
+       }
+       return shared_resource_path;
+}
+
+SLPAPI const char *aul_get_app_shared_trusted_path(void)
+{
+       static char shared_trusted_path[_MAX_BASE_PATH_LEN] = {0,};
+       if (shared_trusted_path[0] == '\0')
+       {
+               if (__get_path(shared_trusted_path, _MAX_BASE_PATH_LEN - 1, _SHARED_TRUSTED_DIR, false) != AUL_R_OK)
+               {
+                       return NULL;
+               }
+       }
+       return shared_trusted_path;
+}
+
+SLPAPI const char *aul_get_app_external_data_path(void)
+{
+       static char external_data_path[_MAX_BASE_PATH_LEN] = {0,};
+       if (external_data_path[0] == '\0')
+       {
+               if (__get_path(external_data_path, _MAX_BASE_PATH_LEN - 1, _DATA_DIR, true) != AUL_R_OK)
+               {
+                       return NULL;
+               }
+       }
+       return external_data_path;
+}
+
+SLPAPI const char *aul_get_app_external_cache_path(void)
+{
+       static char external_cache_path[_MAX_BASE_PATH_LEN] = {0,};
+       if (external_cache_path[0] == '\0')
+       {
+               if (__get_path(external_cache_path, _MAX_BASE_PATH_LEN - 1, _CACHE_DIR, true) != AUL_R_OK)
+               {
+                       return NULL;
+               }
+       }
+       return external_cache_path;
+}
+
+SLPAPI const char *aul_get_app_external_shared_data_path(void)
+{
+       static char external_shared_data_path[_MAX_BASE_PATH_LEN] = {0,};
+       if (external_shared_data_path[0] == '\0')
+       {
+               if (__get_path(external_shared_data_path, _MAX_PACKAGE_ID_LEN - 1, _SHARED_DATA_DIR, true) != AUL_R_OK)
+               {
+                       return NULL;
+               }
+       }
+       return external_shared_data_path;
+}
+
+SLPAPI const char *aul_get_app_specific_path(void)
+{
+       return _APP_SPECIFIC_PATH;
+}
+
+SLPAPI const char *aul_get_app_external_specific_path(void)
+{
+       return _EXTERNAL_APP_SPECIFIC_PATH;
+}
+
+SLPAPI int aul_get_app_shared_data_path_by_appid(const char *appid, char **path)
+{
+       return __get_path_by_appid(path, appid, _SHARED_DATA_DIR, false);
+}
+
+SLPAPI int aul_get_app_shared_resource_path_by_appid(const char *appid, char **path)
+{
+       return __get_path_by_appid(path, appid, _SHARED_RESOURCE_DIR, false);
+}
+
+SLPAPI int aul_get_app_shared_trusted_path_by_appid(const char *appid, char **path)
+{
+       return __get_path_by_appid(path, appid, _SHARED_TRUSTED_DIR, false);
+}
+
+SLPAPI int aul_get_app_external_shared_data_path_by_appid(const char *appid, char **path)
+{
+       return __get_path_by_appid(path, appid, _SHARED_DATA_DIR, true);
+}
index 6542905..9b636fa 100755 (executable)
@@ -28,6 +28,9 @@
 #include <string.h>
 #include <dirent.h>
 #include <glib.h>
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+#include <pkgmgr-info.h>
+#endif
 
 #include "aul.h"
 #include "aul_api.h"
@@ -55,9 +58,14 @@ static int __app_start_internal(gpointer data);
 static int __app_launch_local(bundle *b);
 static int __send_result_to_launchpad(int fd, int res);
 
-
-#ifdef PROCESS_POOL_ENABLE
+#ifdef _APPFW_FEATURE_PROCESS_POOL
 static void *__window_object = NULL;
+static void *__bg_object = NULL;
+static void *__conformant_object = NULL;
+#endif
+
+#ifdef _APPFW_FEATURE_DATA_CONTROL
+static data_control_provider_handler_fn __dc_handler = NULL;
 #endif
 
 extern  int aul_launch_fini();
@@ -76,8 +84,22 @@ static int __call_aul_handler(aul_type type, bundle *kb)
 
 int app_start(bundle *kb)
 {
+       const char *str = NULL;
+
        _app_start_res_prepare(kb);
        __call_aul_handler(AUL_START, kb);
+
+#ifdef _APPFW_FEATURE_DATA_CONTROL
+       // Handle the DataControl callback
+       str = bundle_get_val(kb, AUL_K_DATA_CONTROL_TYPE);
+       if (str != NULL && strcmp(str, "CORE") == 0)
+       {
+               if (__dc_handler != NULL)
+               {
+                       __dc_handler(kb, 0, NULL); // bundle, request_id, data
+               }
+       }
+#endif
        return 0;
 }
 
@@ -93,6 +115,19 @@ static int app_terminate()
        return 0;
 }
 
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+static int app_resume_lcd_on()
+{
+       __call_aul_handler(AUL_RESUME_LCD_ON, NULL);
+       return 0;
+}
+
+static int app_pause_lcd_off()
+{
+       __call_aul_handler(AUL_PAUSE_LCD_OFF, NULL);
+       return 0;
+}
+#endif
 
 /**
  * @brief      encode kb and send it to 'pid'
@@ -130,6 +165,14 @@ SLPAPI int app_send_cmd(int pid, int cmd, bundle *kb)
                case -ENOLAUNCHPAD:
                        res = AUL_R_ENOLAUNCHPAD;
                        break;
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+               case -EUGLOCAL_LAUNCH:
+                       res = AUL_R_UG_LOCAL;
+                       break;
+#endif
+               case -EREJECTED:
+                       res = AUL_R_EREJECTED;
+                       break;
                default:
                        res = AUL_R_ERROR;
                }
@@ -250,15 +293,36 @@ int app_request_to_launchpad(int cmd, const char *pkgname, bundle *kb)
                ret = app_send_cmd(AUL_UTIL_PID, cmd, kb);
 
        _D("launch request result : %d", ret);
-       if (ret == AUL_R_LOCAL) {
+       if (ret == AUL_R_LOCAL
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+               || ret == AUL_R_UG_LOCAL
+#endif
+               ) {
                _E("app_request_to_launchpad : Same Process Send Local");
                bundle *b;
 
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+               if(ret == AUL_R_UG_LOCAL) {
+                       pkgmgrinfo_appinfo_h handle;
+                       char *exec = NULL;
+
+                       pkgmgrinfo_appinfo_get_appinfo(pkgname, &handle);
+                       pkgmgrinfo_appinfo_get_exec(handle, &exec);
+
+                       bundle_add(kb, "__AUL_UG_EXEC__", exec);
+
+                       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+               }
+#endif
+
                switch (cmd) {
                        case APP_START:
                        case APP_START_RES:
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+                       case APP_START_MULTI_INSTANCE:
+#endif
                                b = bundle_dup(kb);
-                               ret = __app_launch_local(b);
+                               __app_launch_local(b);
                                break;
                        case APP_OPEN:
                        case APP_RESUME:
@@ -302,7 +366,7 @@ int aul_sock_handler(int fd)
        int clifd;
        struct ucred cr;
 
-       const char *pid_str = NULL;
+       const char *str = NULL;
        int pid;
        int ret;
 
@@ -318,7 +382,11 @@ int aul_sock_handler(int fd)
                return -1;
        }
 
-       if (pkt->cmd != APP_RESULT && pkt->cmd != APP_CANCEL) {
+       if (pkt->cmd != APP_RESULT && pkt->cmd != APP_CANCEL && pkt->cmd != APP_KEY_EVENT && pkt->cmd != APP_TERM_BY_PID_ASYNC
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+               && pkt->cmd != APP_PAUSE_LCD_OFF && pkt->cmd != APP_RESUME_LCD_ON
+#endif
+               ) {
                ret = __send_result_to_launchpad(clifd, 0);
                if (ret < 0) {
                        free(pkt);
@@ -332,6 +400,9 @@ int aul_sock_handler(int fd)
        case APP_START: /* run in callee */
        case APP_START_RES:
        case APP_START_ASYNC:
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+       case APP_START_MULTI_INSTANCE:
+#endif
                kbundle = bundle_decode(pkt->data, pkt->len);
                if (kbundle == NULL)
                        goto err;
@@ -346,6 +417,7 @@ int aul_sock_handler(int fd)
                break;
 
        case APP_TERM_BY_PID:   /* run in callee */
+       case APP_TERM_BY_PID_ASYNC:
                app_terminate();
                break;
 
@@ -359,9 +431,9 @@ int aul_sock_handler(int fd)
                if (kbundle == NULL)
                        goto err;
 
-               pid_str = bundle_get_val(kbundle, AUL_K_CALLEE_PID);
-               if(pid_str) {
-                       pid = atoi(pid_str);
+               str = bundle_get_val(kbundle, AUL_K_CALLEE_PID);
+               if(str) {
+                       pid = atoi(str);
                        app_result(pkt->cmd, kbundle, pid);
                }
                bundle_free(kbundle);
@@ -375,6 +447,15 @@ int aul_sock_handler(int fd)
                bundle_free(kbundle);
                break;
 
+#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
+       case APP_PAUSE_LCD_OFF:
+               app_pause_lcd_off();
+               break;
+
+       case APP_RESUME_LCD_ON:
+               app_resume_lcd_on();
+               break;
+#endif
        default:
                _E("no support packet");
        }
@@ -473,46 +554,44 @@ SLPAPI void aul_finalize()
 
 SLPAPI int aul_launch_app(const char *appid, bundle *kb)
 {
-       int ret;
-
        if (appid == NULL)
                return AUL_R_EINVAL;
 
-       ret = app_request_to_launchpad(APP_START, appid, kb);
-       return ret;
+       return app_request_to_launchpad(APP_START, appid, kb);
 }
 
 SLPAPI int aul_launch_app_async(const char *appid, bundle *kb)
 {
-       int ret;
+       if (appid == NULL)
+               return AUL_R_EINVAL;
+
+       return app_request_to_launchpad(APP_START_ASYNC, appid, kb);
+}
 
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+SLPAPI int aul_launch_app_for_multi_instance(const char *appid, bundle *kb)
+{
        if (appid == NULL)
                return AUL_R_EINVAL;
 
-       ret = app_request_to_launchpad(APP_START_ASYNC, appid, kb);
-       return ret;
+       return app_request_to_launchpad(APP_START_MULTI_INSTANCE, appid, kb);
 }
+#endif
 
 SLPAPI int aul_open_app(const char *appid)
 {
-       int ret;
-
        if (appid == NULL)
                return AUL_R_EINVAL;
 
-       ret = app_request_to_launchpad(APP_OPEN, appid, NULL);
-       return ret;
+       return app_request_to_launchpad(APP_OPEN, appid, NULL);
 }
 
 SLPAPI int aul_resume_app(const char *appid)
 {
-       int ret;
-
        if (appid == NULL)
                return AUL_R_EINVAL;
 
-       ret = app_request_to_launchpad(APP_RESUME, appid, NULL);
-       return ret;
+       return app_request_to_launchpad(APP_RESUME, appid, NULL);
 }
 
 SLPAPI int aul_resume_pid(int pid)
@@ -541,6 +620,32 @@ SLPAPI int aul_terminate_pid(int pid)
        return ret;
 }
 
+SLPAPI int aul_terminate_pid_without_restart(int pid)
+{
+       char pkgname[MAX_PID_STR_BUFSZ];
+       int ret;
+
+       if (pid <= 0)
+               return AUL_R_EINVAL;
+
+       snprintf(pkgname, MAX_PID_STR_BUFSZ, "%d", pid);
+       ret = app_request_to_launchpad(APP_TERM_BY_PID_WITHOUT_RESTART, pkgname, NULL);
+       return ret;
+}
+
+SLPAPI int aul_terminate_pid_async(int pid)
+{
+       char pkgname[MAX_PID_STR_BUFSZ];
+       int ret;
+
+       if (pid <= 0)
+               return AUL_R_EINVAL;
+
+       snprintf(pkgname, MAX_PID_STR_BUFSZ, "%d", pid);
+       ret = app_request_to_launchpad(APP_TERM_BY_PID_ASYNC, pkgname, NULL);
+       return ret;
+}
+
 SLPAPI int aul_kill_pid(int pid)
 {
        char pkgname[MAX_PID_STR_BUFSZ];
@@ -554,17 +659,50 @@ SLPAPI int aul_kill_pid(int pid)
        return ret;
 }
 
-#ifdef PROCESS_POOL_ENABLE
+#ifdef _APPFW_FEATURE_PROCESS_POOL
 SLPAPI void aul_set_preinit_window(void *evas_object)
 {
         __window_object = evas_object;
 }
 
-SLPAPI void* aul_get_preinit_window(void)
+SLPAPI void* aul_get_preinit_window(const char *win_name)
 {
         return __window_object;
 }
+
+SLPAPI void aul_set_preinit_background(void *evas_object)
+{
+        __bg_object = evas_object;
+}
+
+SLPAPI void* aul_get_preinit_background(void)
+{
+        return __bg_object;
+}
+
+SLPAPI void aul_set_preinit_conformant(void *evas_object)
+{
+       __conformant_object = evas_object;
+}
+
+SLPAPI void* aul_get_preinit_conformant(void)
+{
+       return __conformant_object;
+}
 #endif
 
-/* vi: set ts=8 sts=8 sw=8: */
+#ifdef _APPFW_FEATURE_DATA_CONTROL
+SLPAPI int aul_set_data_control_provider_cb(data_control_provider_handler_fn handler)
+{
+       __dc_handler = handler;
+       return 0;
+}
 
+SLPAPI int aul_unset_data_control_provider_cb(void)
+{
+       __dc_handler = NULL;
+       return 0;
+}
+#endif
+
+/* vi: set ts=8 sts=8 sw=8: */
index 7f1f155..ed8bb20 100755 (executable)
@@ -45,6 +45,10 @@ typedef struct _app_resultcb_info_t {
 
 static int latest_caller_pid = -1;
 static app_resultcb_info_t *rescb_head = NULL;
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+static app_resultcb_info_t *rescb_head2 = NULL;
+#endif
+
 
 static int is_subapp = 0;
 subapp_fn subapp_cb = NULL;
@@ -83,18 +87,19 @@ static void __add_resultcb(int pid, void (*cbfunc) (bundle *, int, void *),
 static app_resultcb_info_t *__find_resultcb(int pid)
 {
        app_resultcb_info_t *tmp;
+       app_resultcb_info_t *ret = NULL;
 
        pthread_mutex_lock(&result_lock);
        tmp = rescb_head;
        while (tmp) {
                if (tmp->launched_pid == pid) {
-                       pthread_mutex_unlock(&result_lock);
-                       return tmp;
+                       ret = tmp;
                }
                tmp = tmp->next;
        }
        pthread_mutex_unlock(&result_lock);
-       return NULL;
+
+       return ret;
 }
 
 static void __remove_resultcb(app_resultcb_info_t *info)
@@ -121,6 +126,71 @@ static void __remove_resultcb(app_resultcb_info_t *info)
        }
 }
 
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+static void __add_resultcb2(int pid, void (*cbfunc) (bundle *, int, void *),
+                        void *data)
+{
+       app_resultcb_info_t *info;
+
+       _D("id : %d", pid);
+
+       info = (app_resultcb_info_t *) malloc(sizeof(app_resultcb_info_t));
+       if(info == NULL)
+               return;
+       info->launched_pid = pid;
+       info->cb_func = cbfunc;
+       info->priv_data = data;
+       info->caller_cb = NULL;
+       info->caller_data = NULL;
+
+       info->next = rescb_head2;
+       rescb_head2 = info;
+}
+
+static app_resultcb_info_t *__find_resultcb2(int pid)
+{
+       app_resultcb_info_t *tmp;
+       app_resultcb_info_t *ret = NULL;
+
+       pthread_mutex_lock(&result_lock);
+       tmp = rescb_head2;
+       while (tmp) {
+               _D("id_id : %d", tmp->launched_pid);
+               if (tmp->launched_pid == pid) {
+                       ret = tmp;
+               }
+               tmp = tmp->next;
+       }
+       pthread_mutex_unlock(&result_lock);
+
+       return ret;
+}
+
+static void __remove_resultcb2(app_resultcb_info_t *info)
+{
+       app_resultcb_info_t *tmp;
+
+       if (rescb_head2 == NULL || info == NULL)
+               return;
+
+       if (rescb_head2 == info) {
+               rescb_head2 = info->next;
+               free(info);
+               return;
+       }
+
+       tmp = rescb_head2;
+       while (tmp) {
+               if (tmp->next == info) {
+                       tmp->next = info->next;
+                       free(info);
+                       return;
+               }
+               tmp = tmp->next;
+       }
+}
+#endif
+
 /**
  * call result callback function
  * run in caller
@@ -151,8 +221,31 @@ static int __call_app_result_callback(bundle *kb, int is_cancel,
                return -1;
 
        /* In case of aul_forward_app, update the callback data */
-       if(is_cancel == 1 &&
-       (fwdpid_str = (char *)bundle_get_val(kb, AUL_K_FWD_CALLEE_PID)))
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+       if(is_cancel == 1 && (fwdpid_str = (char *)bundle_get_val(kb, "__AUL_FWD_UG_ID__")))
+       {
+               app_resultcb_info_t newinfo;
+               newinfo.launched_pid = atoi(fwdpid_str);
+               newinfo.cb_func = info->cb_func;
+               newinfo.priv_data = info->priv_data;
+               newinfo.caller_cb = NULL;
+               newinfo.caller_data = NULL;
+
+               if(info->caller_cb) {
+                       info->caller_cb(newinfo.launched_pid, info->caller_data);
+               }
+
+               __remove_resultcb(info);
+               __add_resultcb2(newinfo.launched_pid, newinfo.cb_func, newinfo.priv_data);
+
+               _D("change callback __AUL_FWD_UG_ID__ - %d\n", newinfo.launched_pid);
+
+               goto end;
+       }
+       else if(is_cancel == 1 && (fwdpid_str = (char *)bundle_get_val(kb, AUL_K_FWD_CALLEE_PID)))
+#else
+       if(is_cancel == 1 && (fwdpid_str = (char *)bundle_get_val(kb, AUL_K_FWD_CALLEE_PID)))
+#endif
        {
                app_resultcb_info_t newinfo;
                newinfo.launched_pid = atoi(fwdpid_str);
@@ -277,6 +370,10 @@ SLPAPI int aul_launch_app_with_result(const char *pkgname, bundle *kb,
                               void *data)
 {
        int ret;
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+       int id = -1;
+       char id_str[256] = {0, };
+#endif
 
        if (!aul_is_initialized()) {
                if (aul_launch_init(NULL, NULL) < 0)
@@ -287,10 +384,21 @@ SLPAPI int aul_launch_app_with_result(const char *pkgname, bundle *kb,
                return AUL_R_EINVAL;
 
        pthread_mutex_lock(&result_lock);
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+       id = rand();
+       sprintf(id_str, "%d", id);
+       bundle_add(kb, "__AUL_UG_ID__", id_str);
+#endif
        ret = app_request_to_launchpad(APP_START_RES, pkgname, kb);
-
        if (ret > 0)
                __add_resultcb(ret, cbfunc, data);
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+       else if (ret == AUL_R_UG_LOCAL) {
+               __add_resultcb2(id, cbfunc, data);
+               pthread_mutex_unlock(&result_lock);
+               return getpid();
+       }
+#endif
        pthread_mutex_unlock(&result_lock);
 
        return ret;
@@ -309,6 +417,10 @@ SLPAPI int aul_forward_app(const char* pkgname, bundle *kb)
        bundle *dupb;
        bundle *outb;
        char tmp_pid[MAX_PID_STR_BUFSZ];
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+       int caller_pid;
+       int callee_pid;
+#endif
 
        if(pkgname == NULL || kb == NULL)
                return AUL_R_EINVAL;
@@ -322,6 +434,10 @@ SLPAPI int aul_forward_app(const char* pkgname, bundle *kb)
        bundle_del(kb, AUL_K_ORG_CALLER_PID);
        bundle_add(kb, AUL_K_ORG_CALLER_PID, caller);
 
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+       caller_pid = atoi(caller);
+#endif
+
        dupb = bundle_dup(kb);
        if(dupb == NULL) {
                _E("bundle duplicate fail");
@@ -337,7 +453,9 @@ SLPAPI int aul_forward_app(const char* pkgname, bundle *kb)
                goto end;
        }
 
-//     bundle_iterate(dupb, __iterate, NULL);
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+       callee_pid = ret;
+#endif
 
        snprintf(tmp_pid, MAX_PID_STR_BUFSZ,"%d",ret);
 
@@ -345,8 +463,20 @@ SLPAPI int aul_forward_app(const char* pkgname, bundle *kb)
        if(ret < 0)
                goto end;
 
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+       _D("callee_pid(%d) caller_pid(%d)", callee_pid, caller_pid);
+
+       if(callee_pid == caller_pid) {
+               bundle_del(outb, AUL_K_FWD_CALLEE_PID);
+               bundle_add(outb, "__AUL_FWD_UG_ID__", bundle_get_val(kb, "__AUL_UG_ID__"));
+       } else {
+               bundle_del(outb, AUL_K_FWD_CALLEE_PID);
+               bundle_add(outb, AUL_K_FWD_CALLEE_PID, tmp_pid);
+       }
+#else
        bundle_del(outb, AUL_K_FWD_CALLEE_PID);
        bundle_add(outb, AUL_K_FWD_CALLEE_PID, tmp_pid);
+#endif
 
 //     bundle_iterate(outb, __iterate, NULL);
 
@@ -520,3 +650,21 @@ SLPAPI int aul_remove_caller_cb(int pid)
 
        return 0;
 }
+
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+SLPAPI int aul_call_ug_result_callback(bundle *kb, int is_cancel, int id)
+{
+       app_resultcb_info_t *info;
+       int pgid;
+
+       info = __find_resultcb2(id);
+
+       _D("id : %d", id);
+
+       info->cb_func(kb, is_cancel, info->priv_data);
+       __remove_resultcb2(info);
+
+       return 0;
+}
+#endif
+
diff --git a/src/mida.c b/src/mida.c
deleted file mode 100755 (executable)
index f61eef7..0000000
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- *  aul
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include "mida.h"
-#include "menu_db_util.h"
-#include "simple_util.h"
-
-#define MIDA_DB_PATH   "/opt/dbspace/.mida.db"
-#define QUERY_MAXLEN   4096
-#define BUF_MAX_LEN            1024
-
-#define MIDA_TBL_NAME  "mida"
-#define MIDA_F_PKGNAME "pkg_name"
-#define MIDA_F_MIMETYPE        "mime_type"
-
-#define SVC_TBL_NAME   "svc"
-#define SVC_F_PKGNAME  "pkg_name"
-#define SVC_F_SVCNAME  "svc_name"
-
-#define SYSSVC_TBL_NAME        "system_svc"
-#define SYSSVC_F_SVCNAME "svc_name"
-
-static sqlite3 *mida_db = NULL;
-
-
-static int _exec(sqlite3 *db, char *query);
-static int _init(void);
-static int __fini(void);
-static int __delete_all(const char *tbl_name);
-static int __delete_with_field(const char *tbl_name, const char *f_name,
-                               const char *val, int equal);
-static int __count_with_field(const char *tbl_name, const char *f_name,
-                               const char *val, int equal);
-static char *__get_with_field(const char *tbl_name, const char *get_f_name, 
-                               const char *f_name, const char *val, int equal);
-static int __doubt_sql_injection(const char *str);
-
-
-
-/**
- * exec  
- * param[in] db handler
- * param[in] query query
- * return This method returns 0 (SUCCESS) or -1 (FAIL)
- */
-static int _exec(sqlite3 *db, char *query)
-{
-       int rc = 0;
-       char *errmsg = NULL;
-
-       retvm_if(db == NULL, -1, "DB handler is null");
-
-       rc = sqlite3_exec(db, query, NULL, 0, &errmsg);
-
-       if (rc != SQLITE_OK) {
-               _D("Query: [%s]", query);
-               _E("SQL error: %s\n", errmsg);
-               sqlite3_free(errmsg);
-               return (-1);
-       }
-
-       return 0;
-}
-
-/**
- * db initialize
- */
-static int _init(void)
-{
-       int rc;
-
-       if (mida_db) {
-               _D("Already initialized\n");
-               return 0;
-       }
-
-       rc = sqlite3_open(MIDA_DB_PATH, &mida_db);
-       if (rc) {
-               _E("Can't open database: %s", sqlite3_errmsg(mida_db));
-               goto err;
-       }
-       /* Enable persist journal mode */
-       rc = sqlite3_exec(mida_db, "PRAGMA journal_mode = PERSIST", NULL, NULL,
-                         NULL);
-       if (SQLITE_OK != rc) {
-               _D("Fail to change journal mode\n");
-               goto err;
-       }
-
-       return 0;
-err:
-       sqlite3_close(mida_db);
-       return -1;
-}
-
-static int __fini(void)
-{
-       if (mida_db) {
-               sqlite3_close(mida_db);
-               mida_db = NULL;
-       }
-       return 0;
-}
-
-static int __delete_all(const char *tbl_name)
-{
-       char *_sqlbuf;
-       int rc;
-
-       _sqlbuf = sqlite3_mprintf("DELETE FROM %s;", tbl_name);
-       rc = _exec(mida_db, _sqlbuf);
-       sqlite3_free(_sqlbuf);
-
-       return rc;
-}
-
-static int __delete_with_field(const char *tbl_name, const char *f_name,
-                             const char *val, int equal)
-{
-       char tmp_val[BUF_MAX_LEN];
-       char *_sqlbuf;
-       int rc;
-
-       if (equal) {
-               _sqlbuf = sqlite3_mprintf("DELETE FROM %s WHERE %s = '%s';",
-                                         tbl_name, f_name, val);
-       } else {
-               snprintf(tmp_val, BUF_MAX_LEN, "%%%s%%", val);
-               _sqlbuf = sqlite3_mprintf("DELETE FROM %s WHERE %s like '%s';",
-                                         tbl_name, f_name, tmp_val);
-       }
-
-       rc = _exec(mida_db, _sqlbuf);
-       sqlite3_free(_sqlbuf);
-
-       return rc;
-}
-
-static int __count_with_field(const char *tbl_name, const char *f_name,
-                            const char *val, int equal)
-{
-       char tmp_val[BUF_MAX_LEN];
-       char *_sqlbuf;
-       int rc;
-       char **db_result = NULL;
-       char *db_err = NULL;
-       int nrows = 0;
-       int ncols = 0;
-       int cnt;
-
-       if (equal) {
-               _sqlbuf = sqlite3_mprintf(
-                               "SELECT COUNT(*) FROM %s WHERE %s = '%s';",
-                               tbl_name, f_name, val);
-       } else {
-               snprintf(tmp_val, BUF_MAX_LEN, "%%%s%%", val);
-               _sqlbuf = sqlite3_mprintf(
-               "SELECT COUNT(*) FROM %s WHERE %s like '%s';", tbl_name,
-               f_name, tmp_val);
-       }
-
-       rc = sqlite3_get_table(mida_db, _sqlbuf, &db_result, &nrows, &ncols,
-                              &db_err);
-       if (rc == -1 || nrows == 0) {
-               _D("get count = 0 or fail");
-               sqlite3_free_table(db_result);
-               sqlite3_free(_sqlbuf);
-               return 0;
-       } else {
-               cnt = atoi(db_result[1]);
-               sqlite3_free_table(db_result);
-               sqlite3_free(_sqlbuf);
-       }
-
-       return cnt;
-}
-
-static char *__get_with_field(const char *tbl_name, const char *get_f_name, 
-                       const char *f_name, const char *val, int equal)
-{
-       char tmp_val[BUF_MAX_LEN];
-       char *_sqlbuf;
-       sqlite3_stmt *stmt;
-       int ret;
-       char *res = NULL;
-
-       if (equal) {
-               _sqlbuf = sqlite3_mprintf("SELECT %s FROM %s WHERE %s = ?;",
-                                         get_f_name, tbl_name, f_name);
-
-       } else {
-               _sqlbuf = sqlite3_mprintf("SELECT %s FROM %s WHERE %s like ?;",
-                                         get_f_name, tbl_name, f_name);
-       }
-       if (_sqlbuf == NULL) {
-               _D("Failed to print the SQL query\n");
-               return res;
-       }
-
-       if (sqlite3_prepare_v2(mida_db, _sqlbuf, 
-                               -1, &stmt, NULL) != SQLITE_OK) {
-               _D("Failed to prepare the SQL stmt\n");
-               sqlite3_free(_sqlbuf);
-               return res;
-       }
-
-       if (equal) {
-               ret = sqlite3_bind_text(stmt, 1, val, -1, SQLITE_STATIC);
-       } else {
-               snprintf(tmp_val, BUF_MAX_LEN, "%%%s%%", val);
-               ret = sqlite3_bind_text(stmt, 1, tmp_val, -1, SQLITE_STATIC);
-       }
-       if (ret != SQLITE_OK) {
-               _D("Failed to bind %s with SQL stmt\n", val);
-               goto end;
-       }
-
-       if (sqlite3_step(stmt) == SQLITE_ROW) {
-               if (sqlite3_column_text(stmt, 0)) {
-                       res = strdup((char *)sqlite3_column_text(stmt, 0));
-               }
-       }
-
-end:
-       sqlite3_finalize(stmt);
-       sqlite3_free(_sqlbuf);
-       return res;
-}
-
-static int __doubt_sql_injection(const char *str)
-{
-       char *tmp;
-       char *token;
-       char *saveptr;
-
-       if (str == NULL)
-               return 1;
-
-       /* check " , ' , ; */
-       tmp = strdup(str);
-       token = strtok_r(tmp, "\"';", &saveptr);
-
-       if (token == NULL)
-               return 1;
-
-       if (strcmp(str, token) != 0)
-               return 1;
-
-       free(tmp);
-
-       return 0;
-}
-
-int mida_clear(void)
-{
-       int rc = 0;
-
-       if (_init() < 0)
-               return -1;
-       rc = __delete_all(MIDA_TBL_NAME);
-       __fini();
-
-       return rc;
-}
-
-int mida_delete_with_pkgname(const char *pkg_name)
-{
-       int rc = 0;
-
-       retvm_if(pkg_name == NULL, -1,
-                "Invalid argument: data to delete is NULL\n");
-
-       if (_init() < 0)
-               return -1;
-       rc = __delete_with_field(MIDA_TBL_NAME, MIDA_F_PKGNAME, pkg_name, 1);
-       __fini();
-
-       return rc;
-}
-
-int mida_delete_with_mimetype(const char *mime_type)
-{
-       int rc = 0;
-
-       retvm_if(mime_type == NULL, -1,
-                "Invalid argument: data to delete is NULL\n");
-
-       if (_init() < 0)
-               return -1;
-       rc = __delete_with_field(MIDA_TBL_NAME, MIDA_F_MIMETYPE, mime_type, 0);
-       __fini();
-
-       return rc;
-}
-
-int mida_add_app(const char *mime_type, const char *pkg_name)
-{
-       int rc = -1;
-       int cnt = 0;
-       char *_sqlbuf;
-
-       retvm_if(mime_type == NULL, -1, "Mime type is null\n");
-       retvm_if(pkg_name == NULL, -1, "Package name is null\n");
-
-       if (__doubt_sql_injection(mime_type))
-               return -1;
-
-       if (_init() < 0)
-               return -1;
-
-       cnt = __count_with_field(MIDA_TBL_NAME, MIDA_F_MIMETYPE, mime_type, 0);
-
-       if (cnt == 0) {
-               SECURE_LOGD("Inserting (%s, %s)", pkg_name, mime_type);
-               /* insert */
-               _sqlbuf = sqlite3_mprintf(
-                           "INSERT INTO %s (%s,%s) values (\"%s\", \"%s\");",
-                           MIDA_TBL_NAME, MIDA_F_PKGNAME, MIDA_F_MIMETYPE, 
-                           pkg_name, mime_type);
-
-               rc = _exec(mida_db, _sqlbuf);
-               sqlite3_free(_sqlbuf);
-       } else {
-               SECURE_LOGD("Setting %s for %s", pkg_name, mime_type);
-               /* update */
-               _sqlbuf = sqlite3_mprintf(
-                                   "UPDATE %s SET %s = '%s' where %s = '%s';",
-                                   MIDA_TBL_NAME, MIDA_F_PKGNAME, pkg_name,
-                                   MIDA_F_MIMETYPE, mime_type);
-
-               rc = _exec(mida_db, _sqlbuf);
-               sqlite3_free(_sqlbuf);
-       }
-
-       if (rc < 0)
-               _E("fail to insert or update\n");
-
-       __fini();
-       return rc;
-}
-
-char *mida_get_app(const char *mime_type)
-{
-       char *res = NULL;
-
-       if (mime_type == NULL)
-               return NULL;
-
-       if (__doubt_sql_injection(mime_type))
-               return NULL;
-
-       if (_init() < 0)
-               return NULL;
-       res =
-           __get_with_field(MIDA_TBL_NAME, MIDA_F_PKGNAME, MIDA_F_MIMETYPE,
-                           mime_type, 0);
-       __fini();
-
-       return res;
-}
-
-int svc_clear(void)
-{
-       int rc = 0;
-
-       if (_init() < 0)
-               return -1;
-       rc = __delete_all(SVC_TBL_NAME);
-       __fini();
-
-       return rc;
-}
-
-int svc_delete_with_pkgname(const char *pkg_name)
-{
-       int rc = 0;
-
-       retvm_if(pkg_name == NULL, -1,
-                "Invalid argument: data to delete is NULL\n");
-
-       if (_init() < 0)
-               return -1;
-       rc = __delete_with_field(SVC_TBL_NAME, SVC_F_PKGNAME, pkg_name, 1);
-       __fini();
-
-       return rc;
-}
-
-int svc_delete_with_svcname(const char *svc_name)
-{
-       int rc = 0;
-
-       retvm_if(svc_name == NULL, -1,
-                "Invalid argument: data to delete is NULL\n");
-
-       if (_init() < 0)
-               return -1;
-       rc = __delete_with_field(SVC_TBL_NAME, SVC_F_SVCNAME, svc_name, 0);
-       __fini();
-
-       return rc;
-}
-
-int svc_add_app(const char *svc_name, const char *pkg_name)
-{
-       int rc = -1;
-       int cnt = 0;
-       char *_sqlbuf;
-
-       retvm_if(svc_name == NULL, -1, "Service name is null\n");
-       retvm_if(pkg_name == NULL, -1, "Package name is null\n");
-
-       if (__doubt_sql_injection(svc_name))
-               return -1;
-
-       if (_init() < 0)
-               return -1;
-
-       cnt = __count_with_field(SVC_TBL_NAME, SVC_F_SVCNAME, svc_name, 0);
-
-       if (cnt == 0) {
-               /* insert */
-               SECURE_LOGD("Inserting (%s, %s)", pkg_name, svc_name);
-               _sqlbuf = sqlite3_mprintf(
-                    "INSERT INTO %s (%s,%s) values (\"%s\", \"%s\");",
-                    SVC_TBL_NAME, SVC_F_PKGNAME, SVC_F_SVCNAME, pkg_name,
-                    svc_name);
-
-               rc = _exec(mida_db, _sqlbuf);
-               sqlite3_free(_sqlbuf);
-       } else {
-               /* update */
-               SECURE_LOGD("Setting %s for %s", pkg_name, svc_name);
-               _sqlbuf = sqlite3_mprintf(
-                                   "UPDATE %s SET %s = '%s' where %s = '%s';",
-                                   SVC_TBL_NAME, SVC_F_PKGNAME, pkg_name,
-                                   SVC_F_SVCNAME, svc_name);
-
-               rc = _exec(mida_db, _sqlbuf);
-               sqlite3_free(_sqlbuf);
-       }
-
-       if (rc < 0)
-               _E("fail to insert or update\n");
-
-       __fini();
-       return rc;
-}
-
-char *svc_get_app(const char *svc_name)
-{
-       char *res = NULL;
-
-       if (svc_name == NULL)
-               return NULL;
-
-       if (__doubt_sql_injection(svc_name))
-               return NULL;
-
-       if (_init() < 0)
-               return NULL;
-       res =
-           __get_with_field(SVC_TBL_NAME, SVC_F_PKGNAME, SVC_F_SVCNAME,
-                           svc_name, 0);
-       __fini();
-
-       return res;
-}
-
-int is_supported_svc(const char *svc_name)
-{
-       int rc = 0;
-       int cnt = 0;
-
-       retvm_if(svc_name == NULL, 0, "Service name is null\n");
-
-       if (__doubt_sql_injection(svc_name))
-               return 0;
-
-       if (_init() < 0)
-               return 0;
-
-       cnt = __count_with_field(SYSSVC_TBL_NAME, 
-                       SYSSVC_F_SVCNAME, svc_name, 0);
-
-       if (cnt > 0)
-               rc = 1;
-       else
-               SECURE_LOGD("%s is not supported.", svc_name);
-
-       __fini();
-       return rc;
-}
-
index 269d049..cd89551 100755 (executable)
  *
  */
 
-
 #include "aul.h"
 #include "aul_api.h"
-#include "mida.h"
 #include "miregex.h"
 #include <stdio.h>
 #include <string.h>
 #include "menu_db_util.h"
 #include "simple_util.h"
 
-#ifdef WEARABLE_PROFILE
-#define MIME_APP_SELECTOR "com.samsung.app-selector"
-#else
-#define MIME_APP_SELECTOR "org.tizen.app-selector"
-#endif
-
-static int __match_content_with_regex(const char *content, regex_t *regex_preg);
-static int get_defapp_from_desktop(const char *mimetype, char *defapp, int len);
-static int _aul_get_defapp_from_mime(const char *mimetype, char *unaliased,
-                                    char *defapp, int len_unaliased,
-                                    int len_defapp);
-static int __launch_with_defapp(const char *mime_type, 
-                                       const char *mime_content);
-
-
-
 static int __match_content_with_regex(const char *content, regex_t *regex_preg)
 {
        if (regexec(regex_preg, content, 0, NULL, 0) == 0)
@@ -119,7 +101,7 @@ SLPAPI int aul_get_mime_description(const char *mimetype, char *desc, int len)
        if (founded != NULL)
                snprintf(desc, len, "%s", founded);
        else {
-               /* TODO : should to try to extract from 
+               /* TODO : should to try to extract from
                   share mime info's comment */
                return AUL_R_ERROR;
        }
@@ -214,232 +196,3 @@ SLPAPI int aul_get_mime_from_file(const char *filename, char *mimetype, int len)
        snprintf(mimetype, len, "%s", mime);
        return AUL_R_OK;
 }
-
-SLPAPI int aul_set_defapp_with_mime(const char *mimetype, const char *defapp)
-{
-       const char *unaliased_mimetype;
-
-       if (mimetype == NULL || defapp == NULL) {
-               _E("invalid arg");
-               return AUL_R_EINVAL;
-       }
-
-       unaliased_mimetype = xdg_mime_unalias_mime_type(mimetype);
-       if (unaliased_mimetype == NULL)
-               return AUL_R_ERROR;
-
-       if (mida_add_app(unaliased_mimetype, defapp) < 0) {
-               _E("fail to add: mimtype-%s and defapp-%s", unaliased_mimetype,
-                  defapp);
-               return AUL_R_ERROR;
-       }
-
-       return AUL_R_OK;
-}
-
-static ail_cb_ret_e __defapp_with_mime_func(
-                       const ail_appinfo_h appinfo, void *user_data)
-{
-       char **package = (char **)user_data;
-       char *str;
-
-       ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &str);
-
-       _D("defapp from desktop = %s", str);
-
-       *package = strdup(str);
-       
-       return AIL_CB_RET_CANCEL;       /*return AIL_CB_RET_CONTINUE;*/ 
-}
-
-static int get_defapp_from_desktop(const char *mimetype, char *defapp, int len)
-{
-       ail_filter_h filter;
-       ail_error_e ret;
-       int pkg_count = 0;
-       char *tmp = NULL;
-
-       ret = ail_filter_new(&filter);
-       if (ret != AIL_ERROR_OK) 
-               return -1;
-       
-       ret = ail_filter_add_str(filter, AIL_PROP_MIMETYPE_STR, mimetype);
-       if (ret != AIL_ERROR_OK) {
-               ret = -1;
-               goto out;
-       }
-       
-       ret = ail_filter_count_appinfo(filter, &pkg_count);
-       if (ret != AIL_ERROR_OK) {
-               ret = -1;
-               goto out;
-       }
-
-       if (pkg_count == 1) {
-               ail_filter_list_appinfo_foreach(filter, 
-                       __defapp_with_mime_func, (void *)&tmp);
-
-               if(tmp) {
-                       strncpy(defapp,tmp,len);
-                       _D("defapp from desktop = %s", defapp);
-                       aul_set_defapp_with_mime(mimetype, defapp);
-                       ret = 0;
-                       free(tmp);
-               }
-       } else 
-               ret = -1;
-       
-out:
-       ail_filter_destroy(filter);
-       return ret;     
-}
-
-SLPAPI int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len)
-{
-       char *res;
-       const char *unaliased_mimetype;
-
-       if (mimetype == NULL || defapp == NULL || len <= 0)
-               return AUL_R_EINVAL;
-
-       unaliased_mimetype = xdg_mime_unalias_mime_type(mimetype);
-       if (unaliased_mimetype == NULL)
-               return AUL_R_ERROR;
-
-       /* search mida db*/
-       if ((res = mida_get_app(unaliased_mimetype)) != NULL) {
-               snprintf(defapp, len, "%s", res);
-               free(res);
-               _D("Found %s for %s from mime db", defapp, unaliased_mimetype);
-               return AUL_R_OK;
-       }
-
-       if (get_defapp_from_desktop(unaliased_mimetype, defapp, len) != 0)
-               return AUL_R_ERROR;
-       else
-               return AUL_R_OK;
-}
-
-static int _aul_get_defapp_from_mime(const char *mimetype, char *unaliased,
-                                    char *defapp, int len_unaliased,
-                                    int len_defapp)
-{
-       char *res;
-       const char *unaliased_mimetype;
-
-       if (mimetype == NULL || unaliased == NULL || len_unaliased <= 0
-           || defapp == NULL || len_defapp <= 0)
-               return AUL_R_EINVAL;
-
-       unaliased_mimetype = xdg_mime_unalias_mime_type(mimetype);
-       if (unaliased_mimetype == NULL)
-               return AUL_R_ERROR;
-
-       snprintf(unaliased, len_unaliased, "%s", unaliased_mimetype);
-
-       /* search mida db*/
-       if ((res = mida_get_app(unaliased_mimetype)) != NULL) {
-               snprintf(defapp, len_defapp, "%s", res);
-               free(res);
-               _D("Found %s for %s from mime db", defapp, unaliased_mimetype);
-               return AUL_R_OK;
-       }
-
-       if (get_defapp_from_desktop(unaliased_mimetype, defapp, len_defapp) < 0)
-               return AUL_R_ERROR;
-       else
-               return AUL_R_OK;
-}
-
-static int __launch_with_defapp(const char *mime_type, const char *mime_content)
-{
-       ail_appinfo_h handle;
-       ail_error_e ail_ret;
-       char defapp[MAX_LOCAL_BUFSZ];
-       char unaliased_mime_type[MAX_LOCAL_BUFSZ];
-       bundle *kb = NULL;
-       int ret = AUL_R_ERROR;
-
-       kb = bundle_create();
-       if (NULL == kb) {
-               _E("bundle creation fail");
-               return ret;
-       }
-       bundle_add(kb, AUL_K_MIME_TYPE, mime_type);
-       bundle_add(kb, AUL_K_MIME_CONTENT, mime_content);
-
- retry:
-       if (_aul_get_defapp_from_mime
-           (mime_type, unaliased_mime_type, defapp,
-            sizeof(unaliased_mime_type), sizeof(defapp)) < 0) {
-               SECURE_LOGD("mimetype : %s, unaliased mimetype : %s, mime_content : %s,"
-                       " no default app", mime_type, 
-                               unaliased_mime_type, mime_content);
-               bundle_add(kb, AUL_K_UNALIASED_MIME_TYPE, unaliased_mime_type);
-               ret = aul_launch_app(MIME_APP_SELECTOR, kb);
-               /* TODO: When launching MIME APP SELECTOR, what should 
-               be the return value? */
-               /* Currently, it returns 0 if the app selector is launched */
-               if (ret > 0)
-                       ret = 0;
-       } else {
-               ail_ret = ail_get_appinfo(defapp, &handle);
-
-               if (ail_ret == AIL_ERROR_OK) {
-                       ail_destroy_appinfo(handle);
-                       SECURE_LOGD("mimetype : %s, unaliased mimetype : %s, "
-                               "mime_content : %s, defapp : %s", mime_type, 
-                                       unaliased_mime_type, 
-                                               mime_content, defapp);
-                       bundle_add(kb, AUL_K_UNALIASED_MIME_TYPE,
-                                  unaliased_mime_type);
-                       ret = aul_launch_app(defapp, kb);
-               } else if (ail_ret == AIL_ERROR_NO_DATA) {
-                       SECURE_LOGD("defapp %s for mimetype : %s, mime_content : %s "
-                               "does NOT exist", defapp, 
-                                       mime_type, mime_content);
-                       mida_delete_with_pkgname(defapp);
-                       ail_destroy_appinfo(handle);
-                       goto retry;
-               } else {
-                       SECURE_LOGE("ail_get_appinfo with %s failed", defapp);
-                       if (kb) {
-                               bundle_free(kb);
-                               kb = NULL;
-                       }
-                       return ret;
-               }       
-       }
-       bundle_free(kb);
-       return ret;
-}
-
-SLPAPI int aul_open_content(const char *content)
-{
-       int ret;
-       char mime[MAX_LOCAL_BUFSZ];
-       if ((ret = aul_get_mime_from_content(content, mime, sizeof(mime))) < 0)
-               return ret;
-
-       return __launch_with_defapp(mime, content);
-}
-
-SLPAPI int aul_open_file_with_mimetype(const char *filename,
-                                      const char *mimetype)
-{
-       if (mimetype == NULL)
-               return AUL_R_EINVAL;
-
-       return __launch_with_defapp(mimetype, filename);
-}
-
-SLPAPI int aul_open_file(const char *filename)
-{
-       int ret;
-       char mime[MAX_LOCAL_BUFSZ];
-       if ((ret = aul_get_mime_from_file(filename, mime, sizeof(mime))) < 0)
-               return ret;
-
-       return __launch_with_defapp(mime, filename);
-}
-
index abbfd7b..72b7e9a 100755 (executable)
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include <pkgmgr-info.h>
 #include "aul.h"
 #include "aul_api.h"
 #include "menu_db_util.h"
 #include "app_sock.h"
 #include "aul_util.h"
 
-typedef struct _internal_param_t {
-       aul_app_info_iter_fn enum_fn;
-       void *user_param;
-} internal_param_t;
+#define METADATA_LEGACY_LIFECYCLE "http://developer.samsung.com/tizen/metadata/legacylifecycle"
 
 static char *__appid = NULL;
+static int __aul_support_legacy_lifecycle = -1;
 
 static int __get_pkgname_bypid(int pid, char *pkgname, int len);
 
@@ -55,7 +54,13 @@ SLPAPI int aul_app_is_running(const char *appid)
        return 0;
 }
 
-SLPAPI int aul_app_get_running_app_info(aul_app_info_iter_fn enum_fn,
+SLPAPI int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn,
+                                       void *user_param)
+{
+       return aul_get_running_app_info_from_memory(iter_fn, user_param);
+}
+
+SLPAPI int aul_get_running_app_info_from_proc(aul_app_info_iter_fn iter_fn,
                                        void *user_param)
 {
        app_pkt_t *pkt = NULL;
@@ -65,7 +70,7 @@ SLPAPI int aul_app_get_running_app_info(aul_app_info_iter_fn enum_fn,
        aul_app_info info;
 
        memset(&info, 0, sizeof(info));
-       if (enum_fn == NULL)
+       if (iter_fn == NULL)
                return AUL_R_EINVAL;
 
        pkt = __app_send_cmd_with_result(AUL_UTIL_PID, APP_RUNNING_INFO, NULL, 0);
@@ -82,7 +87,43 @@ SLPAPI int aul_app_get_running_app_info(aul_app_info_iter_fn enum_fn,
                info.app_path = strtok_r(NULL, ":", &saveptr2);
                info.pkg_name = strdup(info.appid);
 
-               enum_fn(&info, user_param);
+               iter_fn(&info, user_param);
+               free(info.pkg_name);
+       }
+
+       free(pkt);
+
+       return AUL_R_OK;
+}
+
+SLPAPI int aul_get_running_app_info_from_memory(aul_app_info_iter_fn iter_fn,
+                                       void *user_param)
+{
+       app_pkt_t *pkt = NULL;
+       char *saveptr1, *saveptr2;
+       char *token;
+       char *pkt_data;
+       aul_app_info info;
+
+       memset(&info, 0, sizeof(info));
+       if (iter_fn == NULL)
+               return AUL_R_EINVAL;
+
+       pkt = __app_send_cmd_with_result(AUL_UTIL_PID, APP_RUNNING_INFO_MEMORY, NULL, 0);
+
+       if (pkt == NULL)
+               return AUL_R_ERROR;
+
+       for( pkt_data = (char *)pkt->data; ; pkt_data = NULL) {
+               token = strtok_r(pkt_data, ";", &saveptr1);
+               if (token == NULL)
+                       break;
+               info.pid = atoi(strtok_r(token, ":", &saveptr2));
+               info.appid = strtok_r(NULL, ":", &saveptr2);
+               info.app_path = strtok_r(NULL, ":", &saveptr2);
+               info.pkg_name = strdup(info.appid);
+
+               iter_fn(&info, user_param);
                free(info.pkg_name);
        }
 
@@ -132,17 +173,25 @@ SLPAPI int aul_app_get_appid_bypid(int pid, char *appid, int len)
        app_pkt_t *pkt = NULL;
        int pgid;
 
-#ifdef REMOVE_DB_ACCESS
        if (pid == getpid()) {
                char *preinit_appid = __aul_get_preinit_appid();
+
                if (preinit_appid != NULL)
                {
-                       snprintf(appid, len > MAX_PACKAGE_STR_SIZE ? MAX_PACKAGE_STR_SIZE : len, "%s", preinit_appid);
+#ifdef _APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP
+                       if(strncmp(preinit_appid, "org.tizen.phone", MAX_PACKAGE_STR_SIZE) == 0) {
+                               snprintf(appid, len > MAX_PACKAGE_STR_SIZE ? MAX_PACKAGE_STR_SIZE : len, "%s", "org.tizen.contacts");
+                       } else {
+#endif
+                               snprintf(appid, len > MAX_PACKAGE_STR_SIZE ? MAX_PACKAGE_STR_SIZE : len, "%s", preinit_appid);
+#ifdef _APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP
+                       }
+#endif
                        return AUL_R_OK;
                }
        }
-#endif
-       if(pid == getpid() || getuid()==0 || geteuid()==0) {
+
+       if (pid == getpid() || getuid()==0 || geteuid()==0) {
                if (__get_pkgname_bypid(pid, appid, len) == 0) {
                        SECURE_LOGD("appid for %d is %s", pid, appid);
                        return AUL_R_OK;
@@ -167,7 +216,7 @@ SLPAPI int aul_app_get_appid_bypid(int pid, char *appid, int len)
 
        if(pkt == NULL)
                return AUL_R_ERROR;
-       if(pkt->cmd == APP_GET_APPID_BYPID_ERROR) {
+       if(pkt->cmd == APP_GET_INFO_ERROR) {
                free(pkt);
                return AUL_R_ERROR;
        }
@@ -177,3 +226,89 @@ SLPAPI int aul_app_get_appid_bypid(int pid, char *appid, int len)
        return AUL_R_OK;
 }
 
+static int __get_pkgid_bypid(int pid, char *pkgid, int len)
+{
+       char *cmdline;
+       app_info_from_db *menu_info;
+
+       cmdline = __proc_get_cmdline_bypid(pid);
+       if (cmdline == NULL)
+               return -1;
+
+       if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL) {
+               free(cmdline);
+               return -1;
+       } else
+               snprintf(pkgid, len, "%s", _get_pkgid(menu_info));
+
+       free(cmdline);
+       _free_app_info_from_db(menu_info);
+
+       return 0;
+}
+
+SLPAPI int aul_app_get_pkgid_bypid(int pid, char *pkgid, int len)
+{
+       app_pkt_t *pkt = NULL;
+       int pgid;
+
+       if(pid == getpid() || getuid()==0 || geteuid()==0) {
+               if (__get_pkgid_bypid(pid, pkgid, len) == 0) {
+                       SECURE_LOGD("appid for %d is %s", pid, pkgid);
+                       return AUL_R_OK;
+               }
+               /* support app launched by shell script*/
+
+               pgid = getpgid(pid);
+               if (pgid <= 1)
+                       return AUL_R_ERROR;
+
+               _D("second change pgid = %d, pid = %d", pgid, pid);
+               if (__get_pkgid_bypid(pgid, pkgid, len) == 0)
+                       return AUL_R_OK;
+
+               return AUL_R_ERROR;
+       }
+
+       if (pkgid == NULL)
+               return AUL_R_EINVAL;
+
+       pkt = __app_send_cmd_with_result(AUL_UTIL_PID, APP_GET_APPID_BYPID, (unsigned char *)&pid, sizeof(pid));
+
+       if(pkt == NULL)
+               return AUL_R_ERROR;
+       if(pkt->cmd == APP_GET_INFO_ERROR) {
+               free(pkt);
+               return AUL_R_ERROR;
+       }
+
+       snprintf(pkgid, len, "%s", pkt->data);
+       free(pkt);
+       return AUL_R_OK;
+}
+
+SLPAPI int aul_get_support_legacy_lifecycle(void)
+{
+       if (__aul_support_legacy_lifecycle != -1)
+               return __aul_support_legacy_lifecycle;
+
+       int ret = 0;
+       pkgmgrinfo_appinfo_h handle = NULL;
+       char *metadata_value = NULL;
+
+       ret = pkgmgrinfo_appinfo_get_appinfo(__appid, &handle);
+       if (ret != PMINFO_R_OK)
+               return 0;
+
+       ret = pkgmgrinfo_appinfo_get_metadata_value(handle, METADATA_LEGACY_LIFECYCLE, &metadata_value);
+       if (ret != PMINFO_R_OK) {
+               __aul_support_legacy_lifecycle = 0;
+       } else {
+               __aul_support_legacy_lifecycle = 1;
+       }
+
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
+       return __aul_support_legacy_lifecycle;
+}
+
diff --git a/src/runtime_info.c b/src/runtime_info.c
new file mode 100755 (executable)
index 0000000..ab41360
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ *  aul
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/sysinfo.h>
+
+#include "aul.h"
+#include "aul_api.h"
+#include "simple_util.h"
+
+#define _MAX_STATUS_BUF_SIZE   64
+#define _MAX_STAT_BUF_SIZE             1024
+
+static const char PROC_PROCESS_STATUS_INFO[] = "/proc/self/status";
+static const char PROC_KEY_PROCESS_MEMORY[] = "VmSize";
+
+long long __get_process_running_time(pid_t pid)
+{
+       char proc_path[sizeof("/proc//stat") + sizeof(int) * 3] = { 0, };
+       char *line = NULL;
+       ssize_t res = -1;
+       int i = 0;
+       char *str = NULL;
+       char *token = NULL;
+       char *saveptr = NULL;
+       long long start_time = 0;
+       long long running_time = 0;
+
+       if (pid == -1) //self
+       {
+               _D("self");
+               strcpy(proc_path, "/proc/self/stat");
+       }
+       else if (pid > 0)
+       {
+               SECURE_LOGD("pid: %d", pid);
+               sprintf(proc_path, "/proc/%u/task", pid);
+               _E("Not supported");
+               return -1;
+       }
+       else
+       {
+               _E("PID is invalid.");
+               return -1;
+       }
+
+       int fd = open(proc_path, O_RDONLY);
+       if (fd < 0)
+       {
+               SECURE_LOGE("Openning %s is failed.", proc_path);
+               goto CATCH;
+       }
+
+       line = (char *)calloc(_MAX_STAT_BUF_SIZE, sizeof(char));
+       if (line == NULL)
+       {
+               _E("The memory is insufficient.");
+               goto CATCH;
+       }
+
+       res = read(fd, line, _MAX_STAT_BUF_SIZE - 1);
+       if (res < 0)
+       {
+               SECURE_LOGE("Reading %s is failed.", proc_path);
+               goto CATCH;
+       }
+       close(fd);
+       fd = -1;
+
+       for (i = 0, str = line; ; ++i, str = NULL)
+       {
+               token = strtok_r(str, " ", &saveptr);
+               if (token == NULL)
+               {
+                       _E("There is no start time.");
+                       goto CATCH;
+               }
+
+               if (i == 21) //starttime
+               {
+                       start_time = atoll(token);
+                       SECURE_LOGD("Start time: %lld (ticks)", start_time);
+                       break;
+               }
+       }
+       free(line);
+       line = NULL;
+
+       {
+               struct sysinfo info;
+               sysinfo(&info);
+               long long sec_since_boot = (long long)info.uptime;
+
+               start_time /= (long long)sysconf(_SC_CLK_TCK);
+               running_time = sec_since_boot - start_time;
+
+               unsigned long mm = (unsigned long)running_time;
+               unsigned ss = mm % 60;
+               mm /= 60;
+               SECURE_LOGD("Running time: %lu:%02u", mm, ss);
+       }
+
+       return running_time;
+
+CATCH:
+       if (fd >= 0)
+       {
+               close(fd);
+       }
+       if (line != NULL)
+       {
+               free(line);
+       }
+
+       return -1;
+}
+
+int __get_info_from_proc(const char* path, const char* key)
+{
+       int value = 0;
+
+       char line[_MAX_STATUS_BUF_SIZE] = {0, };
+       char field[_MAX_STATUS_BUF_SIZE] = {0, };
+
+       FILE* fp = fopen(path, "r");
+       if (fp != NULL)
+       {
+               while (fgets(line, _MAX_STATUS_BUF_SIZE, fp))
+               {
+                       if (sscanf(line, "%s %d", field, &value) != EOF)
+                       {
+                               if (strncmp(field, key, strlen(key)) == 0)
+                               {
+                                       SECURE_LOGD("PROC %s VALUE: %d\n", field, value * 1024);
+
+                                       fclose(fp);
+
+                                       return value * 1024;;
+                               }
+                       }
+               }
+
+               fclose(fp);
+       }
+
+       return -1;
+}
+
+SLPAPI int aul_get_app_allocated_memory(void)
+{
+       return __get_info_from_proc(PROC_PROCESS_STATUS_INFO, PROC_KEY_PROCESS_MEMORY);
+}
+
+SLPAPI long long aul_get_app_running_time(void)
+{
+       return __get_process_running_time(-1);
+}
index e675002..38c2858 100755 (executable)
@@ -19,7 +19,6 @@
  *
  */
 
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdlib.h>
 #include <string.h>
 #include <bundle.h>
 
-#include "aul_service.h"
 #include "aul.h"
 #include "aul_api.h"
-#include "mida.h"
-#include "menu_db_util.h"
-#include "simple_util.h"
-#include "launch.h"
-
-static int __get_defapp_from_desktop(const char *svcname, 
-                                       char *defapp, int len);
-
-
-
-SLPAPI int aul_set_defapp_for_service(const char *svcname, const char *defapp)
-{
-       if ((svcname == NULL) || (defapp == NULL))
-               return AUL_R_EINVAL;
-
-       if (!is_supported_svc(svcname))
-               return AUL_R_EINVAL;
-
-       if (svc_add_app(svcname, defapp) < 0) {
-               _E("fail to add");
-               return AUL_R_ERROR;
-       }
-
-       return AUL_R_OK;
-}
-
-static ail_cb_ret_e __defapp_with_service_func(
-                       const ail_appinfo_h appinfo, void *user_data)
-{
-       char **package = (char **)user_data;
-       char *str;
-
-       ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &str);
-
-       _D("defapp from desktop = %s", str);
-
-       *package = strdup(str);
-       
-       return AIL_CB_RET_CANCEL;       /*return AIL_CB_RET_CONTINUE;*/ 
-}
-
-
-static int __get_defapp_from_desktop(const char *svcname, char *defapp, int len)
-{
-       char *pkgname = NULL;
-       int ret = -1;
-       ail_filter_h filter;
-       ail_error_e ail_ret;
-       int pkg_count = -1;
-
-       _D("The svcname is: %s", svcname);
-
-       ail_ret = ail_filter_new(&filter);
-       if (ail_ret != AIL_ERROR_OK) 
-               return ret;
-       
-       ail_ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_SERVICE_STR, svcname);
-       if (ail_ret != AIL_ERROR_OK) {
-               _E("ail_filter_add_str failed");
-               goto out;
-       }
-
-       ail_ret = ail_filter_count_appinfo(filter, &pkg_count);
-       if (ail_ret != AIL_ERROR_OK) {
-               _E("ail_filter_count_appinfo failed");
-               goto out;
-       }
-
-       
-       /* TODO: Prioritizing inhouse app depending on the UX policy */
-       if (pkg_count == 1) {
-               ail_filter_list_appinfo_foreach(filter, 
-                       __defapp_with_service_func, (void *)&pkgname);
-
-               if(pkgname) {
-                       strncpy(defapp,pkgname,len);
-                       _D("defapp from desktop = %s", defapp);
-                        aul_set_defapp_for_service(svcname, defapp);
-                       ret = 0;
-                       free(pkgname);
-               }
-               
-       } 
-
- out:
-       if (ail_filter_destroy(filter) != AIL_ERROR_OK)
-               _E("ail_filter_destroy failed");
-       return ret;
-}
-
-SLPAPI int aul_get_defapp_for_service(const char *svcname, char *defapp,
-                                     int len)
-{
-       char *res = NULL;
-
-       if ((svcname == NULL) || (defapp == NULL) || len <= 0)
-               return AUL_R_EINVAL;
-
-       if (!is_supported_svc(svcname))
-               return AUL_R_EINVAL;
-
-       /* search mida db*/
-       if ((res = svc_get_app(svcname)) != NULL) {
-               snprintf(defapp, len, "%s", res);
-               free(res);
-               _D("Found %s for %s from svc db", defapp, svcname);
-               return AUL_R_OK;
-       }
-
-       if (__get_defapp_from_desktop(svcname, defapp, len) < 0)
-               return AUL_R_ERROR;
-       else
-               return AUL_R_OK;
-}
-
-SLPAPI int aul_open_service(const char *svcname, bundle *kb,
-                           aul_service_res_fn cbfunc, void *userdata)
-{
-       char defapp[MAX_LOCAL_BUFSZ];
-       int must_free = 0;
-       int ret = AUL_R_ERROR;
-       ail_appinfo_h handle;
-       ail_error_e ail_ret;
-
-       if (svcname == NULL)
-               return AUL_R_EINVAL;
-
-       if (!is_supported_svc(svcname))
-               return AUL_R_EINVAL;
-
-       if (kb == NULL) {
-               kb = bundle_create();
-               must_free = 1;
-       }
-       bundle_add(kb, AUL_K_SERVICE_NAME, svcname);
-
- retry:
-       if (aul_get_defapp_for_service(svcname, defapp, sizeof(defapp)) < 0) {
-               _D("service : %s, no default app", svcname);
-               if (must_free) {
-                       bundle_free(kb);
-                       kb = NULL;
-               }
-               return ret;
-       } else {
-               ail_ret = ail_get_appinfo(defapp, &handle);
-
-               if (ail_ret == AIL_ERROR_OK) {
-                       ail_destroy_appinfo(handle);
-                       _D("svcname: %s, defapp : %s", svcname, defapp);
-                       
-                       if (cbfunc) {
-                               _D("svcname: %s, defapp : %s - with result",
-                                  svcname, defapp);
-                               ret =
-                                   aul_launch_app_with_result(defapp, kb,
-                                                              cbfunc,
-                                                              userdata);
-                       } else {
-                               _D("svcname: %s, defapp : %s - no result",
-                                  svcname, defapp);
-                               ret = aul_launch_app(defapp, kb);
-                       }
-               } else if (ail_ret == AIL_ERROR_NO_DATA) {
-                       _D("defapp %s for svcname: %s does NOT exist", defapp,
-                          svcname);
-                       svc_delete_with_pkgname(defapp);
-                       ail_destroy_appinfo(handle);
-                       goto retry;
-               } else {
-                       _E("ail_get_appinfo with %s failed", defapp);
-                       if (must_free) {
-                               bundle_free(kb);
-                               kb = NULL;
-                       }
-                       return ret;
-               }       
-       }
-       if (must_free)
-               bundle_free(kb);
-
-       return ret;
-
-}
 
 SLPAPI int aul_send_service_result(bundle *b)
 {
        return aul_send_result(b, 0);
 }
-
index 730cbf7..56c078b 100755 (executable)
@@ -26,7 +26,7 @@ related to this software.
                exit(1);\
        } while (0);
 
-#define SERVICE_NAME "org.tizen.camera"
-#define PATH_NAME "/org/tizen/camera"
+#define SERVICE_NAME "com.samsung.camera"
+#define PATH_NAME "/com/samsung/camera"
 #define INTERFACE_NAME SERVICE_NAME".app_result"
 #define METHOD_NAME "take_and_get"
index bac4a06..72ed4fd 100755 (executable)
@@ -177,6 +177,13 @@ int term_pid_test()
        return aul_terminate_pid(apn_pid);
 }
 
+int term_pid_without_restart_test()
+{
+       static int num = 0;
+       printf("[aul_term_pid_without_restart %d test] %d \n", num++, apn_pid);
+       return aul_terminate_pid_without_restart(apn_pid);
+}
+
 int term_req_pid_test()
 {
        static int num = 0;
@@ -274,42 +281,6 @@ int get_pkgpid_test()
        return 0;
 }
 
-int open_file_test()
-{
-       static int num = 0;
-       printf("[aul_open_file %d test] %s \n", num++, gargv[2]);
-       return aul_open_file(gargv[2]);
-}
-
-int open_content_test()
-{
-       static int num = 0;
-       printf("[aul_open_content %d test] %s \n", num++, gargv[2]);
-       return aul_open_content(gargv[2]);
-}
-
-int get_defapp_test()
-{
-       static int num = 0;
-       int ret;
-       char buf[MAX_LOCAL_BUFSZ];
-       printf("[aul_get_defapp_from_mime %d test] %s \n", num++, gargv[2]);
-       ret = aul_get_defapp_from_mime(gargv[2], buf, sizeof(buf));
-       if (ret >= 0)
-               printf("==> defapp name = %s\n", buf);
-       return ret;
-}
-
-int set_defapp_test()
-{
-       static int num = 0;
-       int ret;
-       printf("[aul_set_defapp_with_mime %d test] %s %s\n", num++, gargv[2],
-              gargv[3]);
-       ret = aul_set_defapp_with_mime(gargv[2], gargv[3]);
-       return ret;
-}
-
 int get_mime_file_test()
 {
        static int num = 0;
@@ -408,10 +379,10 @@ static int set_pkg_func()
 
        pkgname = gargv[2];
        apppath = gargv[3];
-       
+
        appname = strrchr(apppath,'/')+1;
        snprintf(ai.app_icon_path, PATH_LEN, "aul_test_icon_path/%d",getpid());
-       snprintf(ai.desktop_path, PATH_LEN, 
+       snprintf(ai.desktop_path, PATH_LEN,
                "aul_test_desktop_path/%d",getpid());
 
        snprintf (query, sizeof(query), "insert into "TABLE_MENU"(\
@@ -483,90 +454,6 @@ static int test_regex()
        return 0;
 }
 
-int open_svc_test()
-{
-       static int num = 0;
-       int ret;
-
-       bundle *kb = NULL;
-       kb = create_internal_bundle(3);
-       if (kb == NULL) {
-               printf("bundle creation fail\n");
-               return -1;
-       }
-       printf("[aul_open_service %d test] %s \n", num++, gargv[2]);
-       ret = aul_open_service(gargv[2], kb, NULL, NULL);
-       if (ret >= 0) {
-               printf("open service success\n");
-               if (kb) {
-                       bundle_free(kb);
-                       kb = NULL;
-               }
-               return 0;
-       } else {
-               printf("open service fail\n");
-               if (kb) {
-                       bundle_free(kb);
-                       kb = NULL;
-               }
-               return -1;
-       }
-}
-
-int open_svc_res_test()
-{
-       static int num = 0;
-       int ret;
-
-       bundle *kb = NULL;
-       kb = create_internal_bundle(3);
-       if (kb == NULL) {       /* Prevent Fix: ID: 21027,21581 */
-               printf("bundle creation fail\n");
-               return -1;
-       }
-
-       printf("[aul_open_service(wait result) %d test] %s \n", num++,
-              gargv[2]);
-       ret = aul_open_service(gargv[2], kb, cb_func, (void *)num);
-       if (ret >= 0) {
-               printf("open service(wait result) success\n");
-               if (kb) {
-                       bundle_free(kb);
-                       kb = NULL;
-               }
-               return 0;
-       } else {
-               printf("open service(wait result) fail\n");
-               if (kb) {
-                       bundle_free(kb);
-                       kb = NULL;
-               }
-               return -1;
-       }
-}
-
-int get_defapp_svc_test()
-{
-       static int num = 0;
-       int ret;
-       char buf[MAX_LOCAL_BUFSZ];
-       printf("[aul_get_defapp_from_svc %d test] %s \n", num++, gargv[2]);
-       ret = aul_get_defapp_for_service(gargv[2], buf, sizeof(buf));
-       if (ret >= 0)
-               printf("==> defapp name = %s\n", buf);
-       return ret;
-}
-
-int set_defapp_svc_test()
-{
-       static int num = 0;
-       int ret;
-       printf("[aul_set_defapp_with_svc %d test] %s %s\n", num++, gargv[2],
-              gargv[3]);
-       ret = aul_set_defapp_for_service(gargv[2], gargv[3]);
-       return ret;
-}
-
 static test_func_t test_func[] = {
        {"launch",launch_test,"aul_launch_app test",
                "[usage] launch <pkgname> <key1> <val1> <key2> <val2> ..."},
@@ -580,6 +467,8 @@ static test_func_t test_func[] = {
                "[usage] resume_pid <pid>" },
        {"term_pid", term_pid_test,"aul_terminate_pid test",
                "[usage] term_pid <pid>" },
+       {"term_pid_without_restart", term_pid_without_restart_test,"aul_terminate_pid_without_restart test",
+               "[usage] term_pid_without_restart <pid>" },
        {"term_req_pid", term_req_pid_test,"aul_subapp_terminate_request_pid test",
                "[usage] term_req_pid <pid>" },
        {"dbuslaunch", dbus_launch_test,"launch by dbus auto activation",
@@ -593,15 +482,7 @@ static test_func_t test_func[] = {
                "[usage] getallpkg all"},
        {"getpkgpid", get_pkgpid_test, "aul_app_get_appid_bypid test",
                "[usage] getpkgpid <pid>"},
-       
-       {"open_file", open_file_test, "aul_open_file test",
-               "[usage] open_file <filename>"},
-       {"open_content", open_content_test, "aul_open_content test",
-               "[usage] open_content <content>"},
-       {"get_defapp_mime", get_defapp_test, "aul_get_defapp_from_mime test",
-               "[usage] get_defapp_mime <mime_type>"},
-       {"set_defapp_mime", set_defapp_test, "aul_set_defapp_with_mime test",
-               "[usage] set_defapp_mime <mime_type> <defapp to be set>"},
+
        {"get_mime_file", get_mime_file_test, "aul_get_mime_from_file test",
                "[usage] get_mime_file <filename>"},
        {"get_mime_content", get_mime_content_test, "aul_get_mime_from_content",
@@ -617,15 +498,6 @@ static test_func_t test_func[] = {
        {"test_regex", test_regex, "regular expression parser test",
                "[usage] test_regex <full text>"},
 
-       {"open_svc", open_svc_test, "aul_open_service test"
-               "[usage] open_svc <svcname> <key1> <val1> <key2> <val2> ..."},
-       {"open_svc_res", open_svc_res_test, "aul_open_service (wait result) test"
-               "[usage] open_svc <svcname> <key1> <val1> <key2> <val2> ..."},
-       {"set_defapp_svc", set_defapp_svc_test, "aul_set_defapp_with_svc test"
-               "[usage] set_defapp_svc <svcname> <defapp to be set>"},
-       {"get_defapp_svc", get_defapp_svc_test, "aul_get_defapp_from_svc test"
-               "[usage] get_defapp_svc <svcname>"},
-       
        {"getpkg", get_pkg_func, "get package",
                "[usage] getpkg <pkgname>"},
        {"update_list", update_running_list, "update running list",
index 4fe4392..ecaa724 100644 (file)
@@ -1,3 +1,3 @@
 [D-BUS Service]
-Name=org.tizen.camera
-Exec=/usr/bin/aul_test dbuslaunch deb.org.tizen.camera
+Name=com.samsung.camera
+Exec=/usr/bin/aul_test dbuslaunch deb.com.samsung.camera