#include "process_mgr.h"
#define PM_UNLOCK_TIMER_SEC 0.3
+#define W_CLOCK_VIEWER "org.tizen.w-clock-viewer"
.reserved_apps_list = NULL,
.reserved_popup_app_id = NULL,
};
+static int pid_of_w_clock_viewer = 0;
+
+
+
+static int _launch_app(char *pkgname, bundle *b)
+{
+ _D("Clock mgr launch app: %s", pkgname);
+ int result = AUL_R_OK;
+
+ result = aul_launch_app(pkgname, b);
+
+ if (result < 0) {
+ _E("Failed to launch [%s] result=[%d]", pkgname, result);
+ }
+
+ return result;
+}
+
+
+
+static void _check_ambient_state_and_launch(void)
+{
+ int ambient_mode = 0;
+
+ if (vconf_get_bool(VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL, &ambient_mode) < 0) {
+ _E("Failed to get vconfkey: %s", VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL);
+ ambient_mode = 0;
+ }
+
+ if (ambient_mode) {
+ pid_of_w_clock_viewer = _launch_app(W_CLOCK_VIEWER, NULL);
+ }
+}
+
+
+
+static int _w_clock_viewer_dead_cb(int pid, void *data)
+{
+ _D("W_CLOCK_VIEWER_DEAD_CB is called(pid : %d)", pid);
+
+ if (pid == pid_of_w_clock_viewer) {
+ _E("W_CLOCK_VIEWER(%d) is destoryed.", pid);
+ _check_ambient_state_and_launch();
+ }
+ return 0;
+}
+
+
+
+static void _ambient_mode_setting_changed_cb(keynode_t* node, void *data)
+{
+ int ambient_mode = 0;
+
+ ambient_mode = vconf_keynode_get_bool(node);
+ _D("ambient mode is changed to [%d]", ambient_mode);
+
+ if (ambient_mode) {
+ _D("Launch W_CLOCK_VIEWER");
+ pid_of_w_clock_viewer = _launch_app(W_CLOCK_VIEWER, NULL);
+ } else {
+ _D("Kill W_CLOCK_VIEWER[%d]", pid_of_w_clock_viewer);
+ if (pid_of_w_clock_viewer > 0) {
+ aul_kill_pid(pid_of_w_clock_viewer);
+ pid_of_w_clock_viewer = 0;
+ }
+ }
+}
+
+
+
+static void _ambient_mode_init(void)
+{
+ aul_listen_app_dead_signal(_w_clock_viewer_dead_cb, NULL);
+ if (vconf_notify_key_changed(VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL, _ambient_mode_setting_changed_cb, NULL) < 0) {
+ _E("Failed to add VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL changed callback", VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL);
+ }
+ _check_ambient_state_and_launch();
+}
+
+
+
+static void _ambient_mode_fini(void)
+{
+ if (vconf_ignore_key_changed(VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL, _ambient_mode_setting_changed_cb) < 0) {
+ _E("Failed to ignore VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL changed callback", VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL);
+ }
+}
val = status_passive_get()->starter_reserved_apps_status;
tmp = val & 0x10;
- if(tmp == 0x10){
- if(aul_app_is_running(s_clock_mgr.reserved_popup_app_id) == 1){
+ if (tmp == 0x10) {
+ if (aul_app_is_running(s_clock_mgr.reserved_popup_app_id) == 1) {
return TRUE;
- } else{
+ } else {
_E("%s is not running now.", s_clock_mgr.reserved_popup_app_id);
s_clock_mgr.reserved_popup_app_id = NULL;
val = val ^ 0x10;
val = status_passive_get()->starter_reserved_apps_status;
_W("Current reserved apps status : %x", val);
- if(val > 0){
+ if (val > 0) {
return TRUE;
}
-static Eina_Bool _pm_unlock_timer_cb(void *data){
+static Eina_Bool _pm_unlock_timer_cb(void *data)
+{
/* PM_SLEEP_MARGIN : If the current status is lcd off, deviced reset timer to 1 second. */
display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
return ECORE_CALLBACK_CANCEL;
_D("lcd off source : %s", lcd_off_source);
free(lcd_off_source);
- if(_check_reserved_popup_status() > 0){
+ if (_check_reserved_popup_status() > 0) {
_W("reserved popup is on top. do nothing");
return;
}
return;
}
- EINA_LIST_FOREACH(s_clock_mgr.reserved_apps_list, l, info){
- if(aul_app_is_running(info) == 1){
+ EINA_LIST_FOREACH(s_clock_mgr.reserved_apps_list, l, info) {
+ if (aul_app_is_running(info) == 1) {
// STAY_CUR_STATE : State is not changed directly and phone stay current state until timeout expired.
display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
process_mgr_must_open(info, NULL, NULL);
ecore_timer_add(PM_UNLOCK_TIMER_SEC, _pm_unlock_timer_cb, NULL);
break;
- } else{
+ } else {
_W("%s is not running now", info);
s_clock_mgr.reserved_apps_list = eina_list_remove_list(s_clock_mgr.reserved_apps_list, l);
continue;
}
count = eina_list_count(s_clock_mgr.reserved_apps_list);
- if(count == 0){
+ if (count == 0) {
_W("there is no reserved app.");
vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, 0);
}
_W("clock_mgr_init");
dbus_util_receive_lcd_status(_on_lcd_changed_receive, NULL);
+ _ambient_mode_init();
}
void clock_mgr_fini(void)
{
+ _ambient_mode_fini();
}