static gboolean __bt_core_recovery_cb(gpointer data)
{
int ret = 0;
-#ifdef TIZEN_FEATURE_BUSACT
gboolean is_request_failed = FALSE;
static gboolean is_first_failure = TRUE;
-#endif
BT_DBG("+");
-#ifdef TIZEN_FEATURE_BUSACT
if (_bt_core_get_bt_status(BT_RECOVERY_MODE) == 1) {
ret = _bt_core_service_request_adapter(BT_ENABLE_ADAPTER);
if (ret < 0)
}
} else
is_first_failure = TRUE;
-#endif
if (_bt_core_get_bt_status(BT_RECOVERY_MODE) == 1) {
_bt_core_set_bt_status(BT_RECOVERY_MODE, 0);
return BT_STATUS_SUCCESS;
}
+int _bt_hal_dbus_recover_adapter(void)
+{
+ GDBusProxy *proxy;
+ GVariant *result = NULL;
+ GError *error = NULL;
+
+ DBG("+");
+ proxy = __bt_get_core_proxy();
+
+ if (!proxy) {
+ DBG("_bt_hal_dbus_recover_adapter: Core proxy get failed!!!");
+ return BT_STATUS_FAIL;
+ }
+
+ result = g_dbus_proxy_call_sync(proxy, "RecoverAdapter",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL, &error);
+ if (error) {
+ DBG("RecoverAdapter failed: %s", error->message);
+ g_clear_error(&error);
+ error = NULL;
+ return BT_STATUS_FAIL;
+ }
+
+ DBG("-");
+ g_variant_unref(result);
+ return BT_STATUS_SUCCESS;
+}
+
#ifdef TIZEN_BT_HAL
int _bt_hal_dbus_enable_le(void)
{
int _bt_hal_dbus_disable_adapter(void);
+int _bt_hal_dbus_recover_adapter(void);
+
#ifdef TIZEN_BT_HAL
int _bt_hal_dbus_reset_adapter(void);
#endif
}
#ifdef TIZEN_BT_HAL
+/* Tizen Specific Recover Adapter */
+static int recover(void)
+{
+ return _bt_hal_dbus_recover_adapter();
+}
+#endif
+
+#ifdef TIZEN_BT_HAL
/* Tizen Specific Reset Adapter */
static int reset(void)
{
.init = init,
.enable = enable,
.disable = disable,
+
#ifdef TIZEN_BT_HAL
+ .recover = recover,
.reset = reset,
#endif
int (*disable)(void);
#ifdef TIZEN_BT_HAL
+ /** Recovers Adapter. */
+ int (*recover)(void);
+#endif
+
+#ifdef TIZEN_BT_HAL
/** Reset Bluetooth. */
int (*reset)(void);
#endif
oal_status_t adapter_reset(void);
/**
+ * @brief Recovers Adapter.
+ *
+ * @remarks Disables the BT stack and chip, enables after after seconds.
+ *
+ * @details EVENT: OAL_EVENT_ADAPTER_DISABLED
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ */
+oal_status_t adapter_recover(void);
+
+/**
* @brief Start device discovery
*
* @details For each device found either OAL_EVENT_ADAPTER_INQUIRY_RESULT_BREDR_ONLY
return ret;
}
+oal_status_t adapter_recover(void)
+{
+ int result;
+
+ API_TRACE();
+
+ CHECK_OAL_INITIALIZED();
+ BT_INFO("Adapter Recover");
+
+ result = blued_api->recover();
+ if (result != BT_STATUS_SUCCESS) {
+ BT_ERR("Adapter Recover Failed: [%s]", status2string(result));
+ return convert_to_oal_status(result);
+ }
+
+ return result;
+}
+
oal_status_t adapter_start_inquiry(unsigned short duration)
{
int ret;
static void __bt_set_visible_mode(void);
static void __bt_set_local_name(void);
+static gboolean __bt_disconnect_all(void);
+
/* Initialize BT stack (Initialize OAL layer) */
int _bt_stack_init(void)
{
int _bt_recover_adapter(void)
{
- /* TODO_40 : 4.0 merge */
- BT_INFO("Not Supported");
- return BLUETOOTH_ERROR_NOT_SUPPORT;
+ int result = BLUETOOTH_ERROR_NONE;
+
+ if (_bt_adapter_get_status() == BT_DEACTIVATING) {
+ BT_ERR("Disabling in progress");
+ return BLUETOOTH_ERROR_IN_PROGRESS;
+ }
+
+ if (_bt_adapter_get_status() == BT_DEACTIVATED) {
+ BT_ERR("Already Disabled");
+ return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+ }
+
+ _bt_adapter_set_status(BT_DEACTIVATING);
+
+ result = adapter_recover();
+
+ if (result != OAL_STATUS_SUCCESS)
+ return BLUETOOTH_ERROR_INTERNAL;
+
+ __bt_disconnect_all();
+
+ return result;
}
int _bt_reset_adapter(void)
return BLUETOOTH_ERROR_NONE;
}
+static gboolean __bt_disconnect_all(void)
+{
+ int i;
+ gboolean ret = FALSE;
+ GArray *device_list;
+ guint size;
+ int result;
+ bluetooth_device_info_t *info;
+
+ BT_DBG("");
+ device_list = g_array_new(FALSE, FALSE, sizeof(gchar));
+
+ BT_DBG("The length of device list after the initialisation is [%d]", device_list->len);
+
+ _bt_service_get_bonded_dev_list(&device_list);
+
+ size = (device_list->len) / sizeof(bluetooth_device_info_t);
+
+ for (i = 0; i < size; i++) {
+ info = &g_array_index(device_list,
+ bluetooth_device_info_t, i);
+ if (info->connected != BLUETOOTH_CONNECTED_LINK_NONE) {
+ BT_DBG("Found Connected Device");
+ result = _bt_disconnect_device(&info->device_address);
+ if (result != BLUETOOTH_ERROR_NONE) {
+ BT_ERR("Cannot disconnect all the devices. bt_disconnect_device Failed");
+ g_array_free(device_list, TRUE);
+ return ret;
+ }
+ }
+ }
+ ret = TRUE;
+ g_array_free(device_list, TRUE);
+
+ return ret;
+}
+
static void __bt_handle_pending_a2dp_init(unsigned int a2dp_role)
{
int ret;
static unsigned int bonded_list_index = 0;
static gboolean bonded_list_retrieved = FALSE;
-static void __bt_service_get_bonded_dev_list(GArray **dev_list)
+void _bt_service_get_bonded_dev_list(GArray **dev_list)
{
GSList *l;
}
case BT_GET_BONDED_DEVICES: {
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
- __bt_service_get_bonded_dev_list(&out_param);
+ _bt_service_get_bonded_dev_list(&out_param);
_bt_service_method_return(req_info->context, out_param, result);
_bt_free_info_from_invocation_list(req_info);
g_array_free(out_param, TRUE);
int _bt_get_bonded_devices(void);
+void _bt_service_get_bonded_dev_list(GArray **dev_list);
+
bt_remote_dev_info_t *_bt_service_get_remote_dev_info(const char *address);
gboolean _bt_is_bonded_devices_retrived(void);