STATUS_DYING,
STATUS_HOME,
STATUS_NORESTART,
- STATUS_SERVICE
+ STATUS_SERVICE,
+ STATUS_TERMINATE,
};
typedef enum _aul_type {
*/
int aul_unset_alias_appid(const char *alias_appid);
+/*
+ * 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);
+
#ifdef __cplusplus
}
#endif
struct _app_status_cb_info_t *next;
} app_status_cb_info_t;
-app_status_cb_info_t *app_status_cb = NULL;
+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;
+static app_status_cb_info_t *app_status_cb;
static int app_status = STATUS_LAUNCHING;
+extern int aul_launch_fini();
API int aul_status_update(int status)
{
return ret;
}
+void app_status_event(bundle *kb)
+{
+ const char *appid;
+ const char *pkgid;
+ const char *val;
+ int pid = -1;
+ int status = -1;
+ int is_subapp = -1;
+
+ if (kb == NULL) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ 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;
+ }
+
+ if (_aul_status_listen_handler) {
+ _aul_status_listen_handler(appid, pkgid, pid, status,
+ is_subapp, _aul_status_listen_data);
+ }
+}
+
+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 ret;
+ bundle *kb;
+ int initialized = 0;
+
+ if (appid == NULL || aul_handler == 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;
+ }
+
+ kb = bundle_create();
+ if (kb == NULL) {
+ _E("out of memory");
+ if (initialized)
+ aul_launch_fini();
+ 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);
+
+ _aul_status_listen_handler = aul_handler;
+ _aul_status_listen_data = data;
+
+ return ret;
+}
+