int bt_is_enabled() { LOGV(__FUNCTION__); int hci_sock = -1; int ret = -1; struct hci_dev_info dev_info; // Check power first ret = check_bluetooth_power(); if (ret == -1 || ret == 0) goto out; ret = -1; // Power is on, now check if the HCI interface is up hci_sock = create_hci_sock(); if (hci_sock < 0) goto out; dev_info.dev_id = HCI_DEV_ID; if (ioctl(hci_sock, HCIGETDEVINFO, (void *)&dev_info) < 0) { ret = 0; goto out; } ret = hci_test_bit(HCI_UP, &dev_info.flags); out: if (hci_sock >= 0) close(hci_sock); return ret; }
int bt_is_enabled() { LOGV(__FUNCTION__); int hci_sock = -1; int ret = -1; struct hci_dev_info dev_info; // Check power first ret = check_bluetooth_power(); LOGI("# %s(); check ret = %d", __func__, ret); if (ret == -1 || ret == 0) goto out; ret = -1; // Power is on, now check if the HCI interface is up hci_sock = create_hci_sock(); if (hci_sock < 0) goto out; dev_info.dev_id = HCI_DEV_ID; if (ioctl(hci_sock, HCIGETDEVINFO, (void *)&dev_info) < 0) { ret = 0; goto out; } if (dev_info.flags & (1 << (HCI_UP & 31))) { ret = 1; } else { ret = 0; } out: if (hci_sock >= 0) close(hci_sock); return ret; }
int bt_is_enabled() { ALOGV(__FUNCTION__); int hci_sock = -1; int ret = -1; struct hci_dev_info dev_info; #ifndef BLUETOOTH_DOES_NOT_USE_RFKILL // Check power first ret = check_bluetooth_power(); if (ret == -1 || ret == 0) goto out; #endif ret = -1; // Power is on, now check if the HCI interface is up hci_sock = create_hci_sock(); if (hci_sock < 0) goto out; dev_info.dev_id = HCI_DEV_ID; if (ioctl(hci_sock, HCIGETDEVINFO, (void *)&dev_info) < 0) { ret = 0; goto out; } if (dev_info.flags & (1 << (HCI_UP & 31))) { ret = 1; } else { ret = 0; } out: if (hci_sock >= 0) close(hci_sock); return ret; }