int threshold_min;
int cur_event;
bool on_boot;
+ bool app_exists;
} candidate_process_context_t;
typedef struct {
char **argv;
};
+struct app_info {
+ const char *type;
+ bool exists;
+};
+
static int __sys_hwacc;
static GList *loader_info_list;
static int user_slot_offset;
static candidate_process_context_t *__add_slot(int type, int loader_id,
int caller_pid, const char *loader_path, const char *extra,
int detection_method, int timeout_val,
- int threshold_max, int threshold_min, bool on_boot);
+ int threshold_max, int threshold_min, bool on_boot,
+ bool app_exists);
static int __remove_slot(int type, int loader_id);
static int __add_default_slots(void);
static gboolean __handle_idle_checker(gpointer data);
continue;
}
+ if (!cpc->app_exists) {
+ iter = g_list_next(iter);
+ continue;
+ }
+
if (cpc->pid == CANDIDATE_NONE &&
(detection_method == EVENT_BOOTING ||
(cpc->detection_method & detection_method))) {
cpc = __add_slot(LAUNCHPAD_TYPE_DYNAMIC, lid, atoi(caller_pid),
add_slot_str, extra,
METHOD_TIMEOUT | METHOD_VISIBILITY, 2000,
- DEFAULT_CPU_THRESHOLD_MAX, DEFAULT_CPU_THRESHOLD_MIN,
- false);
+ DEFAULT_CPU_THRESHOLD_MAX,
+ DEFAULT_CPU_THRESHOLD_MIN,
+ false,
+ true);
__set_timer(cpc);
return lid;
}
return NULL;
}
+static void __update_slot(int type, bool app_exists)
+{
+ candidate_process_context_t *cpc;
+ unsigned long long total = 0;
+ unsigned long long idle = 0;
+
+ cpc = __find_slot(type, PAD_LOADER_ID_STATIC);
+ if (!cpc)
+ return;
+
+ cpc->app_exists = app_exists;
+ if (!cpc->app_exists) {
+ if (cpc->pid > 0) {
+ if (cpc->source > 0)
+ g_source_remove(cpc->source);
+ if (cpc->timer > 0)
+ g_source_remove(cpc->timer);
+ if (cpc->idle_checker > 0)
+ g_source_remove(cpc->idle_checker);
+ if (cpc->send_fd > 0)
+ close(cpc->send_fd);
+ _D("Dispose candidate process %d", cpc->pid);
+ __kill_process(cpc->pid);
+ __reset_slot(cpc);
+ }
+ } else {
+ if (cpc->pid == CANDIDATE_NONE &&
+ cpc->idle_checker == 0) {
+ _get_cpu_idle(&total, &idle);
+ cpc->cpu_idle_time = idle;
+ cpc->cpu_total_time = total;
+ _D("Add idle checker");
+ cpc->idle_checker = g_timeout_add(CPU_CHECKER_TIMEOUT,
+ __handle_idle_checker,
+ g_list_find(candidate_slot_list, cpc));
+ }
+ }
+}
+
+static void __foreach_loader_info(loader_info_t *info, void *data)
+{
+ struct app_info *ai = (struct app_info *)data;
+ bool exist;
+
+ exist = _loader_info_exist_app_type(info, ai->type);
+ if (!exist)
+ return;
+
+ info->app_exists = ai->exists;
+ __update_slot(info->type, info->app_exists);
+}
+
+static int __dispatch_cmd_update_app_type(bundle *b)
+{
+ int r;
+ struct app_info info;
+ const char *is_installed;
+
+ info.type = bundle_get_val(b, AUL_K_APP_TYPE);
+ if (!info.type)
+ return -1;
+
+ is_installed = bundle_get_val(b, AUL_K_IS_INSTALLED);
+ if (is_installed && !strcmp(is_installed, "true"))
+ info.exists = true;
+ else
+ info.exists = false;
+
+ _I("[LAUNCHPAD] type(%s), exists(%d)", info.type, info.exists);
+
+ r = _loader_info_foreach(loader_info_list, __foreach_loader_info,
+ &info);
+ if (r != 0) {
+ _E("Failed to retrieve loader info");
+ return -1;
+ }
+
+ return 0;
+}
+
static gboolean __handle_launch_event(gpointer data)
{
loader_context_t *lc = (loader_context_t *) data;
__real_send(clifd, 0);
clifd = -1;
goto end;
+ case PAD_CMD_UPDATE_APP_TYPE:
+ __dispatch_cmd_update_app_type(kb);
+ close(clifd);
+ clifd = -1;
+ goto end;
}
INIT_PERF(kb);
static candidate_process_context_t *__add_slot(int type, int loader_id,
int caller_pid, const char *loader_path,
const char *loader_extra, int detection_method,
- int timeout_val, int threshold_max, int threshold_min, bool on_boot)
+ int timeout_val, int threshold_max, int threshold_min,
+ bool on_boot, bool app_exists)
{
candidate_process_context_t *cpc;
int fd = -1;
cpc->threshold_max = threshold_max;
cpc->threshold_min = threshold_min;
cpc->on_boot = on_boot;
+ cpc->app_exists = app_exists;
fd = __listen_candidate_process(cpc->type, cpc->loader_id);
if (fd == -1) {
cpc = __add_slot(LAUNCHPAD_TYPE_USER + user_slot_offset,
PAD_LOADER_ID_DIRECT,
0, info->exe, NULL, 0, 0,
- info->cpu_threshold_max, info->cpu_threshold_min, false);
+ info->cpu_threshold_max,
+ info->cpu_threshold_min,
+ false,
+ info->app_exists);
if (cpc == NULL)
return;
PAD_LOADER_ID_STATIC,
0, info->exe, (char *)extra,
info->detection_method, info->timeout_val,
- info->cpu_threshold_max, info->cpu_threshold_min, info->on_boot);
+ info->cpu_threshold_max,
+ info->cpu_threshold_min,
+ info->on_boot,
+ info->app_exists);
if (cpc == NULL)
return;