mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 21:06:50 +01:00
Pebble: fix of pairing issue with Pebble 2
This commit is contained in:
parent
983b7352cb
commit
2c316bfe9d
@ -100,7 +100,7 @@ public class BondingUtil {
|
||||
case BluetoothDevice.BOND_BONDED: {
|
||||
LOG.info("Bonded with " + device.getAddress());
|
||||
//noinspection StatementWithEmptyBody
|
||||
if (isLePebble(device) || !bondingInterface.getAttemptToConnect()) {
|
||||
if (isLePebble(device) || isPebble2(device) || !bondingInterface.getAttemptToConnect()) {
|
||||
// Do not initiate connection to LE Pebble and some others!
|
||||
} else {
|
||||
attemptToFirstConnect(bondingInterface.getCurrentTarget().getDevice());
|
||||
@ -293,6 +293,15 @@ public class BondingUtil {
|
||||
(device.getName().startsWith("Pebble-LE ") || device.getName().startsWith("Pebble Time LE "));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if device is Pebble 2
|
||||
*/
|
||||
public static boolean isPebble2(BluetoothDevice device) {
|
||||
return device.getType() == BluetoothDevice.DEVICE_TYPE_LE &&
|
||||
device.getName().startsWith("Pebble ") &&
|
||||
!device.getName().startsWith("Pebble Time LE ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the CompanionDeviceManager bonding method
|
||||
*/
|
||||
@ -379,9 +388,15 @@ public class BondingUtil {
|
||||
|
||||
GB.toast(bondingInterface.getContext(), bondingInterface.getContext().getString(R.string.pairing_creating_bond_with, device.getName(), device.getAddress()), Toast.LENGTH_LONG, GB.INFO);
|
||||
toast(bondingInterface.getContext(), bondingInterface.getContext().getString(R.string.discovery_attempting_to_pair, macAddress), Toast.LENGTH_SHORT, GB.INFO);
|
||||
if (GBApplication.getPrefs().getBoolean("enable_companiondevice_pairing", true) &&
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
|
||||
boolean companionPairingEnabled = GBApplication.getPrefs().getBoolean("enable_companiondevice_pairing", true) &&
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
|
||||
|
||||
if (companionPairingEnabled && !isPebble2(device)) {
|
||||
companionDeviceManagerBond(bondingInterface, device, macAddress);
|
||||
} else if (isPebble2(device)) {
|
||||
// TODO: start companionDevicePairing after connecting to Pebble 2 but before writing to pairing trigger
|
||||
attemptToFirstConnect(device);
|
||||
} else {
|
||||
bluetoothBond(bondingInterface, device);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user