#define APP_WATCHDOG_TIMER_INTERVAL 10
+#define APP_TYPE_SERVICE "svcapp"
+#define APP_TYPE_UI "uiapp"
+#define APP_TYPE_WIDGET "widgetapp"
+#define APP_TYPE_WATCH "watchapp"
+
static int current_lcd_state;
static GSource *app_watchdog_check_timer;
resourced_notify(RESOURCED_NOTIFIER_SYSTEMTIME_CHANGED, NULL);
}
+static int get_app_type(char *pkgtype, int *apptype)
+{
+ if (!pkgtype || !apptype) {
+ _E("Invalid parameter of pkgtype");
+ return -EINVAL;
+ }
+
+ if (!strncmp(pkgtype, APP_TYPE_SERVICE, sizeof(APP_TYPE_SERVICE))) {
+ *apptype = PROC_TYPE_SERVICE;
+ } else if (!strncmp(pkgtype, APP_TYPE_WIDGET, sizeof(APP_TYPE_WIDGET))) {
+ *apptype = PROC_TYPE_WIDGET;
+ } else if (!strncmp(pkgtype, APP_TYPE_WATCH, sizeof(APP_TYPE_WATCH))) {
+ *apptype = PROC_TYPE_WATCH;
+ } else if (!strncmp(pkgtype, APP_TYPE_UI, sizeof(APP_TYPE_UI))) {
+ *apptype = PROC_TYPE_GUI;
+ } else {
+ _E("Unknown pkgtype is not able to get app type");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
EXPORT_TEST void proc_dbus_aul_launch(GVariant *params)
{
pid_t pid = 0;
char *appid = NULL;
char *pkgid = NULL;
char *pkgtype = NULL;
+ int ret;
do_expr_unless_g_variant_get_typechecked(return, params, "(i&s&s&s)", &pid, &appid, &pkgid, &pkgtype);
if (pid == 0 || !appid || !pkgid || !pkgtype) {
appid, pkgid, pid, pkgtype);
#endif
- if (!strncmp(pkgtype, "svc", 3)) {
- apptype = PROC_TYPE_SERVICE;
+ ret = get_app_type(pkgtype, &apptype);
+ if (ret < 0)
+ return;
+
+ if (apptype == PROC_TYPE_SERVICE)
status = PROC_CGROUP_SET_SERVICE_REQUEST;
- } else if (!strncmp(pkgtype, "ui", 2)) {
- apptype = PROC_TYPE_GUI;
- status = PROC_CGROUP_SET_LAUNCH_REQUEST;
- } else if (!strncmp(pkgtype, "widget", 6)) {
- apptype = PROC_TYPE_WIDGET;
- status = PROC_CGROUP_SET_LAUNCH_REQUEST;
- } else if (!strncmp(pkgtype, "watch", 5)) {
- apptype = PROC_TYPE_WATCH;
+ else
status = PROC_CGROUP_SET_LAUNCH_REQUEST;
- } else
- return;
resourced_proc_status_change(status, pid, appid, pkgid, apptype);
}
char *appid = NULL;
char *pkgid = NULL;
char *pkgtype = NULL;
+ int ret;
do_expr_unless_g_variant_get_typechecked(return, params, "(i&s&s&s)", &pid, &appid, &pkgid, &pkgtype);
if (pid == 0 || !appid || !pkgid || !pkgtype) {
return;
}
- if (!strncmp(pkgtype, "svc", 3))
- apptype = PROC_TYPE_SERVICE;
- else if (!strncmp(pkgtype, "widget", 6))
- apptype = PROC_TYPE_WIDGET;
- else if (!strncmp(pkgtype, "watch", 5))
- apptype = PROC_TYPE_WATCH;
- else
- apptype = PROC_TYPE_GUI;
+ ret = get_app_type(pkgtype, &apptype);
+ if (ret < 0)
+ return;
resourced_proc_status_change(status, pid, appid, pkgid, apptype);
}
char *pkgid = NULL;
char *statstr = NULL;
char *pkgtype = NULL;
+ int ret;
do_expr_unless_g_variant_get_typechecked(return, params, "(i&s&s&s&s)", &pid, &appid, &pkgid, &statstr, &pkgtype);
if (pid == 0 || !appid || !pkgid || !statstr || !pkgtype) {
else
return;
- if (!strncmp(pkgtype, "svc", 3))
- apptype = PROC_TYPE_SERVICE;
- else if (!strncmp(pkgtype, "widget", 6))
- apptype = PROC_TYPE_WIDGET;
- else if (!strncmp(pkgtype, "watch", 5))
- apptype = PROC_TYPE_WATCH;
- else
- apptype = PROC_TYPE_GUI;
+ ret = get_app_type(pkgtype, &apptype);
+ if (ret < 0)
+ return;
resourced_proc_status_change(status, pid, appid, pkgid, apptype);
}