change usb control process name to usb-server
[framework/system/system-server.git] / ss_predefine.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.tizenopensource.org/license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16
17
18 #include <unistd.h>
19 #include <time.h>
20 #include <limits.h>
21 #include <fcntl.h>
22 #include <dirent.h>
23 #include <sysman.h>
24 #include <vconf.h>
25 #include <pmapi.h>
26 #include <ITapiModem.h>
27 #include <TelPower.h>
28 #include <tapi_event.h>
29 #include <tapi_common.h>
30 #include <syspopup_caller.h>
31 #include <sys/reboot.h>
32 #include <sys/time.h>
33
34 #include "ss_log.h"
35 #include "ss_launch.h"
36 #include "ss_queue.h"
37 #include "ss_device_handler.h"
38 #include "ss_device_plugin.h"
39 #include "ss_predefine.h"
40 #include "ss_procmgr.h"
41 #include "include/ss_data.h"
42
43 #define PREDEFINE_SO_DIR                        PREFIX"/lib/ss_predefine/"
44
45 #define CALL_EXEC_PATH                          PREFIX"/bin/call"
46 #define LOWMEM_EXEC_PATH                        PREFIX"/bin/lowmem-popup"
47 #define LOWBAT_EXEC_PATH                        PREFIX"/bin/lowbatt-popup"
48 #define USBCON_EXEC_PATH                        PREFIX"/bin/usb-server"
49 #define TVOUT_EXEC_PATH                         PREFIX"/bin/tvout-selector"
50 #define PWROFF_EXEC_PATH                        PREFIX"/bin/poweroff-popup"
51 #define MEMPS_EXEC_PATH                         PREFIX"/bin/memps"
52
53 /* wait for 5 sec as victim process be dead */
54 #define WAITING_INTERVAL                        5
55
56 #define TVOUT_X_BIN                             "/usr/bin/xberc"
57 #define TVOUT_FLAG                              0x00000001
58 #define MEMPS_LOG_FILE                          "/var/log/memps"
59 #define MAX_RETRY                               2
60
61 #define POWEROFF_DURATION                       2
62 #define POWEROFF_ANIMATION_PATH                 "/usr/bin/boot-animation"
63 #define POWEROFF_NOTI_NAME                      "power_off_start"
64
65 #define WM_READY_PATH                           "/tmp/.wm_ready"
66
67 #define LOWBAT_OPT_WARNING              1
68 #define LOWBAT_OPT_POWEROFF             2
69 #define LOWBAT_OPT_CHARGEERR    3
70 #define LOWBAT_OPT_CHECK                4
71
72 static Ecore_Timer *lowbat_popup_id = NULL;
73 static int lowbat_popup_option = 0;
74
75 static struct timeval tv_start_poweroff;
76 static void powerdown_ap(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
77
78 static int ss_flags = 0;
79
80 static Ecore_Timer *poweroff_timer_id = NULL;
81 static TapiHandle *tapi_handle = NULL;
82
83 static void make_memps_log(char *file, pid_t pid, char *victim_name)
84 {
85         time_t now;
86         struct tm *cur_tm;
87         char params[4096];
88         char new_log[NAME_MAX];
89         static pid_t old_pid = 0;
90         int ret=-1;
91
92         if (old_pid == pid)
93                 return;
94         old_pid = pid;
95
96         now = time(NULL);
97         cur_tm = (struct tm *)malloc(sizeof(struct tm));
98         if (cur_tm == NULL) {
99                 PRT_TRACE_ERR("Fail to memory allocation");
100                 return;
101         }
102
103         if (localtime_r(&now, cur_tm) == NULL) {
104                 PRT_TRACE_ERR("Fail to get localtime");
105                 return;
106         }
107
108         PRT_TRACE("%s_%s_%d_%.4d%.2d%.2d_%.2d%.2d%.2d.log", file, victim_name,
109                  pid, (1900 + cur_tm->tm_year), 1 + cur_tm->tm_mon,
110                  cur_tm->tm_mday, cur_tm->tm_hour, cur_tm->tm_min,
111                  cur_tm->tm_sec);
112         snprintf(new_log, sizeof(new_log),
113                  "%s_%s_%d_%.4d%.2d%.2d_%.2d%.2d%.2d.log", file, victim_name,
114                  pid, (1900 + cur_tm->tm_year), 1 + cur_tm->tm_mon,
115                  cur_tm->tm_mday, cur_tm->tm_hour, cur_tm->tm_min,
116                  cur_tm->tm_sec);
117
118         snprintf(params, sizeof(params), "-f %s", new_log);
119         ret = ss_launch_evenif_exist(MEMPS_EXEC_PATH, params);
120
121         if(ret > 0) {
122                 char buf[PATH_MAX];
123                 FILE *fp;
124                 snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", ret);
125                 fp = fopen(buf, "w");
126                 if (fp != NULL) {
127                         fprintf(fp, "%d", (-17));
128                         fclose(fp);
129                 }
130         }
131         free(cur_tm);
132 }
133
134 static int lowmem_get_victim_pid()
135 {
136         pid_t pid;
137         int fd;
138
139         if (0 > plugin_intf->OEM_sys_get_memnotify_victim_task(&pid)) {
140                 PRT_TRACE_ERR("Get victim task failed");
141                 return -1;
142         }
143
144         return pid;
145 }
146
147 int lowmem_def_predefine_action(int argc, char **argv)
148 {
149         int pid, ret, oom_adj;
150         char appname[PATH_MAX];
151
152         if (argc < 1)
153                 return -1;
154
155         if (!strcmp(argv[0], OOM_MEM_ACT)) {
156                 pid = lowmem_get_victim_pid();
157                 if (pid > 0 && pid != sysman_get_pid(LOWMEM_EXEC_PATH) && pid != sysman_get_pid(MEMPS_EXEC_PATH)) {
158                         if ((sysman_get_cmdline_name(pid, appname, PATH_MAX)) ==
159                             0) {
160                                 PRT_TRACE_EM
161                                     ("we will kill, lowmem lv2 = %d (%s)\n",
162                                      pid, appname);
163         
164                                 make_memps_log(MEMPS_LOG_FILE, pid, appname);
165
166                                 if(get_app_oomadj(pid, &oom_adj) < 0) {
167                                         PRT_TRACE_ERR("Failed to get oom_adj");
168                                 }
169                                 PRT_TRACE("%d will be killed with %d oom_adj value", pid, oom_adj);
170
171                                 kill(pid, SIGTERM);
172
173                                 if (oom_adj >= OOMADJ_BACKGRD_UNLOCKED) {       
174                                         return 0;
175                                 }
176
177                                 bundle *b = NULL;
178
179                                 b = bundle_create();
180                                 bundle_add(b, "_APP_NAME_", appname);
181                                 ret = syspopup_launch("lowmem-syspopup", b);
182                                 bundle_free(b);
183                                 if (ret < 0) {
184                                         PRT_TRACE_EM("popup lauch failed\n");
185                                         return -1;
186                                 }
187                                 
188                                 if (set_app_oomadj(ret, OOMADJ_SU) < 0) {       
189                                         PRT_TRACE_ERR("Failed to set oom_adj");
190                                 }
191                         }
192                 }
193         } else {
194                 PRT_TRACE_EM("making memps log for low memory\n");
195                 make_memps_log(MEMPS_LOG_FILE, 1, "LOWMEM_WARNING");
196         }
197
198         return 0;
199 }
200
201 int usbcon_def_predefine_action(int argc, char **argv)
202 {
203         int pid;
204         int val = -1;
205         int ret = -1;
206         int bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
207
208         if (plugin_intf->OEM_sys_get_jack_usb_online(&val) == 0) {
209                 if (val == 0) {
210                         vconf_set_int(VCONFKEY_SYSMAN_USB_STATUS,
211                                       VCONFKEY_SYSMAN_USB_DISCONNECTED);
212                         pm_unlock_state(LCD_OFF, STAY_CUR_STATE);
213
214                         vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state);
215                         if(bat_state < VCONFKEY_SYSMAN_BAT_NORMAL) {
216                                 bundle *b = NULL;
217                                 b = bundle_create();
218                                 bundle_add(b, "_SYSPOPUP_CONTENT_", "warning");
219
220                                 ret = syspopup_launch("lowbat-syspopup", b);
221                                 if (ret < 0) {
222                                         PRT_TRACE_EM("popup lauch failed\n");
223                                 }
224                                 bundle_free(b);
225                         }
226                         return 0;
227                 }
228
229                 vconf_set_int(VCONFKEY_SYSMAN_USB_STATUS,
230                               VCONFKEY_SYSMAN_USB_AVAILABLE);
231                 pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
232                 pid = ss_launch_if_noexist(USBCON_EXEC_PATH, NULL);
233                 if (pid < 0) {
234                         PRT_TRACE_ERR("usb predefine action failed\n");
235                         return -1;
236                 }
237                 return pid;
238         }
239         PRT_TRACE_ERR("failed to get usb status\n");
240         return -1;
241 }
242
243 int earjackcon_def_predefine_action(int argc, char **argv)
244 {
245         int val;
246
247         PRT_TRACE_EM("earjack_normal predefine action\n");
248         if (plugin_intf->OEM_sys_get_jack_earjack_online(&val) == 0) {
249                 return vconf_set_int(VCONFKEY_SYSMAN_EARJACK, val);
250         }
251
252         return -1;
253 }
254
255 int lowbat_popup(void *data)
256 {
257         int ret = -1, state = 0;
258         ret = vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &state);
259         if (state == 1 || ret != 0) {
260                 bundle *b = NULL;
261                 b = bundle_create();
262                 if(lowbat_popup_option == LOWBAT_OPT_WARNING) {
263                         bundle_add(b, "_SYSPOPUP_CONTENT_", "warning");
264                 } else if(lowbat_popup_option == LOWBAT_OPT_POWEROFF) {
265                         bundle_add(b, "_SYSPOPUP_CONTENT_", "poweroff");
266                 } else if(lowbat_popup_option == LOWBAT_OPT_CHARGEERR) {
267                         bundle_add(b, "_SYSPOPUP_CONTENT_", "chargeerr");
268                 } else {
269                         bundle_add(b, "_SYSPOPUP_CONTENT_", "check");
270                 }
271
272                 ret = syspopup_launch("lowbat-syspopup", b);
273                 if (ret < 0) {
274                         PRT_TRACE_EM("popup lauch failed\n");
275                         bundle_free(b);
276                         return 1;
277                 }
278                 lowbat_popup_id = NULL;
279                 lowbat_popup_option = 0;
280                 bundle_free(b);
281         } else {
282                 PRT_TRACE_EM("boot-animation running yet");
283                 return 1;
284         }
285
286         return 0;
287 }
288
289 int lowbat_def_predefine_action(int argc, char **argv)
290 {
291         int ret, state=0;
292         char argstr[128];
293         char* option = NULL;
294
295         if (argc < 1)
296                 return -1;
297
298         if(lowbat_popup_id != NULL) {
299                 ecore_timer_del(lowbat_popup_id);
300                 lowbat_popup_id = NULL;
301         }
302
303         bundle *b = NULL;
304         b = bundle_create();
305         if(!strcmp(argv[0],WARNING_LOW_BAT_ACT) || !strcmp(argv[0],CRITICAL_LOW_BAT_ACT)) {
306                 bundle_add(b, "_SYSPOPUP_CONTENT_", "warning");
307                 lowbat_popup_option = LOWBAT_OPT_WARNING;
308         } else if(!strcmp(argv[0],POWER_OFF_BAT_ACT)) {
309                 bundle_add(b, "_SYSPOPUP_CONTENT_", "poweroff");
310                 lowbat_popup_option = LOWBAT_OPT_POWEROFF;
311         } else if(!strcmp(argv[0],CHARGE_ERROR_ACT)) {
312                 bundle_add(b, "_SYSPOPUP_CONTENT_", "chargeerr");
313                 lowbat_popup_option = LOWBAT_OPT_CHARGEERR;
314         } else {
315                 bundle_add(b, "_SYSPOPUP_CONTENT_", "check");
316                 lowbat_popup_option = LOWBAT_OPT_CHECK;
317         }
318
319         ret = vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &state);
320         if (state == 1 || ret != 0) {
321                 ret = syspopup_launch("lowbat-syspopup", b);
322                 if (ret < 0) {
323                         PRT_TRACE_EM("popup lauch failed\n");
324                         bundle_free(b);
325                         lowbat_popup_option = 0;
326                         return -1;
327                 }
328         } else {
329                 PRT_TRACE_EM("boot-animation running yet");
330                 lowbat_popup_id = ecore_timer_add(1, lowbat_popup, NULL);
331         }
332         bundle_free(b);
333         return 0;
334 }
335
336 Eina_Bool powerdown_ap_by_force(void *data)
337 {
338         struct timeval now;
339         int poweroff_duration = POWEROFF_DURATION;
340         char *buf;
341
342         if(tapi_handle != NULL)
343         {
344                 tel_deinit(tapi_handle);
345                 tapi_handle = NULL;
346         }
347         /* Getting poweroff duration */
348         buf = getenv("PWROFF_DUR");
349         if (buf != NULL && strlen(buf) < 1024)
350                 poweroff_duration = atoi(buf);
351         if (poweroff_duration < 0 || poweroff_duration > 60)
352                 poweroff_duration = POWEROFF_DURATION;
353
354         gettimeofday(&now, NULL);
355         /* Waiting until power off duration and displaying animation */
356         while (now.tv_sec - tv_start_poweroff.tv_sec < poweroff_duration) {
357                 usleep(100000);
358                 gettimeofday(&now, NULL);
359         }
360
361         PRT_TRACE("Power off by force\n");
362         kill(-1, SIGTERM);
363         /* give a chance to be terminated for each process */
364         sleep(1);
365         sync();
366         reboot(RB_POWER_OFF);
367         return EINA_TRUE;
368 }
369
370 static void powerdown_ap(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
371 {
372         struct timeval now;
373         int poweroff_duration = POWEROFF_DURATION;
374         char *buf;
375
376         if (poweroff_timer_id) {
377                 ecore_timer_del(poweroff_timer_id);
378                 poweroff_timer_id = NULL;
379         }
380         if (tapi_handle) {
381                 tel_deregister_noti_event(tapi_handle,TAPI_NOTI_MODEM_POWER);
382                 tel_deinit(tapi_handle);
383                 tapi_handle = NULL;
384         }
385         PRT_TRACE("Power off \n");
386
387         /* Getting poweroff duration */
388         buf = getenv("PWROFF_DUR");
389         if (buf != NULL && strlen(buf) < 1024)
390                 poweroff_duration = atoi(buf);
391         if (poweroff_duration < 0 || poweroff_duration > 60)
392                 poweroff_duration = POWEROFF_DURATION;
393
394         gettimeofday(&now, NULL);
395         /* Waiting until power off duration and displaying animation */
396         while (now.tv_sec - tv_start_poweroff.tv_sec < poweroff_duration) {
397                 usleep(100000);
398                 gettimeofday(&now, NULL);
399         }
400
401         kill(-1, SIGTERM);
402         /* give a chance to be terminated for each process */
403         sleep(1);
404         sync();
405         reboot(RB_POWER_OFF);
406 }
407 static void powerdown_res_cb(TapiHandle *handle, int result, void *data, void *user_data)
408 {
409         PRT_TRACE("poweroff command request : %d",result);
410 }
411 int poweroff_def_predefine_action(int argc, char **argv)
412 {
413         int ret;
414
415         heynoti_publish(POWEROFF_NOTI_NAME);
416
417         pm_change_state(LCD_NORMAL);
418         system("/etc/rc.d/rc.shutdown &");
419         sync();
420
421         gettimeofday(&tv_start_poweroff, NULL);
422         ret = tel_register_noti_event(tapi_handle, TAPI_NOTI_MODEM_POWER, powerdown_ap, NULL);
423
424         if (ret != TAPI_API_SUCCESS) {
425                 PRT_TRACE_ERR
426                     ("tel_register_event is not subscribed. error %d\n", ret);
427                 powerdown_ap_by_force(NULL);
428                 return 0;
429         }
430
431         ret = tel_process_power_command(tapi_handle, TAPI_PHONE_POWER_OFF, powerdown_res_cb, NULL);
432         if (ret != TAPI_API_SUCCESS) {
433                 PRT_TRACE_ERR("tel_process_power_command() error %d\n", ret);
434                 powerdown_ap_by_force(NULL);
435                 return 0;
436         }
437
438         poweroff_timer_id = ecore_timer_add(15, powerdown_ap_by_force, NULL);
439         return 0;
440 }
441
442 static void enter_flight_mode_cb(TapiHandle *handle, int result, void *data, void *user_data)
443 {
444         PRT_TRACE("enter flight mode result : %d",result);
445 }
446
447 static void leave_flight_mode_cb(TapiHandle *handle, int result, void *data, void *user_data)
448 {
449         PRT_TRACE("leave flight mode result : %d",result);
450 }
451
452 int entersleep_def_predefine_action(int argc, char **argv)
453 {
454         int ret;
455
456         pm_change_state(LCD_NORMAL);
457         sync();
458
459         ret = tel_set_flight_mode(tapi_handle, TAPI_POWER_FLIGHT_MODE_ENTER, enter_flight_mode_cb, NULL);
460         PRT_TRACE_ERR("request for changing into flight mode : %d\n", ret);
461
462         system("/etc/rc.d/rc.entersleep");
463         pm_change_state(POWER_OFF);
464
465         return 0;
466 }
467
468 int leavesleep_def_predefine_action(int argc, char **argv)
469 {
470         int ret;
471
472         pm_change_state(LCD_NORMAL);
473         sync();
474
475         ret = tel_set_flight_mode(tapi_handle, TAPI_POWER_FLIGHT_MODE_LEAVE, leave_flight_mode_cb, NULL);
476         PRT_TRACE_ERR("request for changing into flight mode : %d\n", ret);
477
478         return 0;
479 }
480
481 static void restart_ap(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
482
483 Eina_Bool restart_ap_ecore(void *data)
484 {
485         restart_ap(tapi_handle,NULL,(void *)-1,NULL);
486         return EINA_TRUE;
487 }
488
489 static void restart_ap(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
490 {
491         struct timeval now;
492         int poweroff_duration = POWEROFF_DURATION;
493         char *buf;
494
495         if (poweroff_timer_id) {
496                 ecore_timer_del(poweroff_timer_id);
497                 poweroff_timer_id = NULL;
498         }
499
500
501         if(tapi_handle != NULL)
502         {
503                 tel_deregister_noti_event(tapi_handle,TAPI_NOTI_MODEM_POWER);
504                 tel_deinit(tapi_handle);
505                 tapi_handle = NULL;
506         }
507
508         PRT_INFO("Restart\n");
509         sync();
510
511         buf = getenv("PWROFF_DUR");
512         if (buf != NULL && strlen(buf) < 1024)
513                 poweroff_duration = atoi(buf);
514         if (poweroff_duration < 0 || poweroff_duration > 60)
515                 poweroff_duration = POWEROFF_DURATION;
516         gettimeofday(&now, NULL);
517         while (now.tv_sec - tv_start_poweroff.tv_sec < poweroff_duration) {
518                 usleep(100000);
519                 gettimeofday(&now, NULL);
520         }
521
522         reboot(RB_AUTOBOOT);
523 }
524
525 static void restart_ap_by_force(void *data)
526 {
527         struct timeval now;
528         int poweroff_duration = POWEROFF_DURATION;
529         char *buf;
530
531         if (poweroff_timer_id) {
532                 ecore_timer_del(poweroff_timer_id);
533                 poweroff_timer_id = NULL;
534         }
535
536
537         if(tapi_handle != NULL)
538         {
539                 tel_deinit(tapi_handle);
540                 tapi_handle = NULL;
541         }
542
543         PRT_INFO("Restart\n");
544         sync();
545
546         buf = getenv("PWROFF_DUR");
547         if (buf != NULL && strlen(buf) < 1024)
548                 poweroff_duration = atoi(buf);
549         if (poweroff_duration < 0 || poweroff_duration > 60)
550                 poweroff_duration = POWEROFF_DURATION;
551         gettimeofday(&now, NULL);
552         while (now.tv_sec - tv_start_poweroff.tv_sec < poweroff_duration) {
553                 usleep(100000);
554                 gettimeofday(&now, NULL);
555         }
556
557         reboot(RB_AUTOBOOT);
558 }
559
560 int restart_def_predefine_action(int argc, char **argv)
561 {
562         int ret;
563
564         pm_change_state(LCD_NORMAL);
565         system("/etc/rc.d/rc.shutdown &");
566         sync();
567
568         gettimeofday(&tv_start_poweroff, NULL);
569
570         ret =
571             tel_register_noti_event(tapi_handle, TAPI_NOTI_MODEM_POWER, restart_ap, NULL);
572         if (ret != TAPI_API_SUCCESS) {
573                 PRT_TRACE_ERR
574                     ("tel_register_event is not subscribed. error %d\n", ret);
575                 restart_ap_by_force((void *)-1);
576                 return 0;
577         }
578
579
580         ret = tel_process_power_command(tapi_handle, TAPI_PHONE_POWER_OFF, powerdown_res_cb, NULL);
581         if (ret != TAPI_API_SUCCESS) {
582                 PRT_TRACE_ERR("tel_process_power_command() error %d\n", ret);
583                 restart_ap_by_force((void *)-1);
584                 return 0;
585         }
586
587         poweroff_timer_id = ecore_timer_add(15, restart_ap_ecore, NULL);
588         return 0;
589 }
590
591 int launching_predefine_action(int argc, char **argv)
592 {
593         int ret;
594
595         if (argc < 0)
596                 return -1;
597
598         /* current just launching poweroff-popup */
599         ret = syspopup_launch("poweroff-syspopup", NULL);
600         if (ret < 0) {
601                 PRT_TRACE_ERR("poweroff popup predefine action failed");
602                 return -1;
603         }
604         return 0;
605 }
606
607 static void ss_action_entry_load_from_sodir()
608 {
609         DIR *dp;
610         struct dirent *dentry;
611         struct sysnoti *msg;
612         char *ext;
613         char tmp[128];
614
615         dp = opendir(PREDEFINE_SO_DIR);
616         if (!dp) {
617                 ERR("fail open %s", PREDEFINE_SO_DIR);
618                 return;
619         }
620
621         msg = malloc(sizeof(struct sysnoti));
622         if (msg == NULL) {
623                 ERR("Malloc failed");
624                 closedir(dp);
625                 return;
626         }
627
628         msg->pid = getpid();
629
630         while ((dentry = readdir(dp)) != NULL) {
631                 if ((ext = strstr(dentry->d_name, ".so")) == NULL)
632                         continue;
633
634                 snprintf(tmp, sizeof(tmp), "%s/%s", PREDEFINE_SO_DIR,
635                          dentry->d_name);
636                 msg->path = tmp;
637                 *ext = 0;
638                 msg->type = &(dentry->d_name[3]);
639                 ss_action_entry_add(msg);
640         }
641         free(msg);
642
643         closedir(dp);
644 }
645
646 void ss_predefine_internal_init(void)
647 {
648
649         /* telephony initialize */
650         int ret = 0;
651         tapi_handle = tel_init(NULL);
652         if (tapi_handle == NULL) {
653                 PRT_TRACE_ERR("tapi init error");
654         }
655 #ifdef NOUSE
656         ss_action_entry_add_internal(PREDEF_CALL, call_predefine_action, NULL,
657                                      NULL);
658 #endif
659         ss_action_entry_add_internal(PREDEF_LOWMEM, lowmem_def_predefine_action,
660                                      NULL, NULL);
661         ss_action_entry_add_internal(PREDEF_LOWBAT, lowbat_def_predefine_action,
662                                      NULL, NULL);
663         ss_action_entry_add_internal(PREDEF_USBCON, usbcon_def_predefine_action,
664                                      NULL, NULL);
665         ss_action_entry_add_internal(PREDEF_EARJACKCON,
666                                      earjackcon_def_predefine_action, NULL,
667                                      NULL);
668         ss_action_entry_add_internal(PREDEF_POWEROFF,
669                                      poweroff_def_predefine_action, NULL, NULL);
670         ss_action_entry_add_internal(PREDEF_PWROFF_POPUP,
671                                      launching_predefine_action, NULL, NULL);
672         ss_action_entry_add_internal(PREDEF_REBOOT,
673                                      restart_def_predefine_action, NULL, NULL);
674
675         ss_action_entry_load_from_sodir();
676
677         /* check and set earjack init status */
678         earjackcon_def_predefine_action(0, NULL);
679 }