merge 2.4 to tizen 40/51840/12
authorJunghoon, Park <jh9216.park@samsung.com>
Thu, 19 Nov 2015 02:05:09 +0000 (11:05 +0900)
committerJunghoon, Park <jh9216.park@samsung.com>
Thu, 19 Nov 2015 11:55:54 +0000 (20:55 +0900)
- add AIT_POOL for launchpad
- remove release-agent, launch-agent
- add TEP feature
- support restarting service app

Change-Id: I40bef863e16c34b9f2ec98f915a51c843beb020b
Signed-off-by: Junghoon, Park <jh9216.park@samsung.com>
14 files changed:
CMakeLists.txt
agent/CMakeLists.txt [deleted file]
agent/daemon-manager-launch-agent.c [deleted file]
agent/daemon-manager-release-agent.c [deleted file]
am_daemon/amd_appinfo.c
am_daemon/amd_appinfo.h
am_daemon/amd_launch.c
am_daemon/amd_main.c
am_daemon/amd_request.c
include/app_signal.h
include/app_sock.h
include/aul.h
packaging/aul.spec
src/launch.c

index a5834c5..bf22841 100644 (file)
@@ -88,17 +88,6 @@ ADD_EXECUTABLE(amd
 TARGET_LINK_LIBRARIES(amd aul_mods aul ${pkgs_LDFLAGS})
 INSTALL(TARGETS amd DESTINATION bin)
 
-# daemon-manager
-SET(REL_AGENT daemon-manager-release-agent)
-ADD_EXECUTABLE(${REL_AGENT} agent/${REL_AGENT}.c)
-TARGET_LINK_LIBRARIES(${REL_AGENT} ${pkgs_LDFLAGS} aul aul_mods)
-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})
-INSTALL(TARGETS ${LAUNCH_AGENT} DESTINATION bin)
-
 # app_launcher
 SET(APP_LAUNCHER "app_launcher")
 ADD_EXECUTABLE(${APP_LAUNCHER} app_launcher.c)
diff --git a/agent/CMakeLists.txt b/agent/CMakeLists.txt
deleted file mode 100644 (file)
index 4f9a22d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-
-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
deleted file mode 100644 (file)
index d221113..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-#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;
-       }
-
-#if !GLIB_CHECK_VERSION(2, 36, 0)
-       g_type_init();
-#endif
-
-       /* 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
deleted file mode 100644 (file)
index 203529f..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#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;
-}
-
index 3726999..bd4c5b7 100644 (file)
@@ -23,6 +23,7 @@ static GHashTable *pkg_pending;
 struct user_appinfo {
        uid_t uid;
        GHashTable *tbl; /* key is filename, value is struct appinfo */
+       void *extra_data;
 };
 
 enum _appinfo_idx {
@@ -39,7 +40,11 @@ enum _appinfo_idx {
        _AI_PKGID,
        _AI_PRELOAD,
        _AI_STATUS,
+       _AI_POOL,
+       _AI_TEP,
+       _AI_STORAGE_TYPE,
        _AI_LAUNCH_MODE,
+       _AI_GLOBAL,
        _AI_MAX,
 };
 #define _AI_START _AI_NAME /* start index */
@@ -62,7 +67,11 @@ static struct appinfo_t _appinfos[] = {
        [_AI_PKGID] = { "PackageId", AIT_PKGID, },
        [_AI_PRELOAD] = { "Preload", AIT_PRELOAD, },
        [_AI_STATUS] = { "Status", AIT_STATUS, },
+       [_AI_POOL] = { "ProcessPool", AIT_POOL, },
+       [_AI_TEP] = {"Tep", AIT_TEP},
+       [_AI_STORAGE_TYPE] = {"StorageType", AIT_STORAGE_TYPE},
        [_AI_LAUNCH_MODE] = {"launch_mode", AIT_LAUNCH_MODE },
+       [_AI_GLOBAL] = {"global", AIT_GLOBAL },
 };
 
 struct appinfo {
@@ -120,6 +129,11 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d
        bool onboot;
        bool restart;
        bool preload;
+       bool process_pool = false;
+       bool is_global = false;
+       char *tep_name = NULL;
+
+       pkgmgrinfo_installed_storage installed_storage;
        pkgmgrinfo_app_hwacceleration hwacc;
        pkgmgrinfo_app_component component;
        pkgmgrinfo_permission_type permission;
@@ -230,6 +244,43 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d
        c->val[_AI_PKGID] = strdup(pkgid);
        c->val[_AI_STATUS] = strdup("installed");
 
+       if (pkgmgrinfo_appinfo_is_process_pool(handle, &process_pool)) {
+               _E("failed to get process_pool");
+               _free_appinfo(c);
+               return -1;
+       }
+
+       if (process_pool == false)
+               c->val[_AI_POOL] = strdup("false");
+       else
+               c->val[_AI_POOL] = strdup("true");
+
+       if (pkgmgrinfo_pkginfo_get_tep_name((pkgmgrinfo_pkginfo_h)info->extra_data, &tep_name)){
+               _E("failed to get tep_name");
+               c->val[_AI_TEP] = NULL;
+       } else {
+               c->val[_AI_TEP] = strdup(tep_name);
+       }
+
+       if (pkgmgrinfo_pkginfo_is_for_all_users((pkgmgrinfo_pkginfo_h)info->extra_data, &is_global)) {
+               _E("get pkginfo failed");
+               return -1;
+       }
+
+       if (is_global)
+               c->val[_AI_GLOBAL] = strdup("true");
+       else
+               c->val[_AI_GLOBAL] = strdup("false");
+
+       if (pkgmgrinfo_appinfo_get_installed_storage_location(handle, &installed_storage) == PMINFO_R_OK) {
+               if (installed_storage == PMINFO_INTERNAL_STORAGE)
+                       c->val[_AI_STORAGE_TYPE] = strdup("internal");
+               else if (installed_storage == PMINFO_EXTERNAL_STORAGE)
+                       c->val[_AI_STORAGE_TYPE] = strdup("external");
+       } else {
+               c->val[_AI_STORAGE_TYPE] = strdup("internal");
+       }
+
        if (pkgmgrinfo_appinfo_get_launch_mode(handle, &mode)) {
                _E("failed to get launch_mode");
                _free_appinfo(c);
@@ -258,6 +309,7 @@ static int __pkg_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data)
        if (info->uid != GLOBAL_USER && is_global)
                return 0;
 
+       info->extra_data = handle;
        if (pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_ALL_APP,
                        __app_info_insert_handler, user_data,
                        info->uid)) {
@@ -550,6 +602,7 @@ int appinfo_insert(uid_t uid, const char *pkgid)
                return -1;
        }
 
+       info->extra_data = handle;
        if (pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_ALL_APP,
                                __app_info_insert_handler,
                                info, info->uid)) {
index e544090..05f8998 100644 (file)
@@ -19,7 +19,11 @@ enum appinfo_type {
        AIT_PKGID,
        AIT_PRELOAD,
        AIT_STATUS,
+       AIT_POOL,
+       AIT_TEP,
+       AIT_STORAGE_TYPE,
        AIT_LAUNCH_MODE,
+       AIT_GLOBAL,
        AIT_MAX
 };
 
index adab09a..f238d73 100644 (file)
@@ -29,6 +29,9 @@
 #include <stdio.h>
 #include <sys/prctl.h>
 #include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 #include <pkgmgr-info.h>
 #include <poll.h>
 #include <tzplatform_config.h>
@@ -41,6 +44,7 @@
 #include "app_sock.h"
 #include "simple_util.h"
 #include "launch.h"
+#include "app_signal.h"
 
 #define DAC_ACTIVATE
 
 
 // SDK related defines
 #define PATH_APP_ROOT tzplatform_getenv(TZ_USER_APP)
+#define PATH_GLOBAL_APP_ROOT tzplatform_getenv(TZ_SYS_RW_APP)
 #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 GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
+#define PREFIX_EXTERNAL_STORAGE_PATH "/opt/storage/sdcard/"
 
 typedef struct {
        char *pkg_name;     /* package */
@@ -88,6 +94,7 @@ int _start_app_local_with_bundle(uid_t uid, const char *appid, bundle *kb)
        const char *pkg_type;
        const char *pkg_id;
        const char *hwacc;
+       const char *process_pool;
        char tmpbuf[MAX_PID_STR_BUFSZ];
 
        snprintf(tmpbuf, sizeof(tmpbuf), "%d", getpid());
@@ -112,12 +119,14 @@ int _start_app_local_with_bundle(uid_t uid, const char *appid, bundle *kb)
        app_path = appinfo_get_value(ai, AIT_EXEC);
        pkg_type = appinfo_get_value(ai, AIT_TYPE);
        pkg_id = appinfo_get_value(ai, AIT_PKGID);
+       process_pool = appinfo_get_value(ai, AIT_POOL);
 
        __set_stime(kb);
        bundle_add_str(kb, AUL_K_HWACC, hwacc);
        bundle_add_str(kb, AUL_K_EXEC, app_path);
        bundle_add_str(kb, AUL_K_PACKAGETYPE, pkg_type);
        bundle_add_str(kb, AUL_K_PKGID, pkg_id);
+       bundle_add_str(kb, AUL_K_INTERNAL_POOL, process_pool);
 
        pid = app_agent_send_cmd(uid, APP_START, kb);
        if (pid > 0)
@@ -598,6 +607,109 @@ static int __get_pid_for_app_group(const char *appid, int pid, int caller_uid, b
        return pid;
 }
 
+static int __tep_mount(char *mnt_path[])
+{
+       DBusMessage *msg;
+       int func_ret = 0;
+       int rv = 0;
+       struct stat link_buf = {0,};
+
+       static DBusConnection *conn = NULL;
+
+       if (!conn) {
+               conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+               if (!conn) {
+                       _E("dbus_bus_get error");
+                       return -1;
+               }
+       }
+
+       rv = lstat(mnt_path[0], &link_buf);
+       if (rv == 0) {
+               rv = unlink(mnt_path[0]);
+               if (rv)
+                       _E("Unable tp remove link file %s", mnt_path[0]);
+       }
+
+       msg = dbus_message_new_method_call(TEP_BUS_NAME, TEP_OBJECT_PATH,
+                                          TEP_INTERFACE_NAME, TEP_MOUNT_METHOD);
+       if (!msg) {
+               _E("dbus_message_new_method_call(%s:%s-%s)", TEP_OBJECT_PATH,
+                  TEP_INTERFACE_NAME, TEP_MOUNT_METHOD);
+               return -1;
+       }
+
+       if (!dbus_message_append_args(msg,
+                                     DBUS_TYPE_STRING, &mnt_path[0],
+                                     DBUS_TYPE_STRING, &mnt_path[1],
+                                     DBUS_TYPE_INVALID)) {
+               _E("Ran out of memory while constructing args\n");
+               func_ret = -1;
+               goto func_out;
+       }
+
+       if (dbus_connection_send(conn, msg, NULL) == FALSE) {
+               _E("dbus_connection_send error");
+               func_ret = -1;
+               goto func_out;
+       }
+func_out :
+       dbus_message_unref(msg);
+       return func_ret;
+}
+
+static void __send_mount_request(const struct appinfo *ai, const char *tep_name,
+                                 bundle *kb)
+{
+       SECURE_LOGD("tep name is: %s", tep_name);
+       char *mnt_path[2] = {NULL, };
+       const char *installed_storage = NULL;
+       char tep_path[PATH_MAX] = {0, };
+       const char *path_app_root = NULL;
+
+       const char *global = appinfo_get_value(ai, AIT_GLOBAL);
+       const char *pkgid = appinfo_get_value(ai, AIT_PKGID);
+       installed_storage = appinfo_get_value(ai, AIT_STORAGE_TYPE);
+
+       if (global && strcmp("true", global) == 0)
+               path_app_root = PATH_GLOBAL_APP_ROOT;
+       else
+               path_app_root = PATH_APP_ROOT;
+
+       if (installed_storage != NULL) {
+               SECURE_LOGD("storage: %s", installed_storage);
+               if (strncmp(installed_storage, "internal", 8) == 0) {
+                       snprintf(tep_path, PATH_MAX, "%s/%s/res/%s", path_app_root, pkgid,
+                                tep_name);
+                       mnt_path[1] = strdup(tep_path);
+                       snprintf(tep_path, PATH_MAX, "%s/%s/res/tep", path_app_root, pkgid);
+                       mnt_path[0] = strdup(tep_path);
+               } else if (strncmp(installed_storage, "external", 8) == 0) {
+                       snprintf(tep_path, PATH_MAX, "%step/%s", PREFIX_EXTERNAL_STORAGE_PATH,
+                                tep_name);
+                       mnt_path[1] = strdup(tep_path);
+                       snprintf(tep_path, PATH_MAX, "%step/tep-access",
+                                PREFIX_EXTERNAL_STORAGE_PATH); /* TODO : keeping tep/tep-access for now for external storage */
+                       mnt_path[0] = strdup(tep_path);
+               }
+
+               if (mnt_path[0] && mnt_path[1]) {
+                       bundle_add(kb, AUL_TEP_PATH, mnt_path[0]);
+                       int ret = -1;
+                       ret = aul_is_tep_mount_dbus_done(mnt_path[0]);
+                       if (ret != 1) {
+                               ret = __tep_mount(mnt_path);
+                               if (ret < 0)
+                                       _E("dbus error %d", ret);
+                       }
+               }
+               if (mnt_path[0])
+                       free(mnt_path[0]);
+               if (mnt_path[1])
+                       free(mnt_path[1]);
+       }
+}
+
 int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
                uid_t caller_uid, int fd)
 {
@@ -609,6 +721,8 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
        const char *pkg_type = NULL;
        const char *pkg_id = NULL;
        const char *component_type = NULL;
+       const char *process_pool = NULL;
+       const char *tep_name = NULL;
        int pid = -1;
        char tmpbuf[MAX_PID_STR_BUFSZ];
        const char *hwacc;
@@ -661,6 +775,7 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
        app_path = appinfo_get_value(ai, AIT_EXEC);
        pkg_type = appinfo_get_value(ai, AIT_TYPE);
        pkg_id = appinfo_get_value(ai, AIT_PKGID);
+       process_pool = appinfo_get_value(ai, AIT_POOL);
 
        if ((ret = __compare_signature(ai, cmd, caller_uid, appid, caller_appid, fd)) != 0)
                return ret;
@@ -679,6 +794,10 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
                }
        }
 
+       tep_name = appinfo_get_value(ai, AIT_TEP);
+       if (tep_name != NULL)
+               __send_mount_request(ai, tep_name, kb);
+
        if (pid > 0)
                callee_status = _status_get_app_info_status(pid, caller_uid);
 
@@ -704,6 +823,7 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
                bundle_add(kb, AUL_K_EXEC, app_path);
                bundle_add(kb, AUL_K_PACKAGETYPE, pkg_type);
                bundle_add(kb, AUL_K_PKGID, pkg_id);
+               bundle_add(kb, AUL_K_INTERNAL_POOL, process_pool);
                pid = app_agent_send_cmd(caller_uid, cmd, kb);
 
                if (strncmp(component_type, APP_TYPE_UI, strlen(APP_TYPE_UI)) == 0) {
index 81f41f6..013cc93 100644 (file)
@@ -35,6 +35,7 @@
 #include <dbus/dbus.h>
 #include <dbus/dbus-glib-lowlevel.h>
 #include <bundle.h>
+#include <stdbool.h>
 
 #include "amd_config.h"
 #include "simple_util.h"
@@ -56,7 +57,14 @@ typedef struct _r_app_info_t {
        uid_t user;
 } r_app_info_t;
 
-GSList *r_app_info_list;
+struct restart_info {
+       char *appid;
+       int count;
+       guint timer;
+};
+
+static GSList *r_app_info_list;
+static GHashTable *restart_tbl;
 
 static void __vconf_cb(keynode_t *key, void *data);
 static int __init(void);
@@ -240,6 +248,83 @@ static void __vconf_cb(keynode_t *key, void *data)
        }
 }
 
+static gboolean __restart_timeout_handler(void *data)
+{
+       struct restart_info *ri = (struct restart_info *)data;
+
+       _D("ri (%x)", ri);
+       _D("appid (%s)", ri->appid);
+
+       g_hash_table_remove(restart_tbl, ri->appid);
+       free(ri->appid);
+       free(ri);
+
+       return FALSE;
+}
+
+static bool __check_restart(const char *appid)
+{
+       struct restart_info *ri = NULL;
+
+       ri = g_hash_table_lookup(restart_tbl, appid);
+       if (!ri) {
+               ri = malloc(sizeof(struct restart_info));
+               if (!ri) {
+                       _E("create restart info: %s", strerror(errno));
+                       return false;
+               }
+               memset(ri, 0, sizeof(struct restart_info));
+               ri->appid = strdup(appid);
+               ri->count = 1;
+               g_hash_table_insert(restart_tbl, ri->appid, ri);
+
+               _D("ri (%x)", ri);
+               _D("appid (%s)", appid);
+
+               ri->timer = g_timeout_add(10 * 1000, __restart_timeout_handler, ri);
+       } else {
+               ri->count++;
+               _D("count (%d)", ri->count);
+               if (ri->count > 5) {
+                       g_source_remove(ri->timer);
+                       g_hash_table_remove(restart_tbl, ri->appid);
+                       free(ri->appid);
+                       free(ri);
+                       return false;
+               }
+       }
+       return true;
+}
+
+static bool __can_restart_app(int pid)
+{
+       const char *pkg_status;
+       const char *appid = NULL;
+       const struct appinfo *ai = NULL;
+
+       appid = _status_app_get_appid_bypid(pid);
+
+       if (!appid)
+               return false;
+
+       ai = appinfo_find(getuid(), appid);
+       pkg_status = appinfo_get_value(ai, AIT_STATUS);
+       _D("appid: %s", appid);
+
+       if (ai && pkg_status && strncmp(pkg_status, "blocking", 8) == 0) {
+               appinfo_set_value((struct appinfo *)ai, AIT_STATUS, "restart");
+       } else if (ai && pkg_status && strncmp(pkg_status, "norestart", 9) == 0) {
+               appinfo_set_value((struct appinfo *)ai, AIT_STATUS, "installed");
+       } else {
+               int r = appinfo_get_boolean(ai, AIT_RESTART);
+
+               if (r && __check_restart(appid))
+                       return true;
+       }
+
+       return false;
+}
+
 static int __app_dead_handler(int pid, void *data)
 {
        if (pid <= 0)
@@ -247,6 +332,18 @@ static int __app_dead_handler(int pid, void *data)
 
         _D("APP_DEAD_SIGNAL : %d", pid);
 
+       bool restart;
+       char *appid = NULL;
+       const char *tmp_appid;
+
+       restart =  __can_restart_app(pid);
+       if (restart) {
+               tmp_appid = _status_app_get_appid_bypid(pid);
+
+               if (tmp_appid)
+                       appid = strdup(tmp_appid);
+       }
+
        if (app_group_is_leader_pid(pid)) {
                _W("app_group_leader_app, pid: %d", pid);
                if (app_group_find_second_leader(pid) == -1) {
@@ -273,6 +370,11 @@ static int __app_dead_handler(int pid, void *data)
        __remove_item_running_list(pid, getuid());
        _status_remove_app_info_list(pid, getuid());
 
+       if (restart)
+               _start_app_local(getuid(), appid);
+       if (appid)
+               free(appid);
+
        return 0;
 }
 
@@ -371,6 +473,7 @@ static int __init(void)
                return -1;
        }
 
+       restart_tbl = g_hash_table_new(g_str_hash, g_str_equal);
        _request_init();
        app_group_init();
 
index 55bfd11..97e2845 100644 (file)
@@ -289,7 +289,6 @@ static int __app_process_by_pid(int cmd,
        return ret;
 }
 
-
 static gboolean __add_history_handler(gpointer user_data)
 {
        struct rua_rec rec;
@@ -339,28 +338,6 @@ static gboolean __add_history_handler(gpointer user_data)
        return FALSE;
 }
 
-
-static int __release_srv(uid_t caller_uid, const char *appid)
-{
-       int r;
-       const struct appinfo *ai;
-
-       ai = (struct appinfo *)appinfo_find(caller_uid, appid);
-       if (!ai) {
-               SECURE_LOGE("release service: '%s' not found", appid);
-               return -1;
-       }
-
-       r = appinfo_get_boolean(ai, AIT_RESTART);
-       if (r == 1) {
-               /* Auto restart */
-               SECURE_LOGD("Auto restart set: '%s'", appid);
-               return _start_app_local(caller_uid, appid);
-       }
-
-       return 0;
-}
-
 static void __handle_agent_dead_signal(struct ucred *pcr)
 {
        /* TODO: check the credentials from the caller: must be the amd agent */
@@ -931,25 +908,6 @@ static int __dispatch_app_get_status(int clifd, const app_pkt_t *pkt, struct ucr
        return 0;
 }
 
-static int __dispatch_app_released(int clifd, const app_pkt_t *pkt, struct ucred *cr)
-{
-       char *appid;
-       int ret;
-
-       appid = malloc(MAX_PACKAGE_STR_SIZE);
-       if (appid == NULL) {
-               _E("out of memory");
-               __send_result_to_client(clifd, -1);
-               return -1;
-       }
-       strncpy(appid, (const char*)pkt->data, MAX_PACKAGE_STR_SIZE-1);
-       ret = __release_srv(cr->uid, appid);
-       __send_result_to_client(clifd, ret);
-       free(appid);
-
-       return 0;
-}
-
 static int __dispatch_agent_dead_signal(int clifd, const app_pkt_t *pkt, struct ucred *cr)
 {
        _D("AMD_AGENT_DEAD_SIGNAL");
@@ -1088,7 +1046,6 @@ static app_cmd_dispatch_func dispatch_table[APP_CMD_MAX] = {
        [APP_KEY_RESERVE] = __dispatch_legacy_command,
        [APP_KEY_RELEASE] = __dispatch_legacy_command,
        [APP_STATUS_UPDATE] = __dispatch_app_status_update,
-       [APP_RELEASED] = __dispatch_app_released,
        [APP_RUNNING_LIST_UPDATE] = __dispatch_legacy_command,
        [APP_TERM_REQ_BY_PID] = __dispatch_app_process_by_pid,
        [APP_TERM_BY_PID_ASYNC] = __dispatch_app_term_async,
index 6d5ad2d..d98b6b0 100644 (file)
 #define PROC_TYPE_INCLUDE              "include"
 #define PROC_TYPE_WAKEUP               "wakeup"
 
+#define TEP_BUS_NAME "org.tizen.system.deviced"
+#define TEP_OBJECT_PATH "/Org/Tizen/System/DeviceD/Tzip"
+#define TEP_INTERFACE_NAME "org.tizen.system.deviced.Tzip"
+#define TEP_MOUNT_METHOD "Mount"
+#define TEP_UNMOUNT_METHOD "Unmount"
+#define TEP_IS_MOUNTED_METHOD "IsMounted"
+
 #endif
index d741363..ed3866e 100644 (file)
@@ -51,7 +51,6 @@ enum app_cmd {
        APP_KEY_RESERVE,
        APP_KEY_RELEASE,
        APP_STATUS_UPDATE,
-       APP_RELEASED,
        APP_RUNNING_LIST_UPDATE,
        APP_TERM_REQ_BY_PID,
        APP_TERM_BY_PID_ASYNC,
index 20e9027..163bd01 100644 (file)
@@ -151,6 +151,10 @@ typedef enum _aul_type{
 #define AUL_K_DATA_CONTROL_TYPE   "__AUL_DATA_CONTROL_TYPE__"
 /** AUL internal private key */
 #define AUL_K_PKGID            "__AUL_PKGID_"
+/** AUL internal private key */
+#define AUL_K_INTERNAL_POOL "__AUL_INTERNAL_POOL__"
+/** AUL internal private key */
+#define AUL_TEP_PATH           "_AUL_TEP_PATH_"
 
 /**
  * @brief      This is callback function for aul_launch_init
@@ -1859,6 +1863,15 @@ int aul_listen_cooldown_signal(int (*func) (const char *, void *), void *data);
  */
 int aul_listen_app_status_signal(int (*func) (int, int, void *), void *data);
 
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_check_tep_mount(const char *tep_path);
+
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_is_tep_mount_dbus_done(const char *tep_string);
 
 #ifdef __cplusplus
        }
index 1531791..398afcd 100644 (file)
@@ -111,7 +111,6 @@ cp -R %{_builddir}/%{name}-%{version}/alias/* %{buildroot}%{_datadir}/appsvc
 if [ $1 == 0 ]; then
     systemctl stop ac.service
     systemctl disable ac
-    systemctl --global disable amd_session_agent
 fi
 
 %post
@@ -145,8 +144,6 @@ systemctl daemon-reload
 %{_unitdir_user}/ac.socket
 %{_unitdir_user}/sockets.target.wants/ac.socket
 %{_bindir}/amd
-%{_bindir}/daemon-manager-release-agent
-%{_bindir}/daemon-manager-launch-agent
 %{_sysconfdir}/skel/.applications/dbspace/.appsvc.db
 
 %files test
index 2acb5ad..97356c3 100644 (file)
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <dirent.h>
 #include <glib.h>
+#include <dbus/dbus.h>
 
 #include "aul.h"
 #include "aul_api.h"
@@ -38,6 +39,9 @@
 #include "launch.h"
 #include "key.h"
 #include "aul_util.h"
+#include "app_signal.h"
+
+#define TEP_ISMOUNT_MAX_RETRY_CNT 20
 
 static int aul_initialized = 0;
 static int aul_fd;
@@ -823,5 +827,75 @@ SLPAPI int aul_reload_appinfo(void)
        return app_request_to_launchpad(AMD_RELOAD_APPINFO, pkgname, NULL);
 }
 
-/* vi: set ts=8 sts=8 sw=8: */
+SLPAPI int aul_is_tep_mount_dbus_done(const char *tep_string)
+{
+       DBusMessage *msg;
+       DBusMessage *reply;
+       DBusError err;
+       int ret = -1;
+       int r = -1;
+
+       DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (!conn) {
+               _E("dbus_bus_get error");
+               return -EBADMSG;
+       }
+
+       msg = dbus_message_new_method_call(TEP_BUS_NAME, TEP_OBJECT_PATH,
+                                       TEP_INTERFACE_NAME, TEP_IS_MOUNTED_METHOD);
+       if (!msg) {
+               _E("dbus_message_new_method_call(%s:%s-%s)", TEP_OBJECT_PATH,
+                       TEP_INTERFACE_NAME, TEP_IS_MOUNTED_METHOD);
+               return ret;
+       }
+
+       if (!dbus_message_append_args(msg,
+                               DBUS_TYPE_STRING, &tep_string,
+                               DBUS_TYPE_INVALID)) {
+               _E("Ran out of memory while constructing args\n");
+               dbus_message_unref(msg);
+               return ret;
+       }
+
+       dbus_error_init(&err);
+       reply = dbus_connection_send_with_reply_and_block(conn, msg, 500, &err);
+       if (!reply) {
+               _E("dbus_connection_send error(%s:%s)", err.name, err.message);
+               goto func_out;
+       }
+
+       r = dbus_message_get_args(reply, &err, DBUS_TYPE_INT32, &ret,
+                               DBUS_TYPE_INVALID);
+       if (!r) {
+               _E("no message : [%s:%s]", err.name, err.message);
+               goto func_out;
+       }
+
+func_out:
+       dbus_message_unref(msg);
+       dbus_error_free(&err);
+       return ret;
+}
+
+SLPAPI int aul_check_tep_mount(const char *tep_path)
+{
+       if (tep_path) {
+               int rv = -1;
+               int cnt = 0;
+               while (cnt < TEP_ISMOUNT_MAX_RETRY_CNT) {
+                       rv = aul_is_tep_mount_dbus_done(tep_path);
+                       if (rv == 1)
+                               break;
+                       usleep(50 * 1000);
+                       cnt++;
+               }
+               /* incase after trying 1 sec, not getting mounted then quit */
+               if (rv != 1) {
+                       _E("Not able to mount within 1 sec");
+                       return -1;
+               }
+       }
+       return 0;
+}
+