summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--am_daemon/amd_launch.c26
-rw-r--r--am_daemon/amd_launch.h1
-rw-r--r--am_daemon/amd_main.c93
-rw-r--r--include/app_signal.h12
-rw-r--r--src/app_signal.c5
-rwxr-xr-xsrc/service_db.c4
6 files changed, 119 insertions, 22 deletions
diff --git a/am_daemon/amd_launch.c b/am_daemon/amd_launch.c
index 933767c5..68e9d660 100644
--- a/am_daemon/amd_launch.c
+++ b/am_daemon/amd_launch.c
@@ -82,18 +82,16 @@ static void __set_stime(bundle *kb)
bundle_add(kb, AUL_K_STARTTIME, tmp);
}
-int _start_app_local(uid_t uid, const char *appid)
+int _start_app_local_with_bundle(uid_t uid, const char *appid, bundle *kb)
{
int ret;
int pid;
const struct appinfo *ai;
- bundle *kb;
const char *app_path;
const char *pkg_type;
const char *hwacc;
char tmpbuf[MAX_PID_STR_BUFSZ];
- kb = bundle_create();
snprintf(tmpbuf, sizeof(tmpbuf), "%d", getpid());
bundle_add_str(kb, AUL_K_CALLER_PID, tmpbuf);
snprintf(tmpbuf, sizeof(tmpbuf), "%d", uid);
@@ -103,7 +101,6 @@ int _start_app_local(uid_t uid, const char *appid)
pid = _status_app_is_running(appid, uid);
if (pid > 0) {
ret = __nofork_processing(APP_START, pid, kb, -1);
- bundle_free(kb);
return ret;
}
@@ -123,15 +120,30 @@ int _start_app_local(uid_t uid, const char *appid)
bundle_add_str(kb, AUL_K_PACKAGETYPE, pkg_type);
pid = app_agent_send_cmd(uid, APP_START, kb);
-
- bundle_free(kb);
-
if (pid > 0)
_status_add_app_info_list(appid, app_path, pid, LAUNCHPAD_PID, uid);
return pid;
}
+int _start_app_local(uid_t uid, const char *appid)
+{
+ int pid;
+ bundle *kb;
+
+ kb = bundle_create();
+ if (kb == NULL) {
+ _E("out of memory");
+ return -1;
+ }
+
+ pid = _start_app_local_with_bundle(uid, appid, kb);
+
+ bundle_free(kb);
+
+ return pid;
+}
+
int _send_to_sigkill(int pid)
{
int pgid;
diff --git a/am_daemon/amd_launch.h b/am_daemon/amd_launch.h
index 5e737d72..212124d8 100644
--- a/am_daemon/amd_launch.h
+++ b/am_daemon/amd_launch.h
@@ -36,5 +36,6 @@ int _term_sub_app(int pid);
int _fake_launch_app(int cmd, int pid, bundle * kb, int clifd);
int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_uid, int fd);
int _start_app_local(uid_t uid, const char *appid);
+int _start_app_local_with_bundle(uid_t uid, const char *appid, bundle *kb);
#endif /* __AUL_AMD_LAUNCH_H_ */
diff --git a/am_daemon/amd_main.c b/am_daemon/amd_main.c
index e7846a66..50026ed8 100644
--- a/am_daemon/amd_main.c
+++ b/am_daemon/amd_main.c
@@ -21,6 +21,7 @@
*/
#include <stdio.h>
+#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -31,6 +32,9 @@
#include <glib.h>
#include <stdlib.h>
#include <tzplatform_config.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <bundle.h>
#include "amd_config.h"
#include "simple_util.h"
@@ -41,8 +45,10 @@
#include "amd_request.h"
#include "amd_app_group.h"
-
#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
+#define AUL_SP_DBUS_PATH "/Org/Tizen/Aul/Syspopup"
+#define AUL_SP_DBUS_SIGNAL_INTERFACE "org.tizen.aul.syspopup"
+#define AUL_SP_DBUS_LAUNCH_REQUEST_SIGNAL "syspopup_launch_request"
typedef struct _r_app_info_t {
char pkg_name[MAX_PACKAGE_STR_SIZE];
@@ -53,7 +59,7 @@ typedef struct _r_app_info_t {
GSList *r_app_info_list;
static void __vconf_cb(keynode_t *key, void *data);
-static int __init();
+static int __init(void);
static int __send_to_sigkill(int pid)
{
@@ -234,7 +240,7 @@ static void __vconf_cb(keynode_t *key, void *data)
}
}
-int __app_dead_handler(int pid, void *data)
+static int __app_dead_handler(int pid, void *data)
{
if (pid <= 0)
return 0;
@@ -264,7 +270,83 @@ int __agent_dead_handler(uid_t user)
return 0;
}
-static int __init()
+static DBusHandlerResult __syspopup_signal_filter(DBusConnection *conn,
+ DBusMessage *message, void *data)
+{
+ DBusError error;
+ const char *interface;
+ const char *appid;
+ const char *b_raw;
+ bundle *kb;
+
+ dbus_error_init(&error);
+
+ interface = dbus_message_get_interface(message);
+ if (interface == NULL) {
+ _E("reject by security issue - no interface");
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+ if (dbus_message_is_signal(message, interface,
+ AUL_SP_DBUS_LAUNCH_REQUEST_SIGNAL)) {
+ if (dbus_message_get_args(message, &error, DBUS_TYPE_STRING, &appid,
+ DBUS_TYPE_STRING, &b_raw, DBUS_TYPE_INVALID) == FALSE) {
+ _E("Failed to get data: %s", error.message);
+ dbus_error_free(&error);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+ _D("syspopup launch request: %s", appid);
+ kb = bundle_decode((const bundle_raw *)b_raw, strlen(b_raw));
+ if (kb) {
+ if (_start_app_local_with_bundle(getuid(), appid, kb) < 0)
+ _E("syspopup launch request failed: %s", appid);
+
+ bundle_free(kb);
+ }
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static int __syspopup_dbus_signal_handler_init(void)
+{
+ DBusError error;
+ DBusConnection *conn;
+ char rule[MAX_LOCAL_BUFSZ];
+
+ dbus_error_init(&error);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (conn == NULL) {
+ _E("Failed to connect to the D-BUS Daemon: %s", error.message);
+ dbus_error_free(&error);
+ return -1;
+ }
+
+ dbus_connection_setup_with_g_main(conn, NULL);
+
+ snprintf(rule, sizeof(rule), "path='%s',type='signal',interface='%s'",
+ AUL_SP_DBUS_PATH, AUL_SP_DBUS_SIGNAL_INTERFACE);
+ dbus_bus_add_match(conn, rule, &error);
+ if (dbus_error_is_set(&error)) {
+ _E("Failed to rule set: %s", error.message);
+ dbus_error_free(&error);
+ return -1;
+ }
+
+ if (dbus_connection_add_filter(conn,
+ __syspopup_signal_filter, NULL, NULL) == FALSE) {
+ _E("Failed to add filter");
+ return -1;
+ }
+
+ _D("syspopup dbus signal initialized");
+
+ return 0;
+}
+
+static int __init(void)
{
if (appinfo_init()) {
_E("appinfo_init failed\n");
@@ -283,6 +365,9 @@ static int __init()
__vconf_cb, NULL) != 0)
_E("Unable to register callback for VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS\n");
+ if (__syspopup_dbus_signal_handler_init() < 0)
+ _E("__syspopup_dbus_signal_handler_init failed");
+
return 0;
}
diff --git a/include/app_signal.h b/include/app_signal.h
index 2b3f1834..6d5ad2d5 100644
--- a/include/app_signal.h
+++ b/include/app_signal.h
@@ -43,18 +43,18 @@
#define AUL_APP_STATUS_DBUS_GROUP "AppGroup"
#define AUL_APP_STATUS_DBUS_TERMINATED "AppTerminated"
-#define SYSTEM_PATH_CORE "/Org/Tizen/System/DeviceD/Core"
-#define SYSTEM_INTERFACE_CORE "org.tizen.system.deviced.core"
+#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_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_PATH_CORE "/Org/Tizen/ResourceD/Process"
+#define RESOURCED_INTERFACE_CORE "org.tizen.resourced.process"
#define RESOURCED_SIGNAL_PROCESS_STATUS "ProcStatus"
diff --git a/src/app_signal.c b/src/app_signal.c
index 3aaa1ab2..53dddcad 100644
--- a/src/app_signal.c
+++ b/src/app_signal.c
@@ -110,7 +110,6 @@ __dbus_signal_filter_session(DBusConnection *conn, DBusMessage *message,
const char *interface;
const char *cooldown_status;
int pid = -1;
- int status;
DBusError error;
dbus_error_init(&error);
@@ -324,7 +323,7 @@ SLPAPI int aul_listen_booting_done_signal(int (*func) (int, void *), void *data)
_E("error app signal fini");
return AUL_R_ERROR;
}
- } else {
+ } else if (!_booting_done_handler) {
if (__app_dbus_signal_remove_rule(system_conn, SYSTEM_PATH_CORE, SYSTEM_INTERFACE_CORE) != 0)
return AUL_R_ERROR;
}
@@ -354,7 +353,7 @@ SLPAPI int aul_listen_cooldown_signal(int (*func) (const char *, void *), void *
_E("error app signal fini");
return AUL_R_ERROR;
}
- } else {
+ } else if (!_cooldown_handler) {
if (__app_dbus_signal_remove_rule(system_conn, SYSTEM_PATH_SYSNOTI, SYSTEM_INTERFACE_SYSNOTI) != 0)
return AUL_R_ERROR;
}
diff --git a/src/service_db.c b/src/service_db.c
index e4c07668..d777c185 100755
--- a/src/service_db.c
+++ b/src/service_db.c
@@ -118,7 +118,7 @@ static void __mkdir_for_user(const char* dir, uid_t uid, gid_t gid) {
}
}
-static char *__get_svc_db(uid_t uid)
+static const char *__get_svc_db(uid_t uid)
{
const char *appsvc_db = NULL;
const char *db_path = NULL;
@@ -143,7 +143,7 @@ static char *__get_svc_db(uid_t uid)
}
-static char *__get_app_info_db(uid_t uid)
+static const char *__get_app_info_db(uid_t uid)
{
const char *app_info_db = NULL;
const char *db_path = NULL;