Fix to recover bt_adapter when turn on flight mode 74/96574/2 accepted/tizen/common/20161110.190133 accepted/tizen/ivi/20161111.001145 accepted/tizen/mobile/20161111.001049 accepted/tizen/tv/20161111.001105 accepted/tizen/wearable/20161111.001126 submit/tizen/20161110.000647
authorTaejin Woo <tt.woo@samsung.com>
Thu, 10 Nov 2016 01:41:50 +0000 (10:41 +0900)
committerTaejin Woo <tt.woo@samsung.com>
Thu, 10 Nov 2016 01:47:37 +0000 (10:47 +0900)
- When turn on and off flight mode, don't recovery BT's before state

Change-Id: Ie58ceb5a4a8e3e1c339cef6a2fade9e9a99ff94d
Signed-off-by: Taejin Woo <tt.woo@samsung.com>
bt-core/bt-core-adapter.c
bt-core/bt-core-noti-handler.c
bt-service/bt-service-adapter.c
bt-service/bt-service-event-receiver.c

index 7fbb10da18d7619ff4b8c65bba1de947a51cd470..a50285611ea6e166ee2a6111a55f4c704f61c412 100644 (file)
@@ -34,6 +34,8 @@
 static bt_status_t adapter_status = BT_DEACTIVATED;
 static bt_le_status_t adapter_le_status = BT_LE_DEACTIVATED;
 static gboolean is_recovery_mode = FALSE;
+static guint core_enable_timer_id;
+
 
 static int bt_status_before[BT_MODE_MAX] = { VCONFKEY_BT_STATUS_OFF, };
 static int bt_le_status_before[BT_MODE_MAX] = { VCONFKEY_BT_LE_STATUS_OFF, };
@@ -381,10 +383,6 @@ int _bt_disable_adapter_le(void)
 
 int _bt_core_service_request_adapter(int service_function)
 {
-       /* busact module is not in platform */
-#ifndef TIZEN_FEATURE_BUSACT
-       return BLUETOOTH_ERROR_NONE;
-#else
        int ret = -1;
 
        GArray *in_param1 = NULL;
@@ -403,7 +401,6 @@ int _bt_core_service_request_adapter(int service_function)
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
        return ret;
-#endif
 }
 
 static gboolean __bt_core_check_the_adapter_path(GDBusConnection *conn)
@@ -533,7 +530,7 @@ gboolean _bt_core_disable_adapter(void)
 gboolean _bt_core_recover_adapter(void)
 {
        int ret;
-#ifdef TIZEN_FEATURE_BUSACT
+#if 0
        int ret_le;
 #endif
        BT_INFO_C("Recover bt adapter");
@@ -548,11 +545,15 @@ gboolean _bt_core_recover_adapter(void)
 
        if (_bt_core_get_status() == BT_ACTIVATED) {
                _bt_core_set_bt_status(BT_RECOVERY_MODE, 1);
+#ifdef TIZEN_FEATURE_BUSACT
                _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
+#endif
        }
        if (_bt_core_get_le_status() == BT_LE_ACTIVATED) {
                _bt_core_set_bt_le_status(BT_RECOVERY_MODE, 1);
+#ifdef TIZEN_FEATURE_BUSACT
                _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
+#endif
        }
 
        ret = _bt_disable_adapter();
@@ -607,6 +608,8 @@ static gboolean __bt_core_enable_core_timeout_cb(gpointer data)
 {
        BT_DBG("+");
 
+       core_enable_timer_id = 0;
+
        _bt_core_init_vconf_value();
 
        return FALSE;
@@ -618,7 +621,10 @@ gboolean _bt_core_enable_core(void)
 
        _bt_core_update_status();
 
-       g_timeout_add(200, (GSourceFunc)__bt_core_enable_core_timeout_cb, NULL);
+       if (core_enable_timer_id > 0)
+               g_source_remove(core_enable_timer_id);
+
+       core_enable_timer_id = g_timeout_add(200, (GSourceFunc)__bt_core_enable_core_timeout_cb, NULL);
 
        BT_DBG("-");
        return TRUE;
@@ -797,7 +803,9 @@ static gboolean __bt_core_disable_timeout_cb(gpointer data)
                if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status_before_mode) == 0)
                        _bt_core_set_bt_status(BT_FLIGHT_MODE, bt_status_before_mode);
 
+#ifdef TIZEN_FEATURE_BUSACT
                _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
+#endif
                _bt_disable_adapter();
        }
 
@@ -807,7 +815,9 @@ static gboolean __bt_core_disable_timeout_cb(gpointer data)
                if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status_before_mode) == 0)
                        _bt_core_set_bt_le_status(BT_FLIGHT_MODE, bt_le_status_before_mode);
 
+#ifdef TIZEN_FEATURE_BUSACT
                _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
+#endif
                _bt_disable_adapter_le();
        }
 
index 153ef440c91134b836cb0a064378dfc7f8386fe6..fe49f4e69a61fdadf2389fad1a4a1a239a5da225 100644 (file)
@@ -84,7 +84,9 @@ static void __bt_core_handle_adapter_with_flight_mode(gboolean flight_mode)
                        if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status_before_mode) == 0)
                                _bt_core_set_bt_status(BT_FLIGHT_MODE, bt_status_before_mode);
 
+#ifdef TIZEN_FEATURE_BUSACT
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
+#endif
 #ifndef USB_BLUETOOTH
                        _bt_disable_adapter();
 #endif
@@ -96,7 +98,9 @@ static void __bt_core_handle_adapter_with_flight_mode(gboolean flight_mode)
                        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status_before_mode) == 0)
                                _bt_core_set_bt_le_status(BT_FLIGHT_MODE, bt_le_status_before_mode);
 
+#ifdef TIZEN_FEATURE_BUSACT
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
+#endif
 #ifndef USB_BLUETOOTH
                        _bt_disable_adapter_le();
 #endif
@@ -165,7 +169,9 @@ static void __bt_core_handle_adapter_with_power_saving_mode(int power_saving_mod
                        if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status_before_mode) == 0)
                                _bt_core_set_bt_status(BT_POWER_SAVING_MODE, bt_status_before_mode);
 
+#ifdef TIZEN_FEATURE_BUSACT
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
+#endif
 #ifndef USB_BLUETOOTH
                        _bt_disable_adapter();
 #endif
@@ -176,8 +182,10 @@ static void __bt_core_handle_adapter_with_power_saving_mode(int power_saving_mod
                        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status_before_mode) == 0)
                                _bt_core_set_bt_le_status(BT_POWER_SAVING_MODE, bt_le_status_before_mode);
 
+#ifdef TIZEN_FEATURE_BUSACT
                        /* Disable the BT LE */
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
+#endif
 #ifndef USB_BLUETOOTH
                        _bt_disable_adapter_le();
 #endif
index 93dee474fe4d8be0a2449ae79505e3ec7cf519ed..656595f211c45faed220a9c6dfcb0f66a054de10 100644 (file)
@@ -839,8 +839,6 @@ void _bt_handle_adapter_added(void)
                _bt_adapter_set_status(BT_ACTIVATED);
        }
 
-       _bt_service_register_vconf_handler();
-
        /* eventsystem */
        if (eventsystem_register_event(SYS_EVENT_BT_STATE, &status_reg_id,
                        (eventsystem_handler)__bt_state_event_handler, NULL) != ES_R_OK) {
index 639e932cfbd6aa263527ae225ae8f4b3a05d9e2a..428e5f3f333d35ca0a5a9638e841b054d547a4ce 100644 (file)
@@ -430,6 +430,22 @@ static void __bt_device_remote_connected_properties(
        BT_DBG("-");
 }
 
+gboolean __bt_handle_is_flight_mode_enabled(void)
+{
+#ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
+       int is_flight_mode = 0;
+       int ret = -1;
+
+       ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &is_flight_mode);
+       if (ret != 0)
+               BT_ERR("vconf_get_bool failed");
+
+       return (is_flight_mode == 0) ? FALSE : TRUE;
+#else
+       return FALSE;
+#endif
+}
+
 void _bt_handle_adapter_event(GVariant *msg, const char *member)
 {
        BT_DBG("+");
@@ -774,7 +790,10 @@ static void __bt_adapter_property_changed_event(GVariant *msg, const char *path)
 #else
                                if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_state) == 0 &&
                                bt_state != VCONFKEY_BT_STATUS_OFF) {
-                                       _bt_disable_adapter();
+                                       if (__bt_handle_is_flight_mode_enabled() == FALSE)
+                                               _bt_disable_adapter();
+                                       else
+                                               _bt_handle_adapter_removed();
                                }
 #endif
                                if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_state) == 0 &&