+BT_EXPORT_API int bluetooth_set_battery_monitor_state(bool state)
+{
+ if (vconf_set_bool(VCONFKEY_BATTERY_MONITOR_STATUS, state) != 0)
+ {
+ BT_ERR("vconf_set_bool failed");
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ battery_monitor_state = (state == false) ? BT_MONITOR_OFF : BT_MONITOR_ON;
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+static void __bt_battery_monitor_status_changed_cb(keynode_t *node, void *data)
+{
+ gboolean status = FALSE;
+ int type;
+
+ type = vconf_keynode_get_type(node);
+ if (type == VCONF_TYPE_BOOL) {
+ status = vconf_keynode_get_bool(node);
+
+ BT_DBG("Update the monitor state to %d", status);
+
+ battery_monitor_state = (status == FALSE) ? BT_MONITOR_OFF : BT_MONITOR_ON;
+ } else {
+ BT_ERR("Invaild vconf key type : %d", type);
+ return;
+ }
+}
+
+void _bt_reset_battery_monitor_info(void)
+{
+ vconf_ignore_key_changed(VCONFKEY_BATTERY_MONITOR_STATUS,
+ (vconf_callback_fn)__bt_battery_monitor_status_changed_cb);
+
+ _bt_rfcomm_server_reset_timer();
+ _bt_rfcomm_client_reset_timer();
+
+ battery_monitor_state = BT_MONITOR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_get_battery_monitor_state()
+{
+ int state = 0;
+
+ if (battery_monitor_state != BT_MONITOR_NONE)
+ return battery_monitor_state;
+
+ if (vconf_get_bool(VCONFKEY_BATTERY_MONITOR_STATUS, &state) != 0)
+ BT_ERR("vconf_get_bool failed");
+
+ battery_monitor_state = state;
+
+ if (vconf_notify_key_changed(VCONFKEY_BATTERY_MONITOR_STATUS,
+ (vconf_callback_fn)__bt_battery_monitor_status_changed_cb, NULL) < 0)
+ BT_ERR("Unable to register key handler");
+
+ return state;
+}
+