mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Casio: Disable connection priority change on connection
This commit is contained in:
+7
@@ -990,8 +990,10 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
||||
if (connectionType.usesBluetoothClassic() || connectionType.usesBluetoothLE()) {
|
||||
settings = ArrayUtils.insert(0, settings, R.xml.devicesettings_reconnect_periodic);
|
||||
settings = ArrayUtils.insert(0, settings, R.xml.devicesettings_device_connect_back);
|
||||
if (supportsConnectionPriority()) {
|
||||
settings = ArrayUtils.add(settings, R.xml.devicesettings_connection_priority_low_power);
|
||||
}
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
@@ -1201,4 +1203,9 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
||||
// 2 seconds.
|
||||
return 2000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsConnectionPriority() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -965,4 +965,10 @@ public interface DeviceCoordinator {
|
||||
* @return delay in ms for this device to wait before a reconnection attempt is made.
|
||||
*/
|
||||
int getReconnectionDelay();
|
||||
|
||||
/**
|
||||
* Returns whether the device supports changing bluetooth connection priority.
|
||||
* @return
|
||||
*/
|
||||
boolean supportsConnectionPriority();
|
||||
}
|
||||
|
||||
+5
@@ -46,4 +46,9 @@ public abstract class CasioDeviceCoordinator extends AbstractBLEDeviceCoordinato
|
||||
public DeviceKind getDeviceKind(@NonNull GBDevice device) {
|
||||
return DeviceKind.WATCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsConnectionPriority() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -458,10 +458,13 @@ public abstract class AbstractBTLEMultiDeviceSupport extends AbstractBTLEDeviceS
|
||||
|
||||
initializeDevice(builder, deviceIdx);
|
||||
|
||||
boolean lowPower = getDevicePrefs().getConnectionPriorityLowPower();
|
||||
if (getDevice().getDeviceCoordinator().supportsConnectionPriority()) {
|
||||
final boolean lowPower = getDevicePrefs().getConnectionPriorityLowPower();
|
||||
// have to explicitly request normal ("balanced") as some Android devices remember the last
|
||||
// request. Else low power would become a set once option.
|
||||
// #5054 / #5956 - However, on some devices requesting it altogether can make the connection fail
|
||||
builder.requestConnectionPriority(lowPower ? BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER : BluetoothGatt.CONNECTION_PRIORITY_BALANCED);
|
||||
}
|
||||
|
||||
builder.queue();
|
||||
}
|
||||
|
||||
+4
-1
@@ -366,10 +366,13 @@ public abstract class AbstractBTLESingleDeviceSupport extends AbstractBTLEDevice
|
||||
|
||||
initializeDevice(builder);
|
||||
|
||||
boolean lowPower = getDevicePrefs().getConnectionPriorityLowPower();
|
||||
if (getDevice().getDeviceCoordinator().supportsConnectionPriority()) {
|
||||
final boolean lowPower = getDevicePrefs().getConnectionPriorityLowPower();
|
||||
// have to explicitly request normal ("balanced") as some Android devices remember the last
|
||||
// request. Else low power would become a set once option.
|
||||
// #5054 / #5956 - However, on some devices requesting it altogether can make the connection fail
|
||||
builder.requestConnectionPriority(lowPower ? BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER : BluetoothGatt.CONNECTION_PRIORITY_BALANCED);
|
||||
}
|
||||
|
||||
builder.queue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user