tizen 2.3.1 release submit/tizen_2.3.1/20150915.080210 tizen_2.3.1_release
authorjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:14:25 +0000 (22:14 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:14:25 +0000 (22:14 +0900)
86 files changed:
.gitignore [new file with mode: 0755]
CMakeLists.txt
agent/CMakeLists.txt [new file with mode: 0644]
agent/daemon-manager-launch-agent.c [new file with mode: 0644]
agent/daemon-manager-release-agent.c [new file with mode: 0755]
am_daemon/ac_status.c [new file with mode: 0755]
am_daemon/amd_appinfo.c [new file with mode: 0755]
am_daemon/amd_appinfo.h [new file with mode: 0755]
am_daemon/amd_cgutil.c [new file with mode: 0755]
am_daemon/amd_cgutil.h [new file with mode: 0755]
am_daemon/amd_config.h [new file with mode: 0755]
am_daemon/amd_key.c [new file with mode: 0755]
am_daemon/amd_key.h [new file with mode: 0755]
am_daemon/amd_launch.c [new file with mode: 0755]
am_daemon/amd_launch.h [new file with mode: 0755]
am_daemon/amd_main.c [new file with mode: 0755]
am_daemon/amd_request.c [new file with mode: 0755]
am_daemon/amd_request.h [new file with mode: 0755]
am_daemon/amd_status.c [new file with mode: 0755]
am_daemon/amd_status.h [new file with mode: 0755]
aul.manifest [new file with mode: 0644]
data/aul_mime.sh [deleted file]
data/aul_service.sh [deleted file]
data/aul_service_test.sh [deleted file]
data/config_splash.sh [new file with mode: 0755]
data/create_default_service.sh [deleted file]
data/mida_db.sql [deleted file]
data/service/README [deleted file]
debian/changelog [deleted file]
debian/compat [deleted file]
debian/control [deleted file]
debian/dirs [deleted file]
debian/docs [deleted file]
debian/libaul-1-dev.install.in [deleted file]
debian/libaul-1-executable.install.in [deleted file]
debian/libaul-1-executable.postinst [deleted file]
debian/libaul-1.install.in [deleted file]
debian/libaul-1.postinst [deleted file]
debian/rules [deleted file]
effect_img/type0_portrait.bmp [new file with mode: 0755]
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]
feature/preexec.h
include/SLP_AUL_PG.h [changed mode: 0755->0644]
include/access_control.h [moved from include/mida.h with 54% similarity]
include/app_signal.h
include/app_sock.h
include/aul.h
include/aul_service.h [deleted file]
include/aul_util.h
include/launch.h
include/menu_db_util.h
include/simple_util.h
launchpad_run
launchpad_src/access_control.h [deleted file]
launchpad_src/launchpad.c
launchpad_src/sigchild.h
legacy/preload.h
legacy/preload_list.txt
packaging/ac.service [new file with mode: 0644]
packaging/aul.spec
packaging/launchpad-preload.service [new file with mode: 0644]
src/app_signal.c
src/app_sock.c
src/aul_path.c [new file with mode: 0755]
src/key.c
src/launch.c
src/launch_glib.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
src/simple_util.c
src/status.c [new file with mode: 0755]
test/CMakeLists.txt
test/ac_daemon.c [deleted file]
test/aul_dbus.c
test/aul_dbus.h
test/aul_test.c
test/launch_app.c
test/open_app.c [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100755 (executable)
index 0000000..ff0dafd
--- /dev/null
@@ -0,0 +1,24 @@
+build_log
+*.log
+*.pyc
+usr
+opt
+*.o
+*.os
+*.exe
+packages
+binaries
+*.ipk
+*~
+build-stamp
+cmake_tmp/
+configure-stamp
+debian/files
+debian/*.install
+debian/*.substvars
+debian/*.debhelper
+debian/tmp/
+debian/libaul-1-dbg/
+debian/libaul-1-dev/
+debian/libaul-1-executable/
+debian/libaul-1/
index 1a37d91..a72728e 100755 (executable)
@@ -22,8 +22,18 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 # Set required packages
 INCLUDE(FindPkgConfig)
 
-pkg_check_modules(pkgs REQUIRED dlog ecore x11 libprivilege-control app-checker rua glib-2.0 ecore-x ecore-input evas)
-pkg_check_modules(libpkgs REQUIRED dlog bundle dbus-glib-1 ail xdgmime app-checker)
+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)
 
@@ -42,13 +52,16 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/feature)
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fdata-sections -ffunction-sections -Wl,--gc-sections")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -D_FILE_OFFSET_BITS=64")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 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")
@@ -59,6 +72,60 @@ ENDIF("${ARCH}" STREQUAL "arm")
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DSHARE_PREFIX=\"/usr/share/aul\"")
+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")
@@ -72,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
@@ -80,10 +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})
@@ -93,15 +167,39 @@ 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.
 
+add_executable(amd
+                am_daemon/amd_main.c
+               am_daemon/amd_key.c
+               am_daemon/amd_request.c
+               am_daemon/amd_appinfo.c
+               am_daemon/amd_cgutil.c
+               am_daemon/amd_launch.c
+               am_daemon/amd_status.c
+                )
+target_link_libraries(amd aul_mods rua glib-2.0 bundle ail aul utilX ${pkgs_LDFLAGS} "-pie")
+
+SET(REL_AGENT daemon-manager-release-agent)
+ADD_EXECUTABLE(${REL_AGENT} agent/${REL_AGENT}.c)
+TARGET_LINK_LIBRARIES(${REL_AGENT} ${PKGS_LDFLAGS} "-pie" aul aul_mods)
+SET_TARGET_PROPERTIES(${REL_AGENT} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS} -fPIE")
+
+INSTALL(TARGETS ${REL_AGENT} DESTINATION bin)
+
+SET(LAUNCH_AGENT daemon-manager-launch-agent)
+ADD_EXECUTABLE(${LAUNCH_AGENT} agent/${LAUNCH_AGENT}.c)
+TARGET_LINK_LIBRARIES(${LAUNCH_AGENT} ${PKGS_LDFLAGS} "-pie")
+SET_TARGET_PROPERTIES(${LAUNCH_AGENT} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS} -fPIE")
+
+INSTALL(TARGETS ${LAUNCH_AGENT} DESTINATION bin)
+
 
 
 # pkgconfig file
@@ -111,20 +209,31 @@ CONFIGURE_FILE(aul.pc.in aul.pc @ONLY)
 ### Install ###
 INSTALL(TARGETS aul DESTINATION lib COMPONENT RuntimeLibraries)
 INSTALL(TARGETS ${AVATAR_NAME} 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)
+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}/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)
diff --git a/agent/CMakeLists.txt b/agent/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4f9a22d
--- /dev/null
@@ -0,0 +1,16 @@
+
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${PKGS_CFLAGS}")
+
+SET(REL_AGENT daemon-manager-release-agent)
+ADD_EXECUTABLE(${REL_AGENT} ${REL_AGENT}.c)
+TARGET_LINK_LIBRARIES(${REL_AGENT} ${PKGS_LDFLAGS})
+SET_TARGET_PROPERTIES(${REL_AGENT} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+
+INSTALL(TARGETS ${REL_AGENT} DESTINATION bin)
+
+SET(LAUNCH_AGENT daemon-manager-launch-agent)
+ADD_EXECUTABLE(${LAUNCH_AGENT} ${LAUNCH_AGENT}.c)
+TARGET_LINK_LIBRARIES(${LAUNCH_AGENT} ${PKGS_LDFLAGS})
+SET_TARGET_PROPERTIES(${LAUNCH_AGENT} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+
+INSTALL(TARGETS ${LAUNCH_AGENT} DESTINATION bin)
diff --git a/agent/daemon-manager-launch-agent.c b/agent/daemon-manager-launch-agent.c
new file mode 100644 (file)
index 0000000..8f93c32
--- /dev/null
@@ -0,0 +1,98 @@
+#include <glib.h>
+#include <gio/gio.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#define DAEMON_MANAGER_NAME "org.tizen.DaemonManager"
+#define DAEMON_MANAGER_PATH "/org/tizen/DaemonManager"
+#define DAEMON_MANAGER_INTERFACE "org.tizen.DaemonManager"
+
+#define METHOD_RELEASED "Start"
+
+#define BUS_TYPE G_BUS_TYPE_SYSTEM
+
+#define LOG_PATH "/tmp/dmlaunch.err"
+
+static void elog(const char *fmt, ...)
+{
+       FILE *fp;
+       va_list ap;
+
+       fp = fopen(LOG_PATH, "w+");
+       if (!fp)
+               return;
+
+       va_start(ap, fmt);
+       vfprintf(fp, fmt, ap);
+       va_end(ap);
+
+       fclose(fp);
+}
+
+int main(int argc, char *argv[])
+{
+       GError *err;
+       GDBusProxy *proxy = NULL;
+       GDBusConnection *conn = NULL;
+       GVariant *res = NULL;
+
+       if (argc < 2) {
+               elog("usage) %s path\n", argv[0]);
+               return 1;
+       }
+
+       g_type_init();
+
+       /* TODO: use private bus? */
+       err = NULL;
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+       if (!conn) {
+               elog("Connection failed: %s\n", err ? err->message : "");
+               goto err;
+       }
+
+       err = NULL;
+       proxy = g_dbus_proxy_new_sync(conn,
+                       G_DBUS_PROXY_FLAGS_NONE,
+                       NULL,
+                       DAEMON_MANAGER_NAME,
+                       DAEMON_MANAGER_PATH,
+                       DAEMON_MANAGER_INTERFACE,
+                       NULL,
+                       &err);
+       if (!proxy) {
+               elog("Proxy new: %s\n", err ? err->message : "");
+               goto err;
+       }
+
+       err = NULL;
+       res = g_dbus_proxy_call_sync(proxy,
+                       METHOD_RELEASED,
+                       g_variant_new("(s)", argv[1]),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1,
+                       NULL,
+                       &err);
+       if (!res) {
+               elog("Call error: %s\n", err ? err->message : "");
+               goto err;
+       }
+
+err:
+       if (res)
+               g_variant_unref(res);
+
+       if (proxy)
+               g_object_unref(proxy);
+
+       if (conn)
+               g_object_unref(conn);
+
+       if (err) {
+               g_clear_error(&err);
+               return 1;
+       }
+
+       return 0;
+}
+
diff --git a/agent/daemon-manager-release-agent.c b/agent/daemon-manager-release-agent.c
new file mode 100755 (executable)
index 0000000..203529f
--- /dev/null
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include "app_sock.h"
+#include "aul_util.h"
+
+#define LOG_PATH "/tmp/dmlaunch.err"
+
+static void elog(const char *fmt, ...)
+{
+       FILE *fp;
+       va_list ap;
+
+       fp = fopen(LOG_PATH, "w+");
+       if (!fp)
+               return;
+
+       va_start(ap, fmt);
+       vfprintf(fp, fmt, ap);
+       va_end(ap);
+
+       fclose(fp);
+}
+
+
+int main(int argc, char *argv[])
+{
+       int ret = 0;
+
+       elog("release agent : [%d:%s]\n", argc, argv[1]);
+
+       if (argc < 2) {
+               elog("usage) %s path\n", argv[0]);
+               return 1;
+       }
+
+       ret = __app_send_raw(AUL_UTIL_PID, APP_RELEASED, (unsigned char*)argv[1], strlen(argv[1]));
+
+       elog("release agent : %d\n", ret);
+
+       return 0;
+}
+
diff --git a/am_daemon/ac_status.c b/am_daemon/ac_status.c
new file mode 100755 (executable)
index 0000000..6507b24
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ *  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 <stdlib.h>
+#include <glib.h>
+#include <aul.h>
+#include "aul_util.h"
+#include "simple_util.h"
+
+GSList *app_status_info_list = NULL;
+
+int _add_app_status_info_list(char *appid, int pid)
+{
+       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(pid == info_t->pid) {
+                       return 0;
+               }
+       }
+
+       info_t = malloc(sizeof(app_status_info_t));
+       strncpy(info_t->appid, appid, MAX_PACKAGE_STR_SIZE-1);
+       info_t->status = STATUS_LAUNCHING;
+       info_t->pid = pid;
+       app_status_info_list = g_slist_append(app_status_info_list, info_t);
+
+       for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (app_status_info_t *)iter->data;
+
+               _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+       }
+
+       return 0;
+}
+
+int _update_app_status_info_list(int pid, int status)
+{
+       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(pid == info_t->pid) {
+                       info_t->status = status;
+                       break;
+               }
+       }
+
+       for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (app_status_info_t *)iter->data;
+
+               _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+       }
+
+       return 0;
+}
+
+int _remove_app_status_info_list(int pid)
+{
+       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(pid == info_t->pid) {
+                       app_status_info_list = g_slist_remove(app_status_info_list, info_t);
+                       free(info_t);
+                       break;
+               }
+       }
+
+       for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (app_status_info_t *)iter->data;
+
+               _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+       }
+
+       return 0;
+}
+
diff --git a/am_daemon/amd_appinfo.c b/am_daemon/amd_appinfo.c
new file mode 100755 (executable)
index 0000000..61b31f3
--- /dev/null
@@ -0,0 +1,861 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+#include <glib.h>
+#include <dirent.h>
+
+#include <pkgmgr-info.h>
+#include <vconf.h>
+#include "amd_config.h"
+#include "simple_util.h"
+#include "amd_appinfo.h"
+
+
+#define SERVICE_GROUP "Service"
+
+struct appinfomgr {
+       GHashTable *tbl; /* key is filename, value is struct appinfo */
+};
+
+enum _appinfo_idx {
+       _AI_FILE = 0, /* service filename */
+       _AI_NAME,
+       _AI_COMP,
+       _AI_EXEC,
+       _AI_TYPE,
+       _AI_ONBOOT,
+       _AI_RESTART,
+       _AI_MULTI,
+       _AI_HWACC,
+       _AI_PERM,
+       _AI_PKGID,
+       _AI_TASKMANAGE,
+       _AI_PRELOAD,
+       _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 */
+
+struct appinfo_t {
+       char *name;
+       enum appinfo_type type;
+};
+
+static struct appinfo_t _appinfos[] = {
+       [_AI_NAME] = { "Name", AIT_NAME, },
+       [_AI_COMP] = { "Component", AIT_COMP, },
+       [_AI_EXEC] = { "Exec", AIT_EXEC, },
+       [_AI_TYPE] = { "PkgType", AIT_TYPE, },
+       [_AI_ONBOOT] = { "StartOnBoot", AIT_ONBOOT, },
+       [_AI_RESTART] = { "AutoRestart", AIT_RESTART, },
+       [_AI_MULTI] = { "Multiple", AIT_MULTI, },
+       [_AI_HWACC] = { "Hwacceleration", AIT_HWACC, },
+       [_AI_PERM] = { "PermissionType", AIT_PERM, },
+       [_AI_PKGID] = { "PackageId", AIT_PKGID, },
+       [_AI_TASKMANAGE] = { "Taskmanage", AIT_TASKMANAGE, },
+       [_AI_PRELOAD] = { "Preload", AIT_PRELOAD, },
+       [_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 {
+       char *val[_AI_MAX];
+};
+
+struct pkginfo {
+       char *pkgid;
+       char *op;
+};
+
+int gles = 1;
+
+GHashTable *pkg_tbl;
+
+static void _free_appinfo(gpointer data)
+{
+       struct appinfo *c = data;
+       int i;
+
+       if (!c)
+               return;
+
+       for (i = 0; i < sizeof(c->val)/sizeof(c->val[0]); i++) {
+               if(c->val[i] != NULL)
+                       free(c->val[i]);
+       }
+
+       free(c);
+}
+
+static void _fini(struct appinfomgr *cf)
+{
+       assert(cf);
+
+       g_hash_table_destroy(cf->tbl);
+       g_hash_table_destroy(pkg_tbl);
+       free(cf);
+}
+
+static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *data)
+{
+       struct appinfo *c;
+       struct appinfomgr *cf = (struct appinfomgr *)data;
+       gboolean r;
+       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;
+       pkgmgrinfo_app_component component;
+       pkgmgrinfo_permission_type permission;
+       bool indicator_display;
+       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");
+               return -1;
+       }
+
+       ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
+       if (ret < 0) {
+               _E("fail to get appinfo");
+               return -1;
+       }
+
+       g_hash_table_remove(cf->tbl, appid);
+
+       c = calloc(1, sizeof(*c));
+       if (!c) {
+               _E("create appinfo: %s", strerror(errno));
+               return -1;
+       }
+
+       memset(c, 0, sizeof(struct appinfo));
+
+       c->val[_AI_FILE] = strdup(appid);
+       if (!c->val[_AI_FILE]) {
+               _E("create appinfo: %s", strerror(errno));
+               _free_appinfo(c);
+               return -1;
+       }
+
+       c->val[_AI_NAME] = strdup(appid); //TODO :
+
+       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 :
+
+               r = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
+               if(multiple == true)
+                       c->val[_AI_MULTI] = strdup("true");
+               else c->val[_AI_MULTI] = strdup("false");
+
+               r = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
+               if (taskmanage == false) {
+                       c->val[_AI_TASKMANAGE] = strdup("false");
+               } else {
+                       c->val[_AI_TASKMANAGE] = strdup("true");
+               }
+
+               r = pkgmgrinfo_appinfo_is_preload(handle, &preload);
+               if (preload == false) {
+                       c->val[_AI_PRELOAD] = strdup("false");
+               } else {
+                       c->val[_AI_PRELOAD] = strdup("true");
+               }
+
+               if(gles == 0) {
+                       c->val[_AI_HWACC] = strdup("NOT_USE");
+               } else {
+
+                       r = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacc);
+                       if (hwacc == PMINFO_HWACCELERATION_ON) {
+                               c->val[_AI_HWACC] = strdup("USE");
+                       } else if (hwacc == PMINFO_HWACCELERATION_DEFAULT) {
+                               c->val[_AI_HWACC] = strdup("SYS");
+                       } else {
+                               c->val[_AI_HWACC] = strdup("NOT_USE");
+                       }
+               }
+
+               r = pkgmgrinfo_appinfo_is_indicator_display_allowed(handle, &indicator_display);
+               if (r <0 ){
+                       _E("ERROR IN FETCHING INDICATOR DISP INFO\n");
+                       c->val[_AI_INDICATORDISP] = strdup("true");
+               }else{
+                       if (indicator_display == true){
+                               c->val[_AI_INDICATORDISP] = strdup("true");
+                       }else{
+                               c->val[_AI_INDICATORDISP] = strdup("false");
+                       }
+               }
+
+               r = pkgmgrinfo_appinfo_get_effectimage(handle, &portraitimg, &landscapeimg);
+               if (r < 0){
+                       _E("ERROR IN FETCHING EFFECT IMAGES\n");
+                       c->val[_AI_EFFECTIMAGEPORT] = NULL;
+                       c->val[_AI_EFFECTIMAGELAND] = NULL;
+               }else{
+                       if (portraitimg)
+                               c->val[_AI_EFFECTIMAGEPORT] = strdup(portraitimg);
+                       else
+                               c->val[_AI_EFFECTIMAGEPORT] = NULL;
+                       if (landscapeimg)
+                               c->val[_AI_EFFECTIMAGELAND] = strdup(landscapeimg);
+                       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);
+
+               r = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
+               if(onboot == true)
+                       c->val[_AI_ONBOOT] = strdup("true");
+               else c->val[_AI_ONBOOT] = strdup("false");
+
+               r = pkgmgrinfo_appinfo_is_autorestart(handle, &restart);
+               if(restart == true)
+                       c->val[_AI_RESTART] = strdup("true");
+               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");
+
+               r = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
+               if(onboot == true)
+                       c->val[_AI_ONBOOT] = strdup("true");
+               else c->val[_AI_ONBOOT] = strdup("false");
+
+               r = pkgmgrinfo_appinfo_is_autorestart(handle, &restart);
+               if(restart == true)
+                       c->val[_AI_RESTART] = strdup("true");
+               else c->val[_AI_RESTART] = strdup("false");
+       }
+
+       r = pkgmgrinfo_appinfo_get_exec(handle, &exec);
+       c->val[_AI_EXEC] = strdup(exec);
+
+       r = pkgmgrinfo_appinfo_get_apptype(handle, &type);
+       if(strncmp(type, "capp", 4) == 0 ) {
+               c->val[_AI_TYPE] = strdup("rpm");
+       } else if (strncmp(type, "c++app", 6) == 0 || strncmp(type, "ospapp", 6) == 0) {
+               c->val[_AI_TYPE] = strdup("tpk");
+       } else if (strncmp(type, "webapp", 6) == 0) {
+               c->val[_AI_TYPE] = strdup("wgt");
+       }
+
+       r = pkgmgrinfo_appinfo_get_permission_type(handle, &permission);
+       if (permission == PMINFO_PERMISSION_SIGNATURE) {
+               c->val[_AI_PERM] = strdup("signature");
+       } else if (permission == PMINFO_PERMISSION_PRIVILEGE) {
+               c->val[_AI_PERM] = strdup("privilege");
+       } else {
+               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("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);
+
+       return 0;
+}
+
+static int __app_info_delete_handler (const pkgmgrinfo_appinfo_h handle, void *data)
+{
+       struct appinfomgr *cf = (struct appinfomgr *)data;
+       char *appid;
+
+       pkgmgrinfo_appinfo_get_appid(handle, &appid);
+
+       g_hash_table_remove(cf->tbl, appid);
+
+       return 0;
+}
+
+static int _read_pkg_info(struct appinfomgr *cf)
+{
+       int ret = pkgmgrinfo_appinfo_get_install_list(__app_info_insert_handler, cf);
+
+       assert(ret == PMINFO_R_OK);
+
+       return ret;
+}
+
+static struct appinfomgr *_init()
+{
+       struct appinfomgr *cf;
+
+       cf = calloc(1, sizeof(*cf));
+       if (!cf) {
+               _E("appinfo init: %s", strerror(errno));
+               return NULL;
+       }
+
+       cf->tbl = g_hash_table_new_full(g_str_hash, g_str_equal,
+                       NULL, _free_appinfo);
+
+       pkg_tbl = g_hash_table_new(g_str_hash, g_str_equal);
+       _E("pkg_tbl : %x", pkg_tbl);
+       return cf;
+}
+
+static gboolean __amd_pkgmgrinfo_start_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("blocking");
+               SECURE_LOGD("pkgmgr working for this application(%s)", c->val[_AI_NAME]);
+       }
+       return TRUE;
+}
+
+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)
+{
+       char *appid = NULL;
+       struct appinfomgr *cf = (struct appinfomgr *)user_data;
+       struct appinfo *c;
+       const char *componet;
+       int r;
+
+       pkgmgrinfo_appinfo_get_appid(handle, &appid);
+
+       __app_info_insert_handler(handle, user_data);
+       c = g_hash_table_lookup(cf->tbl, appid);
+
+       componet = appinfo_get_value(c, AIT_COMPTYPE);
+       r = appinfo_get_boolean(c, AIT_ONBOOT);
+
+       if (r == 1 && componet && strncmp(componet, "svcapp", 6) == 0)
+       {
+               _D("start service - %s", appid);
+               _start_srv(c, NULL);
+       }
+
+       return 0;
+}
+
+static int __amd_pkgmgrinfo_update_end_handler(pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+       char *appid = NULL;
+       struct appinfomgr *cf = (struct appinfomgr *)user_data;
+       struct appinfo *c;
+       const char *componet;
+       int r;
+
+       pkgmgrinfo_appinfo_get_appid(handle, &appid);
+       c = g_hash_table_lookup(cf->tbl, appid);
+
+       if (c != NULL && strncmp(c->val[_AI_STATUS], "restart", 7) == 0) {
+               __app_info_insert_handler(handle, user_data);
+               __release_srv(appid);
+       } else {
+               __app_info_insert_handler(handle, user_data);
+               c = g_hash_table_lookup(cf->tbl, appid);
+
+               componet = appinfo_get_value(c, AIT_COMPTYPE);
+               r = appinfo_get_boolean(c, AIT_ONBOOT);
+
+               if (r == 1 && componet && strncmp(componet, "svcapp", 6) == 0)
+               {
+                       _D("start service - %s", appid);
+                       _start_srv(c, NULL);
+               }
+       }
+
+       return 0;
+}
+
+static gboolean __amd_pkgmgrinfo_uninstall_end_handler (gpointer key, gpointer value, gpointer user_data)
+{
+       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;
+       }
+       return FALSE;
+}
+
+static int __amd_pkgmgrinfo_status_cb(int req_id, const char *pkg_type,
+                      const char *pkgid, const char *key, const char *val,
+                      const void *pmsg, void *user_data)
+{
+       int ret = 0;
+       pkgmgrinfo_pkginfo_h handle;
+       char *op = NULL;
+       struct pkginfo *p = NULL;
+       struct appinfomgr *cf = (struct appinfomgr *)user_data;
+
+       SECURE_LOGD("pkgid(%s), key(%s), value(%s)", pkgid, key, val);
+
+       if(strncmp(key,"start", 5) == 0) {
+               g_hash_table_remove(pkg_tbl, pkgid);
+               p = calloc(1, sizeof(*p));
+               if (p == NULL) {
+                       _E("out of memory");
+                       return -1;
+               }
+
+               p->pkgid = strdup(pkgid);
+               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) || (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) {
+               p = g_hash_table_lookup(pkg_tbl, pkgid);
+               if(p) {
+                       op = p->op;
+                       SECURE_LOGD("op(%s), value(%s)", op, val);
+                       if (strncmp(val, "ok", 2) == 0) {
+                               if (op && strncmp(op, "install", 7)== 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_install_end_handler, user_data);
+                                       if (ret != PMINFO_R_OK) {
+                                               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+                                               return -1;
+                                       }
+                                       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+                               }
+                               else if (op && strncmp(op, "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_end_handler, user_data);
+                                       if (ret != PMINFO_R_OK) {
+                                               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+                                               return -1;
+                                       }
+                                       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+                               }
+                               else if (op && strncmp(op, "uninstall", 9) == 0) {
+                                       ret = g_hash_table_foreach_remove(cf->tbl, __amd_pkgmgrinfo_uninstall_end_handler, (gpointer)pkgid);
+                                       _D("g_hash_table_foreach_remove, %d", ret);
+                                       ret = 0;
+                               }
+                       }
+                       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);
+                       free(p->op);
+                       free(p);
+               }
+       }
+       return ret;
+}
+
+static int __unmounted_list_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+       char *appid;
+       struct appinfomgr *cf = (struct appinfomgr *)user_data;
+       struct appinfo *c;
+
+       pkgmgrinfo_appinfo_get_appid(handle, &appid);
+       c = g_hash_table_lookup(cf->tbl, appid);
+       if (c == NULL)
+               return -1;
+
+       SECURE_LOGD("%s : %s", c->val[_AI_FILE], c->val[_AI_STATUS]);
+       free(c->val[_AI_STATUS]);
+       c->val[_AI_STATUS] = strdup("unmounted");
+       SECURE_LOGD("unmounted(%s)", appid);
+
+       return 0;
+}
+
+static int __mounted_list_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+       char *appid;
+       struct appinfomgr *cf = (struct appinfomgr *)user_data;
+       struct appinfo *c;
+
+       pkgmgrinfo_appinfo_get_appid(handle, &appid);
+       c = g_hash_table_lookup(cf->tbl, appid);
+       if (c == NULL)
+               return -1;
+
+       SECURE_LOGD("%s : %s", c->val[_AI_FILE], c->val[_AI_STATUS]);
+       if(strncmp(c->val[_AI_STATUS], "unmounted", 9) ==0 ) {
+               free(c->val[_AI_STATUS]);
+               c->val[_AI_STATUS] = strdup("installed");
+       }
+       SECURE_LOGD("mounted(%s)", appid);
+
+       return 0;
+}
+
+static void __amd_mmc_vconf_cb(keynode_t *key, void *data)
+{
+       int status;
+       struct appinfomgr *cf = (struct appinfomgr *)data;
+       int ret = 0;
+
+       status = vconf_keynode_get_int(key);
+       if( status < 0 ) {
+               return;
+       }
+
+       if(status == VCONFKEY_SYSMAN_MMC_REMOVED || status == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
+               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){
+               ret = pkgmgrinfo_appinfo_get_mounted_list(__mounted_list_cb, data);
+               if (ret != PMINFO_R_OK){
+                       _E("pkgmgrinfo_appinfo_get_mounted_list failed: %d", ret);
+               }
+       }
+}
+
+int appinfo_init(struct appinfomgr **cf)
+{
+       struct appinfomgr *_cf;
+       int r;
+       FILE *fp = NULL;
+       char buf[4096] = {0,};
+       char *tmp = NULL;
+
+       if (!cf) {
+               errno = EINVAL;
+               _E("appinfo init: %s", strerror(errno));
+               return -1;
+       }
+
+       fp = fopen("/proc/cmdline", "r");
+       if (fp == NULL){
+               _E("appinfo init failed: %s", strerror(errno));
+               return -1;
+       }
+       r = fgets(buf, sizeof(buf), fp);
+       tmp = strstr(buf, "gles");
+       if(tmp != NULL) {
+               sscanf(tmp,"gles=%d", &gles);
+       }
+       fclose(fp);
+
+       _cf = _init();
+       if (!_cf) {
+               assert(_cf);
+               return -1;
+       }
+
+       r = _read_pkg_info(_cf);
+       if (r != PMINFO_R_OK) {
+               _fini(_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);
+       pkgmgrinfo_client_set_status_type(pc, event_type);
+       pkgmgrinfo_client_listen_status(pc, __amd_pkgmgrinfo_status_cb , _cf);
+
+       *cf = _cf;
+
+       return 0;
+}
+
+void appinfo_fini(struct appinfomgr **cf)
+{
+       if (!cf || !*cf)
+               return;
+
+       _fini(*cf);
+       *cf = NULL;
+}
+
+const struct appinfo *appinfo_insert(struct appinfomgr *cf, const char *pkg_name)
+{
+       pkgmgrinfo_pkginfo_h handle;
+       if (pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &handle) == PMINFO_R_OK){
+               pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, __app_info_insert_handler, cf);
+               pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __app_info_insert_handler, cf);
+               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       }
+       return cf;
+}
+
+void appinfo_delete(struct appinfomgr *cf, const char *pkg_name)
+{
+       pkgmgrinfo_pkginfo_h handle;
+       if (pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &handle) != PMINFO_R_OK)
+               return;
+       pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, __app_info_delete_handler, cf);
+       pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __app_info_delete_handler, cf);
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+}
+
+const struct appinfo *appinfo_find(struct appinfomgr *cf, const char *filename)
+{
+       if (!cf || !filename || !*filename) {
+               errno = EINVAL;
+               return NULL;
+       }
+
+       return g_hash_table_lookup(cf->tbl, FILENAME(filename));
+}
+
+const char *appinfo_get_value(const struct appinfo *c, enum appinfo_type type)
+{
+       enum _appinfo_idx i;
+
+       if (!c) {
+               errno = EINVAL;
+               _E("appinfo get value: %s, %d", strerror(errno), type);
+               return NULL;
+       }
+
+       for (i = _AI_START; i < sizeof(_appinfos)/sizeof(_appinfos[0]); i++) {
+               if (type == _appinfos[i].type)
+                       return c->val[i];
+       }
+
+       errno = ENOENT;
+       _E("appinfo get value: %s", strerror(errno));
+
+       return NULL;
+}
+
+const char *appinfo_set_value(struct appinfo *c, enum appinfo_type type, const char* val)
+{
+       enum _appinfo_idx i;
+       for (i = _AI_START; i < sizeof(_appinfos)/sizeof(_appinfos[0]); i++) {
+               if (type == _appinfos[i].type) {
+                       SECURE_LOGD("%s : %s : %s", c->val[_AI_FILE], c->val[i], val);
+                       free(c->val[i]);
+                       c->val[i] = strdup(val);
+               }
+       }
+
+       return NULL;
+}
+
+const char *appinfo_get_filename(const struct appinfo *c)
+{
+       if (!c) {
+               errno = EINVAL;
+               SECURE_LOGE("appinfo get filename: %s", strerror(errno));
+               return NULL;
+       }
+
+       return c->val[_AI_FILE];
+}
+
+struct _cbinfo {
+       appinfo_iter_callback cb;
+       void *cb_data;
+};
+
+static void _iter_cb(gpointer key, gpointer value, gpointer user_data)
+{
+       struct _cbinfo *cbi = user_data;
+
+       assert(cbi);
+
+       cbi->cb(cbi->cb_data, key, value);
+}
+
+void appinfo_foreach(struct appinfomgr *cf, appinfo_iter_callback cb, void *user_data)
+{
+       struct _cbinfo cbi;
+
+       if (!cf || !cb) {
+               errno = EINVAL;
+               _E("appinfo foreach: %s", strerror(errno));
+               return;
+       }
+
+       cbi.cb = cb;
+       cbi.cb_data = user_data;
+
+       g_hash_table_foreach(cf->tbl, _iter_cb, &cbi);
+}
+
+int appinfo_get_boolean(const struct appinfo *c, enum appinfo_type type)
+{
+       const char *v;
+
+       v = appinfo_get_value(c, type);
+       if (!v)
+               return -1;
+
+       if (!strcmp(v, "1") || !strcasecmp(v, "true"))
+               return 1;
+
+       if (!strcmp(v, "0") || !strcasecmp(v, "false"))
+               return 0;
+
+       errno = EFAULT;
+
+       return -1;
+}
+
diff --git a/am_daemon/amd_appinfo.h b/am_daemon/amd_appinfo.h
new file mode 100755 (executable)
index 0000000..77bf6e6
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef __AUL_AMD_APPINFO_H_
+#define __AUL_AMD_APPINFO_H_
+
+struct appinfomgr;
+struct appinfo;
+
+enum appinfo_type {
+       AIT_NAME,
+       AIT_COMP,
+       AIT_EXEC,
+       AIT_TYPE,
+       AIT_ONBOOT, /* start on boot: boolean */
+       AIT_RESTART, /* auto restart: boolean */
+       AIT_MULTI,
+       AIT_HWACC,
+       AIT_PERM,
+       AIT_PKGID,
+       AIT_TASKMANAGE,
+       AIT_PRELOAD,
+       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);
+void appinfo_fini(struct appinfomgr **cf);
+
+const struct appinfo *appinfo_insert(struct appinfomgr *cf, const char *filename);
+void appinfo_delete(struct appinfomgr *cf, const char *filename);
+
+const struct appinfo *appinfo_find(struct appinfomgr *cf, const char *filename);
+const char *appinfo_get_value(const struct appinfo *c, enum appinfo_type type);
+const char *appinfo_set_value(struct appinfo *c, enum appinfo_type type, const char* val);
+const char *appinfo_get_filename(const struct appinfo *c);
+int appinfo_get_boolean(const struct appinfo *c, enum appinfo_type type);
+
+typedef void (*appinfo_iter_callback)(void *user_data,
+               const char *filename, const struct appinfo *c);
+void appinfo_foreach(struct appinfomgr *cf, appinfo_iter_callback cb, void *user_data);
+
+#endif /* __AUL_AMD_APPINFO_H_ */
diff --git a/am_daemon/amd_cgutil.c b/am_daemon/amd_cgutil.c
new file mode 100755 (executable)
index 0000000..4c6f8b8
--- /dev/null
@@ -0,0 +1,631 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
+#include <limits.h>
+#include <dirent.h>
+#include <mntent.h>
+
+
+#include "amd_config.h"
+#include "simple_util.h"
+#include "amd_cgutil.h"
+
+#define CFILE_RELEASE_AGENT "release_agent"
+#define CFILE_NOTIFY_ON_RELEASE "notify_on_release"
+#define CFILE_TASKS "tasks"
+
+#define DEFAULT_MODE 0755
+
+struct ctrl {
+       enum ctrl_type ctrl;
+       char *root; /* cginfo's mount_point + subsystem name */
+};
+
+struct cginfo {
+       int refcnt;
+       char *mount_point;
+       struct ctrl ctrls[CTRL_MAX];
+};
+
+enum {
+       _MNT_ROOT,
+       _MNT_MGR,
+       _MNT_CPU,
+       _MNT_MEM,
+       /* add type after adding mount information to mntinfos[] */
+};
+
+struct mntinfo {
+       char *source;
+       char *ftype; /* filesystem type */
+       unsigned long flags;
+       char *option;
+};
+
+static struct mntinfo mntinfos[] = {
+       [_MNT_ROOT] = {
+               "cgroup_root",
+               "tmpfs",
+               MS_NODEV | MS_NOSUID | MS_NOEXEC,
+               NULL,
+       },
+       [_MNT_MGR] = {
+               "daemon_mgr",
+               "cgroup",
+               MS_NODEV | MS_NOSUID | MS_NOEXEC,
+               "none,name=daemon_mgr",
+       },
+       [_MNT_CPU] = {
+               "cpuset",
+               "cgroup",
+               MS_NODEV | MS_NOSUID | MS_NOEXEC,
+               "cpuset",
+       },
+       [_MNT_MEM] = {
+               "memory",
+               "cgroup",
+               MS_NODEV | MS_NOSUID | MS_NOEXEC,
+               "memory",
+       },
+       /* TODO: add more */
+};
+
+struct ctrlinfo {
+       int mnt_type;
+       char *name;
+};
+
+static struct ctrlinfo ctrlinfos[] = {
+       [CTRL_MGR] = { _MNT_MGR, "mgr", },
+#if defined(USE_CGROUP_CPU)
+       [CTRL_CPU] = { _MNT_CPU, "cpuset", },
+#endif
+#if defined(USE_CGROUP_MEM)
+       [CTRL_MEM] = { _MNT_MEM, "memory", },
+#endif
+};
+
+static inline int _mount(const char *mount_point, struct mntinfo *mti)
+{
+       assert(mti);
+       return mount(mti->source, mount_point, mti->ftype, mti->flags,
+                       mti->option);
+}
+
+static inline int _umount(const char *mount_point)
+{
+       return umount2(mount_point, MNT_DETACH);
+}
+
+static int _write_single(struct ctrl *ctr,
+               const char *group, const char *file, const char *str)
+{
+       FILE *fp;
+       char path[FILENAME_MAX];
+       int r;
+
+       assert(ctr);
+       assert(file);
+
+       if (!str)
+               str = "";
+
+       snprintf(path, sizeof(path), "%s/%s%s%s", ctr->root,
+                       group ? : "", group ? "/" : "", file);
+       fp = fopen(path, "w");
+       if (!fp) {
+               _E("open: %s: %s", path, strerror(errno));
+               return -1;
+       }
+
+       r = fputs(str, fp);
+       if (r == EOF) {
+               _E("write: %s,%s: %s", path, str, strerror(errno));
+               r = -1;
+       } else {
+               r = 0;
+       }
+
+       fclose(fp);
+
+       return r;
+}
+
+/*
+static void _trunc_newline(char *buf, int sz)
+{
+       char *s;
+
+       assert(buf);
+       assert(sz > 0);
+
+       s = buf;
+       while (*s) {
+               if (*s == '\r' || *s == '\n') {
+                       *s = '\0';
+                       break;
+               }
+               s++;
+       }
+}
+
+static int _read_single(struct ctrl *ctr, const char *file, char *buf, int sz)
+{
+       FILE *fp;
+       char path[FILENAME_MAX];
+       char _buf[LINE_MAX];
+       char *r;
+
+       assert(ctr);
+       assert(file);
+       assert(buf);
+       assert(sz > 0);
+
+       snprintf(path, sizeof(path), "%s/%s", ctr->root, file);
+       fp = fopen(path, "r");
+       if (!fp) {
+               _E("open: %s: %s", path, strerror(errno));
+               return -1;
+       }
+
+       r = fgets(_buf, sizeof(_buf), fp);
+       if (r == NULL) {
+               _E("read: %s: %s", path, strerror(errno));
+       } else {
+               _trunc_newline(_buf, sizeof(_buf));
+               snprintf(buf, sz, "%s", _buf);
+       }
+
+       fclose(fp);
+
+       return r == NULL ? -1 : 0;
+}
+*/
+
+static int _destroy(struct cginfo *cg)
+{
+       int i;
+       int r;
+
+       for (i = 0; i < sizeof(cg->ctrls)/sizeof(cg->ctrls[0]); i++) {
+               struct ctrl *ctr = &cg->ctrls[i];
+
+               if (ctr->root) {
+                       r = _umount(ctr->root);
+                       if (r == -1) {
+                               _E("unmount: %s: %s",
+                                               ctr->root, strerror(errno));
+                               return -1;
+                       }
+                       free(ctr->root);
+                       ctr->root = NULL;
+               }
+       }
+
+       if (cg->mount_point) {
+               r = _umount(cg->mount_point);
+               if (r == -1) {
+                       _E("unmount: %s: %s",
+                                       cg->mount_point, strerror(errno));
+                       return -1;
+               }
+               free(cg->mount_point);
+       }
+
+       free(cg);
+
+       return 0;
+}
+
+void cgutil_destroy(struct cginfo **cg)
+{
+       int r;
+
+       if (!cg || !*cg)
+               return;
+
+       (*cg)->refcnt--;
+
+       if ((*cg)->refcnt > 0)
+               return;
+
+       r = _destroy(*cg);
+       if (r == -1)
+               return;
+
+       *cg = NULL;
+}
+
+static int check_cgroup_mount(const char *mount_point)
+{
+       struct mntent* mnt;
+       const char* table = "/etc/mtab";
+       FILE* fp;
+       int     r = -1;
+       fp = setmntent(table, "r");
+
+       if (!fp)
+               return r;
+
+       while (mnt=getmntent(fp)) {
+               if (strcmp(mount_point, mnt->mnt_dir) == 0) {
+                       r = 0;
+                       break;
+               }
+       }
+       endmntent(fp);
+       return r;
+}
+
+static int _mount_root(struct cginfo *cg, const char *mount_point)
+{
+       int r = 0;
+
+       if (check_cgroup_mount(mount_point) < 0)
+               r = _mount(mount_point, &mntinfos[_MNT_ROOT]);
+       if (r == -1) {
+               if (errno != EBUSY) {
+                       _E("mount: %s: %s", mount_point, strerror(errno));
+                       return -1;
+               }
+               _D("'%s' already mounted", mount_point);
+       }
+
+       cg->mount_point = strdup(mount_point);
+
+       return 0;
+}
+
+static int _init_ctrl(struct ctrl *ctr, struct cginfo *cg, enum ctrl_type ctrl)
+{
+       int r;
+       int mt;
+       char path[FILENAME_MAX];
+
+       assert(ctr);
+       assert(ctrl >= 0);
+       assert(ctrl < sizeof(ctrlinfos)/sizeof(ctrlinfos[0]));
+
+       mt = ctrlinfos[ctrl].mnt_type;
+       snprintf(path, sizeof(path), "%s/%s",
+                       cg->mount_point, ctrlinfos[ctrl].name);
+
+       /* TODO: read /proc/cgroup and check the current type is enabled */
+
+       r = mkdir(path, DEFAULT_MODE);
+       if (r == -1) {
+               if (errno != EEXIST) {
+                       _E("mkdir: %s: %s", path, strerror(errno));
+                       return -1;
+               }
+               _D("'%s' exist", path);
+       }
+
+       r = _mount(path, &mntinfos[mt]);
+       if (r == -1) {
+               if (errno != EBUSY) {
+                       _E("mount: %s: %s", path, strerror(errno));
+                       rmdir(path);
+                       return -1;
+               }
+               _D("'%s' already mounted", path);
+       }
+
+       ctr->ctrl = ctrl;
+       ctr->root = strdup(path);
+
+       return 0;
+}
+
+static int _set_release_agent(struct ctrl *ctr, const char *agent_path)
+{
+       int r;
+
+       r = access(agent_path, X_OK);
+       if (r == -1) {
+               _E("'%s' is not executable: %s",
+                               agent_path, strerror(errno));
+               return -1;
+       }
+
+       r = _write_single(ctr, NULL, CFILE_RELEASE_AGENT, agent_path);
+       if (r == -1)
+               return -1;
+
+       r = _write_single(ctr, NULL, CFILE_NOTIFY_ON_RELEASE, "1");
+       if (r == -1)
+               return -1;
+
+       return 0;
+}
+
+struct cginfo *cgutil_ref(struct cginfo *cg)
+{
+       if (cg)
+               cg->refcnt++;
+
+       return cg;
+}
+
+static int _create(struct cginfo *cg,
+               const char *mount_point, const char *agent_path)
+{
+       int i;
+       int r;
+
+       r = _mount_root(cg, mount_point);
+       if (r == -1)
+               return -1;
+
+       for (i = 0; i < sizeof(cg->ctrls)/sizeof(cg->ctrls[0]); i++) {
+               r = _init_ctrl(&cg->ctrls[i], cg, i);
+               if (r == -1)
+                       return -1;
+       }
+
+       r = _set_release_agent(&cg->ctrls[CTRL_MGR], agent_path);
+       if (r == -1)
+               return -1;
+
+       return 0;
+}
+
+int cgutil_create(const char *mount_point, const char *agent_path,
+               struct cginfo **cg)
+{
+       struct cginfo *_cg;
+       int r;
+
+       if (!mount_point || !*mount_point ||
+                       !agent_path || !*agent_path || !cg) {
+               errno = EINVAL;
+               _E("cgutil create: %s", strerror(errno));
+               return -1;
+       }
+
+       _cg = calloc(1, sizeof(*_cg));
+       if (!_cg) {
+               _E("cgutil alloc: %s", strerror(errno));
+               return -1;
+       }
+
+       r = _create(_cg, mount_point, agent_path);
+       if (r == -1) {
+               _destroy(_cg);
+               return -1;
+       }
+
+       *cg = cgutil_ref(_cg);
+
+       return 0;
+}
+
+int cgutil_create_group(struct cginfo *cg,
+               enum ctrl_type ctrl, const char *group)
+{
+       int r;
+       struct ctrl *ctr;
+       char path[FILENAME_MAX];
+
+       assert(ctrl >= 0 && ctrl < CTRL_MAX);
+
+       if (!cg || !group || !*group) {
+               errno = EINVAL;
+               _E("cgutil create group: %s", strerror(errno));
+               return -1;
+       }
+
+       ctr = &cg->ctrls[ctrl];
+       assert(ctr);
+
+       snprintf(path, sizeof(path), "%s/%s", ctr->root, FILENAME(group));
+
+       r = mkdir(path, DEFAULT_MODE);
+       if (r == -1) {
+               _E("cgutil create group: mkdir: %s", strerror(errno));
+               return -1;
+       }
+
+       return 0;
+}
+
+int cgutil_remove_group(struct cginfo *cg,
+               enum ctrl_type ctrl, const char *group)
+{
+       int r;
+       struct ctrl *ctr;
+       char path[FILENAME_MAX];
+
+       assert(ctrl >= 0 && ctrl < CTRL_MAX);
+
+       if (!cg || !group || !*group) {
+               errno = EINVAL;
+               _E("cgutil remove group: %s", strerror(errno));
+               return -1;
+       }
+
+       ctr = &cg->ctrls[ctrl];
+       assert(ctr);
+
+       snprintf(path, sizeof(path), "%s/%s", ctr->root, FILENAME(group));
+
+       r = rmdir(path);
+       if (r == -1) {
+               _E("cgutil remove group: rmdir: %s", strerror(errno));
+               return -1;
+       }
+
+       return 0;
+}
+
+int cgutil_exist_group(struct cginfo *cg,
+               enum ctrl_type ctrl, const char *group)
+{
+       int r;
+       struct ctrl *ctr;
+       char path[FILENAME_MAX];
+       struct stat st;
+
+       assert(ctrl >= 0 && ctrl < CTRL_MAX);
+
+       if (!cg || !group || !*group) {
+               errno = EINVAL;
+               _E("cgutil exist group: %s", strerror(errno));
+               return -1;
+       }
+
+       ctr = &cg->ctrls[ctrl];
+       assert(ctr);
+
+       snprintf(path, sizeof(path), "%s/%s", ctr->root, FILENAME(group));
+
+       r = stat(path, &st);
+       if (r == -1) {
+               if (errno == ENOENT)
+                       return 0;
+
+               _E("cgutil exist group: %s", strerror(errno));
+               return -1;
+       }
+
+       /* stat() returns no error, then group exists */
+       return 1;
+}
+
+int cgutil_group_add_pid(struct cginfo *cg,
+               enum ctrl_type ctrl, const char *group, pid_t pid)
+{
+       int r;
+       struct ctrl *ctr;
+       char buf[32]; /* 32 is enough for ineger number */
+
+       assert(ctrl >= 0 && ctrl < CTRL_MAX);
+
+       /* PID 1 is init's PID */
+       if (!cg || !group || !*group || pid <= 1) {
+               errno = EINVAL;
+               _E("cgutil add pid: %s", strerror(errno));
+               return -1;
+       }
+
+       ctr = &cg->ctrls[ctrl];
+       assert(ctr);
+
+       snprintf(buf, sizeof(buf), "%d", pid);
+
+       r = _write_single(ctr, FILENAME(group), CFILE_TASKS, buf);
+       if (r == -1)
+               return -1;
+
+       return 0;
+}
+
+static int _foreach_pid(struct ctrl *ctr, const char *group,
+               cgutil_iter_pid_callback cb, void *user_data)
+{
+       int r;
+       FILE *fp;
+       char path[FILENAME_MAX];
+
+       assert(ctr);
+       assert(cb);
+
+       snprintf(path, sizeof(path), "%s/%s/%s",
+                       ctr->root, FILENAME(group), CFILE_TASKS);
+       fp = fopen(path, "r");
+       if (!fp) {
+               _E("open: %s: %s", path, strerror(errno));
+               return -1;
+       }
+
+       while (!feof(fp)) {
+               unsigned long l;
+
+               r = fscanf(fp, "%lu", &l);
+               if (r != 1)
+                       break;
+
+               r = cb(user_data, group, l);
+               if (r == -1)
+                       break;
+       }
+
+       fclose(fp);
+
+       return 0;
+}
+
+int cgutil_group_foreach_pid(struct cginfo *cg,
+               enum ctrl_type ctrl, const char *group,
+               cgutil_iter_pid_callback cb, void *user_data)
+{
+       struct ctrl *ctr;
+
+       assert(ctrl >= 0 && ctrl < CTRL_MAX);
+
+       if (!cg || !group || !*group || !cb) {
+               errno = EINVAL;
+               _E("cgutil foreach pid: %s", strerror(errno));
+               return -1;
+       }
+
+       ctr = &cg->ctrls[ctrl];
+       assert(ctr);
+
+       return _foreach_pid(ctr, group, cb, user_data);
+}
+
+static int _foreach_group(struct ctrl *ctr,
+               cgutil_iter_group_callback cb, void *user_data)
+{
+       int r;
+       DIR *d;
+       struct dirent *de;
+
+       assert(ctr);
+       assert(cb);
+
+       d = opendir(ctr->root);
+       if (!d) {
+               _E("open: %s: %s", ctr->root, strerror(errno));
+               return -1;
+       }
+
+       for (de = readdir(d); de; de = readdir(d)) {
+               if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
+                       continue;
+
+               r = cb(user_data, de->d_name);
+               if (r == -1)
+                       break;
+       }
+
+       closedir(d);
+
+       return 0;
+}
+
+int cgutil_foreach_group(struct cginfo *cg, enum ctrl_type ctrl,
+               cgutil_iter_group_callback cb, void *user_data)
+{
+       struct ctrl *ctr;
+
+       assert(ctrl >= 0 && ctrl < CTRL_MAX);
+
+       if (!cg || !cb) {
+               errno = EINVAL;
+               _E("cgutil foreach group: %s", strerror(errno));
+               return -1;
+       }
+
+       ctr = &cg->ctrls[ctrl];
+       assert(ctr);
+
+       return _foreach_group(ctr, cb, user_data);
+}
diff --git a/am_daemon/amd_cgutil.h b/am_daemon/amd_cgutil.h
new file mode 100755 (executable)
index 0000000..360bef2
--- /dev/null
@@ -0,0 +1,48 @@
+
+#ifndef __AUL_AMD_CGROUP_UTIL_H__
+#define __AUL_AMD_CGROUP_UTIL_H__
+
+enum ctrl_type {
+       CTRL_MGR, /* for manager */
+#if defined(USE_CGROUP_CPU) /* not implemented */
+       CTRL_CPU, /* cpuset */
+#endif
+#if defined(USE_CGROUP_MEM) /* not implemented */
+       CTRL_MEM, /* memory */
+#endif
+       /* TODO: add more */
+       CTRL_MAX,
+};
+
+struct cginfo;
+
+int cgutil_create(const char *mount_point, const char *agent_path,
+               struct cginfo **cg);
+void cgutil_destroy(struct cginfo **cg);
+
+struct cginfo *cgutil_ref(struct cginfo *cg);
+#define cgutil_unref(cg) cgutil_destroy(cg)
+
+
+int cgutil_create_group(struct cginfo *cg,
+               enum ctrl_type ctrl, const char *group);
+int cgutil_remove_group(struct cginfo *cg,
+               enum ctrl_type ctrl, const char *group);
+int cgutil_exist_group(struct cginfo *cg,
+               enum ctrl_type ctrl, const char *group);
+
+typedef int (*cgutil_iter_group_callback)(void *user_data, const char *group);
+int cgutil_foreach_group(struct cginfo *cg, enum ctrl_type ctrl,
+               cgutil_iter_group_callback cb, void *user_data);
+
+
+int cgutil_group_add_pid(struct cginfo *cg,
+               enum ctrl_type ctrl, const char *group, pid_t pid);
+
+typedef int (*cgutil_iter_pid_callback)(void *user_data, const char *group,
+               pid_t pid);
+int cgutil_group_foreach_pid(struct cginfo *cg,
+               enum ctrl_type ctrl, const char *group,
+               cgutil_iter_pid_callback cb, void *user_data);
+
+#endif /* __AUL_AMD_CGROUP_UTIL_H__ */
diff --git a/am_daemon/amd_config.h b/am_daemon/amd_config.h
new file mode 100755 (executable)
index 0000000..d8671b0
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ *  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.
+ *
+ */
+
+
+#define AMD_LOG
+
diff --git a/am_daemon/amd_key.c b/am_daemon/amd_key.c
new file mode 100755 (executable)
index 0000000..3df8f43
--- /dev/null
@@ -0,0 +1,214 @@
+/*
+ *  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 <Ecore_X.h>
+#include <Ecore_Input.h>
+#include <utilX.h>
+#include <Ecore.h>
+#include <Evas.h>
+#include <aul.h>
+#include <glib.h>
+
+#include "amd_config.h"
+#include "amd_key.h"
+#include "simple_util.h"
+#include "app_sock.h"
+#include "launch.h"
+
+static struct {
+       Ecore_X_Window win;
+       Ecore_Event_Handler *key_up;
+       Ecore_Event_Handler *key_down;
+} key_info = {
+       .win = NULL,
+       .key_up = NULL,
+       .key_down = NULL,
+};
+
+GSList *key_pid_list = NULL;
+
+static Eina_Bool __key_release_cb(void *data, int type, void *event);
+static Eina_Bool __key_press_cb(void *data, int type, void *event);
+
+static Eina_Bool __key_release_cb(void *data, int type, void *event)
+{
+       Evas_Event_Key_Up *ev = event;
+       int ret;
+       GSList *entry;
+       int *pid_data;
+       bundle *kb;
+
+       _D("Released");
+
+       if (!ev) {
+               _D("Invalid event object");
+               return ECORE_CALLBACK_RENEW;
+       }
+
+       entry = key_pid_list;
+       if (entry && entry->data) {
+               pid_data = (int *) entry->data;
+
+               kb = bundle_create();
+               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_with_noreply(*pid_data, APP_KEY_EVENT, kb);
+               if (ret < 0)
+                       _E("app_send_cmd failed with error %d\n", ret);
+
+               bundle_free(kb);
+       }
+
+       return ECORE_CALLBACK_RENEW;
+}
+
+
+static Eina_Bool __key_press_cb(void *data, int type, void *event)
+{
+       Evas_Event_Key_Down *ev = event;
+       int ret;
+       GSList *entry;
+       int *pid_data;
+       bundle *kb;
+
+       _D("Pressed");
+
+       if (!ev) {
+               _D("Invalid event object");
+               return ECORE_CALLBACK_RENEW;
+       }
+
+       entry = key_pid_list;
+       if (entry && entry->data) {
+               pid_data = (int *) entry->data;
+
+               kb = bundle_create();
+               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_with_noreply(*pid_data, APP_KEY_EVENT, kb);
+               if (ret < 0)
+                       _E("app_send_cmd failed with error %d\n", ret);
+
+               bundle_free(kb);
+       }
+
+       return ECORE_CALLBACK_RENEW;
+}
+
+int _register_key_event(int pid)
+{
+       int *pid_data;
+       GSList *entry;
+
+       pid_data = malloc(sizeof(int));
+       if (pid_data == NULL) {
+               _E("out of memory");
+               return -1;
+       }
+
+       *pid_data = pid;
+
+       key_pid_list = g_slist_prepend(key_pid_list, pid_data);
+
+       _D("===key stack===");
+
+       for (entry = key_pid_list; entry; entry = entry->next) {
+               if (entry->data) {
+                       pid_data = (int *) entry->data;
+                       _D("pid : %d",*pid_data);
+               }
+       }
+
+       return 0;
+}
+
+int _unregister_key_event(int pid)
+{
+       GSList *entry;
+       int *pid_data;
+
+       for (entry = key_pid_list; entry;) {
+               if (entry->data) {
+                       pid_data = (int *) entry->data;
+                       entry = entry->next;
+                       if(pid == *pid_data) {
+                               key_pid_list = g_slist_remove(key_pid_list, pid_data);
+                               free(pid_data);
+                       }
+               }
+       }
+
+       _D("===key stack===");
+
+       for (entry = key_pid_list; entry; entry = entry->next) {
+               if (entry->data) {
+                       pid_data = (int *) entry->data;
+                       _D("pid : %d",*pid_data);
+               }
+       }
+
+       return 0;
+}
+
+Ecore_X_Window _input_window_get()
+{
+       return key_info.win;
+}
+
+int _key_init()
+{
+       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);
+       utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_NEXTSONG, SHARED_GRAB);
+       utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_PREVIOUSSONG, SHARED_GRAB);
+       utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_REWIND, SHARED_GRAB);
+       utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_FASTFORWARD, SHARED_GRAB);
+       utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_PLAYPAUSE, SHARED_GRAB);
+
+       key_info.key_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, __key_release_cb, NULL);
+       if (!key_info.key_up) {
+               _D("Failed to register a key up event handler");
+       }
+
+       key_info.key_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, __key_press_cb, NULL);
+       if (!key_info.key_down) {
+               _D("Failed to register a key down event handler");
+       }
+
+       return 0;
+}
+
diff --git a/am_daemon/amd_key.h b/am_daemon/amd_key.h
new file mode 100755 (executable)
index 0000000..bee999e
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  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 __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
+
diff --git a/am_daemon/amd_launch.c b/am_daemon/amd_launch.c
new file mode 100755 (executable)
index 0000000..cae9032
--- /dev/null
@@ -0,0 +1,1955 @@
+/*
+ *  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 <signal.h>
+#include <Ecore_X.h>
+#include <Ecore_Input.h>
+#include <utilX.h>
+#include <Ecore.h>
+#include <Evas.h>
+#include <Ecore_Evas.h>
+
+#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 <stdbool.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/prctl.h>
+#include <sys/resource.h>
+#include <pkgmgr-info.h>
+#include <vconf.h>
+#include <proc_stat.h>
+#include <poll.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"
+#include "launch.h"
+#include "app_signal.h"
+
+#define DAC_ACTIVATE
+
+#include "access_control.h"
+
+
+#define TERM_WAIT_SEC 3
+#define INIT_PID 1
+
+#define AUL_PR_NAME                    16
+#define PATH_APP_ROOT "/opt/usr/apps"
+#define PATH_DATA "/data"
+#define SDK_CODE_COVERAGE "CODE_COVERAGE"
+#define SDK_DYNAMIC_ANALYSIS "DYNAMIC_ANALYSIS"
+#define PATH_DA_SO "/home/developer/sdk_tools/da/da_probe.so"
+
+#define PHONE_ORIENTATION_MODE "memory/private/sensor/10001"
+#define AMD_EFFECT_IMAGE_ENABLE "db/setting/effect_image"
+#define PHONE_ROTATE_LOCK "db/setting/auto_rotate_screen"
+
+#define SYS_MIN_CPU_LOCK_FILE "/sys/devices/system/cpu/cpufreq/slp/min_cpu_lock"
+#define MIN_CPU_LCK_CNT 0
+#define MAX_CPU_LCK_CNT 2
+
+#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*/
+typedef struct {
+       char *pkg_name;         /* package */
+       char *app_path;         /* exec */
+       char *original_app_path;        /* exec */
+       int multiple;           /* x_slp_multiple */
+       char *pkg_type;
+} app_info_from_pkgmgr;
+#endif
+
+static GList *_kill_list;
+
+struct ktimer {
+       pid_t pid;
+       char *group;
+       guint tid; /* timer ID */
+       struct cginfo *cg;
+};
+
+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, 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];
+       int ret;
+
+       _D("key : %s / value : %s", AUL_K_SDK, str);
+       /* http://gcc.gnu.org/onlinedocs/gcc/Cross_002dprofiling.html*/
+       /* GCOV_PREFIX contains the prefix to add to the absolute paths in the object file. */
+       /*              Prefix can be absolute, or relative. The default is no prefix.  */
+       /* GCOV_PREFIX_STRIP indicates the how many initial directory names */
+       /*              to stripoff the hardwired absolute paths. Default value is 0. */
+       if (strncmp(str, SDK_CODE_COVERAGE, strlen(str)) == 0) {
+               snprintf(buf, MAX_LOCAL_BUFSZ, PATH_APP_ROOT"/%s"PATH_DATA, appid);
+               ret = setenv("GCOV_PREFIX", buf, 1);
+               _D("GCOV_PREFIX : %d", ret);
+               ret = setenv("GCOV_PREFIX_STRIP", "4096", 1);
+               _D("GCOV_PREFIX_STRIP : %d", ret);
+       } else if (strncmp(str, SDK_DYNAMIC_ANALYSIS, strlen(str)) == 0) {
+               ret = setenv("LD_PRELOAD", PATH_DA_SO, 1);
+               _D("LD_PRELOAD : %d", ret);
+       }
+}
+
+#define USE_ENGINE(engine) setenv("ELM_ENGINE", engine, 1);
+
+static void _set_env(const char *appid, bundle * kb, const char *hwacc)
+{
+       const char *str;
+       const char **str_array;
+       int len;
+       int i;
+
+       setenv("PKG_NAME", appid, 1);
+
+       USE_ENGINE("gl")
+
+       str = bundle_get_val(kb, AUL_K_STARTTIME);
+       if (str != NULL)
+               setenv("APP_START_TIME", str, 1);
+
+       if(bundle_get_type(kb, AUL_K_SDK) & BUNDLE_TYPE_ARRAY) {
+               str_array = bundle_get_str_array(kb, AUL_K_SDK, &len);
+               if(str_array != NULL) {
+                       for (i = 0; i < len; i++) {
+                               _D("index : [%d]", i);
+                               _set_sdk_env(appid, (char *)str_array[i]);
+                       }
+               }
+       } else {
+               str = bundle_get_val(kb, AUL_K_SDK);
+               if(str != NULL) {
+                       _set_sdk_env(appid, (char *)str);
+               }
+       }
+       if (hwacc != NULL)
+               setenv("HWACC", hwacc, 1);
+}
+
+static void _prepare_exec(const char *appid, bundle *kb)
+{
+       const struct appinfo *ai;
+       const char *app_path = NULL;
+       const char *pkg_type = NULL;
+       char *file_name;
+       char process_name[AUL_PR_NAME];
+       const char *hwacc;
+       int ret;
+
+       setsid();
+
+       signal(SIGINT, SIG_DFL);
+       signal(SIGTERM, SIG_DFL);
+       signal(SIGCHLD, SIG_DFL);
+
+       ai = appinfo_find(_laf, appid);
+
+       app_path = appinfo_get_value(ai, AIT_EXEC);
+       pkg_type = appinfo_get_value(ai, AIT_TYPE);
+       hwacc = appinfo_get_value(ai, AIT_HWACC);
+
+       /* SET PRIVILEGES*/
+        _D("appid : %s / pkg_type : %s / app_path : %s ", appid, pkg_type, app_path);
+       if (pkg_type && 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;
+       }
+
+       /* 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;
+       }
+       file_name = strrchr(app_path, '/') + 1;
+       if (file_name == NULL) {
+               _D("can't locate file name to execute");
+               return;
+       }
+       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(appid, kb, hwacc);
+}
+
+static int _add_cgroup(struct cginfo *cg, const char *group, int pid)
+{
+       int r;
+
+       r = cgutil_exist_group(cg, CTRL_MGR, group);
+       if (r == -1) {
+               _E("exist check error: %s", strerror(errno));
+               return -1;
+       }
+
+       if (r == 0) { /* not exist */
+               r = cgutil_create_group(cg, CTRL_MGR, group);
+               if (r == -1) {
+                       _E("create group error");
+                       return -1;
+               }
+       }
+
+       r = cgutil_group_add_pid(cg, CTRL_MGR, group, pid);
+       if (r == -1) {
+               _E("add pid to group error");
+               cgutil_remove_group(cg, CTRL_MGR, group);
+               return -1;
+       }
+
+       return 0;
+}
+
+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 void _do_exec(struct cginfo *cg, const char *cmd, const char *group, bundle *kb)
+{
+       gchar **argv;
+       gint argc;
+       char **b_argv;
+       int b_argc;
+       gboolean b;
+       int r;
+
+       r = _add_cgroup(cg, group, getpid());
+       if (r == -1)
+               return;
+
+       b = g_shell_parse_argv(cmd, &argc, &argv, NULL);
+
+       if (kb) {
+               b_argv = __create_argc_argv(kb, &b_argc);
+               b_argv[0] = strdup(argv[0]);
+               _prepare_exec(group, kb);
+               execv(b_argv[0], b_argv);
+       }
+
+       if (b) {
+               _prepare_exec(group, kb);
+               execv(argv[0], argv);
+       }
+
+       _E("exec error: %s", strerror(errno));
+       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;
+       pid_t p;
+
+       if (!cg || !group || !*group || !cmd || !*cmd) {
+               errno = EINVAL;
+               _E("service start: %s", strerror(errno));
+               return -1;
+       }
+
+       p = fork();
+       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 */
+
+               exit(0);
+               break;
+       case -1:
+               _E("service start: fork: %s", strerror(errno));
+               r = -1;
+               break;
+       default: /* parent process */
+               _D("child process: %d", p);
+               r = __check_cmdline(p);
+               if(r > 0)
+                       __send_app_launch_signal(r);
+               break;
+       }
+
+       return r;
+}
+
+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);
+
+       cmd = appinfo_get_value(ai, AIT_EXEC);
+       if (!cmd) {
+               _E("start service: '%s' has no exec", group);
+               return -1;
+       }
+
+       r = service_start(_lcg, group, cmd, kb);
+       if (r == -1) {
+               _E("start service: '%s': failed", group);
+               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;
+}
+
+static void _free_kt(struct ktimer *kt)
+{
+       if (!kt)
+               return;
+
+       cgutil_unref(&kt->cg);
+       free(kt->group);
+       free(kt);
+}
+
+static void _kill_pid(struct cginfo *cg, const char *group, pid_t pid)
+{
+       int r;
+
+       if (pid <= INIT_PID) /* block sending to all process or init */
+               return;
+
+       r = cgutil_exist_group(cg, CTRL_MGR, group);
+       if (r == -1) {
+               _E("send SIGKILL: exist: %s", strerror(errno));
+               return;
+       }
+       if (r == 0) {
+               _D("send SIGKILL: '%s' not exist", group);
+               return;
+       }
+
+       /* TODO: check pid exist in group */
+
+       r = kill(pid, 0);
+       if (r == -1) {
+               _D("send SIGKILL: pid %d not exist", pid);
+               return;
+       }
+
+       r = kill(pid, SIGKILL);
+       if (r == -1)
+               _E("send SIGKILL: %s", strerror(errno));
+}
+
+static gboolean _ktimer_cb(gpointer data)
+{
+       struct ktimer *kt = data;
+
+       _kill_pid(kt->cg, kt->group, kt->pid);
+       _kill_list = g_list_remove(_kill_list, kt);
+       _free_kt(kt);
+
+       return FALSE;
+}
+
+static void _add_list(struct cginfo *cg, const char *group, pid_t pid)
+{
+       struct ktimer *kt;
+
+       kt = calloc(1, sizeof(*kt));
+       if (!kt)
+               return;
+
+       kt->pid = pid;
+       kt->group = strdup(group);
+       if (!kt->group) {
+               free(kt);
+               return;
+       }
+
+       kt->cg = cgutil_ref(cg);
+       kt->tid = g_timeout_add_seconds(TERM_WAIT_SEC, _ktimer_cb, kt);
+
+       _kill_list = g_list_append(_kill_list, kt);
+}
+
+static inline void _del_list(GList *l)
+{
+       struct ktimer *kt;
+
+       if (!l)
+               return;
+
+       kt = l->data;
+
+       g_source_remove(kt->tid);
+       _free_kt(kt);
+       _kill_list = g_list_delete_link(_kill_list, l);
+}
+
+static int _kill_pid_cb(void *user_data, const char *group, pid_t pid)
+{
+       int r;
+
+       if (pid <= INIT_PID) /* block sending to all process or init */
+               return 0;
+
+       r = kill(pid, SIGTERM);
+       if (r == -1)
+               _E("send SIGTERM: %s", strerror(errno));
+
+       _add_list(user_data, group, pid);
+
+       return 0;
+}
+
+int service_stop(struct cginfo *cg, const char *group)
+{
+       if (!cg || !group || !*group) {
+               errno = EINVAL;
+               return -1;
+       }
+
+       _D("service_stop, group %s", group);
+
+       return cgutil_group_foreach_pid(cg, CTRL_MGR, FILENAME(group),
+                       _kill_pid_cb, cg);
+}
+
+void service_release(const char *group)
+{
+       GList *l;
+       GList *d;
+
+       if (!group || !*group)
+               return;
+
+       group = FILENAME(group);
+
+       d = NULL;
+       for (l = _kill_list; l; l = g_list_next(l)) {
+               struct ktimer *k = l->data;
+
+               _del_list(d);
+
+               if (k->group && !strcmp(k->group, group))
+                       d = l;
+               else
+                       d = NULL;
+       }
+
+       _del_list(d);
+}
+
+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;
+}
+int _resume_app(int pid, int clifd)
+{
+       int dummy;
+       int ret;
+       if ((ret =
+            __app_send_raw_with_delay_reply(pid, APP_RESUME_BY_PID, (unsigned char *)&dummy,
+                           sizeof(int))) < 0) {
+               if (ret == -EAGAIN)
+                       _E("resume packet timeout error");
+               else {
+                       _E("raise failed - %d resume fail\n", pid);
+                       _E("we will term the app - %d\n", 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 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) {
+               _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;
+}
+
+static void __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");
+               }
+               _E("send fail to client");
+       }
+
+       close(clifd);
+}
+
+static gboolean __au_glib_check(GSource *src)
+{
+       GSList *fd_list;
+       GPollFD *tmp;
+
+       fd_list = src->poll_fds;
+       do {
+               tmp = (GPollFD *) fd_list->data;
+               if ((tmp->revents & (POLLIN | POLLPRI)))
+                       return TRUE;
+               fd_list = fd_list->next;
+       } while (fd_list);
+
+       return FALSE;
+}
+
+static gboolean __au_glib_dispatch(GSource *src, GSourceFunc callback,
+               gpointer data)
+{
+       callback(data);
+       return TRUE;
+}
+
+static gboolean __au_glib_prepare(GSource *src, gint *timeout)
+{
+       return FALSE;
+}
+
+static GSourceFuncs funcs = {
+       .prepare = __au_glib_prepare,
+       .check = __au_glib_check,
+       .dispatch = __au_glib_dispatch,
+       .finalize = NULL
+};
+
+struct reply_info {
+       GSource *src;
+       GPollFD *gpollfd;
+       guint timer_id;
+       int clifd;
+       int pid;
+       int cmd;
+};
+
+static gboolean __reply_handler(gpointer data)
+{
+       struct reply_info *r_info = (struct reply_info *) data;;
+       int fd = r_info->gpollfd->fd;
+       int len;
+       int res = 0;
+       int clifd = r_info->clifd;
+       int pid = r_info->pid;
+       int cmd = r_info->cmd;
+
+       len = recv(fd, &res, sizeof(int), 0);
+       if (len == -1) {
+               if (errno == EAGAIN) {
+                       _E("recv timeout : %s", strerror(errno));
+                       res = -EAGAIN;
+               } else {
+                       _E("recv error : %s", strerror(errno));
+                       res = -ECOMM;
+               }
+       }
+       close(fd);
+
+       if(res < 0) {
+               if ( cmd == APP_TERM_BY_PID ) {
+                       __real_send(clifd, -1);
+               } else if ( cmd == APP_START_ASYNC ) {
+                       close(clifd);
+               } else {
+                       __real_send(clifd, res);
+               }
+       } else {
+               if ( cmd == APP_TERM_BY_PID ) {
+                       __real_send(clifd, 0);
+               } else if ( cmd == APP_START_ASYNC ) {
+                       close(clifd);
+               } else {
+                       __real_send(clifd, pid);
+               }
+       }
+
+       _D("listen fd(%d) , send fd(%d), pid(%d), cmd(%d)", fd, clifd, pid, cmd);
+
+       g_source_remove(r_info->timer_id);
+       g_source_remove_poll(r_info->src, r_info->gpollfd);
+       g_source_destroy(r_info->src);
+       g_free(r_info->gpollfd);
+       free(r_info);
+
+       return TRUE;
+}
+
+static gboolean __recv_timeout_handler(gpointer data)
+{
+       struct reply_info *r_info = (struct reply_info *) data;
+       int fd = r_info->gpollfd->fd;
+
+       _E("application is not responding : pid(%d) cmd(%d)", r_info->pid, r_info->cmd);
+
+       close(fd);
+
+       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);
+       g_source_destroy(r_info->src);
+       g_free(r_info->gpollfd);
+       free(r_info);
+
+       return FALSE;
+}
+
+static void __set_reply_handler(int fd, int pid, int clifd, int cmd)
+{
+       GPollFD *gpollfd;
+       GSource *src;
+       struct reply_info *r_info;
+
+       src = g_source_new(&funcs, sizeof(GSource));
+
+       gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+       if (gpollfd == NULL) {
+               _E("out of memory");
+               g_source_unref(src);
+               return;
+       }
+
+       gpollfd->events = POLLIN;
+       gpollfd->fd = fd;
+
+       r_info = malloc(sizeof(*r_info));
+       if (r_info == NULL) {
+               _E("out of memory");
+               g_free(gpollfd);
+               g_source_unref(src);
+               return;
+       }
+
+       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");
+               if (_send_to_sigkill(pid) < 0) {
+                       _E("fail to killing - %d\n", pid);
+                       __real_send(clifd, -1);
+                       return -1;
+               }
+               __real_send(clifd, 0);
+       }
+       _D("term done\n");
+       if (ret > 0)
+               __set_reply_handler(ret, pid, clifd, APP_TERM_BY_PID);
+
+       return 0;
+}
+
+#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;
+
+       if (sqlite3_open("/opt/dbspace/.pkgmgr_parser.db", &db) != SQLITE_OK) {
+           _E("sqlite3_open() failed! -> %s\n", sqlite3_errmsg(db));
+           return -1;
+       }
+
+       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;
+       }
+
+       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;
+       }
+
+       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;
+       const char *operation;
+
+       operation = bundle_get_val(kb, "__APP_SVC_OP_TYPE__");
+
+#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", 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);
+               _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, clifd)) < 0)
+                       _E("__resume_app failed. error code = %d", ret);
+               _D("resume app done");
+               break;
+
+       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, clifd)) < 0)
+                       _E("fake_launch failed. error code = %d", ret);
+               _D("fake launch done");
+               break;
+       }
+
+       return ret;
+}
+
+#if __CPU_FREQ_CON
+#include <sysman.h>
+static Eina_Bool
+__amd_sysman_restore_hz_timer_cb(void *data)
+{
+   struct context *ctxt = data;
+
+   if (ctxt->timer)
+     ctxt->timer = NULL;
+
+   sysman_release_cpu_min_frequency ();
+
+   _D("*******[1.6MHZ Support] Released\n " );
+
+   return ECORE_CALLBACK_CANCEL; // same as EINA_FALSE
+}
+#endif
+
+struct context{
+       Ecore_Timer *timer;
+};
+
+static int __amd_change_min_cpulock_count(int value)
+{
+       int fd = -1;
+       char buf[16]={0,};
+       fd = open(SYS_MIN_CPU_LOCK_FILE, O_WRONLY);
+       if (fd == -1)
+               return -1;
+       snprintf(buf, sizeof(buf), "%d", value);
+       if (write(fd, buf, strlen(buf)) < 0) {
+               _E("[AMD]: Unable to change min_cpu_lock value!, err: %s\n",strerror(errno));
+               close(fd);
+               return -1;
+       }
+       close(fd);
+       _D("[AMD]: Succesfully changed min cpu value to %d\n", value);
+       return 0;
+}
+
+static Eina_Bool __amd_restore_min_cpulock_count_cb(void *data)
+{
+       struct context *ctxt = data;
+       if (ctxt->timer)
+               ctxt->timer = NULL;
+       __amd_change_min_cpulock_count(MIN_CPU_LCK_CNT);
+       return ECORE_CALLBACK_CANCEL;
+}
+
+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, 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,0,270,180,90};
+       if (screenmode > 4 || screenmode < 0)
+               screenmode=0;
+
+       if (strncmp(indicator, "true", 4) == 0){
+               _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, effect_type,
+                       screen_orientation[screenmode],
+                       SHOW_INDICATOR, theme, 0);
+
+       }else{
+               _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, effect_type,
+                       screen_orientation[screenmode],
+                       HIDE_INDICATOR, theme, 0);
+       }
+       ecore_x_flush();
+       _D("ecore_x_client_message32_send : %d",ret);
+}
+
+
+
+static int append_variant(DBusMessageIter *iter, const char *sig, char *param[])
+{
+       char *ch;
+       int i;
+       int int_type;
+       uint64_t int64_type;
+
+       if (!sig || !param)
+               return 0;
+
+       for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) {
+               switch (*ch) {
+               case 'i':
+                       int_type = atoi(param[i]);
+                       dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &int_type);
+                       break;
+               case 'u':
+                       int_type = atoi(param[i]);
+                       dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &int_type);
+                       break;
+               case 't':
+                       int64_type = atoi(param[i]);
+                       dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT64, &int64_type);
+                       break;
+               case 's':
+                       dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, param[i]);
+                       break;
+               default:
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
+int invoke_dbus_method_sync(const char *dest, const char *path,
+               const char *interface, const char *method,
+               const char *sig, char *param[])
+{
+       DBusMessage *msg;
+       DBusMessageIter iter;
+       DBusMessage *reply;
+       DBusError err;
+       int r, ret;
+
+       msg = dbus_message_new_method_call(dest, path, interface, method);
+       if (!msg) {
+               _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+               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);
+
+       reply = dbus_connection_send_with_reply_and_block(conn, msg, 500, &err);
+       dbus_message_unref(msg);
+       if (!reply) {
+               _E("dbus_connection_send error(%s:%s)", err.name, err.message);
+               dbus_error_free(&err);
+               return -EBADMSG;
+       }
+
+       r = dbus_message_get_args(reply, &err, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+       dbus_message_unref(reply);
+       if (!r) {
+               _E("no message : [%s:%s]", err.name, err.message);
+               dbus_error_free(&err);
+               return -EBADMSG;
+       }
+
+       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(tts_support && 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(ups_support && 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;
+       const char *pkg_type = NULL;
+       const char *component_type = NULL;
+       int pid = -1;
+       char tmp_pid[MAX_PID_STR_BUFSZ];
+       const char *permission;
+       const char *pkgid;
+       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];
+
+       int effect_mode = 0;
+#ifdef _APPFW_FEATURE_WMS_CONNECTION_CHECK
+       int wmanager_connected = 0;
+#endif
+       char *caller_component_type = NULL;
+
+       if (appid == NULL || kb == NULL
+               || caller_pid < 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);
+
+       if (cmd == APP_START_RES)
+               bundle_add(kb, AUL_K_WAIT_RESULT, "1");
+
+       caller = _status_app_get_appid_bypid(caller_pid);
+       if(caller == NULL) {
+               ret = aul_app_get_appid_bypid(caller_pid, caller_appid, sizeof(caller_appid));
+               if(ret == 0) {
+                       bundle_add(kb, AUL_K_CALLER_APPID, caller_appid);
+               }
+       } else {
+               bundle_add(kb, AUL_K_CALLER_APPID, caller);
+       }
+       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, "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);
+                       return -1;
+               }
+       }
+
+       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
+#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;
+                                       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", strlen("uiapp")) == 0
+               || strncmp(component_type, "watchapp", strlen("watchapp")) == 0
+               || strncmp(component_type, "widgetapp", strlen("widgetapp")) == 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);
+               if (pid > 0 && status != STATUS_DYING) {
+                       if (caller_pid == pid) {
+                               SECURE_LOGD("caller process & callee process is same.[%s:%d]", appid, pid);
+                               pid = -ELOCALLAUNCH_ID;
+                       } else {
+                               if(pkg_type && strncmp(pkg_type, "wgt", 3) == 0) {
+                                       __pre_launching_processing(appid);
+                               }
+                               proc_group_change_status(PROC_CGROUP_SET_RESUME_REQUEST, pid, appid);
+                               if ((ret = __nofork_processing(cmd, pid, kb, fd)) < 0) {
+                                       pid = ret;
+                               } else {
+                                       delay_reply = 1;
+                               }
+                       }
+               } else if (cmd != APP_RESUME) {
+                       if(status == STATUS_DYING && pid > 0) {
+                               r = kill(pid, SIGKILL);
+                               if (r == -1)
+                                       _D("send SIGKILL: %s", strerror(errno));
+                       }
+                       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", 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);
+                               _D("%s-%s : %d", SYSTEM_INTERFACE_NAME, SYSTEM_METHOD_NAME, ret);
+                       }
+#endif
+                       /*
+                        *      effect_mode = 0
+                        *              default mode : fake effect off, 1.6 MHZ off
+                        *      effect_mode = 1
+                        *              full mode : fake effect on, 1.6 MHZ on
+                        *      effect_mode = 2
+                        *              fake effect mode : fake effect on, 1.6 MHZ off
+                        *      effect_mode = 3
+                        *              1.6 MHZ mode : faek effect off, 1.6MHZ on
+                        *
+                        */
+                       vconf_get_int(AMD_EFFECT_IMAGE_ENABLE, &effect_mode);
+#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)
+                               && !(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 (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);
+                                       }
+                               }
+                       }
+
+#ifdef _APPFW_FEATURE_DEBUG_LAUNCHPAD
+                       if (bundle_get_type(kb, AUL_K_SDK) != BUNDLE_TYPE_NONE) {
+                               pad_pid = DEBUG_LAUNCHPAD_PID;
+                       } else if (pkg_type && strncmp(pkg_type, "wgt", 3) == 0) {
+                               pad_pid = WEB_LAUNCHPAD_PID;
+                       }
+#else
+                       if (pkg_type && strncmp(pkg_type, "wgt", 3) == 0) {
+                               pad_pid = WEB_LAUNCHPAD_PID;
+                       }
+#endif
+#ifdef _APPFW_FEATURE_NATIVE_LAUNCHPAD
+                       else if (pkg_type && 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", process_pool);
+
+                               const char *hwacc = appinfo_get_value(ai, AIT_HWACC);
+                               _D("h/w acceleration: %s", hwacc);
+
+                               SECURE_LOGD("appid: %s", appid);
+
+                               if (process_pool && strncmp(process_pool, "true", strlen("true")) == 0)
+                               {
+ #ifndef _APPFW_FEATURE_PROCESS_POOL_COMMON
+                                       if (hwacc && 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 //_APPFW_FEATURE_PROCESS_POOL
+
+                       __set_appinfo_for_launchpad(ai, kb);
+                       pid = app_send_cmd(pad_pid, cmd, kb);
+                       if(pid == AUL_R_ECOMM) {
+                               pid = -ENOLAUNCHPAD;
+                       }
+                       //_add_cgroup(_lcg, appid, pid);
+                       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);
+               }
+               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) {
+               pid = _status_app_is_running_v2(appid);
+               if (pid > 0) {
+                       if ((ret = __nofork_processing(cmd, pid, kb, fd)) < 0) {
+                               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);
+                       proc_cgroup_launch(PROC_CGROUP_SET_SERVICE_REQUEST, pid, appid, pkgid);
+#endif
+               }
+       } else {
+               _E("unkown application");
+       }
+
+       if(!delay_reply) {
+               if(cmd == APP_START_ASYNC)
+                       close(fd);
+               else
+                       __real_send(fd, pid);
+       }
+
+       if(pid > 0) {
+#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 _APPFW_FEATURE_APP_CHECKER
+               const char *pkgtype = NULL;
+
+               pkgtype = appinfo_get_value(ai, AIT_TYPE);
+               if (pkgtype == NULL) {
+                       _E("pkgtype is NULL");
+                       return -1;
+               }
+
+               ret = ac_server_check_launch_privilege(appid, pkgtype, 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;
+}
+
+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));
+}
diff --git a/am_daemon/amd_launch.h b/am_daemon/amd_launch.h
new file mode 100755 (executable)
index 0000000..9cde936
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  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 __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 clifd);
+int _term_app(int pid, int clifd);
+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_ */
diff --git a/am_daemon/amd_main.c b/am_daemon/amd_main.c
new file mode 100755 (executable)
index 0000000..0a366cd
--- /dev/null
@@ -0,0 +1,495 @@
+/*
+ *  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 <sys/types.h>
+#include <sys/stat.h>
+#include <sys/inotify.h>
+#include <fcntl.h>
+#include <Ecore_X.h>
+#include <Ecore_Input.h>
+#include <utilX.h>
+#include <Ecore.h>
+#include <Evas.h>
+#include <aul.h>
+#include <vconf.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"
+#include "amd_status.h"
+#include "amd_launch.h"
+#include "amd_request.h"
+
+#ifndef MOUNT_PATH
+#  define MOUNT_PATH "/sys/fs/cgroup"
+#endif
+
+#ifndef AGENT_PATH
+#  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 {
+       int watch_fd;
+       int win_watch_wd;
+       Ecore_Fd_Handler *win_watch_ewd;
+} _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));
+               if (info_t == NULL) {
+                       _E("out of memory");
+                       goto END;
+               }
+
+               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;
+}
+
+static void __start_cb(void *user_data,
+               const char *filename, const struct appinfo *ai)
+{
+       /*struct amdmgr *amd = user_data;*/
+       const char *componet = NULL;
+       int r;
+
+       componet = appinfo_get_value(ai, AIT_COMPTYPE);
+
+       r = appinfo_get_boolean(ai, AIT_ONBOOT);
+
+       if (r == 1 && componet && strncmp(componet, "svcapp", 6) == 0)
+       {
+               const char *appid = appinfo_get_value(ai, AIT_NAME);
+               if (appid && _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);
+               }
+       }
+}
+
+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;
+}
+
+static gboolean _check_window_ready(void)
+{
+       if (access(WINDOW_READY, R_OK) == 0)
+               return true;
+       else
+               return false;
+}
+
+static void __window_init(void)
+{
+       _D("_window_init");
+
+       ecore_x_init(NULL);
+       _set_atom_effect();
+#ifndef __i386__
+       _key_init();
+#endif
+}
+
+static Eina_Bool _window_cb(void *data, Ecore_Fd_Handler * fd_handler)
+{
+       int fd;
+       char buf[FILENAME_MAX];
+       ssize_t len = 0;
+       struct inotify_event* event;
+
+       if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR)) {
+               _E("An error has occurred. Stop watching this fd and quit");
+               return ECORE_CALLBACK_CANCEL;
+       }
+
+       fd = ecore_main_fd_handler_fd_get(fd_handler);
+       if(fd < 0) {
+               _E("ecore_main_fd_handler_fd_get error");
+               return ECORE_CALLBACK_CANCEL;
+       }
+       len = read(fd, buf, FILENAME_MAX);
+
+       event = (struct inotify_event*) &buf[0];
+
+       _D("filename : %s", event->name);
+
+       if (access(WINDOW_READY, R_OK) == 0) {
+               __window_init();
+               if (win_info_t) {
+                       ecore_main_fd_handler_del(win_info_t->win_watch_ewd);
+                       inotify_rm_watch(win_info_t->watch_fd, win_info_t->win_watch_wd);
+                       free(win_info_t);
+                       win_info_t = NULL;
+               }
+       }
+
+       return ECORE_CALLBACK_RENEW;
+}
+
+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");
+               return;
+       }
+       win_info_t->watch_fd = inotify_init();
+       win_info_t->win_watch_wd = inotify_add_watch(win_info_t->watch_fd, "/tmp", IN_CREATE);
+       win_info_t->win_watch_ewd = ecore_main_fd_handler_add(win_info_t->watch_fd,
+                                                   ECORE_FD_READ, _window_cb, NULL, NULL, NULL);
+}
+
+static void _window_init(void)
+{
+       if (_check_window_ready())
+               __window_init();
+       else
+               _register_window_init();
+}
+
+static int __init()
+{
+       struct amdmgr amd;
+       int ret = 0;
+
+       ecore_init();
+       evas_init();
+       ecore_event_init();
+
+       _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();
+
+       _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)
+{
+       _D("AMD ready\n");
+
+       int handle = creat("/tmp/amd_ready", S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+       if (handle != -1)
+               close(handle);
+
+       return FALSE;
+}
+
+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;
+       }
+
+       g_idle_add(__amd_ready, NULL);
+
+       ecore_main_loop_begin();
+
+       return 0;
+}
diff --git a/am_daemon/amd_request.c b/am_daemon/amd_request.c
new file mode 100755 (executable)
index 0000000..3f75b6e
--- /dev/null
@@ -0,0 +1,859 @@
+/*
+ *  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 <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <poll.h>
+#include <aul.h>
+#include <glib.h>
+#include <bundle.h>
+#include <rua.h>
+#include <proc_stat.h>
+#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_launch.h"
+#include "amd_appinfo.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) {
+                       _E("send failed due to EPIPE.\n");
+               }
+
+               _E("send fail to client");
+       }
+       close(fd);
+       return 0;
+}
+
+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");
+               }
+               _E("send fail to client");
+       }
+
+       close(clifd);
+}
+
+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;
+       int pgid;
+       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;
+       }
+
+       pgid = getpgid(cr_pid);
+       if(pgid > 0) {
+               snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", pgid);
+               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;
+
+       free(kb_data);
+
+       return res;
+}
+
+static int __app_process_by_pid(int cmd,
+       const char *pkg_name, struct ucred *cr, int clifd)
+{
+       int pid;
+       int ret = -1;
+       int dummy;
+
+       if (pkg_name == NULL)
+               return -1;
+
+       pid = atoi(pkg_name);
+       if (pid <= 1) {
+               _E("invalid pid");
+               return -1;
+       }
+
+       if (_status_get_app_info_status(pid) == -1) {
+               char buf[512];
+               if (_status_get_pkgname_bypid(pid, buf, 512) == -1) {
+                       _E("request for unknown pid. It might not be a pid of app: %d", pid);
+                       return -1;
+               }
+       }
+
+       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);
+
+       _D("__app_process_by_pid, cmd: %d, pid: %d, ", cmd, pid);
+       switch (cmd) {
+       case APP_RESUME_BY_PID:
+               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:
+               if ((ret = _send_to_sigkill(pid)) < 0)
+                       _E("fail to killing - %d\n", pid);
+               __real_send(clifd, ret);
+               break;
+       case APP_TERM_REQ_BY_PID:
+               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;
+}
+
+static gboolean __add_history_handler(gpointer user_data)
+{
+       struct rua_rec rec;
+       int ret;
+       bundle *kb = NULL;
+       char *appid = NULL;
+       char *app_path = NULL;
+       struct appinfo *ai;
+       app_pkt_t *pkt = (app_pkt_t *)user_data;
+
+       if (!pkt)
+               return FALSE;
+
+       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);
+
+       memset((void *)&rec, 0, sizeof(rec));
+
+       rec.pkg_name = appid;
+       rec.app_path = app_path;
+
+       if(pkt->len > 0) {
+               rec.arg = (char *)pkt->data;
+       }
+
+       SECURE_LOGD("add rua history %s %s", rec.pkg_name, rec.app_path);
+
+       ret = rua_add_history(&rec);
+       if (ret == -1)
+               _D("rua add history error");
+
+       if (kb != NULL)
+               bundle_free(kb);
+       free(pkt);
+
+#ifdef _APPFW_FEATURE_CONTACT_PHONE_AS_ONE_APP
+       if (need_free)
+               free(appid);
+#endif
+
+       return FALSE;
+}
+
+static int __get_pid_cb(void *user_data, const char *group, pid_t pid)
+{
+       int *sz = user_data;
+
+       _D("%s: %d : %d", *sz, pid);
+       *sz = 1; /* 1 is enough */
+
+       return -1; /* stop the iteration */
+}
+
+static int __releasable(const char *filename)
+{
+       int sz;
+       int r;
+
+       if (!filename || !*filename) {
+               _E("release service: name is empty");
+               return -1;
+       }
+
+       r = cgutil_exist_group(_rcg, CTRL_MGR, filename);
+       if (r == -1) {
+               SECURE_LOGE("release service: exist: %s", strerror(errno));
+               return -1;
+       }
+       if (r == 0) {
+               SECURE_LOGE("release service: '%s' already not exist", filename);
+               return -1;
+       }
+
+       sz = 0;
+       r = cgutil_group_foreach_pid(_rcg, CTRL_MGR, filename,
+                       __get_pid_cb, &sz);
+       if (r == -1) {
+               SECURE_LOGE("release service: '%s' read pid error", filename);
+               return -1;
+       }
+       if (sz > 0) {
+               SECURE_LOGE("release service: '%s' group has process", filename);
+               return -1;
+       }
+
+       return 0;
+}
+
+int __release_srv(const char *filename)
+{
+       int r;
+       const struct appinfo *ai;
+
+       r = __releasable(filename);
+       if (r == -1)
+               return -1;
+
+       ai = (struct appinfo *)appinfo_find(_raf, filename);
+       if (!ai) {
+               SECURE_LOGE("release service: '%s' not found", filename);
+               return -1;
+       }
+
+       r = appinfo_get_boolean(ai, AIT_RESTART);
+       if (r == 1) {
+               SECURE_LOGD("Auto restart set: '%s'", filename);
+               return _start_srv(ai, NULL);
+       }
+
+       service_release(filename);
+
+       r = cgutil_remove_group(_rcg, CTRL_MGR, filename);
+       if (r == -1) {
+               SECURE_LOGE("'%s' group remove error: %s", filename, strerror(errno));
+               return -1;
+       }
+
+       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;
+       int fd = gpollfd->fd;
+       app_pkt_t *pkt;
+       int clifd;
+       struct ucred cr;
+       int *status;
+       int ret = -1;
+       int free_pkt = 1;
+       char *appid;
+       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:
+               case APP_START:
+               case APP_START_RES:
+               case APP_START_ASYNC:
+                       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);
+
+#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 && 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);
+                               }
+
+                               if (kb != NULL)
+                                       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);
+                       ret = __foward_cmd(pkt->cmd, kb, cr.pid);
+                       //__real_send(clifd, ret);
+                       close(clifd);
+                       break;
+               case APP_RESUME_BY_PID:
+               case APP_TERM_REQ_BY_PID:
+                       kb = bundle_decode(pkt->data, pkt->len);
+                       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;
+                                       __real_send(clifd, ret);
+                               }
+                       }
+                       break;
+               case APP_TERM_BY_PID:
+               case APP_KILL_BY_PID:
+                       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);
+                               appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
+                               ret = __app_process_by_pid(pkt->cmd, appid, &cr, clifd);
+                       }
+                       break;
+               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);
+                       if (appid == NULL) {
+                               _E("out of memory");
+                               ret = -1;
+                               __send_result_to_client(clifd, ret);
+                               break;
+                       }
+
+                       strncpy(appid, (const char*)pkt->data, MAX_PACKAGE_STR_SIZE-1);
+                       ret = _status_app_is_running_v2(appid);
+                       SECURE_LOGD("APP_IS_RUNNING : %s : %d",appid, ret);
+                       __send_result_to_client(clifd, ret);
+                       free(appid);
+                       break;
+               case APP_GET_APPID_BYPID:
+                       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);
+                       break;
+               case APP_KEY_RELEASE:
+                       ret = _unregister_key_event(cr.pid);
+                       __send_result_to_client(clifd, ret);
+                       break;
+               case APP_STATUS_UPDATE:
+                       status = (int *)pkt->data;
+                       if(*status == STATUS_NORESTART) {
+                               appid = _status_app_get_appid_bypid(cr.pid);
+                               ai = appinfo_find(_raf, appid);
+                               if (ai)
+                                       appinfo_set_value(ai, AIT_STATUS, "norestart");
+                       } else {
+                               ret = _status_update_app_info_list(cr.pid, *status);
+                       }
+                       //__send_result_to_client(clifd, ret);
+                       close(clifd);
+                       break;
+               case APP_RELEASED:
+                       appid = malloc(MAX_PACKAGE_STR_SIZE);
+                       if (appid == NULL) {
+                               _E("out of memory");
+                               ret = -1;
+                               __send_result_to_client(clifd, ret);
+                               break;
+                       }
+
+                       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);
+                       SECURE_LOGD("appid(%s) pkg_status(%s)", appid, pkg_status);
+                       if(ai && pkg_status && strncmp(pkg_status, "blocking", 8) == 0) {
+                               appinfo_set_value(ai, AIT_STATUS, "restart");
+                       } else if (ai && pkg_status && strncmp(pkg_status, "norestart", 9) == 0) {
+                               appinfo_set_value(ai, AIT_STATUS, "installed");
+                       } else {
+                               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:
+                       /*kb = bundle_decode(pkt->data, pkt->len);
+                         appid = (char *)bundle_get_val(kb, AUL_K_APPID);
+                         app_path = (char *)bundle_get_val(kb, AUL_K_EXEC);
+                         tmp_pid = (char *)bundle_get_val(kb, AUL_K_PID);
+                         pid = atoi(tmp_pid);
+                         ret = _status_add_app_info_list(appid, app_path, pid);*/
+                       ret = 0;
+                       __send_result_to_client(clifd, ret);
+                       break;
+
+               case APP_GET_CMDLINE:
+                       memcpy(&pid, pkt->data, sizeof(int));
+                       ret = _status_get_cmdline(clifd, pid);
+                       _D("APP_GET_CMDLINE : %d : %d", pid, ret);
+                       break;
+
+               default:
+                       _E("no support packet");
+                       close(clifd);
+       }
+
+       if (free_pkt)
+               free(pkt);
+
+       if (kb != NULL)
+               bundle_free(kb), kb = NULL;
+
+       return TRUE;
+}
+
+static gboolean __au_glib_check(GSource *src)
+{
+       GSList *fd_list;
+       GPollFD *tmp;
+
+       fd_list = src->poll_fds;
+       do {
+               tmp = (GPollFD *) fd_list->data;
+               if ((tmp->revents & (POLLIN | POLLPRI)))
+                       return TRUE;
+               fd_list = fd_list->next;
+       } while (fd_list);
+
+       return FALSE;
+}
+
+static gboolean __au_glib_dispatch(GSource *src, GSourceFunc callback,
+               gpointer data)
+{
+       callback(data);
+       return TRUE;
+}
+
+static gboolean __au_glib_prepare(GSource *src, gint *timeout)
+{
+       return FALSE;
+}
+
+static GSourceFuncs funcs = {
+       .prepare = __au_glib_prepare,
+       .check = __au_glib_check,
+       .dispatch = __au_glib_dispatch,
+       .finalize = NULL
+};
+
+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));
+
+       gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+       if (gpollfd == NULL) {
+               _E("out of memory");
+               g_source_unref(src);
+               close(fd);
+               return -1;
+       }
+
+       gpollfd->events = POLLIN;
+       gpollfd->fd = fd;
+
+       g_source_add_poll(src, gpollfd);
+       g_source_set_callback(src, (GSourceFunc) __request_handler,
+                       (gpointer) gpollfd, NULL);
+       g_source_set_priority(src, G_PRIORITY_DEFAULT);
+
+       r = g_source_attach(src, NULL);
+       if (r  == 0)
+       {
+               _E("fail to attach the source : %d", r);
+               return -1;
+       }
+
+       _raf = amd->af;
+       _rcg = amd->cg;
+
+       r = rua_init();
+       r = rua_clear_history();
+
+       _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;
+}
+
+
diff --git a/am_daemon/amd_request.h b/am_daemon/amd_request.h
new file mode 100755 (executable)
index 0000000..ca409b1
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *  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 __AUL_AMD_REQUEST_H_
+#define __AUL_AMD_REQUEST_H_
+
+int _request_init(struct amdmgr *amd);
+
+
+
+#endif
+
diff --git a/am_daemon/amd_status.c b/am_daemon/amd_status.c
new file mode 100755 (executable)
index 0000000..b74bec5
--- /dev/null
@@ -0,0 +1,799 @@
+/*
+ *  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 <stdlib.h>
+#include <stdio.h>
+#include <glib.h>
+#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 "amd_appinfo.h"
+#include "aul_util.h"
+#include "simple_util.h"
+#include "app_sock.h"
+#include "menu_db_util.h"
+
+GSList *app_status_info_list = NULL;
+struct appinfomgr *_saf = NULL;
+
+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;
+
+       for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (app_status_info_t *)iter->data;
+               if(pid == info_t->pid) {
+                       return 0;
+               }
+       }
+
+       info_t = malloc(sizeof(app_status_info_t));
+       if (info_t == NULL) {
+               _E("out of memory");
+               return -1;
+       }
+
+       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;
+       app_status_info_list = g_slist_append(app_status_info_list, info_t);
+
+       for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (app_status_info_t *)iter->data;
+
+               //SECURE_LOGD("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+       }
+
+       return 0;
+}
+
+static Eina_Bool __app_terminate_timer_cb(void *data)
+{
+       int pid = (int)data;
+       int ret = 0;
+
+       _D("pid(%d)", pid);
+
+       ret = kill(pid, SIGKILL);
+       if (ret == -1)
+               _D("send SIGKILL: %s", strerror(errno));
+
+       return ECORE_CALLBACK_CANCEL;
+}
+
+int _status_update_app_info_list(int pid, int status)
+{
+       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(pid == info_t->pid) {
+                       info_t->status = status;
+                       if(status == STATUS_DYING) {
+                               if(info_t->pad_pid != DEBUG_LAUNCHPAD_PID)
+                                       ecore_timer_add(2, __app_terminate_timer_cb, info_t->pid);
+                       }
+                       break;
+               }
+       }
+
+       for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (app_status_info_t *)iter->data;
+
+               //SECURE_LOGD("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+       }
+
+       return 0;
+}
+
+int _status_remove_app_info_list(int pid)
+{
+       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(pid == info_t->pid) {
+                       app_status_info_list = g_slist_remove(app_status_info_list, info_t);
+                       free(info_t);
+                       break;
+               }
+       }
+
+       for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (app_status_info_t *)iter->data;
+
+               //SECURE_LOGD("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+       }
+
+       return 0;
+}
+
+int _status_get_app_info_status(int pid)
+{
+       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(pid == info_t->pid) {
+                       return info_t->status;
+               }
+       }
+
+       return -1;
+}
+
+
+int _status_app_is_running(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) == 0 ) {
+                       return info_t->pid;
+               }
+       }
+       return -1;
+}
+
+char* _status_app_get_appid_bypid(int pid)
+{
+       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( pid == info_t->pid ) {
+                       return info_t->appid;
+               }
+       }
+       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;
+       app_status_info_t *info_t = NULL;
+       app_pkt_t *pkt = NULL;
+       int len;
+       char tmp_pid[MAX_PID_STR_BUFSZ];
+
+       pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+       if(!pkt) {
+               _E("malloc fail");
+               return 0;
+       }
+
+       memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+       for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (app_status_info_t *)iter->data;
+               snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", info_t->pid);
+               strncat((char *)pkt->data, tmp_pid, MAX_PID_STR_BUFSZ);
+               strncat((char *)pkt->data, ":", 1);
+               strncat((char *)pkt->data, info_t->appid, MAX_PACKAGE_STR_SIZE);
+               strncat((char *)pkt->data, ":", 1);
+               strncat((char *)pkt->data, info_t->app_path, MAX_PACKAGE_APP_PATH_SIZE);
+               strncat((char *)pkt->data, ";", 1);
+       }
+
+       pkt->cmd = APP_RUNNING_INFO_RESULT;
+       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;
+}
+
+int _status_app_is_running_v2(char *appid)
+{
+       char *apppath = NULL;
+       int ret = 0;
+       int i = 0;
+       const char *ae;
+       const struct appinfo *ai;
+
+       if(appid == NULL)
+               return -1;
+
+       ai = appinfo_find(_saf, appid);
+
+       if (ai == NULL)
+               return -1;
+
+       ae = appinfo_get_value(ai, AIT_EXEC);
+       if (ae == NULL)
+               return -1;
+
+       apppath = strdup(ae);
+       if (apppath == NULL) {
+               _E("out of memory");
+               return -1;
+       }
+
+       /*truncate apppath if it includes default bundles */
+       while (apppath[i] != 0) {
+               if (apppath[i] == ' ' || apppath[i] == '\t') {
+                       apppath[i]='\0';
+                       break;
+               }
+               i++;
+       }
+
+       ret = __proc_iter_cmdline(NULL, apppath);
+
+       free(apppath);
+
+       return ret;
+}
+
+static int __get_pkginfo(const char *dname, const char *cmdline, void *priv)
+{
+       app_info_from_db *menu_info;
+       char *r_info;
+       char *pkgname = NULL;
+       char *app_path = NULL;
+
+       r_info = (char *)priv;
+
+       if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL)
+               goto out;
+       else {
+               pkgname = _get_pkgname(menu_info);
+               if (pkgname == NULL)
+                       goto out;
+
+               app_path = _get_app_path(menu_info);
+               if (app_path == NULL)
+                       goto out;
+
+               strncat(r_info, dname, 8);
+               strncat(r_info, ":", 1);
+               strncat(r_info, pkgname, MAX_PACKAGE_STR_SIZE);
+               strncat(r_info, ":", 1);
+               strncat(r_info, app_path, MAX_PACKAGE_APP_PATH_SIZE);
+               strncat(r_info, ";", 1);
+       }
+
+ out:
+       if (menu_info != NULL)
+               _free_app_info_from_db(menu_info);
+       return 0;
+}
+
+int _status_send_running_appinfo_v2(int fd)
+{
+       app_pkt_t *pkt = NULL;
+       int len;
+
+       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);
+
+       __proc_iter_cmdline(__get_pkginfo, pkt->data);
+
+       pkt->cmd = APP_RUNNING_INFO_RESULT;
+       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;
+}
+
+int _status_get_pkgname_bypid(int pid, char *pkgname, 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(pkgname, len, "%s", _get_pkgname(menu_info));
+       }
+
+       free(cmdline);
+       _free_app_info_from_db(menu_info);
+
+       return 0;
+}
+
+int _status_get_appid_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 (_status_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_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 (_status_get_pkgname_bypid(pgid, (char *)pkt->data, MAX_PACKAGE_STR_SIZE) == 0)
+               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;
+
+       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;
+}
+
+int _status_get_cmdline(int fd, int pid)
+{
+       app_pkt_t *pkt = NULL;
+       int len;
+       int pgid;
+       char *cmdline;
+
+       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;
+
+       cmdline = __proc_get_cmdline_bypid(pid);
+       if (cmdline == NULL)
+               goto out;
+       _E("cmdline : %s", cmdline);
+
+       snprintf((char *)pkt->data, MAX_PACKAGE_STR_SIZE, cmdline);
+       _E("pkt->data : %s", pkt->data);
+       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");
+       }
+
+       free(cmdline);
+
+       if(pkt)
+               free(pkt);
+
+       close(fd);
+
+       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 && component && 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;
+}
+
diff --git a/am_daemon/amd_status.h b/am_daemon/amd_status.h
new file mode 100755 (executable)
index 0000000..1298ba4
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *  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.
+ *
+ */
+
+
+
+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);
+int _status_app_is_running(char *appid);
+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_pkgname_bypid(int pid, char *pkgname, int len);
+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);
+
+
+
+//TODO : remove
+
+typedef struct _item_pkt_t {
+       int pid;
+       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.manifest b/aul.manifest
new file mode 100644 (file)
index 0000000..979caa3
--- /dev/null
@@ -0,0 +1,22 @@
+<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"/>
+               </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="_"/>
+       </assign>
+       <request>
+               <domain name="aul"/>
+       </request>
+</manifest>
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')"
diff --git a/data/config_splash.sh b/data/config_splash.sh
new file mode 100755 (executable)
index 0000000..71abcf4
--- /dev/null
@@ -0,0 +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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.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 = 'org.tizen.helloworld'"
+
+
+
+
diff --git a/data/create_default_service.sh b/data/create_default_service.sh
deleted file mode 100755 (executable)
index 5dbed2a..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/org.tizen.contacts
-
-mkdir -p calendar/cmds
-mkdir -p calendar/apps
-
-echo 0 > calendar/cmds/create
-echo 0 > calendar/cmds/view
-echo "" > calendar/apps/org.tizen.efl-calendar
-
-mkdir -p memo/cmds
-mkdir -p memo/apps
-
-echo 0 > memo/cmds/create
-echo 0 > memo/cmds/view
-echo "" > memo/apps/org.tizen.memo
-
-mkdir -p email/cmds
-mkdir -p email/apps
-
-echo 0 > email/cmds/create
-echo 0 > email/cmds/view
-echo "" > email/apps/org.tizen.email
-
-mkdir -p message/cmds
-mkdir -p message/apps
-
-echo 0 > message/cmds/create
-echo 0 > message/cmds/view
-echo "" > message/apps/org.tizen.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/org.tizen.camera-app
-
-mkdir -p voice_record/cmds
-mkdir -p voice_record/apps
-
-echo 1 > voice_record/cmds/rec_voice
-echo "" > voice_record/apps/org.tizen.voicerecorder
-
-mkdir -p file_browser/cmds
-mkdir -p file_browser/apps
-
-echo 0 > file_browser/cmds/browse
-echo "" > file_browser/apps/org.tizen.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/org.tizen.alarm
-
-mkdir -p search/cmds
-mkdir -p search/apps
-
-echo 1 > search/cmds/search
-echo "" > search/apps/org.tizen.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/org.tizen.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/org.tizen.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/debian/changelog b/debian/changelog
deleted file mode 100644 (file)
index 67d64a9..0000000
+++ /dev/null
@@ -1,1442 +0,0 @@
-aul-1 (0.0.179) unstable; urgency=low
-
-  * changed to use the application ID
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.179
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 05 Jun 2012 20:01:49 +0900
-
-aul-1 (0.0.178) unstable; urgency=low
-
-  * Added exception handling in __app_send_cmd_with_result()
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.178
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 15 May 2012 17:03:32 +0900
-
-aul-1 (0.0.177) unstable; urgency=low
-
-  * Removed elementary dependency
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.177
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 02 May 2012 11:52:12 +0900
-
-aul-1 (0.0.176) unstable; urgency=low
-
-  * Added key event module
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.176
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 30 Apr 2012 13:52:09 +0900
-
-aul-1 (0.0.175) unstable; urgency=low
-
-  * Extended timeout
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.175
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 24 Apr 2012 17:40:20 +0900
-
-aul-1 (0.0.174) unstable; urgency=low
-
-  * Fixed hibernation bug
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.174
-
- -- jaeho81.lee <jaeho81.lee@samsung.com>  Thu, 19 Apr 2012 15:18:17 +0900
-
-aul-1 (0.0.173) unstable; urgency=low
-
-  * Fixed __launchpad_sig_child bug
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.173
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 04 Apr 2012 13:36:13 +0900
-
-aul-1 (0.0.172) unstable; urgency=low
-
-  * Removed waiting profile_ready
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.172
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 02 Apr 2012 13:29:52 +0900
-
-aul-1 (0.0.171) unstable; urgency=low
-
-  * Fixed __app_dbus_signal_handler_fini bug
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.171
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Fri, 30 Mar 2012 19:03:47 +0900
-
-aul-1 (0.0.170) unstable; urgency=low
-
-  * Add new APIs
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.170
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 29 Mar 2012 10:20:52 +0900
-
-aul-1 (0.0.169) unstable; urgency=low
-
-  * Fixed compile warnings
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.169
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 20 Mar 2012 14:36:05 +0900
-
-aul-1 (0.0.168) unstable; urgency=low
-
-  * Fix buffer overflow bug
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.168
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 20 Mar 2012 00:20:29 +0900
-
-aul-1 (0.0.167) unstable; urgency=low
-
-  * Fix buffer overflow bug
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.167
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 19 Mar 2012 21:08:42 +0900
-
-aul-1 (0.0.166) unstable; urgency=low
-
-  * Fix rua add history bug
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.166
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Fri, 16 Mar 2012 13:48:08 +0900
-
-aul-1 (0.0.165) unstable; urgency=low
-
-  * changed spec file
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.165
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 15 Mar 2012 22:47:29 +0900
-
-aul-1 (0.0.164) unstable; urgency=low
-
-  * rua add history
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.164
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 15 Mar 2012 18:17:38 +0900
-
-aul-1 (0.0.163) unstable; urgency=low
-
-  * Add aul_finalize()
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.163
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 28 Feb 2012 16:55:15 +0900
-
-aul-1 (0.0.162) unstable; urgency=low
-
-  * Add rua
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.162
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 15 Feb 2012 19:19:54 +0900
-
-aul-1 (0.0.161) unstable; urgency=low
-
-  * Add pre_exec before execution
-  * Git: slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.161
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 02 Feb 2012 14:43:05 +0900
-
-aul-1 (0.0.160) unstable; urgency=low
-
-  * Fix ELM SCALE bug
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.160
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 31 Jan 2012 18:27:08 +0900
-
-aul-1 (0.0.159) unstable; urgency=low
-
-  * Support SDK
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.159
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 30 Jan 2012 20:02:26 +0900
-
-aul-1 (0.0.158) unstable; urgency=low
-
-  * Remove setenv for scale
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.158
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 18 Jan 2012 17:15:11 +0900
-
-aul-1 (0.0.157) unstable; urgency=low
-
-  * Fix aul_open_app bug
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.157
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 11 Jan 2012 15:40:27 +0900
-
-aul-1 (0.0.156) unstable; urgency=low
-
-  * Modify aul.spec
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.156
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 22 Dec 2011 10:10:34 +0900
-
-aul-1 (0.0.155) unstable; urgency=low
-
-  * Remove systemd dependency
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.155
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 21 Dec 2011 11:01:54 +0900
-
-aul-1 (0.0.154) unstable; urgency=low
-
-  * Fix code for CQ H0100137729
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.154
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Fri, 09 Dec 2011 11:40:18 +0900
-
-aul-1 (0.0.153) unstable; urgency=low
-
-  * Ignore permission error
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.153
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 05 Dec 2011 15:39:47 +0900
-
-aul-1 (0.0.152) unstable; urgency=low
-
-  * Fix code for CQ H0100135781
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.152
-
- -- Sewook Park <sewook7.park@samsung.com>  Thu, 01 Dec 2011 19:18:23 +0900
-
-aul-1 (0.0.151) unstable; urgency=low
-
-  * Modify reply handling of aul_send_result
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.151
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 30 Nov 2011 18:32:50 +0900
-
-aul-1 (0.0.150) unstable; urgency=low
-
-  * Support SMACK
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.150
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 29 Nov 2011 14:59:30 +0900
-
-aul-1 (0.0.149) unstable; urgency=low
-
-  * Support SDK
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.149
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 24 Nov 2011 10:37:42 +0900
-
-aul-1 (0.0.148) unstable; urgency=low
-
-  * Modify XInternAtom function arg
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.148 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 08 Nov 2011 12:59:46 +0900
-
-aul-1 (0.0.147) unstable; urgency=low
-
-  * Changed Boilerplate as per the guideline
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.147 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 07 Nov 2011 18:03:15 +0900
-
-aul-1 (0.0.146) unstable; urgency=low
-
-  * Add logs
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.146 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Fri, 04 Nov 2011 17:41:14 +0900
-
-aul-1 (0.0.145) unstable; urgency=low
-
-  * Remove socket file before launching
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.145 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 03 Nov 2011 14:54:48 +0900
-
-aul-1 (0.0.144) unstable; urgency=low
-
-  * Fix svace defects
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.144 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 27 Oct 2011 10:13:32 +0900
-
-aul-1 (0.0.143) unstable; urgency=low
-
-  * Modify aul_send_result
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.143 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 20 Oct 2011 12:26:28 +0900
-
-aul-1 (0.0.142) unstable; urgency=low
-
-  * add ac_daemon
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.142 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 17 Oct 2011 19:16:11 +0900
-
-aul-1 (0.0.141) unstable; urgency=low
-
-  * Modify oom adj value
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.141 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 06 Oct 2011 17:04:05 +0900
-
-aul-1 (0.0.140) unstable; urgency=low
-
-  * Use strncmp when comparing command line with Exec
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.140 
-
- -- Sewook Park <sewook7.park@samsung.com>  Fri, 30 Sep 2011 11:09:25 +0900
-
-aul-1 (0.0.139) unstable; urgency=low
-
-  * AIL DB close
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.139 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 26 Sep 2011 19:25:00 +0900
-
-aul-1 (0.0.138) unstable; urgency=low
-
-  * Code cleanup
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.138 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 21 Sep 2011 11:36:58 +0900
-
-aul-1 (0.0.137) unstable; urgency=low
-
-  * Fix prevent defects
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.137 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Sat, 20 Aug 2011 18:05:34 +0900
-
-aul-1 (0.0.136) unstable; urgency=low
-
-  * Fix TC error
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.136 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Fri, 19 Aug 2011 13:32:23 +0900
-
-aul-1 (0.0.135) unstable; urgency=low
-
-  * Remove package dependency
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.135 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 17 Aug 2011 10:06:01 +0900
-
-aul-1 (0.0.134) unstable; urgency=low
-
-  * Modify TC Makefile
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.134 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 16 Aug 2011 14:49:35 +0900
-
-aul-1 (0.0.133) unstable; urgency=low
-
-  * Fix prevent defects 
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.133 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Sat, 13 Aug 2011 18:31:09 +0900
-
-aul-1 (0.0.132) unstable; urgency=low
-
-  * Fix aul_app_get_running_app_info bug
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.132 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 10 Aug 2011 14:31:06 +0900
-
-aul-1 (0.0.131) unstable; urgency=low
-
-  * Apply app-svc
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.131 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 09 Aug 2011 11:45:18 +0900
-
-aul-1 (0.0.130) unstable; urgency=low
-
-  * ail API change
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.130 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 08 Aug 2011 16:27:27 +0900
-
-aul-1 (0.0.129) unstable; urgency=low
-
-  * Fix aul_app_is_running bug
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.129 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 03 Aug 2011 19:39:42 +0900
-
-aul-1 (0.0.128) unstable; urgency=low
-
-  * Change preload list
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.128 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 03 Aug 2011 17:25:36 +0900
-
-aul-1 (0.0.127) unstable; urgency=low
-
-  * Code cleanup
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.127 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 01 Aug 2011 19:30:19 +0900
-
-aul-1 (0.0.126) unstable; urgency=low
-
-  * Local launch
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.126 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Fri, 22 Jul 2011 13:08:54 +0900
-
-aul-1 (0.0.125) unstable; urgency=low
-
-  * Code cleanup
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.125 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 13 Jul 2011 16:18:49 +0900
-
-aul-1 (0.0.124) unstable; urgency=low
-
-  * Add cmdline check routine & Fix prevent defects
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.124 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Fri, 01 Jul 2011 11:29:20 +0900
-
-aul-1 (0.0.123) unstable; urgency=low
-
-  * Fix __connect_nonb
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.123 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 21 Jun 2011 14:44:17 +0900
-
-aul-1 (0.0.122) unstable; urgency=low
-
-  * Comment out command line check routine
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.122 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Fri, 17 Jun 2011 17:36:02 +0900
-
-aul-1 (0.0.121) unstable; urgency=low
-
-  * Fix launch_app
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.121 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Sat, 11 Jun 2011 16:59:21 +0900
-
-aul-1 (0.0.120) unstable; urgency=low
-
-  * Fix create_argc_argv()
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.120 
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 08 Jun 2011 15:29:02 +0900
-
-aul-1 (0.0.119) unstable; urgency=low
-
-  * Fix build error
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.119
-
- -- Sewook Park <sewook7.park@samsung.com>  Wed, 08 Jun 2011 11:10:22 +0900
-
-aul-1 (0.0.118) unstable; urgency=low
-
-  * Fix argc in launchpad
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.118 
-
- -- Sewook Park <sewook7.park@samsung.com>  Tue, 07 Jun 2011 23:47:20 +0900
-
-aul-1 (0.0.117) unstable; urgency=low
-
-  * Fix API aul_get_defapp_from_mime
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.117 
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 31 May 2011 13:46:48 +0900
-
-aul-1 (0.0.116) unstable; urgency=low
-
-  * Fix pwlock issue
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.116
-
- -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 24 May 2011 17:52:38 +0900
-
-aul-1 (0.0.115) unstable; urgency=low
-
-  * AIL change 
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.115 
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Wed, 18 May 2011 10:03:58 +0900
-
-aul-1 (0.0.114) unstable; urgency=low
-
-  * Fix memory issue in case when several apps share the same app path
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.114 
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Thu, 12 May 2011 08:59:44 +0900
-
-aul-1 (0.0.113) unstable; urgency=low
-
-  * Remove temp code for new pkgname policy
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.113 
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Thu, 21 Apr 2011 12:24:50 +0900
-
-aul-1 (0.0.112) unstable; urgency=low
-
-  * Adding new API aul_open_app, which will replace aul_resume_app
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.112 
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Mon, 18 Apr 2011 10:57:21 +0900
-
-aul-1 (0.0.111) unstable; urgency=low
-
-  * Temporary change during reflecting the new pkg name policy
-  * Update encoded package names
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.111
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Mon, 11 Apr 2011 21:37:05 +0900
-
-aul-1 (0.0.110) unstable; urgency=low
-
-  * Prevent BS due to EPIPE
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.110
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Wed, 06 Apr 2011 14:16:32 +0900
-
-aul-1 (0.0.109) unstable; urgency=low
-
-  * Setting process name with app name for top
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.109
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Thu, 17 Mar 2011 14:15:41 +0900
-
-aul-1 (0.0.108) unstable; urgency=low
-
-  * Adding new AUL services
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.108
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Wed, 16 Mar 2011 11:56:30 +0900
-
-aul-1 (0.0.107) unstable; urgency=low
-
-  * Applying Active Flushing
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.107
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Thu, 10 Mar 2011 16:07:38 +0900
-
-aul-1 (0.0.106) unstable; urgency=low
-
-  * Show err msg for cmdline not changed
-  * Fix recv_raw bug
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.106
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Mon, 07 Mar 2011 17:14:11 +0900
-
-aul-1 (0.0.105) unstable; urgency=low
-
-  * Fix connect lock-up
-  * Modifly launch-app for SDK
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.105 
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Thu, 24 Feb 2011 18:08:33 +0900
-
-aul-1 (0.0.104) unstable; urgency=low
-
-  * Add launch_app command for SDK
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.104
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Fri, 18 Feb 2011 17:54:52 +0900
-
-aul-1 (0.0.103) unstable; urgency=low
-
-  * Fix prevent defects
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.103
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Wed, 16 Feb 2011 15:13:28 +0900
-
-aul-1 (0.0.102) unstable; urgency=low
-
-  * Modifly get_defapp_for_service
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.102
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Tue, 15 Feb 2011 19:00:50 +0900
-
-aul-1 (0.0.101) unstable; urgency=low
-
-  * Modify URI for MMS
-  * Fix the PIPE issue
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.101 
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Tue, 15 Feb 2011 08:47:40 +0900
-
-aul-1 (0.0.100) unstable; urgency=low
-
-  * Modify URI for sms, mms
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.100
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Fri, 11 Feb 2011 20:06:38 +0900
-
-aul-1 (0.0.99) unstable; urgency=low
-
-  * Modify URI regex for callto, phonenum, tel to recognize +
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.99
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Wed, 09 Feb 2011 20:01:50 +0900
-
-aul-1 (0.0.98) unstable; urgency=low
-
-  * Modify testing app for TC
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.98
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Fri, 28 Jan 2011 14:52:33 +0900
-
-aul-1 (0.0.97) unstable; urgency=low
-
-  * Modify AUL Service APIs
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.97
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Wed, 26 Jan 2011 08:57:58 +0900
-
-aul-1 (0.0.96) unstable; urgency=low
-
-  * Enable AUL Log messages
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.96
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Mon, 24 Jan 2011 12:08:48 +0900
-
-aul-1 (0.0.95) unstable; urgency=low
-
-  * Rollback the change of Service API
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.95
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Thu, 20 Jan 2011 14:05:54 +0900
-
-aul-1 (0.0.94) unstable; urgency=low
-
-  * Update AUL Service APIs
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.94
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Thu, 20 Jan 2011 11:33:31 +0900
-
-aul-1 (0.0.93) unstable; urgency=low
-
-  * Modify TC files
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.93
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Thu, 13 Jan 2011 14:05:08 +0900
-
-aul-1 (0.0.92) unstable; urgency=low
-
-  * Modified MIME API internal function to handle null string input
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.92
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Thu, 06 Jan 2011 13:03:00 +0900
-
-aul-1 (0.0.91) unstable; urgency=low
-
-  * Disabled fake image effect
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.91
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Wed, 05 Jan 2011 20:17:19 +0900
-
-aul-1 (0.0.90) unstable; urgency=low
-
-  * Re-adjusted OOM value to -14 from 0 as requested
-  * Added a new bundle key for unaliased mime type
-  * Temporary modification to hide fake image (final update will be added later)
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.90
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Mon, 27 Dec 2010 14:24:22 +0900
-
-aul-1 (0.0.89) unstable; urgency=low
-
-  * Modify TC to avoid the timing issue among test cases
-  * Modify mime-related API to correctly set/get mime db info
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.89
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Thu, 23 Dec 2010 17:42:38 +0900
-
-aul-1 (0.0.88) unstable; urgency=low
-
-  * Modify menu db function to correctly retrieve the running apps info
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.88 
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Mon, 20 Dec 2010 16:15:14 +0900
-
-aul-1 (0.0.87) unstable; urgency=low
-
-  * Use screen-engine's DB access functions and cleaned up the internal DB-related functions
-  * Run fake launch effect in AUL instead of menu screen
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.87
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Fri, 17 Dec 2010 11:55:30 +0900
-
-aul-1 (0.0.86) unstable; urgency=low
-
-  * Using desktop_get_item instead of RECORD_GET to reduce desktop DB handling time
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.86 
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Thu, 16 Dec 2010 03:03:48 +0900
-
-aul-1 (0.0.85) unstable; urgency=low
-
-  * Modified libaul-1-executable.postinst and libaul-1.postinst
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.85
-
- -- Yoonkyong Lee <yk6629.lee@samsung.com>  Wed, 15 Dec 2010 09:49:31 +0900
-
-aul-1 (0.0.84) unstable; urgency=low
-
-  * Add /usr/lib/ecore/immodules/isf-imf-module.so to preload_list.txt
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.84
-
- -- Youmin Ha <youmin.ha@samsung.com>  Tue, 14 Dec 2010 20:03:26 +0900
-
-aul-1 (0.0.83) unstable; urgency=low
-
-  * Add time check log
-  * Git: 165.213.180.234:/slp/pkgs/a/aul-1
-  * Tag: aul-1_0.0.83
-
- -- Youmin Ha <youmin.ha@samsung.com>  Sat, 11 Dec 2010 16:45:33 +0900
-
-aul-1 (0.0.82) unstable; urgency=low
-
-  * support deb.org.tizen.* package names
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.82
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 24 Nov 2010 09:59:24 +0900
-
-aul-1 (0.0.81) unstable; urgency=low
-
-  * add launchpad launcher for rc4, revert 1777 permission
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.81
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 17 Nov 2010 17:33:38 +0900
-
-aul-1 (0.0.80-1) unstable; urgency=low
-
-  * reupload
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.80-1
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 17 Nov 2010 10:56:30 +0900
-
-aul-1 (0.0.80) unstable; urgency=low
-
-  * Apply security patch by Baik, Change permission of miregex/ dir to 1777
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.80
-
- -- Youmin Ha <youmin.ha@samsung.com>  Wed, 17 Nov 2010 10:41:34 +0900
-
-aul-1 (0.0.79) unstable; urgency=low
-
-  * include sqlite3 in depend pkgs
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.79
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 11 Nov 2010 11:41:54 +0900
-
-aul-1 (0.0.78) unstable; urgency=low
-
-  * pkg re-upload 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.78
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 11 Nov 2010 10:19:19 +0900
-
-aul-1 (0.0.77) unstable; urgency=low
-
-  * db installation : install ==> postinstall
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.77
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 11 Nov 2010 08:59:33 +0900
-
-aul-1 (0.0.76) unstable; urgency=low
-
-  * doxygen work 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.76
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 03 Nov 2010 19:10:18 +0900
-
-aul-1 (0.0.75) unstable; urgency=low
-
-  * modify aul_get_mime_extenstion 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.75
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 29 Oct 2010 15:19:50 +0900
-
-aul-1 (0.0.74) unstable; urgency=low
-
-  * modify scale direction (fix with menu_db)
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.74
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 27 Oct 2010 14:57:57 +0900
-
-aul-1 (0.0.73) unstable; urgency=low
-
-  * modify scale direction 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.73
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 27 Oct 2010 14:05:20 +0900
-
-aul-1 (0.0.72) unstable; urgency=low
-
-  * support miregex description and updating miregex and add 2 APIs
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.72
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 27 Oct 2010 11:30:17 +0900
-
-aul-1 (0.0.71) unstable; urgency=low
-
-  * support alias mimetype 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.71
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Mon, 25 Oct 2010 17:53:48 +0900
-
-aul-1 (0.0.70) unstable; urgency=low
-
-  * lazy preinit util launching first pkg 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.70
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Mon, 25 Oct 2010 10:13:59 +0900
-
-aul-1 (0.0.69) unstable; urgency=low
-
-  * add contact_shortcut.uri 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.69
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 22 Oct 2010 13:17:15 +0900
-
-aul-1 (0.0.68) unstable; urgency=low
-
-  * change mimetype max length & auto-set default application when 1 application 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.68
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 21 Oct 2010 17:01:31 +0900
-
-aul-1 (0.0.67) unstable; urgency=low
-
-  * change max cmdline when preloading
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.67
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 21 Oct 2010 10:47:11 +0900
-
-aul-1 (0.0.66) unstable; urgency=low
-
-  * add libprivileg-control
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.66
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 21 Oct 2010 08:49:50 +0900
-
-aul-1 (0.0.65) unstable; urgency=low
-
-  * build error fix 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.65
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 20 Oct 2010 17:00:20 +0900
-
-aul-1 (0.0.64) unstable; urgency=low
-
-  * build by upgrading xdgmime version
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.64
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 20 Oct 2010 16:39:36 +0900
-
-aul-1 (0.0.63) unstable; urgency=low
-
-  * Modify Race Condition Problem in single instance
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.63
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 19 Oct 2010 14:06:27 +0900
-
-aul-1 (0.0.62) unstable; urgency=low
-
-  * modify PG according to SPRC/SERI
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.62
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Mon, 18 Oct 2010 11:29:21 +0900
-
-aul-1 (0.0.61) unstable; urgency=low
-
-  * aul_open_file_with_mimetype bug fix 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.61
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 15 Oct 2010 20:45:11 +0900
-
-aul-1 (0.0.60) unstable; urgency=low
-
-  * remove aul_launch_with_result to guiding by mike 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.60
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 15 Oct 2010 18:35:18 +0900
-
-aul-1 (0.0.59) unstable; urgency=low
-
-  * modify service API according to guiding by mike. (Lacking const, Header
-    file Directory)
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.59
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 15 Oct 2010 12:03:12 +0900
-
-aul-1 (0.0.58) unstable; urgency=low
-
-  * pid-pgid mapping check at single instance
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.58
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 14 Oct 2010 17:06:39 +0900
-
-aul-1 (0.0.57) unstable; urgency=low
-
-  * update by desktop-library structure change
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.57
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 13 Oct 2010 18:50:01 +0900
-
-aul-1 (0.0.56) unstable; urgency=low
-
-  * add X error handling
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.56
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 12 Oct 2010 21:48:05 +0900
-
-aul-1 (0.0.55) unstable; urgency=low
-
-  * give EFL signal handler to child
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.55
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 12 Oct 2010 10:20:57 +0900
-
-aul-1 (0.0.54) unstable; urgency=low
-
-  * remove ELM_THEHE, kill same process groupid when child died 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.54
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 07 Oct 2010 20:50:55 +0900
-
-aul-1 (0.0.53) unstable; urgency=low
-
-  * add timeout feature 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.53
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 06 Oct 2010 21:04:35 +0900
-
-aul-1 (0.0.52) unstable; urgency=low
-
-  * usr -> opt 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.52
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 06 Oct 2010 17:25:25 +0900
-
-aul-1 (0.0.51) unstable; urgency=low
-
-  * libaul-1-executable debian bug fix 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.51
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Mon, 04 Oct 2010 14:44:36 +0900
-
-aul-1 (0.0.50) unstable; urgency=low
-
-  * divide libaul and libaul-executable (due to dependency X/Ecore) 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.50
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Mon, 04 Oct 2010 10:36:58 +0900
-
-aul-1 (0.0.49) unstable; urgency=low
-
-  * add service api 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.49
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Mon, 27 Sep 2010 19:32:14 +0900
-
-aul-1 (0.0.48) unstable; urgency=low
-
-  * update due to screen-engine ABI change 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.48
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 17 Sep 2010 16:58:05 +0900
-
-aul-1 (0.0.47) unstable; urgency=low
-
-  * add multiple instance field, add prctl(PR_SET_DUMPABLE)
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.47
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 15 Sep 2010 15:32:28 +0900
-
-aul-1 (0.0.46) unstable; urgency=low
-
-  * EFL upgrade 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.46
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Mon, 13 Sep 2010 09:24:35 +0900
-
-aul-1 (0.0.45) unstable; urgency=low
-
-  * TC work done 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.45
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 10 Sep 2010 15:43:17 +0900
-
-aul-1 (0.0.44) unstable; urgency=low
-
-  * fix build error 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.44
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 09 Sep 2010 12:01:26 +0900
-
-aul-1 (0.0.43) unstable; urgency=low
-
-  * release MIME API 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.43
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 09 Sep 2010 11:23:25 +0900
-
-aul-1 (0.0.42) unstable; urgency=low
-
-  * temprory release - by yoomin.ha 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.42
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 09 Sep 2010 11:23:25 +0900
-
-aul-1 (0.0.41) unstable; urgency=low
-
-  * disable SUPPORT_SYSASSERT
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.41
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 02 Sep 2010 18:38:45 +0900
-
-aul-1 (0.0.40) unstable; urgency=low
-
-  * transfer some signal handlers to child for sys-assert 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.40
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 02 Sep 2010 14:17:26 +0900
-
-aul-1 (0.0.39) unstable; urgency=low
-
-  * add aul_kill_pid API for task_manager, modify dbus shared connection ==> dbus private connection
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.39
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 02 Sep 2010 11:51:22 +0900
-
-aul-1 (0.0.38) unstable; urgency=low
-
-  * bug fix - size problem, dbus realloc lock problem 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.38
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Mon, 30 Aug 2010 23:26:11 +0900
-
-aul-1 (0.0.37) unstable; urgency=low
-
-  * re-upload 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.37
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 27 Aug 2010 14:22:03 +0900
-
-aul-1 (0.0.36) unstable; urgency=low
-
-  * enable preload & pre-initialize 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.36
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 27 Aug 2010 14:12:29 +0900
-
-aul-1 (0.0.35) unstable; urgency=low
-
-  * remove DISPLAY enviroment (X should be set)
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.35
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 25 Aug 2010 16:48:16 +0900
-
-aul-1 (0.0.34) unstable; urgency=low
-
-  * sprintf -> snprintf 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.34
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 25 Aug 2010 11:35:48 +0900
-
-aul-1 (0.0.33) unstable; urgency=low
-
-  * add doxygen work , prepare to remove aul_launch_with_result 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.33
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Mon, 23 Aug 2010 23:08:48 +0900
-
-aul-1 (0.0.32) unstable; urgency=low
-
-  * add APP_START_TIME environment 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.32
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 18 Aug 2010 16:05:03 +0900
-
-aul-1 (0.0.31) unstable; urgency=low
-
-  * bug fix - readproc fix close 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.31
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 18 Aug 2010 12:41:28 +0900
-
-aul-1 (0.0.30) unstable; urgency=low
-
-  * add dbus auto-activation test
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.30
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 18 Aug 2010 09:57:32 +0900
-
-aul-1 (0.0.29) unstable; urgency=low
-
-  * add exception case - shell script , no app-core ... 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.29
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Mon, 16 Aug 2010 21:57:14 +0900
-
-aul-1 (0.0.28) unstable; urgency=low
-
-  * mime content done 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.28
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 12 Aug 2010 20:59:21 +0900
-
-aul-1 (0.0.27) unstable; urgency=low
-
-  * delete journal db 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.27
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 11 Aug 2010 12:58:16 +0900
-
-aul-1 (0.0.26) unstable; urgency=low
-
-  * add app dead signal using dbus
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.26
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 11 Aug 2010 11:26:47 +0900
-
-aul-1 (0.0.25) unstable; urgency=low
-
-  * add sticky bit - /tmp/alaunch 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.25
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 10 Aug 2010 20:23:13 +0900
-
-aul-1 (0.0.24) unstable; urgency=low
-
-  * rollback security 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.24
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 10 Aug 2010 20:05:16 +0900
-
-aul-1 (0.0.23) unstable; urgency=low
-
-  * more security enhanced
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.23
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 10 Aug 2010 18:54:01 +0900
-
-aul-1 (0.0.22) unstable; urgency=low
-
-  * build fix
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.22
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 10 Aug 2010 14:07:58 +0900
-
-aul-1 (0.0.21) unstable; urgency=low
-
-  * bug fix related by DAC - /tmp/alaunch permission
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.21
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 10 Aug 2010 14:05:23 +0900
-
-aul-1 (0.0.20) unstable; urgency=low
-
-  * build fix 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.20
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 10 Aug 2010 09:14:28 +0900
-
-aul-1 (0.0.19) unstable; urgency=low
-
-  * support mime api
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.19
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 10 Aug 2010 08:26:03 +0900
-
-aul-1 (0.0.18) unstable; urgency=low
-
-  * aul_test minor change 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.18
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 06 Aug 2010 17:11:45 +0900
-
-aul-1 (0.0.17) unstable; urgency=low
-
-  * clear internal key 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.17
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 06 Aug 2010 12:39:09 +0900
-
-aul-1 (0.0.16) unstable; urgency=low
-
-  * modification with mike'review - modify return value, argv->bundle
-    conversion
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.16
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 05 Aug 2010 14:35:20 +0900
-
-aul-1 (0.0.15) unstable; urgency=low
-
-  * modification of API(remove dead_handler, remove aul_get_app_info,
-    aul_free_app_info, add const to argument)
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.15
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 04 Aug 2010 14:41:49 +0900
-
-aul-1 (0.0.14) unstable; urgency=low
-
-  * add dlog 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.14
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 30 Jul 2010 17:41:56 +0900
-
-aul-1 (0.0.13) unstable; urgency=low
-
-  * add theme 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.13
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 30 Jul 2010 16:37:33 +0900
-
-aul-1 (0.0.12) unstable; urgency=low
-
-  * reupload2
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.12
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 30 Jul 2010 14:07:31 +0900
-
-aul-1 (0.0.11) unstable; urgency=low
-
-  * reupload
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.11
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 30 Jul 2010 13:50:44 +0900
-
-aul-1 (0.0.10) unstable; urgency=low
-
-  * upgrade aul_test program 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.9
-  
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Fri, 30 Jul 2010 13:44:31 +0900
-
-aul-1 (0.0.9) unstable; urgency=low
-
-  * glib integration API by default 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.9
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 29 Jul 2010 22:06:35 +0900
-
-aul-1 (0.0.8) unstable; urgency=low
-
-  * add resume, terminate, ... add argv0, check more security 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.8
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 29 Jul 2010 19:55:24 +0900
-
-aul-1 (0.0.6) unstable; urgency=low
-
-  * add resume, terminate, ... add argv0, check more security 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.7
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Thu, 29 Jul 2010 19:44:15 +0900
-
-aul-1 (0.0.5) unstable; urgency=low
-
-  * re-upload due to ecore package dependency
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.5
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Wed, 28 Jul 2010 09:24:21 +0900
-
-aul-1 (0.0.4) unstable; urgency=low
-
-  * re-upload due to tag verfication
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.4
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 27 Jul 2010 21:40:58 +0900
-
-aul-1 (0.0.3) unstable; urgency=low
-
-  * CMakeList fix , fix according to change screen-engine API 
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.3
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 27 Jul 2010 21:31:14 +0900
-
-aul-1 (0.0.2) unstable; urgency=low
-
-  * initial package upload
-  * Git: 165.213.180.234:/git/slp/pkgs/aul-1
-  * Tag: aul-1_0.0.2
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 27 Jul 2010 20:52:56 +0900
-
-aul-1 (0.0.1) unstable; urgency=low
-
-  * initial update
-
- -- Kunhoon Baik <knhoon.baik@samsung.com>  Tue, 27 Jul 2010 15:51:31 +0900
-
-
diff --git a/debian/compat b/debian/compat
deleted file mode 100644 (file)
index 7ed6ff8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100644 (file)
index 686c2ab..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-Source: aul-1
-Section: devel
-Priority: extra
-Maintainer: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>, Yoonkyong Lee <yk6629.lee@samsung.com>, Youmin Ha <youmin.ha@samsung.com>, Kunhoon Baik <knhoon.baik@samsung.com>
-Build-Depends: debhelper (>= 5), libdbus-glib-1-dev, libsqlite3-dev, libx11-dev, libecore-dev, libbundle-dev, libail-0-dev, dlog-dev, libxdgmime-dev, libprivilege-control-dev, sqlite3, libapp-checker-dev, libapp-checker-server-dev, librua-dev, libslp-utilx-dev, libecore-dev, libecore-x, libevas-dev
-Standards-Version: 0.1.0 
-
-Package: libaul-1
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, sqlite3
-Description: libaul-1 package
-
-Package: libaul-1-dev
-Section: libs
-Architecture: any
-Depends: libaul-1 (= ${Source-Version}), libdbus-glib-1-dev, libsqlite3-dev, libbundle-dev, libail-0-dev, dlog-dev, libxdgmime-dev, sqlite3
-Description: libaul-1 dev package
-
-Package: libaul-1-dbg
-Section: debug
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libaul-1 (= ${Source-Version})
-Description: libaul-1 dbg package 
-
-Package: libaul-1-executable
-Section: libs
-Architecture: any
-Depends: libaul-1 (= ${Source-Version}), ${shlibs:Depends}, ${misc:Depends} 
-Description: libaul-1 executable package (aul_daemon(launchpad), aul_test)
-
diff --git a/debian/dirs b/debian/dirs
deleted file mode 100644 (file)
index ca882bb..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/bin
-usr/sbin
diff --git a/debian/docs b/debian/docs
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/debian/libaul-1-dev.install.in b/debian/libaul-1-dev.install.in
deleted file mode 100644 (file)
index 0f2a4da..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-@PREFIX@/include/*
-@PREFIX@/lib/pkgconfig/*.pc
diff --git a/debian/libaul-1-executable.install.in b/debian/libaul-1-executable.install.in
deleted file mode 100644 (file)
index 4d08215..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-@PREFIX@/bin/aul_test
-@PREFIX@/bin/launch_app
-@PREFIX@/bin/launchpad_preloading_preinitializing_daemon
-@PREFIX@/bin/ac_daemon
-/etc/*
diff --git a/debian/libaul-1-executable.postinst b/debian/libaul-1-executable.postinst
deleted file mode 100644 (file)
index 9ad55cd..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-if [ "${USER}" = "root" ]
-then
-        chown root:root /usr/bin/launchpad_preloading_preinitializing_daemon
-        chown root:root /etc/rc.d/init.d/launchpad_run
-fi
-
-chmod 755 /usr/bin/launchpad_preloading_preinitializing_daemon
-chmod 755 /etc/rc.d/init.d/launchpad_run
diff --git a/debian/libaul-1.install.in b/debian/libaul-1.install.in
deleted file mode 100644 (file)
index 6fc2818..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-@PREFIX@/lib/libaul.*\r
-@PREFIX@/bin/aul_service.sh\r
-@PREFIX@/bin/aul_service_test.sh\r
-@PREFIX@/bin/aul_mime.sh\r
-@PREFIX@/share/*\r
diff --git a/debian/libaul-1.postinst b/debian/libaul-1.postinst
deleted file mode 100644 (file)
index 2e32be8..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-mkdir -p /opt/dbspace
-sqlite3 /opt/dbspace/.mida.db < /opt/share/mida_db.sql
-rm -rf /opt/share/mida_db.sql
-
-if [ "${USER}" = "root" ]
-then
-       chown root:root /usr/lib/libaul.so.0.1.0
-       chown root:5000 /opt/dbspace/.mida.db
-       chown root:5000 /opt/dbspace/.mida.db-journal
-fi
-
-chmod 644 /usr/lib/libaul.so.0.1.0
-chmod 664 /opt/dbspace/.mida.db
-chmod 664 /opt/dbspace/.mida.db-journal
-
-#chmod 1777 /opt/share/miregex # Set directory to be writable for other accounts
diff --git a/debian/rules b/debian/rules
deleted file mode 100755 (executable)
index 225e645..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-export DH_VERBOSE=1
-
-CFLAGS += -Wall -g
-LDFLAGS ?= 
-PREFIX ?= /usr
-DATADIR ?= /opt
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
-       CFLAGS += -O0
-else
-       CFLAGS += -O2
-endif
-
-LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
-
-CMAKE_TMP_DIR = $(CURDIR)/cmake_tmp
-
-configure: configure-stamp
-configure-stamp:
-       dh_testdir
-       # Add here commands to configure the package.
-       mkdir -p $(CMAKE_TMP_DIR);
-       cd $(CMAKE_TMP_DIR); CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX)
-
-       touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp 
-       dh_testdir
-
-       # Add here commands to compile the package.
-       cd $(CMAKE_TMP_DIR) && $(MAKE) all test
-
-       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
-               cat $$f > $${f%.in}; \
-               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
-               sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
-       done
-
-       touch $@
-
-clean:
-       dh_testdir
-       dh_testroot
-       rm -f build-stamp configure-stamp
-
-       # Add here commands to clean up after the build process.
-       rm -rf $(CMAKE_TMP_DIR)
-
-       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
-               rm -f $${f%.in}; \
-       done
-
-       rm -rf include/pg-doxy/doxygen_output
-
-       rm -rf TC/results
-       rm -rf TC/tet_tmp_dir
-       cd TC/unit/ && make clean && cd ../../
-
-       dh_clean 
-
-install: build
-       dh_testdir
-       dh_testroot
-       dh_clean -k 
-       dh_installdirs
-
-       # Add here commands to install the package into debian/wavplayer.
-       cd $(CMAKE_TMP_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
-       mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/init.d
-       mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d
-       cp $(CURDIR)/launchpad_run $(CURDIR)/debian/tmp/etc/rc.d/init.d
-       ln -s ../init.d/launchpad_run $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S35launchpad_run
-       mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc4.d
-       ln -s ../init.d/launchpad_run $(CURDIR)/debian/tmp/etc/rc.d/rc4.d/S80launchpad_run
-
-       #OUTDIR=$(CURDIR)/debian/tmp/opt/share/service $(CURDIR)/data/create_default_service.sh
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-       dh_testdir
-       dh_testroot
-       dh_installchangelogs 
-       dh_installdocs
-       dh_installexamples
-       dh_install --sourcedir=debian/tmp
-#      dh_installmenu
-#      dh_installdebconf       
-#      dh_installlogrotate
-#      dh_installemacsen
-#      dh_installpam
-#      dh_installmime
-#      dh_python
-#      dh_installinit
-#      dh_installcron
-#      dh_installinfo
-       dh_installman
-       dh_link
-       dh_strip --dbg-package=libaul-1-dbg
-       dh_compress
-       dh_fixperms
-#      dh_perl
-       dh_makeshlibs
-       dh_installdeb
-       dh_shlibdeps
-       dh_gencontrol
-       dh_md5sums
-       dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/effect_img/type0_portrait.bmp b/effect_img/type0_portrait.bmp
new file mode 100755 (executable)
index 0000000..1588e9e
Binary files /dev/null and b/effect_img/type0_portrait.bmp differ
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
index 6848c7d..1b567c4 100755 (executable)
@@ -51,6 +51,7 @@ static void __preexec_list_free()
                }
        }
        g_slist_free(preexec_list);
+       preexec_initialized = 0;
        return;
 }
 
@@ -93,6 +94,7 @@ static inline void __preexec_init(int argc, char **argv)
                if (type_t == NULL) {
                        _E("no available memory\n");
                        __preexec_list_free();
+                       fclose(preexec_file);
                        return;
                }
 
@@ -109,6 +111,7 @@ static inline void __preexec_init(int argc, char **argv)
                           type, sopath);
                        free(type_t);
                        dlclose(handle);
+                       handle = NULL;
                        continue;
                }
 
@@ -117,6 +120,7 @@ static inline void __preexec_init(int argc, char **argv)
                        _E("no available memory\n");
                        free(type_t);
                        __preexec_list_free();
+                       fclose(preexec_file);
                        return;
                }
                type_t->so_path = strdup(sopath);
@@ -125,6 +129,7 @@ static inline void __preexec_init(int argc, char **argv)
                        free(type_t->pkg_type);
                        free(type_t);
                        __preexec_list_free();
+                       fclose(preexec_file);
                        return;
                }
                type_t->dl_do_pre_exe = func;
@@ -166,6 +171,10 @@ static inline void __preexec_run(const char *pkg_type, const char *pkg_name,
 
 #else
 
+static void __preexec_list_free()
+{
+}
+
 static inline void __preexec_init(int argc, char **argv)
 {
 }
old mode 100755 (executable)
new mode 100644 (file)
index 60fe408..458c9e4
@@ -50,7 +50,7 @@ In single instance model, if a currently running application is requested to be
 Low-level AUL API(primitive APIs) expects the application to provide APN(application package name) it wishes to launch.\n Low-level interface used by AUL are as shown below. Unix Domain Socket is used to send events between launchpad deamon and applications.
 Launchpad deamon is responsible for setup default configuration of application like "setup authority", " setup application scale",...  DB is used to store / retain default configuration of application.
 
-@image html low-level2.png "Low-level AUL diagram" 
+@image html low-level2.png "Low-level AUL diagram"
 
 High-level APIs support to launch based on MIME types(based on filename, URI, service name). This feature is abstraction of APN. Most develpers want to launch based on filename, URI, service name without knowing APN. Below is example list.
  - When developer open browser appliction with "http://www.samsung.com".
@@ -58,7 +58,7 @@ High-level APIs support to launch based on MIME types(based on filename, URI, se
  - When developer launching application with service name "camera" and service command "take_picture"
 
 Internally, AUL finds MIME type with given filename, URI, service name. Next, AUL find APN of default application from DB with associated MIME type. and then, AUL launch the application using primitive AUL APIs.
+
 @image html high-level2.png "High-Level AUL diagram"
 @}
 
@@ -81,7 +81,7 @@ Application Utility Library has the following features:\n
        - AUL can get the default application associated with the MIME type.
        - AUL can launch default applications associated with the MIME(file or content) when AUL find default application.
        - AUL automatically launch "application selection popup" when AUL don't find default application associated with the MIME(file or content)
-       
+
  - Application Service support (High-Level APIs)
        - AUL can launch applications based on service name and service command
 @}
@@ -109,13 +109,13 @@ 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("org.tizen.callee",kb);
        bundle_free(kb);
 }
 @endcode
 
-- Return the application to the foreground 
-- You might want to use aul_open_app when you need to resume, 
+- Return the application to the foreground
+- You might want to use aul_open_app when you need to resume,
        e.g., get it back to foreground, an application
 - If the application is not running, the application will be launched.
 
@@ -124,12 +124,12 @@ void launch_func()
 #include <aul.h>
 void resume_func()
 {
-       aul_open_app("org.tizen.callee"); 
+       aul_open_app("org.tizen.callee");
 }
 @endcode
 
 
-Callee application 
+Callee application
 
 - Integated with Appcore
 - If you use Appcore Library, Aul library already was integrated.\n
@@ -156,20 +156,20 @@ static void _app_initialize_with_arg(bundle *b)
        // initialize your app with argument
 }
 
-// 
+//
 // called by window manager event
-// or called by aul_open_app 
+// or called by aul_open_app
 // create your resume handler
 //
 static int app_resume(void *data){return 0;}
 static int app_pause(void *data) {return 0;}
 
-// 
+//
 // called by aul_terminate_api
 //
 static int app_terminate(void *data){return 0;}
 
-// 
+//
 // called by aul_launch_app or aul_launch_api_with_result
 // this is example code. create your reset handler
 //
@@ -242,7 +242,7 @@ int main(int argc, char** argv)
 
        ecore_main_loop_begin();  // You must need ecore or glib mainloop
        return 0;
-} 
+}
 @endcode
 @}
 
@@ -257,7 +257,7 @@ int main(int argc, char** argv)
 @code
 #include <aul.h>
 
-int iterfunc(const aul_app_info* info, void* data) 
+int iterfunc(const aul_app_info* info, void* data)
 {
        printf("package name: %s\n", info->pkg_name);
        printf("running pid: %d\n", info->pid);
@@ -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>
@@ -458,7 +357,7 @@ void send_result(bundle *recved_bundle, char* id)
        bundle_add(res_kb, "searched_id", id);
        aul_send_service_result(res_kb);
        bundle_free(res_kb);
-} 
+}
 @endcode
 @}
 
similarity index 54%
rename from include/mida.h
rename to include/access_control.h
index 271f951..92368cc 100755 (executable)
  *
  */
 
+#ifndef __ACCESS_CONTROL_H_
+#define __ACCESS_CONTROL_H_
 
-#ifndef __MIDA_H__
-#define __MIDA_H__
+#ifdef DAC_ACTIVATE
 
-#include <sqlite3.h>
-#include <time.h>
-#include <sys/types.h>
+#include <privilege-control.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);
+#define INHOUSE_UID     5000
+static inline int __set_access(const char* pkg_name, const char* pkg_type, const char* app_path)
+{
+       return perm_app_set_privilege(pkg_name, pkg_type, app_path);
+}
 
-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);
+#else
 
-int is_supported_svc(const char *svc_name);
-#ifdef __cplusplus
+static inline int __set_access(const char* pkg_name, const char* pkg_type, const char* app_path)
+{
+       return 0;
 }
+
 #endif
-#endif                         /*__MIDA_H__ */
 
+#endif
index b30cb51..ec121ff 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"
 #define AUL_DBUS_SIGNAL_INTERFACE "org.tizen.aul.signal"
 #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 74c8307..d69b4a7 100755 (executable)
@@ -34,23 +34,61 @@ 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_PKGID_BYPID,
+       APP_GET_INFO_OK,
+       APP_GET_INFO_ERROR,
        APP_KEY_EVENT,
        APP_KEY_RESERVE,
-       APP_KEY_RELEASE
+       APP_KEY_RELEASE,
+       APP_STATUS_UPDATE,
+       APP_RELEASED,
+       APP_RUNNING_LIST_UPDATE,
+       APP_TERM_REQ_BY_PID,
+       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
+       APP_GET_CMDLINE,
 };
 
 #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;
@@ -61,8 +99,11 @@ typedef struct _app_pkt_t {
 int __create_server_sock(int pid);
 int __create_client_sock(int pid);
 int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen);
+int __app_send_raw_with_noreply(int pid, int cmd, unsigned char *kb_data, int datalen);
+int __app_send_raw_with_delay_reply(int pid, int cmd, unsigned char *kb_data, int datalen);
 app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr);
-app_pkt_t *__app_send_cmd_with_result(int pid, int cmd);
+app_pkt_t *__app_send_cmd_with_result(int pid, int cmd, unsigned char *kb_data, int datalen);
+
 
 #endif
 
index 0a2ddef..e05baa5 100755 (executable)
@@ -32,14 +32,14 @@ extern "C" {
 
 /**
  * @mainpage
- * 
- * This is new version of Application Utility Library 
+ *
+ * This is new version of Application Utility Library
  *
  * Almost function's input param is application package name(APN).\n
  * APN is application package name which is set by developer.\n
  * In case of in-house application, prefix is org.tizen.\n
  * It is different from debian package name.\n
- * 
+ *
  * - Debian Package Name : Name which is managed by package manager
  * - Application Package Name : Name which is used by AUL
  * - Execution Path : real program executable path
@@ -52,7 +52,7 @@ extern "C" {
  * @{
  */
 
-       
+
 /**
  * @file       aul.h
  * @brief      Application Utility Library header
@@ -65,11 +65,20 @@ extern "C" {
  * @addtogroup aul
  * @{
  */
-       
+
 /**
- * @brief Return values in AUL. 
+ * @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 */
+       AUL_R_EILLACC = -8,             /**< Illegal Access */
        AUL_R_LOCAL = -7,               /**< Launch by himself */
        AUL_R_ETIMEOUT = -6,            /**< Timeout */
        AUL_R_ECANCELED = -5,           /**< Operation canceled */
@@ -80,13 +89,24 @@ typedef enum _aul_return_val {
        AUL_R_OK = 0                    /**< General success */
 }aul_return_val;
 
-/** @} */ 
+enum app_status {
+       STATUS_LAUNCHING,
+       STATUS_CREATED,
+       STATUS_FOCUS,
+       STATUS_VISIBLE,
+       STATUS_BG,
+       STATUS_DYING,
+       STATUS_HOME,
+       STATUS_NORESTART
+};
+
+/** @} */
 
 /**
- * @defgroup aul_launch                Primitive APIs to launch/resume/terminate application 
+ * @defgroup aul_launch                Primitive APIs to launch/resume/terminate application
  * @ingroup aul
  * @brief
- *     APIs to launch/resume/terminate application 
+ *     APIs to launch/resume/terminate application
  *     - Launch application based on application package name
  *     - Resume application based on application package name
  *     - Resume application based on pid (required root or inhouse permisssion)
@@ -96,19 +116,23 @@ typedef enum _aul_return_val {
  *     - AUL grant pid, gid to launched application for security
  *     - AUL send RESET/RESUME/TERM event for running application in case of single instance
  *     - AUL set application enviroment based on desktop entry
- *     - AUL support single instance / multi instance 
+ *     - AUL support single instance / multi instance
  *     - AUL support application data exchange format (bundle)
  */
 
 /**
- * @addtogroup aul_launch 
+ * @addtogroup aul_launch
  * @{
  */
 
 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 */
@@ -126,12 +150,20 @@ typedef enum _aul_type{
 /** AUL internal private key - To check forwarded callee app's pid */
 #define AUL_K_FWD_CALLEE_PID   "__AUL_FWD_CALLEE_PID__"
 
+/** AUL internal private key */
+#define AUL_K_NO_CANCEL        "__AUL_NO_CANCEL__"
+
 /** AUL public key - To check caller's secuirty */
 #define AUL_K_CALLER_PID       "__AUL_CALLER_PID__"
 /** AUL public key - To check callee's secuirty */
 #define AUL_K_CALLEE_PID       "__AUL_CALLEE_PID__"
 
-/** AUL public key - To find argv0 */ 
+/** AUL public key - To check caller's secuirty */
+#define AUL_K_CALLER_APPID     "__AUL_CALLER_APPID__"
+/** AUL public key - To check caller's secuirty */
+#define AUL_K_CALLEE_APPID     "__AUL_CALLEE_APPID__"
+
+/** AUL public key - To find argv0 */
 #define AUL_K_ARGV0            "__AUL_ARGV0__"
 /** AUL public key - To measure launching time */
 #define AUL_K_STARTTIME                "__AUL_STARTTIME__"
@@ -162,9 +194,39 @@ typedef enum _aul_type{
 /** AUL public bundle value - To support Media key*/
 #define AUL_V_KEY_RELEASED     "__AUL_KEY_RELEASED__"
 
+/** AUL internal private key */
+#define AUL_K_EXEC             "__AUL_EXEC__"
+/** AUL internal private key */
+#define AUL_K_MULTIPLE         "__AUL_MULTIPLE__"
+/** AUL internal private key */
+#define AUL_K_PACKAGETYPE      "__AUL_PACKAGETYPE__"
+/** AUL internal private key */
+#define AUL_K_HWACC            "__AUL_HWACC__"
+/** AUL internal private key */
+#define AUL_K_TASKMANAGE       "__AUL_TASKMANAGE__"
+
+
+/** AUL internal private key */
+#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__"
 
+#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
  * @param[in]  type    event's type received from system
  * @param[in]  b       In case of RESET events, bundle which is received from peer
@@ -182,7 +244,7 @@ typedef int (*aul_handler_fn) (aul_type type, bundle * b, void *data);
  *     In general, you need not use this API.
  *      If you use AppCore, you should NOT use this API.
  *      AppCore will set default aul_handler.
- *              
+ *
  * @param[in]  handler         aul main callback handler function
  * @param[in]  data            user-supplied data for start_handler
  * @return     0 if success, negative value(<0) if fail\n
@@ -190,16 +252,16 @@ typedef int (*aul_handler_fn) (aul_type type, bundle * b, void *data);
  * @retval     AUL_R_ECANCELD  - aul handler was installed already by others
  * @retval     AUL_R_ECOMM     - error to create internal ipc
  * @retval     AUL_R_ERROR     - error to attach glib main loop or ecore main loop
- *             
+ *
  * @warning    If you use AppCore, you should NOT use this API.\n
  *             You need glib main loop or ecore main loop.\n
  * @pre
  *     you must have aul handler to use this API.
  *     aul_luanch_init register aul handler.
- * @post 
+ * @post
+ *     None
+ * @see
  *     None
- * @see 
- *     None    
  * @code
  * #include <aul.h>
  * #include <bundle.h>
@@ -228,7 +290,7 @@ typedef int (*aul_handler_fn) (aul_type type, bundle * b, void *data);
  *      aul_launch_argv_handler(argc, argv);
  *     ecore_main_loop_begin();
  * }
- * 
+ *
  * @endcode
  * @remark
  *     None
@@ -251,21 +313,21 @@ int aul_launch_init(aul_handler_fn handler, void *data);
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_ENOINIT   - aul handler was NOT yet installed
  * @retval     AUL_R_ECANCLED  - error to create internal bundle with given argc,argv.
- * @retval     AUL_R_ERROR     - general error 
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     you must have aul handler to use this API.
  *     aul_luanch_init register aul handler.
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_launch_init
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int send_local_reset_event()
- * { 
+ * {
  *     int argc=3;
  *     char* argv[4];
  *     argv[0] = "local.app";
@@ -283,10 +345,57 @@ int aul_launch_argv_handler(int argc, char **argv);
 
 /**
  * @par Description:
+ *     This API create internal RESET events with given argc, argv \n
+ * @par Purpose:
+ *      This API's purpose is to generate reset event.
+ *      If you want to generate local RESET events with argument vector format, use this API
+ * @par Typical use case:
+ *     In general, you need not use this API.
+ *     AppCore use this API to create internal reset event.
+ *
+ * @param[in]  argc    # of args
+ * @param[in]  argv    list of arg strings
+ * @return     0 if success, negative value(<0) if fail
+ * @retval     AUL_R_OK        - success
+ * @retval     AUL_R_ENOINIT   - aul handler was NOT yet installed
+ * @retval     AUL_R_ECANCLED  - error to create internal bundle with given argc,argv.
+ * @retval     AUL_R_ERROR     - general error
+ *
+ * @pre
+ *     you must have aul handler to use this API.
+ *     aul_luanch_init register aul handler.
+ * @post
+ *     None
+ * @see
+ *     aul_launch_init
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * int send_local_reset_event()
+ * {
+ *     int argc=3;
+ *     char* argv[4];
+ *     argv[0] = "local.app";
+ *     argv[1] = "event_type";
+ *     argv[2] = "my_reset";
+ *     argv[3] = NULL;
+ *     aul_launch_argv_handler_for_efl(argc,argv);
+ * }
+ *
+ * @endcode
+ * @remark
+ *      If you use AppCore, you NEED NOT use this API.
+*/
+int aul_launch_argv_handler_for_efl(int argc, char **argv);
+
+
+/**
+ * @par Description:
  *     This API creates internal RESET events with given bundle \n
  * @par Purpose:
  *  This API's purpose is to generate reset event.
- *  If you want to generate local RESET events with argument vector format, first use 
+ *  If you want to generate local RESET events with argument vector format, first use
  *  bundle_import_from_argv to create a bundle from the argument vector and then use this API
  *  Eventually, this API will replace aul_launch_argv_handler().
  * @par Typical use case:
@@ -297,21 +406,21 @@ int aul_launch_argv_handler(int argc, char **argv);
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_ENOINIT   - aul handler was NOT yet installed
- * @retval     AUL_R_ERROR     - general error 
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     you must have aul handler to use this API.
  *     aul_luanch_init register aul handler.
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_launch_init, bundle_import_from_argv
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int send_local_reset_event()
- * { 
+ * {
  *  bundle* b;
  *     int argc=3;
  *     char* argv[4];
@@ -332,42 +441,43 @@ int aul_launch_local(bundle *b);
 
 /**
  * @par Description:
- *     This API launches application with the given bundle. 
+ *     This API launches application with the given bundle.
  *  If the application is not running or a multiple-instance one, this API launches with the given bundle.
  *     If the application is running, this API sends a RESET event to the App.
- *     While the application is running, if the application cannot receive the RESET event, 
+ *     While the application is running, if the application cannot receive the RESET event,
  *     this API returns a general error(AUL_R_ERROR).\n
  * @par Purpose:
  *      This API is for caller.
  *      This API's purpose is to launch/reset application with given bundle.
  * @par Typical use case:
- *     If you know the target application's pkgname and bundle types, 
+ *     If you know the target application's pkgname and bundle types,
  *     you can use this API to launch/reset the application.
  *
  * @param[in]  pkgname         package name to be run as callee
  * @param[in]  kb              bundle to be passed to callee
  * @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_ERROR     - general error 
- * 
+ * @retval     AUL_R_EINVAL    - invaild package name
+ * @retval     AUL_R_ECOMM     - internal AUL IPC error
+ * @retval     AUL_R_ERROR     - general error
+ *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_open_app
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int launch_inhouse_contact_app()
- * { 
+ * {
  *     bundle *b;
  *     b = bundle_create();
  *     bundle_add(b,"type","SIM");
  *     aul_launch_app("org.tizen.contact",b);
+ *     iuu
  * }
  *
  * @endcode
@@ -389,33 +499,33 @@ int aul_launch_app(const char *appid, bundle *kb);
  *      This API's purpose is to resume/launch application
  * @par Typical use case:
  *     If you only want to show application with previous state or default state, Use this API.
- *             
+ *
  * @param[in]  pkgname         package name to be resume as callee
  * @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_ERROR     - general error 
+ * @retval     AUL_R_EINVAL    - invaild package name
+ * @retval     AUL_R_ECOMM     - internal AUL IPC error
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_launch_app, aul_app_is_running, aul_resume_pid
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int open_inhouse_contact_app()
- * { 
+ * {
  *     if(aul_app_is_running("org.tizen.contact"))
  *             aul_open_app("org.tizen.contact");
  * }
  *
  * @endcode
  * @remark
- *     If you don't want to launch the app, 
+ *     If you don't want to launch the app,
  *     you should check app's running state with aul_app_is_running.
  *     This API will launch the application if the application is not running.
 */
@@ -423,45 +533,45 @@ int aul_open_app(const char *appid);
 
 /**
  * @par Description:
- *     This API trigger to resume application 
+ *     This API trigger to resume application
  *     If the application is running, this API send a resume event to the App.
  *     If the application is not running, this API returns fail.
- *     Although the application is running, if the application cannot receive resume event, 
+ *     Although the application is running, if the application cannot receive resume event,
  *     AUL try to raise the application's default windows.
  * @par Purpose:
  *      This API is for caller.
  *      This API's purpose is to send resume event.
  * @par Typical use case:
  *     If you only want to show application with previous state or default state, Use this API.
- *             
+ *
  * @param[in]  pkgname         package name to be resume as callee
  * @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_ERROR     - general error 
+ * @retval     AUL_R_EINVAL    - invaild package name
+ * @retval     AUL_R_ECOMM     - internal AUL IPC error
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_launch_app, aul_app_is_running, aul_resume_pid
  * @deprecated
  *  This function will be deprecated. Use aul_open_add() instead.
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int resume_inhouse_contact_app()
- * { 
+ * {
  *     if(aul_app_is_running("org.tizen.contact"))
  *             aul_resume_app("org.tizen.contact");
  * }
  *
  * @endcode
  * @remark
- *     If you don't want to launch the app, 
+ *     If you don't want to launch the app,
  *     you should check app's running state with aul_app_is_running.
  *     This API will launch the application if the application is not running.
  *     If you want to only resume without launching in multiple instance application model,
@@ -471,10 +581,10 @@ int aul_resume_app(const char *appid);
 
 /**
  * @par Description:
- *     This API trigger to resume application 
+ *     This API trigger to resume application
  *     If the application is running, this API send a resume event to the App.
  *     If the application is not running, this API return AUL_R_ERROR.
- *     Although the application is running, if the application cannot receive resume event, 
+ *     Although the application is running, if the application cannot receive resume event,
  *     AUL try to raise the application's default windows.
  * @par Purpose:
  *      This API is for caller.
@@ -485,21 +595,21 @@ int aul_resume_app(const char *appid);
  * @param[in]  pid     application's pid to be resumed
  * @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_ERROR     - general error (include application is not running) 
+ * @retval     AUL_R_EINVAL    - invaild pid
+ * @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
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_launch_app
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int iterfunc(const aul_app_info *info, void *data)
  * {
  *     if(strcmp(info->pkg_name,"org.tizen.contact")==0)
@@ -507,7 +617,7 @@ int aul_resume_app(const char *appid);
  * }
  *
  * int iterate_running_apps()
- * { 
+ * {
  *      return aul_app_get_running_app_info(iterfunc,NULL);
  * }
  *
@@ -519,35 +629,35 @@ int aul_resume_pid(int pid);
 
 /**
  * @par Description:
- *     This API trigger to terminate application 
- * 
+ *     This API trigger to terminate application
+ *
  *     If the application is running, this API send a terminate event to the App. \n
  *     If the app cannot receive the event, AUL kill forcely the application.\n
  * @par Purpose:
- *      This API's purpose is to kill application 
+ *      This API's purpose is to kill application
  * @par Typical use case:
  *     In general, Application like Task Manager use this API.
- *     
+ *
  *             This API need to require root or inhouse permisssion. \n
  *
- * @param[in]  pid     application's pid to be terminated 
+ * @param[in]  pid     application's pid to be terminated
  * @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_ERROR     - general error 
+ * @retval     AUL_R_EINVAL    - invaild pid
+ * @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
  *
  * @pre
  *     None
- * @post 
+ * @post
+ *     None
+ * @see
  *     None
- * @see 
- *     None    
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int iterfunc(const aul_app_info *info, void *data)
  * {
  *     if(strcmp(info->pkg_name,"org.tizen.contact")==0)
@@ -555,7 +665,7 @@ int aul_resume_pid(int pid);
  * }
  *
  * int iterate_running_apps()
- * { 
+ * {
  *      return aul_app_get_running_app_info(iterfunc,NULL);
  * }
  *
@@ -564,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);
+
 
 /** @} */
 
@@ -582,8 +695,8 @@ int aul_terminate_pid(int pid);
  * @{
  */
 
-/** 
- *@brief Running application's information structure retrieved by AUL 
+/**
+ *@brief Running application's information structure retrieved by AUL
  */
 typedef struct _aul_app_info {
        int pid;                /**< app's pid if running*/
@@ -592,10 +705,10 @@ typedef struct _aul_app_info {
        char* appid;
 } aul_app_info;
 
-/** 
- * @brief iterator function running with aul_app_get_running_app_info 
+/**
+ * @brief iterator function running with aul_app_get_running_app_info
  * @param[out] ainfo   aul_app_info retreived by aul_app_get_running_app_info
- * @param[out] data    user-supplied data      
+ * @param[out] data    user-supplied data
 */
 typedef int (*aul_app_info_iter_fn)(const aul_app_info *ainfo, void *data);
 
@@ -605,7 +718,7 @@ typedef int (*aul_app_info_iter_fn)(const aul_app_info *ainfo, void *data);
  * @par Purpose:
  *     To know whether some application is running or not, use this API
  * @par Typical use case:
- *     For example, If you want to know browser application running, 
+ *     For example, If you want to know browser application running,
  *     you can check it by using this API.
  *
  * @param[in]  pkgname application package name
@@ -615,22 +728,22 @@ typedef int (*aul_app_info_iter_fn)(const aul_app_info *ainfo, void *data);
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
  *
  * int is_running_browser_app()
- * { 
+ * {
  *      return aul_app_is_running("org.tizen.browser");
  * }
  *
  * @endcode
  * @remark
  *     None
-* 
+*
 */
 int aul_app_is_running(const char *appid);
 
@@ -652,9 +765,9 @@ int aul_app_is_running(const char *appid);
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
@@ -670,7 +783,7 @@ int aul_app_is_running(const char *appid);
  * }
  *
  * int iterate_running_apps()
- * { 
+ * {
  *      return aul_app_get_running_app_info(iterfunc,NULL);
  * }
  *
@@ -684,9 +797,25 @@ 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 
+ *     If you want to get package name of running application, use this API
  * @par Typical use case:
  *     In general, You can use this API when you want to know caller's information.
  *
@@ -695,19 +824,19 @@ int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
  * @param[in]  len             length of pkgname
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
- * @retval     AUL_R_ERROR     - no such a package name 
+ * @retval     AUL_R_ERROR     - no such a package name
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
  * #include <bundle.h>
  *
- * static int app_reset(bundle *b, void *data) 
- * { 
+ * static int app_reset(bundle *b, void *data)
+ * {
  *     int pid;
  *     char appname[255];
  *
@@ -760,19 +889,21 @@ 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);
+
 
 /** @} */
 
 /**
- * @defgroup aul_mime High-level APIs to launch default application based on mime type 
+ * @defgroup aul_mime High-level APIs to launch default application based on mime type
  * @ingroup aul
  * @brief
  *   AUL High-level APIs based on mime type
  *
  *   These APIs provide two functionality\n
- *   
+ *
  *   -# To launch default application to open a file based on its MIME type \n
- *   For example, you can launch the default video player to open .mp4 files 
+ *   For example, you can launch the default video player to open .mp4 files
  *   or launch the default browser to open HTML files \n
  *   -# To launch default application to process given content \n
  *   For example, you can launch the default e-mail application to process
@@ -786,254 +917,38 @@ 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(package name) 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 package name 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(package name) 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 package name 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 
+ *     This API use to get mimetype associteted with given filename
  *     In general, This API use when you want to know only mimetype given filename.
  * @par Typical use case:
- *     For example, In trasfering data through bluetooth, 
+ *     For example, In trasfering data through bluetooth,
  *     additional information like mimetype should be added.
  *     In such situation, You can get mimetype by using this API.
- *     
- * @param[in]  filename        file name 
+ *
+ * @param[in]  filename        file name
  * @param[out] mimetype        a mime type
- * @param[in]  len             length of mimetype 
+ * @param[in]  len             length of mimetype
  * @return     0 if success, negative value if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invalid argument(filename)
- * @retval     AUL_R_ERROR     - general error 
- * 
+ * @retval     AUL_R_ERROR     - general error
+ *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
- * 
+ *
  * void get_mimetype()
  * {
  *     char mimetype[255];
  *     aul_get_mime_from_file("image.jpg",mimetype,sizeof(mimetype));
  * }
- * 
+ *
  * @endcode
  * @remark
  *     None
@@ -1042,38 +957,38 @@ int aul_get_mime_from_file(const char *filename, char *mimetype, int len);
 
 /**
  * @par Description:
- *     This API get the mimetype associated with given content 
+ *     This API get the mimetype associated with given content
  * @par Purpose:
- *     This API use to get mimetype associteted with given content 
- *     In general, This API use when you want to know only mimetype given content 
+ *     This API use to get mimetype associteted with given content
+ *     In general, This API use when you want to know only mimetype given content
  * @par Typical use case:
- *     For example, In trasfering data through bluetooth, 
+ *     For example, In trasfering data through bluetooth,
  *     additional information like mimetype should be added.
  *     In such situation, You can get mimetype by using this API.
  *
- * @param[in]  content         content string like "011-0000-0000" 
+ * @param[in]  content         content string like "011-0000-0000"
  * @param[out] mimetype        a mime type
- * @param[in]  len             length of mimetype 
+ * @param[in]  len             length of mimetype
  * @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 
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
- * 
+ *
  * void get_mimetype()
  * {
  *     char mimetype[255];
  *     aul_get_mime_from_content("http://www.samsung.com",mimetype,sizeof(mimetype));
  * }
- * 
+ *
  * @endcode
  * @remark
  *     None
@@ -1082,7 +997,7 @@ int aul_get_mime_from_content(const char *content, char *mimetype, int len);
 
 /**
  * @par Description:
- *     This API get the icon's name associated with given mimetype 
+ *     This API get the icon's name associated with given mimetype
  * @par Purpose:
  *     This API use to get icon's name associteted with given mimetype
  * @par Typical use case:
@@ -1094,23 +1009,23 @@ int aul_get_mime_from_content(const char *content, char *mimetype, int len);
  * @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 (no such mime type) 
+ * @retval     AUL_R_ERROR     - general error (no such mime type)
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
- * 
+ *
  * void get_mime_icon()
  * {
  *     char icon[255];
  *     aul_get_mime_icon("text/html",icon,sizeof(icon));
  * }
- * 
+ *
  * @endcode
  * @remark
  *     None
@@ -1119,7 +1034,7 @@ int aul_get_mime_icon(const char *mimetype, char *iconname, int len);
 
 /**
  * @par Description:
- *     This API get the extensions associated with given mimetype 
+ *     This API get the extensions associated with given mimetype
  * @par Purpose:
  *     This API use to get extensions associteted with given mimetype
  * @par Typical use case:
@@ -1133,34 +1048,34 @@ int aul_get_mime_icon(const char *mimetype, char *iconname, int len);
  * @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 (no mimetype or no extenstion) 
+ * @retval     AUL_R_ERROR     - general error (no mimetype or no extenstion)
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_get_mime_description
  * @code
  * #include <aul.h>
- * 
+ *
  * void get_extension()
  * {
  *     char extlist[255];
  *     aul_get_mime_extension("text/html",extlist,sizeof(extlist));
  * }
- * 
+ *
  * @endcode
  * @remark
  *     Some mimetype don't have extension.
  *     In that case, You can use aul_get_mime_description.
- * 
+ *
 */
 int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
 
 /**
  * @par Description:
- *     This API get the description associated with given mimetype 
+ *     This API get the description associated with given mimetype
  * @par Purpose:
  *     This API use to get description associteted with given mimetype
  * @par Typical use case:
@@ -1170,22 +1085,22 @@ int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
  *     At that time,to show mimetype information to user, use this API
  *
  * @param[in]  mimetype        a mime type
- * @param[out] desc            description (ex> Call client)   
+ * @param[out] desc            description (ex> Call client)
  * @param[in]  len             length of desc
  * @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 (no mimetype or no descrition) 
+ * @retval     AUL_R_ERROR     - general error (no mimetype or no descrition)
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_get_mime_extension
  * @code
  * #include <aul.h>
- * 
+ *
  * void get_information_from_mime()
  * {
  *     char info[255];
@@ -1193,34 +1108,21 @@ int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
  *             aul_get_mime_description("text/html",info,sizeof(info));
  *     }
  * }
- * 
+ *
  * @endcode
  * @remark
- *     None 
+ *     None
  */
 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");                                          */
-/************************************************************************************************/
-
 /** @} */
 
 /**
- * @defgroup aul_service High-level APIs to launch applications based on service. 
+ * @defgroup aul_service High-level APIs to launch applications based on service.
  * @ingroup aul
  * @brief
- *      AUL High-level APIs based on service 
- * 
+ *      AUL High-level APIs based on service
+ *
  *     This is Request/Response mechanism based on AUL like DBUS service call with auto-activation.\n
  *     We recommend this APIs for requesting application service like camera application service (take_picture)
  *     But, You can use other mechanism like DBUS service or your own internal IPC
@@ -1240,71 +1142,15 @@ int aul_get_mime_description(const char *mimetype, char *desc, int len);
  * @{
  */
 
-/** 
+/**
  * @brief aul_service_res_fn is service result function
- * @param[out] b       result bundle   
- * @param[out] data    user-supplied data      
+ * @param[out] b       result bundle
+ * @param[out] data    user-supplied data
 */
 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.
@@ -1312,20 +1158,20 @@ int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc,
  *     This API is for callee which provide application service.\n
  *      To send result to caller, You must create result bundle. \n
  *      Callee(application providing the service) can send result by using this API and aul_send_service_result.
- * 
- * @param[in]   inb             bundle received in reset event 
- * @param[out]  outb            bundle to use for returning result 
+ *
+ * @param[in]   inb             bundle received in reset event
+ * @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_ERROR     - general error 
+ * @retval      AUL_R_EINVAL    - inb is not bundle
+ * @retval      AUL_R_ERROR     - general error
  *
  * @pre
  *     To create result bundle, You need received original bundle.
  *     The original bundle can get from app_reset handler.
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_send_service_result
  * @code
  * #include <aul.h>
@@ -1335,7 +1181,7 @@ int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc,
  * {
  *      ad->recved_bundle = bundle_dup(b);
  * }
- * 
+ *
  * int click_ok()
  * {
  *      bundle* res_bundle;
@@ -1346,7 +1192,7 @@ int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc,
  * @endcode
  * @remark
  *     None
- * 
+ *
  */
 int aul_create_result_bundle(bundle *inb, bundle **outb);
 
@@ -1365,14 +1211,14 @@ int aul_create_result_bundle(bundle *inb, bundle **outb);
  * @retval      AUL_R_OK        - success
  * @retval      AUL_R_EINVAL    - invalid result bundle
  * @retval      AUL_R_ECOMM     - internal AUL IPC error
- * @retval      AUL_R_ERROR     - general error 
+ * @retval      AUL_R_ERROR     - general error
  *
  * @pre
- *     To send result bundle, You must create result bundle. 
- *      see aul_create_result_bundle   
- * @post 
+ *     To send result bundle, You must create result bundle.
+ *      see aul_create_result_bundle
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_create_result_bundle
  * @code
  * #include <aul.h>
@@ -1382,7 +1228,7 @@ int aul_create_result_bundle(bundle *inb, bundle **outb);
  * {
  *      ad->recved_bundle = bundle_dup(b);
  * }
- * 
+ *
  * int click_ok()
  * {
  *      bundle* res_bundle;
@@ -1393,88 +1239,9 @@ int aul_create_result_bundle(bundle *inb, bundle **outb);
  * @endcode
  * @remark
  *     None
- * 
- */
-int aul_send_service_result(bundle *b);
-
-/**
- * @par Description:
- *     This API set the default application(package name) 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 package name 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);
+int aul_send_service_result(bundle *b);
 
 /**
  * @par Description:
@@ -1556,6 +1323,80 @@ 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);
+
+int aul_set_subapp(subapp_fn cb, void *data);
+int aul_subapp_terminate_request_pid(int pid);
+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(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_app_get_cmdline_bypid(int pid, char *cmdline, int len);
+
+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);
+
+char *aul_get_cmdline_bypid(int pid);
+
 /** @} */
 
 
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 91e2416..f93e518 100755 (executable)
 #define MAX_PACKAGE_APP_PATH_SIZE 512
 #define MAX_RUNNING_APP_INFO 512
 
-struct history_data {
-       char pkg_name[MAX_PACKAGE_STR_SIZE];
+typedef struct _app_status_info_t{
+       char appid[MAX_PACKAGE_STR_SIZE];
        char app_path[MAX_PACKAGE_APP_PATH_SIZE];
-       int len;
-       unsigned char data[1];
+       char caller[MAX_PACKAGE_STR_SIZE];
+       int status;
+       int pid;
+       int pad_pid;
+} app_status_info_t;
+
+struct amdmgr {
+       struct appinfomgr *af;  /* appinfo manager */
+       struct cginfo *cg;  /* cgroup infomation */
 };
 
+int _add_app_status_info_list(char *appid, int pid);
+int _update_app_status_info_list(int pid, int status);
+int _remove_app_status_info_list(int pid);
+
 #endif
 
 
index 090f403..4025cde 100755 (executable)
@@ -34,6 +34,7 @@ int aul_make_bundle_from_argv(int argc, char **argv, bundle **kb);
 
 int app_start(bundle *kb);
 int app_send_cmd(int pid, int cmd, bundle *kb);
+int app_send_cmd_with_noreply(int pid, int cmd, bundle *kb);
 int app_request_to_launchpad(int cmd, const char *pkgname, bundle *kb);
 
 int _app_start_res_prepare(bundle *kb);
index d76815c..0624542 100755 (executable)
  *
  */
 
+#ifndef __MENU_DB_UTIL_H_
+#define __MENU_DB_UTIL_H_
 
 #include <ail.h>
 #include <string.h>
+#include <stdio.h>
 #include "simple_util.h"
 
 #define MAX_PATH_LEN   1024
@@ -46,17 +49,20 @@ typedef struct {
        char *pkg_name;         /* package */
        char *app_path;         /* exec */
        char *original_app_path;        /* exec */
-       char *app_type;         /* x_slp_packagetype */
-       int multiple;           /* x_slp_multiple */
-       int task_manage;        /* x_slp_taskmanage */
-       char *pkg_type;
+       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)
 {
-       if (menu_info->pkg_name == NULL)
-               return NULL;
-       return menu_info->pkg_name;
+       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)
@@ -64,7 +70,7 @@ static inline char *_get_app_path(app_info_from_db *menu_info)
        int i = 0;
        int path_len = -1;
 
-       if (menu_info->app_path == NULL)
+       if (!menu_info || menu_info->app_path == NULL)
                return NULL;
 
        while (menu_info->app_path[i] != 0) {
@@ -93,27 +99,7 @@ static inline char *_get_app_path(app_info_from_db *menu_info)
 
 static inline char *_get_original_app_path(app_info_from_db *menu_info)
 {
-       if (menu_info->original_app_path == NULL)
-               return NULL;
-       return menu_info->original_app_path;
-}
-
-static inline char *_get_app_app_type(app_info_from_db *menu_info)
-{
-       return menu_info->app_type;
-}
-
-static inline int _is_app_multi_inst(app_info_from_db *menu_info)
-{
-       if (menu_info->multiple)
-               return 1;
-       else
-               return 0;
-}
-
-static inline int _get_app_task_manage(app_info_from_db *menu_info)
-{
-       return menu_info->task_manage;
+       return menu_info ? menu_info->original_app_path : NULL;
 }
 
 static inline void _free_app_info_from_db(app_info_from_db *menu_info)
@@ -125,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->app_type != NULL)
-                       free(menu_info->app_type);
+               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);
        }
 }
@@ -144,7 +136,7 @@ static inline app_info_from_db *_get_app_info_from_db_by_pkgname(
                return NULL;
        }
 
-       ret = ail_package_get_appinfo(pkgname, &handle);
+       ret = ail_get_appinfo(pkgname, &handle);
        if (ret != AIL_ERROR_OK) {
                _free_app_info_from_db(menu_info);
                return NULL;
@@ -152,7 +144,7 @@ static inline app_info_from_db *_get_app_info_from_db_by_pkgname(
 
        ret = ail_appinfo_get_str(handle, AIL_PROP_PACKAGE_STR, &str);
        if (str) {
-               menu_info->pkg_name = strdup(str);      
+               menu_info->pkg_name = strdup(str);
                str = NULL;
        }
 
@@ -165,24 +157,12 @@ static inline app_info_from_db *_get_app_info_from_db_by_pkgname(
        if (menu_info->app_path != NULL)
                menu_info->original_app_path = strdup(menu_info->app_path);
 
-       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_MULTIPLE_BOOL,
-               (bool *)&menu_info->multiple);
-
-       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_TASKMANAGE_BOOL,
-               (bool *)&menu_info->task_manage);
-       
-       ret = ail_appinfo_get_str(handle, AIL_PROP_TYPE_STR, &str);
-       if (str) {
-               menu_info->app_type = strdup(str);
-               str = NULL;
-       }
-
        ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &str);
        if (str) {
                menu_info->pkg_type = strdup(str);
                str = NULL;
        }
-       
+
        ret = ail_destroy_appinfo(handle);
        if (ret != AIL_ERROR_OK) {
                _E("ail_destroy_appinfo failed");
@@ -200,12 +180,24 @@ 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)
+               return ret;
 
        ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
+       if (package) {
+               menu_info->pkg_name = strdup(package);
+               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);
+       }
 
-       menu_info->pkg_name = strdup(package);
-       
-       return AIL_CB_RET_CANCEL;       /*return AIL_CB_RET_CONTINUE;*/ 
+       return ret;
 }
 
 static inline app_info_from_db *_get_app_info_from_db_by_apppath(
@@ -215,7 +207,7 @@ static inline app_info_from_db *_get_app_info_from_db_by_apppath(
        ail_filter_h filter;
        ail_error_e ret;
        int count;
-       
+
        if (apppath == NULL)
                return NULL;
 
@@ -256,6 +248,7 @@ static inline app_info_from_db *_get_app_info_from_db_by_apppath(
        menu_info->original_app_path = strdup(apppath);
 
        return menu_info;
-       
+
 }
 
+#endif
index eed476d..89993ad 100755 (executable)
 
 #ifdef LAUNCHPAD_LOG
 #undef LOG_TAG
-#define LOG_TAG "AULD"
+#define LOG_TAG "AUL_PAD"
 #else
 #undef LOG_TAG
 #define LOG_TAG "AUL"
 #endif
+#ifdef AMD_LOG
+#undef LOG_TAG
+#define LOG_TAG "AUL_AMD"
+#endif
+
 
 #define MAX_LOCAL_BUFSZ 128
 #define MAX_PID_STR_BUFSZ 20
 
-#define _E(fmt, arg...) LOGE("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
-#define _D(fmt, arg...) LOGD("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
+#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) { \
@@ -62,5 +70,25 @@ int __proc_iter_cmdline(int (*iterfunc)
 int __proc_iter_pgid(int pgid, int (*iterfunc) (int pid, void *priv),
                     void *priv);
 char *__proc_get_cmdline_bypid(int pid);
+void __trm_app_info_send_socket(char *write_buf);
+
+
+static inline const char *FILENAME(const char *filename)
+{
+       const char *p;
+       const char *r;
+
+       if (!filename)
+               return NULL;
+
+       r = p = filename;
+       while (*p) {
+               if (*p == '/')
+                       r = p + 1;
+               p++;
+       }
+
+       return r;
+}
 
 #endif
index 40c8172..1ae8878 100755 (executable)
@@ -2,5 +2,6 @@
 mkdir /tmp/alaunch
 chmod 1777 /tmp/alaunch
 
+
+/usr/bin/amd &
 /usr/bin/launchpad_preloading_preinitializing_daemon "                                                                                                                                                                                                         " &
-/usr/bin/ac_daemon &
diff --git a/launchpad_src/access_control.h b/launchpad_src/access_control.h
deleted file mode 100755 (executable)
index c9a7496..0000000
+++ /dev/null
@@ -1,87 +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.
- *
- */
-
-
-#ifdef DAC_ACTIVATE
-
-#include <sys/types.h>
-#include <sys/xattr.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <privilege-control.h>
-
-#define INHOUSE_UID     5000
-#define LABEL_LEN              23
-
-static inline void __dac_init()
-{
-}
-
-static inline int __set_dac(const char *pkg_name)
-{
-       return set_privilege(pkg_name);
-}
-
-static inline int __set_smack(char* path)
-{
-/*
- * This is additional option.
- * Though such a application fails in this function, that error is ignored.
- */
-       char label[LABEL_LEN + 1] = {0, };
-       int fd = 0;
-       int result = -1;
-
-       result = getxattr(path, "security.SMACK64EXEC", label, LABEL_LEN);
-       if(result < 0)  // fail to get extended attribute
-               return 0;       // ignore error
-
-       fd = open("/proc/self/attr/current", O_RDWR);
-       if(fd < 0)              // fail to open file
-               return 0;       // ignore error
-
-       result = write(fd, label, strlen(label));
-       if(result < 0) {        // fail to write label
-               close(fd);
-               return 0;       // ignore error
-       }
-
-       close(fd);
-       return 0;
-}
-
-#else
-static inline void __dac_init()
-{
-}
-
-static inline int __set_dac(const char *pkg_name)
-{
-       return 0;
-}
-
-static inline int __set_smack(char* path)
-{
-       return 0;
-}
-#endif
-
-
index 0e893d4..10f3b3b 100755 (executable)
@@ -21,7 +21,7 @@
 
 
 /*
- * simple AUL daemon - launchpad 
+ * simple AUL daemon - launchpad
  */
 
 #include <stdio.h>
@@ -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"
@@ -58,7 +59,6 @@
 
 #include "gl.h"
 
-#include <app-checker.h>
 #include <sqlite3.h>
 
 #define _static_ static inline
 #define SQLITE_FLUSH_MAX       (1048576)       /* (1024*1024) */
 #define AUL_POLL_CNT           15
 #define AUL_PR_NAME                    16
-#define PATH_APP_ROOT "/opt/apps"
-#define PATH_DATA "/data"
-#define SDK_CODE_COVERAGE "CODE_COVERAGE"
-#define SDK_DYNAMIC_ANALYSIS "DYNAMIC_ANALYSIS"
-#define PATH_DA_SO "/home/developer/sdk_tools/da/da_probe.so"
 
 
 static char *launchpad_cmdline;
+static char *__appid = NULL;
 static int initialized = 0;
 
-
-_static_ void __set_oom();
 _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,
@@ -86,8 +80,6 @@ _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_ void __add_history(int caller, int callee, const char *pkgname,
-                               bundle *b, const char *app_path);
 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);
@@ -96,10 +88,7 @@ _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 __app_process_by_pid(int cmd, 
-       const char *pkg_name, struct ucred *cr);
-_static_ int __nofork_processing(int cmd, int pid, bundle * kb);
-_static_ void __real_send(int clifd, int ret);
+_static_ int __real_send(int clifd, int ret);
 _static_ void __send_result_to_caller(int clifd, int ret);
 _static_ void __launchpad_main_loop(int main_fd);
 _static_ int __launchpad_pre_init(int argc, char **argv);
@@ -109,50 +98,10 @@ extern ail_error_e ail_db_close(void);
 
 
 
-_static_ void __set_oom()
-{
-       char buf[MAX_LOCAL_BUFSZ];
-       FILE *fp;
-
-       /* we should reset oomadj value as default because child 
-       inherits from parent oom_adj*/
-       snprintf(buf, MAX_LOCAL_BUFSZ, "/proc/%d/oom_adj", getpid());
-       fp = fopen(buf, "w");
-       if (fp == NULL)
-               return;
-       fprintf(fp, "%d", -16);
-       fclose(fp);
-}
-
-_static_ void __set_sdk_env(app_info_from_db* menu_info, char* str) {
-       char buf[MAX_LOCAL_BUFSZ];
-       int ret;
-
-       _D("key : %s / value : %s", AUL_K_SDK, str);
-       /* http://gcc.gnu.org/onlinedocs/gcc/Cross_002dprofiling.html*/
-       /* GCOV_PREFIX contains the prefix to add to the absolute paths in the object file. */
-       /*              Prefix can be absolute, or relative. The default is no prefix.  */
-       /* GCOV_PREFIX_STRIP indicates the how many initial directory names */
-       /*              to stripoff the hardwired absolute paths. Default value is 0. */
-       if (strncmp(str, SDK_CODE_COVERAGE, strlen(str)) == 0) {
-               snprintf(buf, MAX_LOCAL_BUFSZ, PATH_APP_ROOT"/%s"PATH_DATA, _get_pkgname(menu_info));
-               ret = setenv("GCOV_PREFIX", buf, 1);
-               _D("GCOV_PREFIX : %d", ret);
-               ret = setenv("GCOV_PREFIX_STRIP", "4096", 1);
-               _D("GCOV_PREFIX_STRIP : %d", ret);
-       } else if (strncmp(str, SDK_DYNAMIC_ANALYSIS, strlen(str)) == 0) {
-               ret = setenv("LD_PRELOAD", PATH_DA_SO, 1);
-               _D("LD_PRELOAD : %d", ret);
-       }
-}
-
 
 _static_ void __set_env(app_info_from_db * menu_info, bundle * kb)
 {
        const char *str;
-       const char **str_array;
-       int len;
-       int i;
 
        setenv("PKG_NAME", _get_pkgname(menu_info), 1);
 
@@ -162,20 +111,10 @@ _static_ void __set_env(app_info_from_db * menu_info, bundle * kb)
        if (str != NULL)
                setenv("APP_START_TIME", str, 1);
 
-       if(bundle_get_type(kb, AUL_K_SDK) & BUNDLE_TYPE_ARRAY) {
-               str_array = bundle_get_str_array(kb, AUL_K_SDK, &len);
-               if(str_array != NULL) {
-                       for (i = 0; i < len; i++) {
-                               _D("index : [%d]", i);
-                               __set_sdk_env(menu_info, (char *)str_array[i]);
-                       }
-               }
-       } else {
-               str = bundle_get_val(kb, AUL_K_SDK);
-               if(str != NULL) {
-                       __set_sdk_env(menu_info, (char *)str);
-               }
-       }
+       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,
@@ -184,6 +123,7 @@ _static_ int __prepare_exec(const char *pkg_name,
 {
        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 */
@@ -192,15 +132,10 @@ _static_ int __prepare_exec(const char *pkg_name,
 
        __preexec_run(menu_info->pkg_type, pkg_name, app_path);
 
-       /* SET OOM*/
-       __set_oom();
-
-       /* SET SMACK LABEL */
-       __set_smack((char *)app_path);
-
-       /* SET DAC*/
-       if (__set_dac(pkg_name) < 0) {
-               _D("fail to set DAC - check your package's credential\n");
+       /* 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*/
@@ -254,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]);
@@ -274,59 +217,22 @@ _static_ void __real_launch(const char *app_path, bundle * kb)
        app_argv = __create_argc_argv(kb, &app_argc);
        app_argv[0] = strdup(app_path);
 
-       for (i = 0; i < app_argc; i++)
-               _D("input argument %d : %s##", i, app_argv[i]);
+       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");
-       _E("lock up test log(no error) : setup argument done");
 
        /* Temporary log: launch time checking */
-       LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:launchpad:done]", app_path);
+       SECURE_LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:launchpad:done]", app_path);
 
        __preload_exec(app_argc, app_argv);
 
        __normal_fork_exec(app_argc, app_argv);
 }
 
-_static_ void __add_history(int caller, int callee, const char *pkgname, 
-                               bundle *b, const char *app_path)
-{
-       struct history_data *hd;
-       bundle_raw *kb_data;
-       int len;
-
-       _D("***** HISTORY *****\n");
-       _D("%d ==> %d(%s) \n", caller, callee, pkgname);
-       _D("*******************\n");
-
-       if (b) {
-               bundle_encode(b, (bundle_raw **)&kb_data, &len);
-               hd = (struct history_data *)malloc(sizeof(char) * (len+1029));
-
-               strncpy(hd->pkg_name, pkgname, MAX_PACKAGE_STR_SIZE-1);
-               strncpy(hd->app_path, app_path, MAX_PACKAGE_APP_PATH_SIZE-1);
-               hd->len = len;
-               memcpy(hd->data, kb_data, len);
-
-               __app_send_raw(AUL_UTIL_PID, APP_ADD_HISTORY, (unsigned char *)hd,
-                       hd->len+1029);
-               free(kb_data);
-               free(hd);
-       } else {
-               hd = (struct history_data *)malloc(sizeof(char) * 1029);
-
-               strncpy(hd->pkg_name, pkgname, MAX_PACKAGE_STR_SIZE-1);
-               strncpy(hd->app_path, app_path, MAX_PACKAGE_APP_PATH_SIZE-1);
-               hd->len = 0;
-
-               __app_send_raw(AUL_UTIL_PID, APP_ADD_HISTORY, (unsigned char *)hd,
-                       1029);
-               free(hd);
-       }
-
-       return;
-}
-
 
 /*
  * Parsing original app path to retrieve default bundle
@@ -426,16 +332,22 @@ 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)
 {
-       char tmp_pid[MAX_PID_STR_BUFSZ];
-
-       snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", caller_pid);
-       bundle_add(kb, AUL_K_CALLER_PID, tmp_pid);
        bundle_del(kb, AUL_K_PKG_NAME);
-       if (cmd == APP_START_RES)
-               bundle_add(kb, AUL_K_WAIT_RESULT, "1");
+       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_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;
@@ -448,7 +360,7 @@ _static_ void __modify_bundle(bundle * kb, int caller_pid,
                        char value[256];
 
                        ptr += flag;
-                       _D("parsing app_path: EXEC - %s\n", exe);
+                       SECURE_LOGD("parsing app_path: EXEC - %s\n", exe);
 
                        do {
                                flag = __parser(ptr, key, sizeof(key));
@@ -586,7 +498,7 @@ _static_ int __foward_cmd(int cmd, bundle *kb, int cr_pid)
        bundle_add(kb, AUL_K_CALLEE_PID, tmp_pid);
 
        bundle_encode(kb, &kb_data, &datalen);
-       if ((res = __app_send_raw(pid, cmd, kb_data, datalen)) < 0)
+       if ((res = __app_send_raw_with_noreply(pid, cmd, kb_data, datalen)) < 0)
                res = AUL_R_ERROR;
 
        free(kb_data);
@@ -594,74 +506,19 @@ _static_ int __foward_cmd(int cmd, bundle *kb, int cr_pid)
        return res;
 }
 
-_static_ int __app_process_by_pid(int cmd, 
-       const char *pkg_name, struct ucred *cr)
-{
-       int pid;
-       int ret = -1;
-
-       if (pkg_name == NULL)
-               return -1;
-
-       if ((cr->uid != 0) && (cr->uid != INHOUSE_UID)) {
-               _E("reject by security rule, your uid is %u\n", cr->uid);
-               return -1;
-       }
-
-       pid = atoi(pkg_name);
-       if (pid <= 1) {
-               _E("invalid pid");
-               return -1;
-       }
-
-       switch (cmd) {
-       case APP_RESUME_BY_PID:
-               ret = __resume_app(pid);
-               break;
-       case APP_TERM_BY_PID:
-               ret = __term_app(pid);
-               break;
-       case APP_KILL_BY_PID:
-               if ((ret = __send_to_sigkill(pid)) < 0)
-                       _E("fail to killing - %d\n", pid);
-       }
-
-       return ret;
-}
-
-_static_ int __nofork_processing(int cmd, int pid, bundle * kb)
-{
-       int ret = -1;
-       switch (cmd) {
-       case APP_OPEN:
-       case APP_RESUME:
-               _D("resume app's pid : %d\n", pid);
-               if ((ret = __resume_app(pid)) < 0)
-                       _E("__resume_app failed. error code = %d", ret);
-               PERF("resume app done");
-               break;
-
-       case APP_START:
-       case APP_START_RES:
-               _D("fake launch pid : %d\n", pid);
-               if ((ret = __fake_launch_app(cmd, pid, kb)) < 0)
-                       _E("fake_launch failed. error code = %d", ret);
-               PERF("fake launch done");
-               break;
-       }
-       return ret;
-}
-
-_static_ void __real_send(int clifd, int ret)
+_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)
@@ -670,6 +527,7 @@ _static_ void __send_result_to_caller(int clifd, int ret)
        int wait_count;
        int cmdline_changed = 0;
        int cmdline_exist = 0;
+       int r;
 
        if (clifd == -1)
                return;
@@ -695,9 +553,9 @@ _static_ void __send_result_to_caller(int clifd, int ret)
                }
 
                _D("-- now wait to change cmdline --");
-               usleep(50 * 1000);      /* 50ms sleep*/
+               usleep(100 * 1000);     /* 100ms sleep*/
                wait_count++;
-       } while (wait_count <= 20);     /* max 50*20ms will be sleep*/
+       } while (wait_count <= 20);     /* max 100*20ms will be sleep*/
 
        if ((!cmdline_exist) && (!cmdline_changed)) {
                __real_send(clifd, -1); /* abnormally launched*/
@@ -707,10 +565,48 @@ _static_ void __send_result_to_caller(int clifd, int ret)
        if (!cmdline_changed)
                _E("process launched, but cmdline not changed");
 
-       __real_send(clifd, ret);
+       if(__real_send(clifd, ret) < 0) {
+               r = kill(ret, SIGKILL);
+               if (r == -1)
+                       _E("send SIGKILL: %s", strerror(errno));
+       }
+
        return;
 }
 
+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 __release_appid_at_exit(void)
+{
+       if (__appid != NULL) {
+               free(__appid);
+       }
+}
+
 _static_ void __launchpad_main_loop(int main_fd)
 {
        bundle *kb = NULL;
@@ -741,21 +637,10 @@ _static_ void __launchpad_main_loop(int main_fd)
        INIT_PERF(kb);
        PERF("packet processing start");
 
-       if (pkt->cmd == APP_RESULT || pkt->cmd == APP_CANCEL) {
-               pid = __foward_cmd(pkt->cmd, kb, cr.pid);
-               goto end;
-       }
-
        pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME);
-       _D("pkg name : %s\n", pkg_name);
+       SECURE_LOGD("pkg name : %s\n", pkg_name);
 
-       if (pkt->cmd == APP_TERM_BY_PID || pkt->cmd == APP_RESUME_BY_PID ||
-           pkt->cmd == APP_KILL_BY_PID) {
-               pid = __app_process_by_pid(pkt->cmd, pkg_name, &cr);
-               goto end;
-       }
-
-       menu_info = _get_app_info_from_db_by_pkgname(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;
@@ -776,29 +661,14 @@ _static_ void __launchpad_main_loop(int main_fd)
 
        PERF("get package information & modify bundle done");
 
-       if (_is_app_multi_inst(menu_info) == 0)
-               pid = __proc_iter_cmdline(NULL, (void *)app_path);
-
-       PERF("find pid by searching proc file system done");
-
-       if (pid > 0) {
-               int ret;
-
-               if (cr.pid == pid) {
-                       _D("caller process & callee process is same.[%s:%d]",
-                          pkg_name, pid);
-                       pid = -ELOCALLAUNCH_ID;
-               } else if ((ret = __nofork_processing(pkt->cmd, pid, kb)) < 0)
-                       pid = ret;
-       } else if (pkt->cmd != APP_RESUME) {
+       {
                pid = fork();
                if (pid == 0) {
                        PERF("fork done");
-                       _E("lock up test log(no error) : fork done");
+                       _D("lock up test log(no error) : fork done");
 
                        close(clifd);
                        close(main_fd);
-                       ail_db_close();
                        __signal_unset_sigchld();
                        __signal_fini();
 
@@ -806,23 +676,27 @@ _static_ void __launchpad_main_loop(int main_fd)
                        unlink(sock_path);
 
                        PERF("prepare exec - first done");
-                       _E("lock up test log(no error) : prepare exec - first done");
+                       _D("lock up test log(no error) : prepare exec - first done");
+
+                       __appid = strdup(pkg_name);
+                       aul_set_preinit_appid(__appid);
+                       atexit(__release_appid_at_exit);
 
                        if (__prepare_exec(pkg_name, app_path,
                                           menu_info, kb) < 0) {
-                               _E("preparing work fail to launch - "
+                               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");
+                       _D("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);
+               SECURE_LOGD("==> real launch pid : %d %s\n", pid, app_path);
                is_real_launch = 1;
        }
 
@@ -830,21 +704,6 @@ _static_ void __launchpad_main_loop(int main_fd)
        __send_result_to_caller(clifd, pid);
 
        if (pid > 0) {
-               int ret;
-               ret = ac_check_launch_privilege(pkg_name, menu_info->pkg_type, pid);
-               _D("ac_check_launch_privilege : %d", ret);
-               switch (pkt->cmd) {
-               case APP_OPEN:
-               case APP_RESUME:
-                       __add_history(cr.pid, pid, pkg_name, NULL, app_path);
-                       break;
-               case APP_START:
-               case APP_START_RES:
-                       __add_history(cr.pid, pid, pkg_name, kb, app_path);
-                       break;
-               default:
-                       _D("no launch case");
-               }
                if (is_real_launch) {
                        /*TODO: retry*/
                        __signal_block_sigchld();
@@ -877,9 +736,6 @@ _static_ int __launchpad_pre_init(int argc, char **argv)
        /* signal init*/
        __signal_init();
 
-       /* dac init*/
-       __dac_init();
-
        /* get my(launchpad) command line*/
        launchpad_cmdline = __proc_get_cmdline_bypid(getpid());
        if (launchpad_cmdline == NULL) {
@@ -897,14 +753,14 @@ _static_ int __launchpad_pre_init(int argc, char **argv)
 
        __preload_init(argc, argv);
 
-       __preexec_init(argc, argv);
+//     __preexec_init(argc, argv);
 
        return fd;
 }
 
 _static_ int __launchpad_post_init()
 {
-       /* Setting this as a global variable to keep track 
+       /* Setting this as a global variable to keep track
        of launchpad poll cnt */
        /* static int initialized = 0;*/
 
@@ -938,11 +794,19 @@ 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;
 
-               /* init with concerning X & EFL (because of booting 
+               /* init with concerning X & EFL (because of booting
                sequence problem)*/
                if (__launchpad_post_init() < 0) {
                        _E("launcpad post init failed");
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 1764cf3..f9f719b 100755 (executable)
@@ -20,7 +20,7 @@
  */
 
 
-#ifdef PRELOAD_ACTIVATE 
+#ifdef PRELOAD_ACTIVATE
 
 #include <dlfcn.h>
 #define PRELOAD_FILE SHARE_PREFIX"/preload_list.txt"
@@ -59,7 +59,7 @@ static inline void __preload_init(int argc, char **argv)
 
        while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) > 0) {
                soname[strlen(soname) - 1] = 0;
-               handle = dlopen(soname, RTLD_NOW);
+               handle = dlopen((const char *) soname, RTLD_NOW);
                if (handle == NULL)
                        continue;
                _D("preload %s# - handle : %x\n", soname, handle);
@@ -114,24 +114,46 @@ 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) {
                        _E("change cmdline fail");
+                       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);
index 8b06c09..3ccda07 100644 (file)
@@ -1,3 +1,4 @@
-/usr/lib/libappcore-efl.so
-/usr/lib/libappcore-common.so
+/usr/lib/libappcore-efl.so.1
+/usr/lib/libappcore-common.so.1
+/usr/lib/libcapi-appfw-application.so.0
 /usr/lib/ecore/immodules/libisf-imf-module.so
diff --git a/packaging/ac.service b/packaging/ac.service
new file mode 100644 (file)
index 0000000..22fe171
--- /dev/null
@@ -0,0 +1,13 @@
+[Unit]
+Description=Start the Access Control server
+After=dbus.service vconf-setup.service
+
+[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
+
+[Install]
+WantedBy=multi-user.target
index a332a9b..854de5e 100644 (file)
@@ -1,13 +1,19 @@
 Name:       aul
 Summary:    App utility library
-Version:    0.0.186
-Release:    1
+Version:    0.2.3.0
+Release:    6
 Group:      System/Libraries
-License:    Apache License, Version 2.0
+License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
+Source101:  ac.service
+Source102:  launchpad-preload.service
 
 Requires(post): /sbin/ldconfig
+Requires(post): /usr/bin/systemctl
 Requires(postun): /sbin/ldconfig
+Requires(postun): /usr/bin/systemctl
+Requires(preun): /usr/bin/systemctl
+
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(dbus-glib-1)
 BuildRequires:  pkgconfig(sqlite3)
@@ -24,7 +30,45 @@ BuildRequires:  pkgconfig(rua)
 BuildRequires:  pkgconfig(ecore-x)
 BuildRequires:  pkgconfig(ecore-input)
 BuildRequires:  pkgconfig(utilX)
-
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(pkgmgr-info)
+BuildRequires:  pkgconfig(libsmack)
+#BuildRequires:  pkgconfig(system-resource)
+BuildRequires:  pkgconfig(libresourced)
+BuildRequires:  pkgconfig(security-server)
+
+%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
 
 %description
 Application utility library
@@ -42,7 +86,83 @@ Application utility library (devel)
 %setup -q
 
 %build
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+%if 0%{?sec_build_binary_debug_enable}
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%endif
+%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}
 
@@ -50,53 +170,54 @@ make %{?jobs:-j%jobs}
 rm -rf %{buildroot}
 %make_install
 
-mkdir -p %{buildroot}/etc/init.d
-install -m 755 launchpad_run %{buildroot}/etc/init.d
-chmod +x %{buildroot}/usr/bin/aul_service.sh
-chmod +x %{buildroot}/usr/bin/aul_service_test.sh
+mkdir -p %{buildroot}/opt/dbspace
+%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
+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
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/%{name}
 
 
 %post
+vconftool set -t int db/setting/effect_image 1 -f -s system::vconf_inhouse
 
-/sbin/ldconfig
-mkdir -p /etc/rc.d/rc3.d
-mkdir -p /etc/rc.d/rc4.d
-ln -sf /etc/init.d/launchpad_run /etc/rc.d/rc3.d/S35launchpad_run
-ln -sf /etc/init.d/launchpad_run /etc/rc.d/rc4.d/S80launchpad_run
-
-mkdir -p /opt/dbspace
-sqlite3 /opt/dbspace/.mida.db < /usr/share/aul/mida_db.sql
-rm -rf /usr/share/aul/mida_db.sql
-
-chown 0:0 /usr/lib/libaul.so.0.1.0
-chown 0:5000 /opt/dbspace/.mida.db
-chown 0:5000 /opt/dbspace/.mida.db-journal
-
-chmod 644 /usr/lib/libaul.so.0.1.0
-chmod 664 /opt/dbspace/.mida.db
-chmod 664 /opt/dbspace/.mida.db-journal
-
-%postun -p /sbin/ldconfig
 
 %files
-/usr/lib/*.so.*
-/etc/init.d/launchpad_run
-/usr/bin/aul_service.sh
-/usr/bin/aul_service_test.sh
-/usr/share/aul/mida_db.sql
-/usr/bin/aul_mime.sh
-/usr/bin/aul_test
-/usr/bin/launch_app
+%manifest aul.manifest
+%attr(0644,root,root) %{_libdir}/libaul.so.0
+%attr(0644,root,root) %{_libdir}/libaul.so.0.1.0
+%if 0%{?appfw_feature_default_fake_image}
+%attr(0755,root,root) %{_bindir}/config_splash.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/preexec_list.txt
-/usr/bin/launchpad_preloading_preinitializing_daemon
-/usr/bin/ac_daemon
+%if 0%{?appfw_feature_default_fake_image}
+/usr/share/splash_images/*
+%endif
+%{_bindir}/launchpad_preloading_preinitializing_daemon
+%{_bindir}/amd
+%{_bindir}/daemon-manager-release-agent
+%{_bindir}/daemon-manager-launch-agent
+%{_libdir}/systemd/system/ac.service
+%{_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
+/usr/share/license/%{name}
 
 %files devel
-/usr/include/aul/*.h
-/usr/lib/*.so
-/usr/lib/pkgconfig/*.pc
-
-
+%{_includedir}/aul/*.h
+%{_includedir}/aul/launch/*.h
+%{_includedir}/aul/launchpad/*.h
+%{_libdir}/*.so
+%{_libdir}/*.a
+%{_libdir}/pkgconfig/*.pc
diff --git a/packaging/launchpad-preload.service b/packaging/launchpad-preload.service
new file mode 100644 (file)
index 0000000..9f644be
--- /dev/null
@@ -0,0 +1,13 @@
+[Unit]
+Description=Start the Access Control server
+After=dbus.service vconf-setup.service ac.service
+
+[Service]
+EnvironmentFile=/run/tizen-mobile-env
+ExecStart=/usr/bin/launchpad_preloading_preinitializing_daemon "                                                                                                                                                                                                         "
+TimeoutStopSec=3s
+Restart=always
+RestartSec=0
+
+[Install]
+WantedBy=multi-user.target
index c4b04a5..d54a9b7 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;
 
 static int (*_app_launch_handler) (int pid, void *data);
 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;
 
@@ -41,7 +57,9 @@ __app_dbus_signal_filter(DBusConnection *conn, DBusMessage *message,
 {
        const char *sender;
        const char *interface;
-       int pid;
+       const char *cooldown_status;
+       int pid = -1;
+       int status;
 
        DBusError error;
        dbus_error_init(&error);
@@ -50,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) {
@@ -82,19 +100,65 @@ __app_dbus_signal_filter(DBusConnection *conn, DBusMessage *message,
                }
                if (_app_launch_handler)
                        _app_launch_handler(pid, _app_launch_data);
+       } else if (dbus_message_is_signal(
+         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;
 }
 
-int __app_dbus_signal_handler_init()
+int __app_dbus_signal_handler_init(void)
 {
-       DBusError error;
-       char rule[MAX_LOCAL_BUFSZ];
+       int ret = 0;
 
        if (app_dbus_signal_handler_initialized)
                return 0;
 
+       ret = __app_dbus_signal_handler_init_with_param(AUL_DBUS_PATH, AUL_DBUS_SIGNAL_INTERFACE);
+
+       app_dbus_signal_handler_initialized = 1;
+
+       return ret;
+}
+
+int __app_dbus_signal_handler_init_with_param(const char* path, const char* interface)
+{
+       DBusError error;
+       char rule[MAX_LOCAL_BUFSZ];
+
        dbus_error_init(&error);
        bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
        if (!bus) {
@@ -105,8 +169,7 @@ int __app_dbus_signal_handler_init()
        dbus_connection_setup_with_g_main(bus, NULL);
 
        snprintf(rule, MAX_LOCAL_BUFSZ,
-                "path='%s',type='signal',interface='%s'", AUL_DBUS_PATH,
-                AUL_DBUS_SIGNAL_INTERFACE);
+                "path='%s',type='signal',interface='%s'", path, interface);
        /* listening to messages */
        dbus_bus_add_match(bus, rule, &error);
        if (dbus_error_is_set(&error)) {
@@ -116,31 +179,42 @@ int __app_dbus_signal_handler_init()
        }
 
        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;
-
-       app_dbus_signal_handler_initialized = 1;
+       }
 
        _D("app signal initialized");
 
        return 0;
 }
 
-int __app_dbus_signal_handler_fini()
+int __app_dbus_signal_handler_fini(void)
 {
-       DBusError error;
-       char rule[MAX_LOCAL_BUFSZ];
+       int ret = 0;
 
        if (!app_dbus_signal_handler_initialized)
                return 0;
 
+       ret = __app_dbus_signal_handler_fini_with_param(AUL_DBUS_PATH, AUL_DBUS_SIGNAL_INTERFACE);
+
+       app_dbus_signal_handler_initialized = 0;
+
+       return ret;
+}
+
+int __app_dbus_signal_handler_fini_with_param(const char* path, const char* interface)
+{
+       DBusError error;
+       char rule[MAX_LOCAL_BUFSZ];
+
+
        dbus_error_init(&error);
 
        dbus_connection_remove_filter(bus, __app_dbus_signal_filter, NULL);
 
        snprintf(rule, MAX_LOCAL_BUFSZ,
-                "path='%s',type='signal',interface='%s'", AUL_DBUS_PATH,
-                AUL_DBUS_SIGNAL_INTERFACE);
+                "path='%s',type='signal',interface='%s'", path, interface);
        dbus_bus_remove_match(bus, rule, &error);
        if (dbus_error_is_set(&error)) {
                _E("Fail to rule unset: %s", error.message);
@@ -151,8 +225,6 @@ int __app_dbus_signal_handler_fini()
        dbus_connection_close(bus);
        dbus_connection_unref(bus);
 
-       app_dbus_signal_handler_initialized = 0;
-
        _D("app signal finialized");
 
        return 0;
@@ -195,3 +267,132 @@ SLPAPI int aul_listen_app_launch_signal(int (*func) (int, void *), void *data)
 
        return AUL_R_OK;
 }
+
+SLPAPI int aul_listen_booting_done_signal(int (*func) (int, void *), void *data)
+{
+       if (func) {
+               if (__app_dbus_signal_handler_init_with_param(SYSTEM_PATH_CORE, SYSTEM_INTERFACE_CORE) < 0) {
+                       _E("error app signal init");
+                       return AUL_R_ERROR;
+               }
+       } else if (_booting_done_handler == NULL) {
+               if (__app_dbus_signal_handler_fini_with_param(SYSTEM_PATH_CORE, SYSTEM_INTERFACE_CORE) < 0) {
+                       _E("error app signal fini");
+                       return AUL_R_ERROR;
+               }
+       }
+       _booting_done_handler = func;
+       _booting_done_data = data;
+
+       return AUL_R_OK;
+
+}
+
+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 732da1b..29d95c2 100755 (executable)
 #include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <string.h>
 #include <sys/stat.h>
-#include <sys/xattr.h>
+#include <sys/smack.h>
 #include <errno.h>
 #include <fcntl.h>
 
@@ -39,7 +40,7 @@ static int __connect_client_sock(int sockfd, const struct sockaddr *saptr, sockl
 static inline void __set_sock_option(int fd, int cli)
 {
        int size;
-       struct timeval tv = { 3, 200 * 1000 };  /*  3.2 sec */
+       struct timeval tv = { 5, 200 * 1000 };  /*  5.2 sec */
 
        size = AUL_SOCK_MAXBUFF;
        setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
@@ -57,7 +58,7 @@ int __create_server_sock(int pid)
 
        /* Create basedir for our sockets */
        orig_mask = umask(0);
-       mkdir(AUL_SOCK_PREFIX, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
+       (void) mkdir(AUL_SOCK_PREFIX, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
        umask(orig_mask);
 
        fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
@@ -66,55 +67,60 @@ 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;
                }
        }
 
-       bzero(&saddr, sizeof(saddr));
+       memset(&saddr, 0, sizeof(saddr));
        saddr.sun_family = AF_UNIX;
        snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pid);
        unlink(saddr.sun_path);
 
        /* labeling to socket for SMACK */
        if(getuid() == 0) {     // this is meaningful iff current user is ROOT
-               if((fsetxattr(fd, "security.SMACK64IPOUT", "@", 2, 0)) < 0) {
+               if(smack_fsetlabel(fd, "@", SMACK_LABEL_IPOUT) != 0) {
                        /* in case of unsupported filesystem on 'socket' */
                        /* or permission error by using 'emulator', bypass*/
                        if((errno != EOPNOTSUPP) && (errno != EPERM)) {
                                _E("labeling to socket(IPOUT) error");
+                               close(fd);
                                return -1;
                        }
                }
-               if((fsetxattr(fd, "security.SMACK64IPIN", "*", 2, 0)) < 0) {
+               if(smack_fsetlabel(fd, "*", SMACK_LABEL_IPIN) != 0) {
                        /* in case of unsupported filesystem on 'socket' */
                        /* or permission error by using 'emulator', bypass*/
                        if((errno != EOPNOTSUPP) && (errno != EPERM)) {
                                _E("labeling to socket(IPIN) error");
+                               close(fd);
                                return -1;
                        }
                }
        }
 
        if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
-               _E("bind error");
+               _E("bind error: %d", errno);
+               close(fd);
                return -1;
        }
 
        if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
                /* Flawfinder: ignore*/
                _E("failed to change the socket permission");
+               close(fd);
                return -1;
        }
 
        __set_sock_option(fd, 0);
 
-       if (listen(fd, 10) == -1) {
-               _E("listen error");
+       if (listen(fd, 128) == -1) {
+               _E("listen error: %d", errno);
+               close(fd);
                return -1;
        }
 
@@ -141,20 +147,20 @@ int __create_client_sock(int pid)
 {
        int fd = -1;
        struct sockaddr_un saddr = { 0, };
-       int retry = 1;
+       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;
                }
        }
@@ -165,9 +171,9 @@ 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(100 * 1000);
+                       usleep((1+2*(2-retry))*100 * 1000);
                        retry--;
                        goto retry_con;
                }
@@ -199,7 +205,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);
                }
        }
@@ -214,8 +221,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);
@@ -229,9 +237,9 @@ static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t
                return (-1);    /* select error: sockfd not set*/
 
  done:
-       fcntl(fd, F_SETFL, flags);      
+       (void) fcntl(fd, F_SETFL, flags);
        if (error) {
-               close(fd);      
+               close(fd);
                errno = error;
                return (-1);
        }
@@ -245,6 +253,7 @@ int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
 {
        int fd;
        int len;
+       int ret;
        int res = 0;
        app_pkt_t *pkt = NULL;
 
@@ -253,9 +262,22 @@ int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
                return -EINVAL;
        }
 
+       _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) {
+               struct timeval tv = { 25, 0 };
+               ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+               if ( ret < 0 ) {
+                       _E("setsockopt error");
+               }
+       }
 
        pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
        if (NULL == pkt) {
@@ -270,43 +292,211 @@ int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
 
        if ((len = send(fd, pkt, datalen + 8, 0)) != datalen + 8) {
                _E("sendto() failed - %d %d (errno %d)", len, datalen + 8, errno);
-               if (errno == EPIPE) {
-                       _E("pid:%d, fd:%d\n", pid, fd);
-               }
-               close(fd);
-               if (pkt) {
-                       free(pkt);
-                       pkt = NULL;
+               if(len > 0) {
+                       while (len != datalen + 8) {
+                               ret = send(fd, &pkt->data[len-8], datalen + 8 - len, 0);
+                               if (ret < 0) {
+                                       _E("second send() failed - %d %d (errno: %d)", ret, datalen + 8, errno);
+                                       if (errno == EPIPE) {
+                                               _E("pid:%d, fd:%d\n", pid, fd);
+                                       }
+                                       close(fd);
+                                       if (pkt) {
+                                               free(pkt);
+                                               pkt = NULL;
+                                       }
+                                       return -ECOMM;
+                               }
+                               len += ret;
+                               _D("send() len - %d %d", len, datalen + 8);
+                       }
+               } else {
+                       if (errno == EPIPE) {
+                               _E("pid:%d, fd:%d\n", pid, fd);
+                       }
+                       close(fd);
+                       if (pkt) {
+                               free(pkt);
+                               pkt = NULL;
+                       }
+
+                       _E("send() failed: %d %s", errno, strerror(errno));
+                       return -ECOMM;
                }
-               return -ECOMM;
        }
        if (pkt) {
                free(pkt);
                pkt = NULL;
        }
 
+retry_recv:
        len = recv(fd, &res, sizeof(int), 0);
        if (len == -1) {
                if (errno == EAGAIN) {
-                       _E("recv timeout \n");
+                       _E("recv timeout : cmd(%d) %s", cmd, strerror(errno));
                        res = -EAGAIN;
+               } else if (errno == EINTR) {
+                       _D("recv : %s", strerror(errno));
+                       goto retry_recv;
                } else {
-                       _E("recv error\n");
+                       _E("recv error : %s", strerror(errno));
                        res = -ECOMM;
                }
-       } else
-               _D("recv result  = %d (%d)", res, len);
+       }
+       close(fd);
+
+       return res;
+}
+
+int __app_send_raw_with_noreply(int pid, int cmd, unsigned char *kb_data, int datalen)
+{
+       int fd;
+       int len;
+       int ret;
+       int res = 0;
+       app_pkt_t *pkt = NULL;
+
+       if (kb_data == NULL || datalen > AUL_SOCK_MAXBUFF - 8) {
+               _E("keybundle error\n");
+               return -EINVAL;
+       }
+
+       _D("pid(%d) : cmd(%d)", pid, cmd);
+
+       fd = __create_client_sock(pid);
+       if (fd < 0)
+               return -ECOMM;
+
+       pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+       if (NULL == pkt) {
+               _E("Malloc Failed!");
+               return -ENOMEM;
+       }
+       memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+       pkt->cmd = cmd;
+       pkt->len = datalen;
+       memcpy(pkt->data, kb_data, datalen);
+
+       if ((len = send(fd, pkt, datalen + 8, 0)) != datalen + 8) {
+               _E("sendto() failed - %d %d (errno %d)", len, datalen + 8, errno);
+               if(len > 0) {
+                       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);
+                                       if (errno == EPIPE) {
+                                               _E("pid:%d, fd:%d\n", pid, fd);
+                                       }
+                                       close(fd);
+                                       if (pkt) {
+                                               free(pkt);
+                                               pkt = NULL;
+                                       }
+                                       return -ECOMM;
+                               }
+                               len += ret;
+                               _D("sendto() len - %d %d", len, datalen + 8);
+                       }
+               } else {
+                       if (errno == EPIPE) {
+                               _E("pid:%d, fd:%d\n", pid, fd);
+                       }
+                       close(fd);
+                       if (pkt) {
+                               free(pkt);
+                               pkt = NULL;
+                       }
+                       return -ECOMM;
+               }
+       }
+       if (pkt) {
+               free(pkt);
+               pkt = NULL;
+       }
+
        close(fd);
 
        return res;
 }
 
+int __app_send_raw_with_delay_reply(int pid, int cmd, unsigned char *kb_data, int datalen)
+{
+       int fd;
+       int len;
+       int ret;
+       app_pkt_t *pkt = NULL;
+
+       if (kb_data == NULL || datalen > AUL_SOCK_MAXBUFF - 8) {
+               _E("keybundle error\n");
+               return -EINVAL;
+       }
+
+       _D("pid(%d) : cmd(%d)", pid, cmd);
+
+       fd = __create_client_sock(pid);
+       if (fd < 0)
+               return -ECOMM;
+
+       pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+       if (NULL == pkt) {
+               _E("Malloc Failed!");
+               return -ENOMEM;
+       }
+       memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+       pkt->cmd = cmd;
+       pkt->len = datalen;
+       memcpy(pkt->data, kb_data, datalen);
+
+       if ((len = send(fd, pkt, datalen + 8, 0)) != datalen + 8) {
+               _E("sendto() failed - %d %d (errno %d)", len, datalen + 8, errno);
+               if(len > 0) {
+                       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);
+                                       if (errno == EPIPE) {
+                                               _E("pid:%d, fd:%d\n", pid, fd);
+                                       }
+                                       close(fd);
+                                       if (pkt) {
+                                               free(pkt);
+                                               pkt = NULL;
+                                       }
+                                       return -ECOMM;
+                               }
+                               len += ret;
+                               _D("sendto() len - %d %d", len, datalen + 8);
+                       }
+               } else {
+                       if (errno == EPIPE) {
+                               _E("pid:%d, fd:%d\n", pid, fd);
+                       }
+                       close(fd);
+                       if (pkt) {
+                               free(pkt);
+                               pkt = NULL;
+                       }
+                       return -ECOMM;
+               }
+       }
+       if (pkt) {
+               free(pkt);
+               pkt = NULL;
+       }
+
+       return fd;
+}
+
 app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr)
 {
        int len;
+       int ret;
        struct sockaddr_un aul_addr = { 0, };
        int sun_size;
        app_pkt_t *pkt = NULL;
+       int pkt_header_size = offsetof(app_pkt_t, data);
        int cl = sizeof(struct ucred);
 
        sun_size = sizeof(struct sockaddr_un);
@@ -314,7 +504,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;
        }
 
@@ -337,21 +527,43 @@ 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) || (len != (pkt->len + 8))) {
+       if (len < pkt_header_size) {
                _E("recv error %d %d", len, pkt->len);
                free(pkt);
                close(*clifd);
                return NULL;
        }
 
+       if (pkt->len < 0 || pkt->len > (AUL_SOCK_MAXBUFF - pkt_header_size)) {
+               _E("package length error (%d)", pkt->len);
+               free(pkt);
+               close(*clifd);
+               return NULL;
+       }
+
+       while (len < (pkt->len + pkt_header_size)) {
+               ret = recv(*clifd, &pkt->data[len - pkt_header_size],
+                       (pkt->len + pkt_header_size) - len, 0);
+               if (ret <= 0) { /* ret may be 0 when the peer has performed an orderly shutdown */
+                       _E("recv error: %d %d %d", errno, len, pkt->len);
+                       free(pkt);
+                       close(*clifd);
+                       return NULL;
+               }
+               len += ret;
+               _D("recv len %d %d", len, pkt->len);
+       }
+
        return pkt;
 }
 
-app_pkt_t *__app_send_cmd_with_result(int pid, int cmd)
+app_pkt_t *__app_send_cmd_with_result(int pid, int cmd, unsigned char *kb_data, int datalen)
 {
        int fd;
        int len;
@@ -369,10 +581,13 @@ app_pkt_t *__app_send_cmd_with_result(int pid, int cmd)
        memset(pkt, 0, AUL_SOCK_MAXBUFF);
 
        pkt->cmd = cmd;
-       pkt->len = 0;
+       pkt->len = datalen;
+       if(kb_data) {
+               memcpy(pkt->data, kb_data, datalen);
+       }
 
-       if ((len = send(fd, pkt, 8, 0)) != 8) {
-               _E("sendto() failed - %d", len);
+       if ((len = send(fd, pkt, datalen + 8, 0)) != datalen + 8) {
+               _E("send() failed: %d len: %d", errno, len);
                if (errno == EPIPE) {
                        _E("pid:%d, fd:%d\n", pid, fd);
                }
@@ -389,12 +604,14 @@ retry_recv:
                if (errno == EAGAIN) {
                        _E("recv timeout \n");
                        free(pkt);
+                       close(fd);
                        return NULL;
                } 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;
                }
        } else
diff --git a/src/aul_path.c b/src/aul_path.c
new file mode 100755 (executable)
index 0000000..77150e4
--- /dev/null
@@ -0,0 +1,376 @@
+/*
+ * 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);
+}
+
+SLPAPI char *aul_get_cmdline_bypid(int pid)
+{
+       return __proc_get_cmdline_bypid(pid);
+}
index da44d65..809757b 100755 (executable)
--- a/src/key.c
+++ b/src/key.c
@@ -75,6 +75,13 @@ SLPAPI int aul_key_init(int (*aul_handler) (bundle *, void *), void *data)
        src = g_source_new(&funcs, sizeof(GSource));
 
        gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+       if (gpollfd == NULL) {
+               _E("out of memory");
+               g_source_unref(src);
+               close(fd);
+               return AUL_R_ERROR;
+       }
+
        gpollfd->events = POLLIN;
        gpollfd->fd = fd;
 
index 5aff5d4..efeb9e5 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"
@@ -36,6 +39,7 @@
 #include "simple_util.h"
 #include "launch.h"
 #include "key.h"
+#include "aul_util.h"
 
 static int aul_initialized = 0;
 static int aul_fd;
@@ -54,6 +58,16 @@ 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 _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();
 
 int aul_is_initialized()
@@ -70,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;
 }
 
@@ -87,6 +115,20 @@ 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'
  * @param[in]  pid             receiver's pid
@@ -114,6 +156,56 @@ SLPAPI int app_send_cmd(int pid, int cmd, bundle *kb)
                case -ELOCALLAUNCH_ID:
                        res = AUL_R_LOCAL;
                        break;
+               case -EILLEGALACCESS:
+                       res = AUL_R_EILLACC;
+                       break;
+               case -ETERMINATING:
+                       res = AUL_R_ETERMINATING;
+                       break;
+               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;
+               }
+       }
+       free(kb_data);
+
+       return res;
+}
+
+SLPAPI int app_send_cmd_with_noreply(int pid, int cmd, bundle *kb)
+{
+       int datalen;
+       bundle_raw *kb_data;
+       int res;
+
+       bundle_encode(kb, &kb_data, &datalen);
+       if ((res = __app_send_raw_with_noreply(pid, cmd, kb_data, datalen)) < 0) {
+               switch (res) {
+               case -EINVAL:
+                       res = AUL_R_EINVAL;
+                       break;
+               case -ECOMM:
+                       res = AUL_R_ECOMM;
+                       break;
+               case -EAGAIN:
+                       res = AUL_R_ETIMEOUT;
+                       break;
+               case -ELOCALLAUNCH_ID:
+                       res = AUL_R_LOCAL;
+                       break;
+               case -EILLEGALACCESS:
+                       res = AUL_R_EILLACC;
+                       break;
                default:
                        res = AUL_R_ERROR;
                }
@@ -186,6 +278,7 @@ int app_request_to_launchpad(int cmd, const char *pkgname, bundle *kb)
        int must_free = 0;
        int ret = 0;
 
+       SECURE_LOGD("launch request : %s", pkgname);
        if (kb == NULL) {
                kb = bundle_create();
                must_free = 1;
@@ -194,15 +287,40 @@ int app_request_to_launchpad(int cmd, const char *pkgname, bundle *kb)
 
        bundle_add(kb, AUL_K_PKG_NAME, pkgname);
        __set_stime(kb);
-       ret = app_send_cmd(LAUNCHPAD_PID, cmd, kb);
-
-       if (ret == AUL_R_LOCAL) {
+       if(cmd == APP_START_ASYNC)
+               ret = app_send_cmd_with_noreply(AUL_UTIL_PID, cmd, kb);
+       else
+               ret = app_send_cmd(AUL_UTIL_PID, cmd, kb);
+
+       _D("launch request result : %d", ret);
+       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);
                                break;
@@ -227,8 +345,11 @@ int app_request_to_launchpad(int cmd, const char *pkgname, bundle *kb)
 static int __send_result_to_launchpad(int fd, int res)
 {
        if (send(fd, &res, sizeof(int), MSG_NOSIGNAL) < 0) {
-               if (errno == EPIPE)
+               if (errno == EPIPE) {
                        _E("send failed due to EPIPE.\n");
+                       close(fd);
+                       return -1;
+               }
                _E("send fail to client");
        }
        close(fd);
@@ -236,7 +357,7 @@ static int __send_result_to_launchpad(int fd, int res)
 }
 
 /**
- * @brief      caller & callee's sock handler  
+ * @brief      caller & callee's sock handler
  */
 int aul_sock_handler(int fd)
 {
@@ -245,8 +366,9 @@ int aul_sock_handler(int fd)
        int clifd;
        struct ucred cr;
 
-       const char *pid_str;
+       const char *str = NULL;
        int pid;
+       int ret;
 
        if ((pkt = __app_recv_raw(fd, &clifd, &cr)) == NULL) {
                _E("recv error");
@@ -260,11 +382,27 @@ int aul_sock_handler(int fd)
                return -1;
        }
 
-       __send_result_to_launchpad(clifd, 0);
+       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);
+                       return -1;
+               }
+       } else {
+               close(clifd);
+       }
 
        switch (pkt->cmd) {
        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;
@@ -279,19 +417,25 @@ int aul_sock_handler(int fd)
                break;
 
        case APP_TERM_BY_PID:   /* run in callee */
+       case APP_TERM_BY_PID_ASYNC:
                app_terminate();
                break;
 
+       case APP_TERM_REQ_BY_PID:       /* run in callee */
+               app_subapp_terminate_request();
+               break;
+
        case APP_RESULT:        /* run in caller */
        case APP_CANCEL:
                kbundle = bundle_decode(pkt->data, pkt->len);
                if (kbundle == NULL)
                        goto err;
 
-               pid_str = bundle_get_val(kbundle, AUL_K_CALLEE_PID);
-               pid = atoi(pid_str);
-
-               app_result(pkt->cmd, kbundle, pid);
+               str = bundle_get_val(kbundle, AUL_K_CALLEE_PID);
+               if(str) {
+                       pid = atoi(str);
+                       app_result(pkt->cmd, kbundle, pid);
+               }
                bundle_free(kbundle);
                break;
 
@@ -303,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");
        }
@@ -334,7 +487,7 @@ int aul_make_bundle_from_argv(int argc, char **argv, bundle **kb)
                        _E("Malloc failed");
                        return AUL_R_ERROR;
                }
-       
+
                bundle_add(*kb, AUL_K_ARGV0, buf);
        }
        if (buf) {              /*Prevent FIX: ID 38717 */
@@ -372,7 +525,7 @@ int aul_register_init_callback(
 int aul_initialize()
 {
        if (aul_initialized) {
-               _E("aul already initialized");
+               //_E("aul already initialized");
                return AUL_R_ECANCELED;
        }
 
@@ -388,12 +541,11 @@ int aul_initialize()
 
 SLPAPI void aul_finalize()
 {
-       int ret;
 
        aul_launch_fini();
 
        if (aul_initialized) {
-               ret = close(aul_fd);
+               close(aul_fd);
        }
 
        return;
@@ -402,35 +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;
+
+       return app_request_to_launchpad(APP_START, appid, kb);
+}
 
+SLPAPI int aul_launch_app_async(const char *appid, bundle *kb)
+{
        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_ASYNC, appid, kb);
 }
 
-SLPAPI int aul_open_app(const char *appid)
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+SLPAPI int aul_launch_app_for_multi_instance(const char *appid, bundle *kb)
 {
-       int ret;
+       if (appid == NULL)
+               return AUL_R_EINVAL;
+
+       return app_request_to_launchpad(APP_START_MULTI_INSTANCE, appid, kb);
+}
+#endif
 
+SLPAPI int aul_open_app(const char *appid)
+{
        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)
@@ -459,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];
@@ -472,5 +659,50 @@ SLPAPI int aul_kill_pid(int pid)
        return ret;
 }
 
-/* vi: set ts=8 sts=8 sw=8: */
+#ifdef _APPFW_FEATURE_PROCESS_POOL
+SLPAPI void aul_set_preinit_window(void *evas_object)
+{
+        __window_object = evas_object;
+}
+
+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
+
+#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 273749e..eca6dd7 100755 (executable)
@@ -27,6 +27,7 @@
 #include "aul_api.h"
 #include "launch.h"
 #include "simple_util.h"
+#include <Ecore.h>
 
 static GSource *src;
 
@@ -36,6 +37,22 @@ static gboolean __aul_glib_dispatch(GSource *src, GSourceFunc callback,
 static gboolean __aul_glib_prepare(GSource *src, gint *timeout);
 static gboolean __app_start_internal(gpointer data);
 
+static void __aul_glib_finalize(GSource *src)
+{
+       GSList *fd_list;
+       GPollFD *tmp;
+
+       fd_list = src->poll_fds;
+       do {
+               tmp = (GPollFD *) fd_list->data;
+               g_free(tmp);
+
+               fd_list = fd_list->next;
+       } while (fd_list);
+
+       return;
+}
+
 static gboolean __aul_glib_check(GSource *src)
 {
        GSList *fd_list;
@@ -68,7 +85,7 @@ GSourceFuncs funcs = {
        .prepare = __aul_glib_prepare,
        .check = __aul_glib_check,
        .dispatch = __aul_glib_dispatch,
-       .finalize = NULL
+       .finalize = __aul_glib_finalize
 };
 
 gboolean __aul_glib_handler(gpointer data)
@@ -106,6 +123,13 @@ SLPAPI int aul_launch_init(
        src = g_source_new(&funcs, sizeof(GSource));
 
        gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+       if (gpollfd == NULL) {
+               _E("out of memory");
+               g_source_unref(src);
+               close(fd);
+               return AUL_R_ERROR;
+       }
+
        gpollfd->events = POLLIN;
        gpollfd->fd = fd;
 
@@ -126,6 +150,7 @@ SLPAPI int aul_launch_init(
 SLPAPI int aul_launch_fini()
 {
        g_source_destroy(src);
+       return AUL_R_OK;
 }
 
 SLPAPI int aul_launch_argv_handler(int argc, char **argv)
@@ -145,6 +170,27 @@ SLPAPI int aul_launch_argv_handler(int argc, char **argv)
                return AUL_R_ERROR;
 }
 
+SLPAPI int aul_launch_argv_handler_for_efl(int argc, char **argv)
+{
+       bundle *b = NULL;
+
+       Ecore_Idler *idler = NULL;
+
+       if (!aul_is_initialized())
+               return AUL_R_ENOINIT;
+
+       b = bundle_import_from_argv(argc, argv);
+       if (b == NULL) {
+               _E("bundle for APP_START is NULL");
+       }
+
+       idler = ecore_idler_add(__app_start_internal, b);
+       if (idler)
+               return AUL_R_OK;
+       else
+               return AUL_R_ERROR;
+}
+
 SLPAPI int aul_launch_local(bundle *b)
 {
        if (!aul_is_initialized())
index db9b83a..ed8bb20 100755 (executable)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <pthread.h>
 
 #include "aul.h"
 #include "aul_api.h"
 #include "app_sock.h"
 #include "simple_util.h"
 #include "launch.h"
+#include "aul_util.h"
 
 /*#define ACTIVATE_PREEMPT_FEATURE*/
 
@@ -36,11 +38,23 @@ typedef struct _app_resultcb_info_t {
        int launched_pid;
        void (*cb_func) (bundle *kb, int is_cancel, void *data);
        void *priv_data;
+       void (*caller_cb) (int launched_pid, void *data);
+       void *caller_data;
        struct _app_resultcb_info_t *next;
 } 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;
+void *subapp_data = NULL;
+
+pthread_mutex_t result_lock = PTHREAD_MUTEX_INITIALIZER;
 
 static void __add_resultcb(int pid, void (*cbfunc) (bundle *, int, void *),
                         void *data);
@@ -63,6 +77,8 @@ static void __add_resultcb(int pid, void (*cbfunc) (bundle *, int, void *),
        info->launched_pid = pid;
        info->cb_func = cbfunc;
        info->priv_data = data;
+       info->caller_cb = NULL;
+       info->caller_data = NULL;
 
        info->next = rescb_head;
        rescb_head = info;
@@ -71,14 +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)
-                       return tmp;
+               if (tmp->launched_pid == pid) {
+                       ret = tmp;
+               }
                tmp = tmp->next;
        }
-       return NULL;
+       pthread_mutex_unlock(&result_lock);
+
+       return ret;
 }
 
 static void __remove_resultcb(app_resultcb_info_t *info)
@@ -105,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
@@ -135,21 +221,50 @@ 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);
+               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_resultcb(newinfo.launched_pid, newinfo.cb_func, newinfo.priv_data);
 
                _D("change callback - %s\n",AUL_K_FWD_CALLEE_PID);
-               
+
                goto end;
-       }               
+       }
 
        info->cb_func(kb, is_cancel, info->priv_data);
        __remove_resultcb(info);
@@ -210,15 +325,22 @@ static int __send_to_cancel(int pid)
 int _app_start_res_prepare(bundle *kb)
 {
        int pid;
+       const char* str = NULL;
 
        if (bundle_get_val(kb, AUL_K_WAIT_RESULT) == NULL)
                return 0;
 
+       str = bundle_get_val(kb, AUL_K_NO_CANCEL);
+       if( str && strncmp("1", str, 1) == 0) {
+               _D("no cancel");
+               return 0;
+       }
+
        if ((pid = __get_caller_pid(kb)) < 0) {
                _E("caller pid is not valid");
                return -1;
        }
-       /* If previous caller is still waiting result, 
+       /* If previous caller is still waiting result,
           send cancel packet to the caller. */
        if (latest_caller_pid != -1)
                __send_to_cancel(latest_caller_pid);
@@ -248,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)
@@ -257,17 +383,30 @@ SLPAPI int aul_launch_app_with_result(const char *pkgname, bundle *kb,
        if (pkgname == NULL || cbfunc == NULL || kb == NULL)
                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;
 }
 
 void __iterate(const char *key, const char *val, void *data)
 {
-       static int i=0; 
+       static int i=0;
        _D("%d %s %s", i++, key, val);
 }
 
@@ -278,44 +417,66 @@ 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;
-       
+
        caller = (char *)bundle_get_val(kb, AUL_K_CALLER_PID);
        if(caller == NULL) {
                _E("original msg doest not have caller pid");
                return AUL_R_EINVAL;
        }
-       
+
        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");
                return AUL_R_EINVAL;
        }
-       
+
        if(bundle_get_val(kb, AUL_K_WAIT_RESULT) != NULL) {
                ret = app_request_to_launchpad(APP_START_RES, pkgname, kb);
-               if(ret < 0) 
-                       goto end;       
+               if(ret < 0)
+                       goto end;
        } else {
                ret = app_request_to_launchpad(APP_START, pkgname, 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);
 
        ret = aul_create_result_bundle(dupb, &outb);
        if(ret < 0)
-               return ret;
+               goto end;
+
+#ifdef _APPFW_FEATURE_APP_CONTROL_LITE
+       _D("callee_pid(%d) caller_pid(%d)", callee_pid, caller_pid);
 
-       bundle_del(outb, AUL_K_FWD_CALLEE_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);
 
@@ -334,7 +495,7 @@ SLPAPI int aul_create_result_bundle(bundle *inb, bundle **outb)
        const char *pid_str;
 
        *outb = NULL;
-       
+
        if(inb == NULL){
                _E("return msg create fail");
                return AUL_R_EINVAL;
@@ -352,14 +513,14 @@ SLPAPI int aul_create_result_bundle(bundle *inb, bundle **outb)
        } else {
                _D("original msg is not msg with result");
        }
-       
+
 
        pid_str = bundle_get_val(inb, AUL_K_ORG_CALLER_PID);
        if(pid_str) {
                bundle_add(*outb, AUL_K_ORG_CALLER_PID, pid_str);
                goto end;
        }
-       
+
        pid_str = bundle_get_val(inb, AUL_K_CALLER_PID);
        if (pid_str == NULL) {
                _E("original msg doest not have caller pid");
@@ -377,21 +538,133 @@ int aul_send_result(bundle *kb, int is_cancel)
 {
        int pid;
        int ret;
+       int callee_pid;
+       int callee_pgid;
+       char callee_appid[256];
+       char tmp_pid[MAX_PID_STR_BUFSZ];
 
        if ((pid = __get_caller_pid(kb)) < 0)
                return AUL_R_EINVAL;
 
+       _D("caller pid : %d", pid);
+
        if (bundle_get_val(kb, AUL_K_SEND_RESULT) == NULL)
        {
                _D("original msg is not msg with result");
                return AUL_R_OK;
        }
 
-       ret = app_send_cmd(LAUNCHPAD_PID, (is_cancel==1)? APP_CANCEL : APP_RESULT, kb);
-       
+       callee_pid = getpid();
+       callee_pgid = getpgid(callee_pid);
+       snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", callee_pgid);
+       bundle_add(kb, AUL_K_CALLEE_PID, tmp_pid);
+
+       ret = aul_app_get_appid_bypid(callee_pid, callee_appid, sizeof(callee_appid));
+       if(ret == 0) {
+               bundle_add(kb, AUL_K_CALLEE_APPID, callee_appid);
+       } else {
+               _W("fail(%d) to get callee appid by pid", ret);
+       }
+
+       ret = app_send_cmd_with_noreply(AUL_UTIL_PID, (is_cancel==1)? APP_CANCEL : APP_RESULT, kb);
+
+       _D("app_send_cmd_with_noreply : %d", ret);
+
        if(latest_caller_pid == pid)
                latest_caller_pid = -1;
 
        return ret;
 }
 
+int app_subapp_terminate_request()
+{
+       if(is_subapp) {
+               subapp_cb(subapp_data);
+
+               return 0;
+       }
+
+       return -1;
+}
+
+SLPAPI int aul_set_subapp(subapp_fn cb, void *data)
+{
+       is_subapp = 1;
+       subapp_cb = cb;
+       subapp_data = data;
+
+       return 0;
+}
+
+SLPAPI int aul_subapp_terminate_request_pid(int pid)
+{
+       char pid_str[MAX_PID_STR_BUFSZ];
+       int ret;
+       app_resultcb_info_t *info;
+
+       if (pid <= 0)
+               return AUL_R_EINVAL;
+
+       info = __find_resultcb(pid);
+       if(info)
+               __remove_resultcb(info);
+
+       snprintf(pid_str, MAX_PID_STR_BUFSZ, "%d", pid);
+       ret = app_request_to_launchpad(APP_TERM_REQ_BY_PID, pid_str, NULL);
+       return ret;
+}
+
+SLPAPI int aul_is_subapp()
+{
+       return is_subapp;
+}
+
+SLPAPI int aul_add_caller_cb(int pid,  void (*caller_cb) (int, void *), void *data)
+{
+       app_resultcb_info_t *info;
+
+       if (pid <= 0)
+               return AUL_R_EINVAL;
+
+       info = __find_resultcb(pid);
+       if (info) {
+               info->caller_cb = caller_cb;
+               info->caller_data = data;
+       }
+
+       return 0;
+}
+
+SLPAPI int aul_remove_caller_cb(int pid)
+{
+       app_resultcb_info_t *info;
+
+       if (pid <= 0)
+               return AUL_R_EINVAL;
+
+       info = __find_resultcb(pid);
+       if(info) {
+               info->caller_cb = NULL;
+               info->caller_data = NULL;
+       }
+
+       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 be597a1..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) {
-               _D("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 {
-               _D("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 */
-               _D("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 */
-               _D("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
-               _D("%s is not supported.", svc_name);
-
-       __fini();
-       return rc;
-}
-
index d12a6e9..cd89551 100755 (executable)
  *
  */
 
-
 #include "aul.h"
 #include "aul_api.h"
-#include "mida.h"
 #include "miregex.h"
 #include <stdio.h>
 #include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 #include <xdgmime.h>
 #include <bundle.h>
+#include <errno.h>
 
 #include "menu_db_util.h"
 #include "simple_util.h"
 
-#define MIME_APP_SELECTOR "org.tizen.app-selector"
-
-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)
@@ -70,7 +60,7 @@ SLPAPI int aul_get_mime_from_content(const char *content, char *mimetype,
                if (__match_content_with_regex(content,
                        &(miregex_tbl->regex_preg))) {
                        founded = miregex_tbl->mimetype;
-                       _D("content %s => mimetype %s\n", content, founded);
+                       SECURE_LOGD("content %s => mimetype %s\n", content, founded);
                        break;
                }
                miregex_tbl = miregex_tbl->next;
@@ -111,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;
        }
@@ -182,242 +172,27 @@ SLPAPI int aul_get_mime_icon(const char *mimetype, char *iconname, int len)
 SLPAPI int aul_get_mime_from_file(const char *filename, char *mimetype, int len)
 {
        const char *mime;
+       struct stat     statbuf;
        if (filename == NULL)
                return AUL_R_EINVAL;
 
-       if (access(filename, F_OK) != 0)
-               return AUL_R_EINVAL;
-
-       mime = xdg_mime_get_mime_type_for_file(filename, 0);
-       if (strcmp(mime, "application/octet-stream") == 0) {
-               mime = xdg_mime_get_mime_type_from_file_name(filename);
-       }
-
-       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");
+       if (access(filename, F_OK) != 0) {
+               _E("access fail(%s)", strerror(errno));
                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);
+       if (stat(filename, &statbuf) != 0){
+               _E("Unable to get stat, error is %s", strerror(errno));
                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;
-       }
-       
-       ail_filter_count_appinfo(filter, &pkg_count);
-
-       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)
+       if(S_ISDIR(statbuf.st_mode))
                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) {
-               _D("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_package_get_appinfo(defapp, &handle);
-
-               if (ail_ret == AIL_ERROR_OK) {
-                       ail_destroy_appinfo(handle);
-                       _D("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) {
-                       _D("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 {
-                       _E("ail_get_appinfo with %s failed", defapp);
-                       if (kb) {
-                               bundle_free(kb);
-                               kb = NULL;
-                       }
-                       return ret;
-               }       
+       mime = xdg_mime_get_mime_type_for_file(filename, 0);
+       if (strcmp(mime, "application/octet-stream") == 0) {
+               mime = xdg_mime_get_mime_type_from_file_name(filename);
        }
-       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);
+       snprintf(mimetype, len, "%s", mime);
+       return AUL_R_OK;
 }
-
index 514a1dc..a6dfe40 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);
 
@@ -47,10 +48,19 @@ SLPAPI int aul_app_is_running(const char *appid)
 
        ret = __app_send_raw(AUL_UTIL_PID, APP_IS_RUNNING, (unsigned char*)appid, strlen(appid));
 
-       return ret;
+       if(ret > 0)
+               return true;
+
+       return 0;
+}
+
+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_app_get_running_app_info(aul_app_info_iter_fn enum_fn,
+SLPAPI int aul_get_running_app_info_from_proc(aul_app_info_iter_fn iter_fn,
                                        void *user_param)
 {
        app_pkt_t *pkt = NULL;
@@ -59,10 +69,11 @@ SLPAPI int aul_app_get_running_app_info(aul_app_info_iter_fn enum_fn,
        char *pkt_data;
        aul_app_info info;
 
-       if (enum_fn == NULL)
+       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);
+       pkt = __app_send_cmd_with_result(AUL_UTIL_PID, APP_RUNNING_INFO, NULL, 0);
 
        if (pkt == NULL)
                return AUL_R_ERROR;
@@ -76,15 +87,61 @@ 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(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);
+       }
+
+       free(pkt);
+
+       return AUL_R_OK;
+}
+
+SLPAPI void aul_set_preinit_appid(const char *appid)
+{
+       __appid = appid;
+}
+
+static char* __aul_get_preinit_appid(void)
+{
+       return __appid;
+}
+
 static int __get_pkgname_bypid(int pid, char *pkgname, int len)
 {
        char *cmdline;
@@ -113,26 +170,168 @@ SLPAPI int aul_app_get_pkgname_bypid(int pid, char *pkgname, int len)
 
 SLPAPI int aul_app_get_appid_bypid(int pid, char *appid, int len)
 {
+       app_pkt_t *pkt = NULL;
        int pgid;
 
+       if (pid == getpid()) {
+               char *preinit_appid = __aul_get_preinit_appid();
+
+               if (preinit_appid != NULL)
+               {
+#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;
+               }
+       }
+
+       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;
+               }
+               /* 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_pkgname_bypid(pgid, appid, len) == 0)
+                       return AUL_R_OK;
+
+               return AUL_R_ERROR;
+       }
+
        if (appid == NULL)
                return AUL_R_EINVAL;
 
-       if (__get_pkgname_bypid(pid, appid, len) == 0) {
-               _D("appid for %d is %s", pid, appid);
-               return AUL_R_OK;
+       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(appid, len, "%s", pkt->data);
+       free(pkt);
+       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;
        }
-       /* support app launched by shell script*/
-       _D("second chance");
-       pgid = getpgid(pid);
-       if (pgid <= 1)
+
+       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_app_get_cmdline_bypid(int pid, char *cmdline, int len)
+{
+       app_pkt_t *pkt = NULL;
+
+       if (cmdline == NULL)
+               return AUL_R_EINVAL;
+
+       pkt = __app_send_cmd_with_result(AUL_UTIL_PID, APP_GET_CMDLINE, (unsigned char *)&pid, sizeof(pid));
 
-       _D("second change pgid = %d, pid = %d", pgid, pid);
-       if (__get_pkgname_bypid(pgid, appid, len) == 0)
-               return AUL_R_OK;
+       if(pkt == NULL)
+               return AUL_R_ERROR;
+       if(pkt->cmd == APP_GET_INFO_ERROR) {
+               free(pkt);
+               return AUL_R_ERROR;
+       }
 
-       return AUL_R_ERROR;
+       snprintf(cmdline, len, "%s", pkt->data);
+       _D("cmdline : %s", cmdline);
+       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 495c382..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_filter_count_appinfo(filter, &pkg_count);
-
-       
-       /* 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_package_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 d5bbeda..139a4f3 100755 (executable)
 #include <dirent.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <linux/un.h>
 #include "simple_util.h"
 
 #define BINSH_NAME     "/bin/sh"
 #define BINSH_SIZE     7
+#define VALGRIND_NAME  "/home/developer/sdk_tools/valgrind/usr/bin/valgrind"
+#define VALGRIND_SIZE  51
+#define BASH_NAME      "/bin/bash"
+#define BASH_SIZE      9
+#define OPROFILE_NAME  "/usr/bin/oprofile_command"
+#define OPROFILE_SIZE  25
+#define OPTION_VALGRIND_NAME   "valgrind"
+#define OPTION_VALGRIND_SIZE   8
+
 
 #define PROC_STAT_GID_POS      5
 
@@ -128,7 +141,9 @@ int __proc_iter_cmdline(
 
 char *__proc_get_cmdline_bypid(int pid)
 {
-       char buf[MAX_LOCAL_BUFSZ];
+#define MAX_CMD_BUFSZ 1024
+
+       char buf[MAX_CMD_BUFSZ];
        int ret;
 
        snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
@@ -137,16 +152,44 @@ char *__proc_get_cmdline_bypid(int pid)
                return NULL;
 
        /* support app launched by shell script*/
-       if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
+       if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0) {
                return strdup(&buf[BINSH_SIZE + 1]);
-       else
-               return strdup(buf);
+       }
+       else if (strncmp(buf, VALGRIND_NAME, VALGRIND_SIZE) == 0) {
+               char* ptr = buf;
+
+               // buf comes with double null-terminated string
+               while (1) {
+                       while (*ptr) {
+                               ptr++;
+                       }
+                       ptr++;
+
+                       if (*ptr == NULL)
+                               break;
+
+                       // ignore trailing "--"
+                       if (strncmp(ptr, "-", 1) != 0)
+                               break;
+               };
+
+               return strdup(ptr);
+       }
+       else if (strncmp(buf, BASH_NAME, BASH_SIZE) == 0) {
+               if (strncmp(&buf[BASH_SIZE + 1], OPROFILE_NAME, OPROFILE_SIZE) == 0) {
+                       if (strncmp(&buf[BASH_SIZE + OPROFILE_SIZE + 2], OPTION_VALGRIND_NAME, OPTION_VALGRIND_SIZE) == 0) {
+                               return strdup(&buf[BASH_SIZE + OPROFILE_SIZE + OPTION_VALGRIND_SIZE + 3]);
+                       }
+               }
+       }
+
+       return strdup(buf);
 }
 
 static inline int __get_pgid_from_stat(int pid)
 {
        char buf[MAX_LOCAL_BUFSZ];
-       char *str;
+       char *str = NULL;
        int ret;
        int i;
        int count = 0;
@@ -171,7 +214,7 @@ static inline int __get_pgid_from_stat(int pid)
                }
        }
 
-       if (count == PROC_STAT_GID_POS)
+       if (count == PROC_STAT_GID_POS && str)
                pid = atoi(str);
        else
                pid = -1;
@@ -208,3 +251,44 @@ int __proc_iter_pgid(int pgid, int (*iterfunc) (int pid, void *priv),
        return ret;
 }
 
+void __trm_app_info_send_socket(char *write_buf)
+{
+        const char trm_socket_for_app_info[] = "/dev/socket/app_info";
+        int socket_fd = 0;
+        int ret = 0;
+        struct sockaddr_un addr;
+
+       _D("__trm_app_info_send_socket");
+
+        if (access(trm_socket_for_app_info, F_OK) != 0) {
+               _E("access");
+               goto trm_end;
+       }
+
+        socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
+        if (socket_fd < 0) {
+               _E("socket");
+                goto trm_end;
+        }
+
+        memset(&addr, 0, sizeof(addr));
+        snprintf(addr.sun_path, UNIX_PATH_MAX, "%s", trm_socket_for_app_info);
+        addr.sun_family = AF_LOCAL;
+
+        ret = connect(socket_fd, (struct sockaddr *) &addr ,sizeof(sa_family_t) + strlen(trm_socket_for_app_info) );
+        if (ret != 0) {
+                close(socket_fd);
+                goto trm_end;
+        }
+
+        ret = send(socket_fd, write_buf, strlen(write_buf), MSG_DONTWAIT | MSG_NOSIGNAL);
+       if (ret < 0)
+               _E("Unable to send data. Error is %s\n",strerror(errno));
+       else
+               _D("send");
+
+        close(socket_fd);
+trm_end:
+        return;
+}
+
diff --git a/src/status.c b/src/status.c
new file mode 100755 (executable)
index 0000000..83678b6
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ *  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 <aul.h>
+#include <bundle.h>
+
+#include "aul_util.h"
+#include "app_sock.h"
+#include "aul_api.h"
+#include "launch.h"
+
+SLPAPI int aul_status_update(int status)
+{
+       int ret;
+
+       ret = __app_send_raw_with_noreply(AUL_UTIL_PID, APP_STATUS_UPDATE, (unsigned char *)&status, sizeof(status));
+
+       return ret;
+}
+
+SLPAPI int aul_running_list_update(char *appid, char *app_path, char *pid)
+{
+       int ret;
+       bundle *kb;
+
+       kb = bundle_create();
+
+       bundle_add(kb, AUL_K_APPID, appid);
+       bundle_add(kb, AUL_K_EXEC, app_path);
+       bundle_add(kb, AUL_K_PID, pid);
+
+       ret = app_send_cmd(AUL_UTIL_PID, APP_RUNNING_LIST_UPDATE, kb);
+
+       if (kb != NULL)
+                       bundle_free(kb);
+
+       return ret;
+}
+
index 53ba673..ebe29a7 100644 (file)
@@ -1,37 +1,35 @@
 # Test executables
 
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS} -fPIE")
 
 add_executable(aul_test
                aul_test.c) 
-target_link_libraries(aul_test aul ${pkgs_LDFLAGS})
+target_link_libraries(aul_test "-pie" aul ${pkgs_LDFLAGS})
 INSTALL(TARGETS aul_test DESTINATION bin)
 
 add_executable(launch_app
                launch_app.c) 
-target_link_libraries(launch_app aul ${pkgs_LDFLAGS})
+target_link_libraries(launch_app "-pie" aul ${pkgs_LDFLAGS})
 INSTALL(TARGETS launch_app DESTINATION bin)
 
+add_executable(open_app
+                open_app.c)
+target_link_libraries(open_app "-pie" aul ${pkgs_LDFLAGS})
+INSTALL(TARGETS open_app DESTINATION bin)
+
 add_executable(dbusapp_test
                dbusapp_test.c) 
-target_link_libraries(dbusapp_test aul ${pkgs_LDFLAGS})
+target_link_libraries(dbusapp_test "-pie" aul ${pkgs_LDFLAGS})
 
 add_executable(aul_dbus
                aul_dbus.c) 
-target_link_libraries(aul_dbus aul ${pkgs_LDFLAGS})
+target_link_libraries(aul_dbus "-pie" aul ${pkgs_LDFLAGS})
 
 add_executable(test_app
                app_test.c)
 set_target_properties(test_app PROPERTIES COMPILE_FLAGS "-fpie")
 target_link_libraries(test_app "-pie" aul ${pkgs_LDFLAGS} )
 
-add_executable(ac_daemon
-                ac_daemon.c
-               ../src/app_sock.c
-               ../src/simple_util.c)
-target_link_libraries(ac_daemon app-checker-server rua glib-2.0 bundle ail aul utilX ${pkgs_LDFLAGS})
-INSTALL(TARGETS ac_daemon DESTINATION bin)
-
 
 
 ### Unit tests ###
diff --git a/test/ac_daemon.c b/test/ac_daemon.c
deleted file mode 100755 (executable)
index 7ef5121..0000000
+++ /dev/null
@@ -1,496 +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 <glib.h>
-#include <stdbool.h>
-#include <app-checker-server.h>
-#include <rua.h>
-#include <bundle.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <stdlib.h>
-#include <dlfcn.h>
-#include <poll.h>
-#include <ail.h>
-#include <aul.h>
-
-#include "simple_util.h"
-#include "app_sock.h"
-#include "aul_util.h"
-#include "menu_db_util.h"
-
-#include <Ecore_X.h>
-#include <Ecore_Input.h>
-#include <utilX.h>
-#include <Ecore.h>
-#include <Evas.h>
-
-static struct {
-       Evas_Object *win;
-       Ecore_Event_Handler *key_up;
-       Ecore_Event_Handler *key_down;
-} key_info = {
-       .win = NULL,
-       .key_up = NULL,
-       .key_down = NULL,
-};
-
-GSList *key_pid_list = NULL;
-
-extern int app_send_cmd(int pid, int cmd, bundle *kb);
-
-static gboolean __add_history_handler(gpointer user_data)
-{
-       struct rua_rec rec;
-       int ret;
-       app_pkt_t *pkt = (app_pkt_t *)user_data;
-       struct history_data *hd = (struct history_data *)pkt->data;
-
-       ret = rua_init();
-
-       memset(&rec, 0, sizeof(rec));
-
-       rec.pkg_name = hd->pkg_name;
-       rec.app_path = hd->app_path;
-
-       if(hd->len > 0) {
-               rec.arg = (char *)hd->data;
-       }
-
-       _D("add rua history %s %s", rec.pkg_name, rec.app_path);
-
-       ret = rua_add_history(&rec);
-       if (ret == -1)
-               _D("rua add history error");
-
-       free(pkt);
-
-       ret = rua_fini();
-
-       return false;
-}
-
-int __send_result_to_client(int fd, int res)
-{
-       if (send(fd, &res, sizeof(int), MSG_NOSIGNAL) < 0) {
-               if (errno == EPIPE)
-                       _E("send failed due to EPIPE.\n");
-               _E("send fail to client");
-       }
-       close(fd);
-       return 0;
-}
-
-static int __get_pkginfo(const char *dname, const char *cmdline, void *priv)
-{
-       app_info_from_db *menu_info;
-       char *r_info;
-
-       r_info = (char *)priv;
-
-       if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL)
-               goto out;
-       else {
-               strncat(r_info, dname, 8);
-               strncat(r_info, ":", 1);
-               strncat(r_info, _get_pkgname(menu_info), MAX_PACKAGE_STR_SIZE);
-               strncat(r_info, ":", 1);
-               strncat(r_info, _get_app_path(menu_info), MAX_PACKAGE_APP_PATH_SIZE);
-               strncat(r_info, ";", 1);
-       }
-
- out:
-       if (menu_info != NULL)
-               _free_app_info_from_db(menu_info);
-       return 0;
-}
-
-int __send_running_appinfo(int fd)
-{
-       app_pkt_t *pkt = NULL;
-       int len;
-
-       pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
-       if(!pkt) {
-               _E("malloc fail");
-               return 0;
-       }
-
-       memset(pkt, 0, AUL_SOCK_MAXBUFF);
-
-       __proc_iter_cmdline(__get_pkginfo, pkt->data);
-
-       pkt->cmd = APP_RUNNING_INFO_RESULT;
-       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;
-}
-
-int __app_is_running(const char *pkgname)
-{
-       char *apppath = NULL;
-       ail_appinfo_h handle;
-       ail_error_e ail_ret;
-
-       int ret = 0;
-       int i = 0;
-
-       if (pkgname == NULL)
-               return 0;
-
-       ail_ret = ail_package_get_appinfo(pkgname, &handle);
-       if (ail_ret != AIL_ERROR_OK) {
-               _E("ail_get_appinfo with %s failed", pkgname);
-               return ret;
-       }
-
-       ail_ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &apppath);
-       if (ail_ret != AIL_ERROR_OK) {
-               _E("ail_appinfo_get_str failed");
-               goto out;
-       }
-
-       if (apppath == NULL)
-               goto out;
-
-       /*truncate apppath if it includes default bundles */
-       while (apppath[i] != 0) {
-               if (apppath[i] == ' ' || apppath[i] == '\t') {
-                       apppath[i]='\0';
-                       break;
-               }
-               i++;
-       }
-
-       if (__proc_iter_cmdline(NULL, apppath) > 0)
-               ret = 1;
-       else
-               ret = 0;
-
- out:
-       if (ail_destroy_appinfo(handle) != AIL_ERROR_OK)
-               _E("ail_destroy_rs failed");
-       return ret;
-}
-
-static int __register_key_event(int pid)
-{
-       int *pid_data;
-       GSList *entry;
-
-       pid_data = malloc(sizeof(int));
-       *pid_data = pid;
-
-       key_pid_list = g_slist_prepend(key_pid_list, pid_data);
-
-       _D("===key stack===");
-
-       for (entry = key_pid_list; entry; entry = entry->next) {
-               if (entry->data) {
-                       pid_data = (int *) entry->data;
-                       _D("pid : %d",*pid_data);
-               }
-       }
-
-       return 0;
-}
-
-static int __unregister_key_event(int pid)
-{
-       GSList *entry;
-       int *pid_data;
-
-       for (entry = key_pid_list; entry; entry = entry->next) {
-               if (entry->data) {
-                       pid_data = (int *) entry->data;
-                       if(pid == *pid_data) {
-                               key_pid_list = g_slist_remove(key_pid_list, entry->data);
-                               free(pid_data);
-                       }
-               }
-       }
-
-       _D("===key stack===");
-
-       for (entry = key_pid_list; entry; entry = entry->next) {
-               if (entry->data) {
-                       pid_data = (int *) entry->data;
-                       _D("pid : %d",*pid_data);
-               }
-       }
-
-       return 0;
-}
-
-static gboolean __util_handler(gpointer data)
-{
-       GPollFD *gpollfd = (GPollFD *) data;
-       int fd = gpollfd->fd;
-       app_pkt_t *pkt;
-       int clifd;
-       struct ucred cr;
-       struct history_data *hd;
-       int ret = -1;
-       char pkgname[MAX_PACKAGE_STR_SIZE];
-
-       if ((pkt = __app_recv_raw(fd, &clifd, &cr)) == NULL) {
-               _E("recv error");
-               return FALSE;
-       }
-
-       switch (pkt->cmd) {
-       case APP_ADD_HISTORY:
-               hd = (struct history_data *)pkt->data;
-               _D("cmd : %d, pkgname : %s, app_path : %s", pkt->cmd, hd->pkg_name, hd->app_path);
-               __send_result_to_client(clifd, 0);
-               g_timeout_add(1000, __add_history_handler, pkt);
-               break;
-       case APP_RUNNING_INFO:
-               __send_running_appinfo(clifd);
-               free(pkt);
-               break;
-       case APP_IS_RUNNING:
-               strncpy(pkgname, (const char*)pkt->data, MAX_PACKAGE_STR_SIZE-1);
-               ret = __app_is_running(pkgname);
-               __send_result_to_client(clifd, ret);
-               free(pkt);
-               break;
-       case APP_KEY_RESERVE:
-               ret = __register_key_event(cr.pid);
-               __send_result_to_client(clifd, ret);
-               free(pkt);
-               break;
-       case APP_KEY_RELEASE:
-               ret = __unregister_key_event(cr.pid);
-               __send_result_to_client(clifd, ret);
-               free(pkt);
-               break;
-       default:
-               _E("no support packet");
-       }
-
-       return TRUE;
-}
-
-static gboolean __au_glib_check(GSource *src)
-{
-       GSList *fd_list;
-       GPollFD *tmp;
-
-       fd_list = src->poll_fds;
-       do {
-               tmp = (GPollFD *) fd_list->data;
-               if ((tmp->revents & (POLLIN | POLLPRI)))
-                       return TRUE;
-               fd_list = fd_list->next;
-       } while (fd_list);
-
-       return FALSE;
-}
-
-static gboolean __au_glib_dispatch(GSource *src, GSourceFunc callback,
-                                 gpointer data)
-{
-       callback(data);
-       return TRUE;
-}
-
-static gboolean __au_glib_prepare(GSource *src, gint *timeout)
-{
-       return FALSE;
-}
-
-static GSourceFuncs funcs = {
-       .prepare = __au_glib_prepare,
-       .check = __au_glib_check,
-       .dispatch = __au_glib_dispatch,
-       .finalize = NULL
-};
-
-static Eina_Bool _key_release_cb(void *data, int type, void *event)
-{
-       Evas_Event_Key_Up *ev = event;
-       int ret;
-       GSList *entry;
-       int *pid_data;
-       bundle *kb;
-
-       _D("Released");
-
-       if (!ev) {
-               _D("Invalid event object");
-               return ECORE_CALLBACK_RENEW;
-       }
-
-       entry = key_pid_list;
-       if (entry && entry->data) {
-               pid_data = (int *) entry->data;
-
-               kb = bundle_create();
-               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);
-
-               bundle_free(kb);
-       }
-
-       return ECORE_CALLBACK_RENEW;
-}
-
-
-static Eina_Bool _key_press_cb(void *data, int type, void *event)
-{
-       Evas_Event_Key_Down *ev = event;
-       int ret;
-       GSList *entry;
-       int *pid_data;
-       bundle *kb;
-
-       _D("Pressed");
-
-       if (!ev) {
-               _D("Invalid event object");
-               return ECORE_CALLBACK_RENEW;
-       }
-
-       entry = key_pid_list;
-       if (entry && entry->data) {
-               pid_data = (int *) entry->data;
-
-               kb = bundle_create();
-               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);
-
-               bundle_free(kb);
-       }
-
-       return ECORE_CALLBACK_RENEW;
-}
-
-static int __app_dead_handler(int pid, void *data)
-{
-       int ret;
-
-       ret = __unregister_key_event(pid);
-
-       return 0;
-}
-
-static void __ac_key_initailize()
-{
-       key_info.win = ecore_x_window_input_new(0, 0, 0, 1, 1);
-       if (!key_info.win) {
-               _D("Failed to create hidden window");
-       }
-
-       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());
-
-       utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_PLAYCD, EXCLUSIVE_GRAB);
-       utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_STOPCD, EXCLUSIVE_GRAB);
-       utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_PAUSECD, EXCLUSIVE_GRAB);
-       utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_NEXTSONG, EXCLUSIVE_GRAB);
-       utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_PREVIOUSSONG, EXCLUSIVE_GRAB);
-       utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_REWIND, EXCLUSIVE_GRAB);
-       utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_FASTFORWARD, EXCLUSIVE_GRAB);
-
-       key_info.key_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_release_cb, NULL);
-       if (!key_info.key_up) {
-               _D("Failed to register a key up event handler");
-       }
-
-       key_info.key_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_press_cb, NULL);
-       if (!key_info.key_down) {
-               _D("Failed to register a key down event handler");
-       }
-
-       aul_listen_app_dead_signal(__app_dead_handler, NULL);
-}
-
-static int __initialize()
-{
-       int fd;
-       int r;
-       GPollFD *gpollfd;
-       GSource *src;
-
-       fd = __create_server_sock(AUL_UTIL_PID);
-
-       src = g_source_new(&funcs, sizeof(GSource));
-
-       gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
-       gpollfd->events = POLLIN;
-       gpollfd->fd = fd;
-
-       g_source_add_poll(src, gpollfd);
-       g_source_set_callback(src, (GSourceFunc) __util_handler,
-                             (gpointer) gpollfd, NULL);
-       g_source_set_priority(src, G_PRIORITY_DEFAULT);
-
-       r = g_source_attach(src, NULL);
-       if (r  == 0)
-       {
-               /* TODO: error handle*/
-               return AC_R_ERROR;
-       }
-
-#ifndef __i386__
-       __ac_key_initailize();
-#endif
-
-       return AC_R_OK;
-}
-
-int main(int argc, char *argv[])
-{
-       int ret;
-
-       ecore_init();
-       evas_init();
-       ecore_event_init();
-       ecore_x_init(NULL);
-
-       ret = ac_server_initailize();
-
-       ret = __initialize();
-
-       ecore_main_loop_begin();
-
-       return 0;
-}
index 0d417b6..d3d54f4 100755 (executable)
@@ -55,6 +55,7 @@ int main(int argc, char **argv)
        DBusMessage *message;
        DBusPendingCall *pc;
        GMainLoop *loop;
+       dbus_bool_t ret;
 
        char tmp[MAX_LOCAL_BUFSZ];
        char *s;
@@ -72,7 +73,7 @@ int main(int argc, char **argv)
 
        message = dbus_message_new_method_call (
                        SERVICE_NAME,PATH_NAME,INTERFACE_NAME,
-                       METHOD_NAME); 
+                       METHOD_NAME);
 
        gettimeofday(&tv, NULL);
        snprintf(tmp, MAX_LOCAL_BUFSZ, "%ld/%ld", tv.tv_sec, tv.tv_usec);
@@ -81,7 +82,12 @@ int main(int argc, char **argv)
        dbus_message_append_args(message,
                                 DBUS_TYPE_STRING, &s, DBUS_TYPE_INVALID);
 
-       dbus_connection_send_with_reply(bus, message, &pc, INT_MAX);
+       ret = dbus_connection_send_with_reply(bus, message, &pc, INT_MAX);
+       if (!ret) {
+               _E("dbus_connection_send_with_reply() failed.");
+               dbus_message_unref(message);
+               return -1;
+       }
        if (!dbus_pending_call_set_notify(pc, request_cb, NULL, NULL))
                _E("pending call set fail");
 
index 82facae..730cbf7 100755 (executable)
@@ -1,23 +1,19 @@
 /*
- *  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.
- *
- */
+Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+PROPRIETARY/CONFIDENTIAL
+This software is the confidential and proprietary information of 
+SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+this software is owned by Samsung and you 
+shall not disclose such Confidential Information and shall 
+use it only in accordance with the terms of the license agreement 
+you entered into with SAMSUNG ELECTRONICS.  SAMSUNG make no 
+representations or warranties about the suitability 
+of the software, either express or implied, including but not 
+limited to the implied warranties of merchantability, fitness for 
+a particular purpose, or non-infringement. 
+SAMSUNG shall not be liable for any damages suffered by licensee arising out of or 
+related to this software.
+*/
 
 #include <stdio.h>
 #include <dbus/dbus.h>
index 8225139..72ed4fd 100755 (executable)
@@ -83,6 +83,27 @@ int launch_test()
        return ret;
 }
 
+int launch_test_async()
+{
+       static int num = 0;
+       int ret = 0;
+       bundle *kb = NULL;
+
+       kb = create_internal_bundle(3);
+       if (NULL == kb) {
+               return -1;
+       }
+       printf("[aul_launch_app %d test] %s \n", num++, gargv[2]);
+
+       ret = aul_launch_app_async(gargv[2], kb);
+
+       if (kb) {
+               bundle_free(kb);
+               kb = NULL;
+       }
+       return ret;
+}
+
 int dbus_launch_test()
 {
        bundle *kb = NULL;
@@ -156,6 +177,20 @@ 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;
+       printf("[aul_subapp_terminate_request_pid %d test] %d \n", num++, apn_pid);
+       return aul_subapp_terminate_request_pid(apn_pid);
+}
+
 static test_func_t scn_func[] = {
        {"n", launch_test, "launch_test", ""},
        {"n", launch_test, "launch_test", ""},
@@ -246,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;
@@ -362,6 +361,14 @@ static int get_pkg_func()
        return 0;
 }
 
+static int update_running_list()
+{
+       aul_running_list_update(gargv[2], gargv[3], gargv[4]);
+
+       return 0;
+}
+
+
 /*
 static int set_pkg_func()
 {
@@ -372,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"(\
@@ -447,93 +454,11 @@ 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> ..."},
+       {"launch_async",launch_test_async,"aul_launch_app test",
+               "[usage] launch_async <pkgname> <key1> <val1> <key2> <val2> ..."},
        {"open",open_test,"aul_open_app test",
                "[usage] open <pkgname>" },
        {"resume",resume_test,"aul_resume_app test",
@@ -542,6 +467,10 @@ 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",
                "[usage] term_pid <pid>" },
        {"all",all_test,"test based on predefine scenario",
@@ -553,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",
@@ -577,17 +498,10 @@ 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",
+               "[usage] update_list <appid> <app_path> <pid>"},
 /*
        {"setpkg", set_pkg_func, "set package",
                "[usage] setpkg <pkgname> <apppath>"},
index 59eac96..d44535d 100755 (executable)
 
 static char **gargv;
 static int gargc;
+bundle *kb = NULL;
+
 
 static bundle *create_internal_bundle(int start)
 {
        bundle *kb;
        int i;
-       char arg[1024];
+       char arg[1024] = {0, };
        char* val_array[128];
 
        kb = bundle_create();
@@ -46,7 +48,7 @@ static bundle *create_internal_bundle(int start)
                        bundle_add(kb, gargv[i], " ");
                else {
                        int j = 1;
-                       strncpy(arg, gargv[i + 1], 1024);
+                       strncpy(arg, gargv[i + 1], 1023);
                        val_array[0] = strtok(arg,",");
                        while(1)
                        {
@@ -68,7 +70,6 @@ static bundle *create_internal_bundle(int start)
 
 int launch()
 {
-       bundle *kb = NULL;
        FILE *fp;
        int ret = -1;
        int pid = -1;
@@ -81,18 +82,14 @@ int launch()
 
        pid = aul_launch_app(gargv[1], kb);
 
-       if (kb) {
-               bundle_free(kb);
-               kb = NULL;
-       }
        /* Write the package name to TMP_FILE*/
-       fp = fopen(TMP_FILE, "w");
+/*     fp = fopen(TMP_FILE, "w");
        if (fp == NULL)
                return -1;
        ret = fprintf(fp, "%d", pid);
        fclose(fp);
        if (ret < 0)
-               return -1;
+               return -1;*/
 
        return pid;
 }
@@ -103,28 +100,46 @@ void print_usage(char *progname)
               progname);
 }
 
+static int __launch_app_dead_handler(int pid, void *data)
+{
+       int listen_pid = (int) data;
+
+       if(listen_pid == pid)
+               ecore_main_loop_quit();
+
+       return 0;
+}
+
 static Eina_Bool run_func(void *data)
 {
-       if (launch() > 0) {
+       int pid = -1;
+       char *str = NULL;
+
+       if ((pid = launch()) > 0) {
                printf("... successfully launched\n");
+               str      = bundle_get_val(kb, "__LAUNCH_APP_MODE__");
+
+               if( str && strcmp(str, "SYNC") == 0 ) {
+                       aul_listen_app_dead_signal(__launch_app_dead_handler, pid);
+               } else {
+                       ecore_main_loop_quit();
+        }
        } else {
                printf("... launch failed\n");
+               ecore_main_loop_quit();
        }
 
-       ecore_main_loop_quit();
+       if (kb) {
+               bundle_free(kb);
+               kb = NULL;
+       }
 
        return 0;
 }
 
+
 int main(int argc, char **argv)
 {
-
-       /* Checking the User ID*/
-       if (getuid() != ROOT_UID) {
-               fprintf(stderr, "permission error\n");
-               exit(EXIT_FAILURE);
-       }
-
        if (argc < 2) {
                print_usage(argv[0]);
                exit(EXIT_FAILURE);
diff --git a/test/open_app.c b/test/open_app.c
new file mode 100755 (executable)
index 0000000..d9b677c
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ *  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 <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include <Ecore.h>
+#include "aul.h"
+
+#define ROOT_UID 0
+#define TMP_FILE "/tmp/.testpkg"
+
+static char **gargv;
+static int gargc;
+bundle *kb = NULL;
+
+
+static bundle *create_internal_bundle(int start)
+{
+       bundle *kb;
+       int i;
+       char arg[1024] = {0, };
+       char* val_array[128];
+
+       kb = bundle_create();
+       for (i = start; i < gargc - 1; i++) {
+               if ((i + 1) > gargc - 1)
+                       bundle_add(kb, gargv[i], " ");
+               else {
+                       int j = 1;
+                       strncpy(arg, gargv[i + 1], 1023);
+                       val_array[0] = strtok(arg,",");
+                       while(1)
+                       {
+                               val_array[j] = strtok(NULL,",");
+                               if(val_array[j] == NULL)
+                                       break;
+                               j++;
+                       }
+                       if(j==1)
+                               bundle_add(kb, gargv[i], gargv[i + 1]);
+                       else if(j>1)
+                               bundle_add_str_array(kb, gargv[i],
+                                       (const char**)val_array, j);
+               }
+       }
+
+       return kb;
+}
+
+int launch()
+{
+       FILE *fp;
+       int ret = -1;
+       int pid = -1;
+
+       kb = create_internal_bundle(2);
+       if (NULL == kb) {
+               printf("bundle creation fail\n");
+               return -1;
+       }
+
+       pid = aul_open_app(gargv[1]);
+
+       /* Write the package name to TMP_FILE*/
+       fp = fopen(TMP_FILE, "w");
+       if (fp == NULL)
+               return -1;
+       ret = fprintf(fp, "%d", pid);
+       fclose(fp);
+       if (ret < 0)
+               return -1;
+
+       return pid;
+}
+
+void print_usage(char *progname)
+{
+       printf("[usage] %s <appid>\n",
+              progname);
+}
+
+static int __launch_app_dead_handler(int pid, void *data)
+{
+       int listen_pid = (int) data;
+
+       if(listen_pid == pid)
+               ecore_main_loop_quit();
+
+       return 0;
+}
+
+static Eina_Bool run_func(void *data)
+{
+       int pid = -1;
+       char *str = NULL;
+       if ((pid = launch()) > 0) {
+               printf("... successfully launched\n");
+       } else {
+               printf("... launch failed\n");
+       }
+
+       str = bundle_get_val(kb, "__LAUNCH_APP_MODE__");
+
+       if( str && strcmp(str, "SYNC") == 0 ) {
+               aul_listen_app_dead_signal(__launch_app_dead_handler, pid);
+       } else {
+               ecore_main_loop_quit();
+       }
+
+       if (kb) {
+               bundle_free(kb);
+               kb = NULL;
+       }
+
+       return 0;
+}
+
+int main(int argc, char **argv)
+{
+       if (argc < 2) {
+               print_usage(argv[0]);
+               exit(EXIT_FAILURE);
+       }
+
+       ecore_init();
+
+       gargc = argc;
+       gargv = argv;
+
+       aul_launch_init(NULL, NULL);
+
+       ecore_idler_add(run_func, NULL);
+
+       ecore_main_loop_begin();
+
+       return 0;
+}
+