Android: correctly detect the different BT device types

The previous code would not add the non-LE address for dual stack
devices. Unfortunately, even with this fix we still don't get the
correct result for the dual stack Shearwater Petrel 2 that I have
for testing as Android incorrectly reports it as a BLE-only device.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2018-04-27 15:04:50 -07:00
parent ddd5ec7f56
commit e9fd4cb7dc

View file

@ -247,15 +247,16 @@ void BTDiscovery::getBluetoothDevices()
continue;
}
jint btType = dev.callMethod<jint>("getType", "()I");
// 1 means Classic. 2 means BLE, 3 means dual stack
result.address = dev.callObjectMethod("getAddress","()Ljava/lang/String;").toString();
if (btType == 2) // DEVICE_TYPE_LE
result.address = QString("LE:%1").arg(result.address);
result.name = dev.callObjectMethod("getName", "()Ljava/lang/String;").toString();
qDebug() << "paired Device type" << btType << "with address" << result.address;
btPairedDevices.append(result);
if (btType == 3) { // DEVICE_TYPE_DUAL
if (btType & 1) { // DEVICE_TYPE_CLASSIC
qDebug() << "paired BT classic device type" << btType << "with address" << result.address;
btPairedDevices.append(result);
}
if (btType & 2) { // DEVICE_TYPE_LE
result.address = QString("LE:%1").arg(result.address);
qDebug() << "paired Device type" << btType << "with address" << result.address;
qDebug() << "paired BLE device type" << btType << "with address" << result.address;
btPairedDevices.append(result);
}
}