This API use to get all running application list, including sub app.
Change-Id: Icd4cd3df43acf752f10045d4df57f054cc3c4801
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
*/
typedef struct _aul_app_info {
int pid; /**< app's pid if running*/
- char* pkg_name; /**< application id */
- char* app_path; /**< application excutable path */
- char* appid;
+ char *pkg_name; /**< application id */
+ char *app_path; /**< application excutable path */
+ char *appid;
+ char *pkgid; /**< package id */
+ int status; /**< app's status */
+ int is_sub_app; /**< state whether sub app of app group */
} aul_app_info;
/**
* This API call iter_fn with each aul_app_info of running apps when running application is found.
* @par Purpose:
* If you want to get running application list, use this API
- * This API give you running applications which has SLP desktop file.
* @par Typical use case:
* In general, this API is used by task manager appllication. (running application list viewer)
*
/**
* @par Description:
+ * This API use to get all running application list, including sub app.
+ * This API call iter_fn with each aul_app_info of running apps when running application is found.
+ * @par Purpose:
+ * If you want to get all running application list, use this API
+ * @par Typical use case:
+ * In general, this API is used by task manager application. (running application list viewer)
+ *
+ * @param[in] iter_fn iterator function
+ * @param[in] data user-supplied data for iter_fn
+ * @return 0 if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_ERROR - internal error
+ *
+ * @code
+ * #include <aul.h>
+ *
+ * int iterfunc_status(const aul_app_info *info, void *data)
+ * {
+ * printf("\t==========================\n");
+ * printf("\t pid: %d\n", info->pid);
+ * printf("\t appid: %s\n", info->appid);
+ * printf("\t app_path: %s\n", info->app_path);
+ * printf("\t pkgid: %s\n", info->pkgid);
+ * printf("\t status: %d\n", info->status);
+ * printf("\t is_sub_app : %d\n", info->is_sub_app);
+ * printf("\t==========================\n");
+ * return 0;
+ * }
+ *
+ * int iterate_running_apps()
+ * {
+ * return aul_app_get_all_running_app_info(iterfunc_status,NULL);
+ * }
+ *
+ * @endcode
+ * @remark
+ * This API should use if you want to know running application which has desktop files.
+ * If you want to get all process list, you must iterate process information by using proc filesystem
+ * Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
+ * This API is only available in User Session.
+ */
+int aul_app_get_all_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
+
+/**
+ * @par Description:
* This API get application package name by pid
* @par Purpose:
* If you want to get package name of running application, use this API
AMD_RELOAD_APPINFO,
/* reserved for AMD Agent */
AGENT_DEAD_SIGNAL,
+
+ APP_ALL_RUNNING_INFO,
APP_CMD_MAX
};
info.pid = atoi(strtok_r(token, ":", &saveptr2));
info.appid = strtok_r(NULL, ":", &saveptr2);
info.app_path = strtok_r(NULL, ":", &saveptr2);
+ info.pkgid = strtok_r(NULL, ":", &saveptr2);
+ info.status = atoi(strtok_r(NULL, ":", &saveptr2));
+ info.is_sub_app = atoi(strtok_r(NULL, ":", &saveptr2));
+ info.pkg_name = strdup(info.appid);
+
+ enum_fn(&info, user_param);
+ free(info.pkg_name);
+ }
+
+ free(pkt);
+
+ return AUL_R_OK;
+}
+
+API int aul_app_get_all_running_app_info(aul_app_info_iter_fn enum_fn,
+ void *user_param)
+{
+ app_pkt_t *pkt;
+ char *saveptr1;
+ char *saveptr2;
+ char *token;
+ char *pkt_data;
+ aul_app_info info;
+
+ memset(&info, 0, sizeof(info));
+ if (enum_fn == NULL)
+ return AUL_R_EINVAL;
+
+ pkt = aul_sock_send_raw_with_pkt_reply(AUL_UTIL_PID, getuid(),
+ APP_ALL_RUNNING_INFO, NULL, 0, AUL_SOCK_NONE);
+ if (pkt == NULL)
+ return AUL_R_ERROR;
+
+ for (pkt_data = (char *)pkt->data; ; pkt_data = NULL) {
+ token = strtok_r(pkt_data, ";", &saveptr1);
+ if (token == NULL)
+ break;
+ info.pid = atoi(strtok_r(token, ":", &saveptr2));
+ info.appid = strtok_r(NULL, ":", &saveptr2);
+ info.app_path = strtok_r(NULL, ":", &saveptr2);
+ info.pkgid = strtok_r(NULL, ":", &saveptr2);
+ info.status = atoi(strtok_r(NULL, ":", &saveptr2));
+ info.is_sub_app = atoi(strtok_r(NULL, ":", &saveptr2));
info.pkg_name = strdup(info.appid);
enum_fn(&info, user_param);
return aul_app_get_running_app_info(iterfunc, NULL);
}
+int iterfunc_status(const aul_app_info *info, void *data)
+{
+ printf("\t==========================\n");
+ printf("\t pid: %d\n", info->pid);
+ printf("\t appid: %s\n", info->appid);
+ printf("\t app_path: %s\n", info->app_path);
+ printf("\t pkgid: %s\n", info->pkgid);
+ printf("\t status: %d\n", info->status);
+ printf("\t is_sub_app : %d\n", info->is_sub_app);
+ printf("\t==========================\n");
+
+ return 0;
+}
+
+int get_all_app_test()
+{
+ static int num = 0;
+ printf("[aul_app_get_all_running_app_info %d test] \n", num++);
+ return aul_app_get_all_running_app_info(iterfunc_status, NULL);
+}
int get_app_bypid_test()
{
int pid = 0;
"[usage] is_run <pkgname>"},
{"getallpkg", get_allpkg_test, "aul_app_get_running_app_info test",
"[usage] getallpkg all"},
+ {"getallappstatus", get_all_app_test, "aul_app_get_all_running_app_info test",
+ "[usage] getallappstatus "},
{"get_app_bypid", get_app_bypid_test, "aul_app_get_appid_bypid test",
"[usage] get_app_bypid <pid>"},
{"get_pkg_bypid", get_pkg_bypid_test, "aul_app_get_pkgid_bypid test",