2 * Copyright 2013 Samsung Electronics Co., Ltd
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
8 * http://floralicense.org
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.
21 #include <sys/types.h>
31 #include "client_life.h"
35 #include "slave_life.h"
36 #include "critical_log.h"
42 static void lcd_state_cb(keynode_t *node, void *user_data)
47 xmonitor_handle_state_changes();
50 HAPI int setting_is_lcd_off(void)
54 if (vconf_get_int(VCONFKEY_PM_STATE, &state) != 0) {
55 ErrPrint("Idle lock state is not valid\n");
56 state = VCONFKEY_PM_STATE_NORMAL; /* UNLOCK */
59 DbgPrint("State: %d, (%d:lcdoff, %d:sleep)\n", state, VCONFKEY_PM_STATE_LCDOFF, VCONFKEY_PM_STATE_SLEEP);
60 return state == VCONFKEY_PM_STATE_LCDOFF || state == VCONFKEY_PM_STATE_SLEEP;
63 static void power_off_cb(keynode_t *node, void *user_data)
66 CRITICAL_LOG("Terminated(vconf)\n");
68 if (vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &val) != 0) {
69 ErrPrint("Failed to get power off status (%d)\n", val);
73 if (val == VCONFKEY_SYSMAN_POWER_OFF_DIRECT || val == VCONFKEY_SYSMAN_POWER_OFF_RESTART) {
74 if (creat("/tmp/.stop.provider", 0644) < 0)
75 ErrPrint("Failed to create .stop.provider [%s]\n", strerror(errno));
79 ErrPrint("Unknown power state: %d\n", val);
83 HAPI int setting_init(void)
87 ret = vconf_notify_key_changed(VCONFKEY_PM_STATE, lcd_state_cb, NULL);
89 ErrPrint("Failed to add vconf for lock state\n");
91 ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, power_off_cb, NULL);
93 ErrPrint("Failed to add vconf for power state\n");
98 HAPI int setting_fini(void)
101 ret = vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_cb);
102 ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, power_off_cb);