Porting flight mode logic to HAL
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-event-receiver.c
index 316a792..6193d99 100644 (file)
@@ -39,6 +39,7 @@
 #include "bt-hal-adapter-le.h"
 #include "bt-hal-gatt-server.h"
 #include "bt-hal-gatt-client.h"
+#include "bt-hal-adapter-dbus-handler.h"
 
 #define BASELEN_PROP_CHANGED (sizeof(struct hal_ev_adapter_props_changed) \
                + sizeof(struct hal_property))
@@ -486,6 +487,43 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
        DBG("-");
 }
 
+static void __bt_hal_flight_ps_mode_cb(keynode_t *node, void *data)
+{
+       gboolean flight_mode = FALSE;
+       int type;
+       DBG_SECURE("HAL callback hit");
+       DBG_SECURE("key=%s", vconf_keynode_get_name(node));
+       type = vconf_keynode_get_type(node);
+       if (type == VCONF_TYPE_BOOL) {
+               flight_mode = vconf_keynode_get_bool(node);
+               if (flight_mode != TRUE) {
+                       ERR("Ignore the event");
+                       return;
+               }
+               else {
+                       ERR("Flight Mode == TRUE");
+               }
+       } else {
+               ERR("Invaild vconf key type : %d", type);
+               return;
+       }
+       DBG("Enabling core now");
+       _bt_hal_enable_core();
+}
+
+static void _bt_hal_register_vconf_handler(void)
+{
+       DBG("+");
+
+       if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+               (vconf_callback_fn)__bt_hal_flight_ps_mode_cb, NULL) < 0)
+                       ERR("Unable to register key handler");
+       DBG("Telephony is disabled");
+       if (vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
+               (vconf_callback_fn)__bt_hal_flight_ps_mode_cb, NULL) < 0)
+                       ERR("Unable to register key handler");
+}
+
 void _bt_hal_handle_adapter_event(GVariant *msg, const char *member)
 {
        DBG("+");
@@ -1455,6 +1493,9 @@ int _bt_hal_initialize_event_receiver(handle_stack_msg cb)
 
        /*TODO: Initialize Obexd Event receiver */
 
+       /* Initialize event receiver for flight mode  */
+       _bt_hal_register_vconf_handler();
+
        event_cb = cb;
        DBG("-");