int aul_app_get_status_bypid_for_uid(int pid, uid_t uid);
/**
+ * @par Description:
+ * This API gets the status of specified application id.
+ * @par Purpose:
+ * This API's purpose is to get the status of the application.
+ *
+ * @param[in] appid application ID
+ * @return 0 or greater if success, nagative value if fail
+ * @retval STATUS_LAUNCHING
+ * @retval STATUS_FOCUS
+ * @retval STATUS_VISIBLE
+ * @retval STATUS_BG
+ * @retval STATUS_DYING
+ * @retval STATUS_NORESTART
+ * @see
+ * aul_status_update
+ * @code
+ * #include <aul.h>
+ *
+ * int func(void)
+ * {
+ * int status;
+ *
+ * status = aul_app_get_status("org.tizen.helloworld");
+ * if (status == STATUS_FOCUS)
+ * printf("org.tizen.helloworld has focus");
+ *
+ * return 0;
+ * }
+ *
+ * @endcode
+ * @remark
+ * This API is only available in User Session.
+ */
+int aul_app_get_status(const char *appid);
+
+/**
+ * @par Description:
+ * This API gets the status of specified application id.
+ * @par Purpose:
+ * This API's purpose is to get the status of the application
+ *
+ * @param[in] appid application ID
+ * @param[in] uid User ID
+ * @return 0 or greater if success, nagative value if fail
+ * @retval STATUS_LAUNCHING
+ * @retval STATUS_FOCUS
+ * @retval STATUS_VISIBLE
+ * @retval STATUS_BG
+ * @retval STATUS_DYING
+ * @retval STATUS_NORESTART
+ *
+ * @remark
+ * This API is only available to System user.
+ */
+int aul_app_get_status_for_uid(const char *appid, uid_t uid);
+
+/**
* @par Description
* This API sets callback function that on application status changed.
* @par Purpose:
return ret;
}
-API int aul_app_get_status_bypid(int pid)
+API int aul_app_get_status_bypid(int pid)
{
return aul_app_get_status_bypid_for_uid(pid, getuid());
}
-API int aul_app_get_status_bypid_for_uid(int pid, uid_t uid)
+API int aul_app_get_status_bypid_for_uid(int pid, uid_t uid)
{
int ret;
return ret;
}
+API int aul_app_get_status(const char *appid)
+{
+ return aul_app_get_status_for_uid(appid, getuid());
+}
+
+API int aul_app_get_status_for_uid(const char *appid, uid_t uid)
+{
+ int ret;
+ bundle *kb;
+
+ if (appid == NULL)
+ return AUL_R_EINVAL;
+
+ kb = bundle_create();
+ if (kb == NULL) {
+ _E("out of memory");
+ return AUL_R_ERROR;
+ }
+
+ bundle_add(kb, AUL_K_APPID, appid);
+ ret = app_send_cmd_for_uid(AUL_UTIL_PID, uid,
+ APP_GET_STATUS_BY_APPID, kb);
+ bundle_free(kb);
+
+ return ret;
+}
+
API int aul_add_status_local_cb(int (*func)(int status, void *data), void *data)
{
app_status_cb_info_t *cb = app_status_cb;
return aul_terminate_pid_sync_for_uid(apn_pid, atoi(gargv[3]));
}
-/*
-static int set_pkg_func()
-{
- char* pkgname;
- char* apppath;
- char* appname;
- char query[QUERY_LEN];
-
- 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,
- "aul_test_desktop_path/%d",getpid());
-
- snprintf (query, sizeof(query), "insert into "TABLE_MENU"(\
- pkg_name,\
- app_path,\
- app_name,\
- app_icon_path,\
- desktop_path)\
- values ('%s', '%s', '%s', '%s', '%s')",
- pkgname,
- apppath,
- appname,
- record->app_icon_path,
- record->desktop_path,
- );
-
- // TODO: record_add is not supported anymore; use AIL
- if (record_add(ADD_ICON, &ai)){
- printf("set pkg success\n");
- return 0;
- }
- else{
- printf("set pkg fail\n");
- return -1;
- }
+static int get_status_test(void)
+{
+ static int num;
+ int ret;
+
+ printf("[aul_app_get_status %d test] %s \n", num++, gargv[2]);
+
+ ret = aul_app_get_status(gargv[2]);
+ printf("appid: %s, status: %d", gargv[2], ret);
+ if (ret >= STATUS_LAUNCHING && ret <= STATUS_NORESTART)
+ printf("(%s)", status_text[ret]);
+ printf("\n");
+
+ return 0;
}
-static int del_pkg_func()
+static int get_status_test_for_uid(void)
{
- app_info ai;
+ static int num;
+ int ret;
- memset(&ai, 0, sizeof(app_info));
- snprintf(ai.pkg_name, NAME_LEN, "%s", gargv[2]);
+ printf("[aul_app_get_status %d test] %s \n", num++, gargv[2]);
- // TODO: record_add is not supported anymore; use AIL
- if(record_delete(DELETE_MENU, &ai)){
- printf("del pkg success\n");
- return 0;
- }
- else {
- printf("del pkg fail\n");
- return -1;
- }
+ ret = aul_app_get_status_for_uid(gargv[2], atoi(gargv[3]));
+ printf("appid: %s, uid: %d, status: %d", gargv[2], atoi(gargv[3]), ret);
+ if (ret >= STATUS_LAUNCHING && ret <= STATUS_NORESTART)
+ printf("(%s)", status_text[ret]);
+ printf("\n");
+
+ return 0;
}
-*/
static int test_regex()
{
"[usage] term_pid_sync <pid>"},
{"term_pid_sync_for_uid", term_pid_sync_test_for_uid, "aul_terminate_pid_sync_for_uid test",
"[usage] term_pid_sync_for_uid <pid> <uid>"},
+ {"get_status", get_status_test, "aul_app_get_status test",
+ "[usage] get_status <appid>"},
+ {"get_status_for_uid", get_status_test_for_uid, "aul_app_get_status_for_uid test",
+ "[usage] get_status_for_uid <appid> <uid>"},
};
int callfunc(char *testname)