The APP_LISTEN_STATUS and APP_STATUS_NOTIFICATION are deleted.
The aul_listen_app_status API uses the app com.
This patch changes the callback type to provide more information.
Change-Id: I68272b701d4c7eaf9c64bc67df5d35b3753ad456
Signed-off-by: Hawnkyu Jhun <h.jhun@samsung.com>
*/
int aul_disable_alias_info(const char *appid);
-/*
+/**
+ * This API is only for Appfw internally.
+ */
+typedef int (*app_status_cb)(aul_app_info *info, int ctx_status, void *data);
+
+/**
+ * This API is only for Appfw internally.
+ */
+typedef struct status_listen_s *status_listen_h;
+
+/**
* This API is only for Appfw internally.
*/
-API int aul_listen_app_status(const char *appid,
- int (*aul_handler)(const char *appid, const char *pkgid,
- int pid, int status, int is_subapp, void *data),
- void *data);
+int aul_listen_app_status(const char *appid, app_status_cb callback,
+ void *data, status_listen_h *handle);
/*
* This API is only for Appfw internally.
APP_RESUME_BY_PID_ASYNC = 72,
APP_SET_ALIAS_APPID = 73,
APP_UNSET_ALIAS_APPID = 74,
- APP_LISTEN_STATUS = 75,
- APP_STATUS_NOTIFICATION = 76,
- APP_ENABLE_ALIAS_INFO = 77,
- APP_DISABLE_ALIAS_INFO = 78,
- APP_GROUP_ACTIVATE_ABOVE = 79,
- ADD_APP_SCREEN = 80,
+ APP_ENABLE_ALIAS_INFO = 75,
+ APP_DISABLE_ALIAS_INFO = 76,
+ APP_GROUP_ACTIVATE_ABOVE = 77,
+ ADD_APP_SCREEN = 78,
+ REMOVE_APP_SCREEN = 79,
+ APP_UPDATE_REQUESTED = 80,
- REMOVE_APP_SCREEN = 81,
- APP_UPDATE_REQUESTED = 82,
- ADD_SCREEN_VIEWER = 83,
- REMOVE_SCREEN_VIEWER = 84,
- LAUNCHPAD_LAUNCH_SIGNAL = 85,
- APP_RUNNING_INSTANCE_INFO = 86,
- APP_GET_INSTANCE_ID_BYPID = 87,
- APP_SET_CACHE = 88,
- APP_GET_APPID_FROM_CACHE = 89,
- APP_INVALIDATE_CACHE = 90,
+ ADD_SCREEN_VIEWER = 81,
+ REMOVE_SCREEN_VIEWER = 82,
+ LAUNCHPAD_LAUNCH_SIGNAL = 83,
+ APP_RUNNING_INSTANCE_INFO = 84,
+ APP_GET_INSTANCE_ID_BYPID = 85,
+ APP_SET_CACHE = 86,
+ APP_GET_APPID_FROM_CACHE = 87,
+ APP_INVALIDATE_CACHE = 88,
+ APP_STARTUP_SIGNAL = 89,
+ APP_WINDOW_ATTACH = 90,
- APP_STARTUP_SIGNAL = 91,
- APP_WINDOW_ATTACH = 92,
- APP_WINDOW_DETACH = 93,
- APP_START_RES_ASYNC = 94,
+ APP_WINDOW_DETACH = 91,
+ APP_START_RES_ASYNC = 92,
APP_CMD_MAX
};
gboolean __aul_glib_handler(gpointer data);
int app_com_recv(bundle *b);
-void app_status_event(bundle *kb);
int aul_launch_app_with_result_async(const char *appid, bundle *b,
void (*callback)(bundle *, int, void *), void *data);
int aul_launch_app_with_result_async_for_uid(const char *appid, bundle *b,
case APP_SUSPEND:
app_prepare_to_suspend(kbundle);
break;
- case APP_STATUS_NOTIFICATION:
- app_status_event(kbundle);
- break;
case WIDGET_GET_CONTENT:
widget_get_content(clifd, kbundle);
break;
#include "aul_sock.h"
#include "aul_api.h"
#include "launch.h"
+#include "aul_app_com.h"
typedef struct _app_status_cb_info_t {
int (*handler)(int status, void *data);
void *data;
} app_status_cb_info_t;
-static int (*_aul_status_listen_handler)(const char *appid, const char *pkgid,
- int pid, int status, int is_sub_app, void *data);
-static void *_aul_status_listen_data;
+struct status_listen_s {
+ aul_app_com_connection_h conn;
+ app_status_cb callback;
+ void *user_data;
+};
static int app_status = STATUS_LAUNCHING;
-extern int aul_launch_fini();
static GList *app_status_cb_list;
API int aul_status_update(int status)
return ret;
}
-void app_status_event(bundle *kb)
+static int __app_status_event_cb(const char *endpoint, aul_app_com_result_e res,
+ bundle *envelope, void *user_data)
{
- const char *appid;
- const char *pkgid;
+ struct status_listen_s *listen = (struct status_listen_s *)user_data;
+ aul_app_info app_info = { 0, };
const char *val;
- int pid = -1;
- int status = -1;
- int is_subapp = -1;
+ int context_status;
- if (kb == NULL) {
- _E("Invalid parameter");
- return;
+ if (listen == NULL) {
+ _E("Critical error");
+ return -1;
+ }
+
+ bundle_get_str(envelope, AUL_K_APPID, &app_info.appid);
+ if (app_info.appid == NULL) {
+ _E("Failed to get application id");
+ return -1;
+ }
+
+ bundle_get_str(envelope, AUL_K_PKGID, &app_info.pkgid);
+ if (app_info.pkgid == NULL) {
+ _E("Failed to get package id");
+ return -1;
+ }
+
+ bundle_get_str(envelope, AUL_K_EXEC, &app_info.app_path);
+ if (app_info.app_path == NULL) {
+ _E("Failed to get app path");
+ return -1;
+ }
+
+ bundle_get_str(envelope, AUL_K_INSTANCE_ID, &app_info.instance_id);
+
+ val = bundle_get_val(envelope, AUL_K_PID);
+ if (val == NULL) {
+ _E("Failed to get pid");
+ return -1;
+ }
+ app_info.pid = atoi(val);
+
+ val = bundle_get_val(envelope, AUL_K_STATUS);
+ if (val == NULL) {
+ _E("Failed to get status");
+ return -1;
}
+ app_info.status = atoi(val);
- appid = bundle_get_val(kb, AUL_K_APPID);
- pkgid = bundle_get_val(kb, AUL_K_PKGID);
- val = bundle_get_val(kb, AUL_K_PID);
- if (val)
- pid = atoi(val);
- val = bundle_get_val(kb, AUL_K_STATUS);
- if (val)
- status = atoi(val);
- val = bundle_get_val(kb, AUL_K_IS_SUBAPP);
- if (val)
- is_subapp = atoi(val);
-
- if (appid == NULL || pkgid == NULL ||
- pid == -1 || status == -1 || is_subapp == -1) {
- _E("Failed to get app status info");
- return;
+ val = bundle_get_val(envelope, AUL_K_IS_SUBAPP);
+ if (val == NULL) {
+ _E("Failed to get is_subapp");
+ return -1;
}
+ app_info.is_sub_app = atoi(val);
- if (_aul_status_listen_handler) {
- _aul_status_listen_handler(appid, pkgid, pid, status,
- is_subapp, _aul_status_listen_data);
+ val = bundle_get_val(envelope, "__CONTEXT_STATUS__");
+ if (val == NULL) {
+ _E("Failed to get context status");
+ return -1;
}
+ context_status = atoi(val);
+
+ listen->callback(&app_info, context_status, listen->user_data);
+
+ return 0;
}
-API int aul_listen_app_status(const char *appid,
- int (*aul_handler)(const char *appid, const char *pkgid,
- int pid, int status, int is_subapp, void *data),
- void *data)
+API int aul_listen_app_status(const char *appid, app_status_cb callback,
+ void *data, status_listen_h *handle)
{
- int ret;
- bundle *kb;
- int initialized = 0;
+ struct status_listen_s *listen;
+ char endpoint[128];
- if (appid == NULL || aul_handler == NULL) {
+ if (appid == NULL || callback == NULL || handle == NULL) {
_E("Invalid parameter");
return AUL_R_EINVAL;
}
- if (!aul_is_initialized()) {
- if (aul_launch_init(NULL, NULL) < 0)
- return AUL_R_ENOINIT;
- initialized = 1;
+ listen = calloc(1, sizeof(struct status_listen_s));
+ if (listen == NULL) {
+ _E("Out of memory");
+ return AUL_R_ERROR;
}
- kb = bundle_create();
- if (kb == NULL) {
- _E("out of memory");
- if (initialized)
- aul_launch_fini();
+ snprintf(endpoint, sizeof(endpoint), "app_status_event:%s:%d",
+ appid, getuid());
+ aul_app_com_create(endpoint, NULL, __app_status_event_cb,
+ listen, &listen->conn);
+ if (listen->conn == NULL) {
+ _E("Failed to create app com");
+ free(listen);
return AUL_R_ERROR;
}
- bundle_add(kb, AUL_K_APPID, appid);
- ret = app_send_cmd(AUL_UTIL_PID, APP_LISTEN_STATUS, kb);
- bundle_free(kb);
+ listen->callback = callback;
+ listen->user_data = data;
- _aul_status_listen_handler = aul_handler;
- _aul_status_listen_data = data;
+ *handle = listen;
- return ret;
+ return AUL_R_OK;
}
-
static char *cmd;
static int apn_pid;
static GMainLoop *mainloop = NULL;
+static status_listen_h listen_handle;
typedef struct _test_func_t {
char *name;
return aul_resume_pid_async_for_uid(apn_pid, atoi(gargv[3]));
}
-static int app_status_handler(const char *appid, const char *pkgid,
- int pid, int status, int is_subapp, void *data)
+static int app_status_handler(aul_app_info *info, int ctx_status, void *data)
{
- printf("aul_listen_app_status: %s status: %d\n", appid, status);
+ printf("aul_listen_app_status: %s status: %d\n", info->appid, ctx_status);
return 0;
}
static int num;
printf("aul_listen_app_status %d test] %s \n", num++, gargv[2]);
- return aul_listen_app_status(gargv[2], app_status_handler, NULL);
+ return aul_listen_app_status(gargv[2], app_status_handler, NULL, &listen_handle);
}
static int test_regex()
if (strcmp(cmd, "launch_res") == 0 || strcmp(cmd, "all") == 0
|| strcmp(cmd, "dbuslaunch") == 0
|| strcmp(cmd, "listen_app_status") == 0
- || strcmp(cmd, "open_svc_res") == 0)
+ || strcmp(cmd, "open_svc_res") == 0 ||
+ strcmp(cmd, "listen_app_status") == 0)
return 0;
else
g_main_loop_quit(mainloop);