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:
+8
-1
@@ -990,7 +990,9 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
|||||||
if (connectionType.usesBluetoothClassic() || connectionType.usesBluetoothLE()) {
|
if (connectionType.usesBluetoothClassic() || connectionType.usesBluetoothLE()) {
|
||||||
settings = ArrayUtils.insert(0, settings, R.xml.devicesettings_reconnect_periodic);
|
settings = ArrayUtils.insert(0, settings, R.xml.devicesettings_reconnect_periodic);
|
||||||
settings = ArrayUtils.insert(0, settings, R.xml.devicesettings_device_connect_back);
|
settings = ArrayUtils.insert(0, settings, R.xml.devicesettings_device_connect_back);
|
||||||
settings = ArrayUtils.add(settings, R.xml.devicesettings_connection_priority_low_power);
|
if (supportsConnectionPriority()) {
|
||||||
|
settings = ArrayUtils.add(settings, R.xml.devicesettings_connection_priority_low_power);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
@@ -1201,4 +1203,9 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
|||||||
// 2 seconds.
|
// 2 seconds.
|
||||||
return 2000;
|
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.
|
* @return delay in ms for this device to wait before a reconnection attempt is made.
|
||||||
*/
|
*/
|
||||||
int getReconnectionDelay();
|
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) {
|
public DeviceKind getDeviceKind(@NonNull GBDevice device) {
|
||||||
return DeviceKind.WATCH;
|
return DeviceKind.WATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsConnectionPriority() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-4
@@ -458,10 +458,13 @@ public abstract class AbstractBTLEMultiDeviceSupport extends AbstractBTLEDeviceS
|
|||||||
|
|
||||||
initializeDevice(builder, deviceIdx);
|
initializeDevice(builder, deviceIdx);
|
||||||
|
|
||||||
boolean lowPower = getDevicePrefs().getConnectionPriorityLowPower();
|
if (getDevice().getDeviceCoordinator().supportsConnectionPriority()) {
|
||||||
// have to explicitly request normal ("balanced") as some Android devices remember the last
|
final boolean lowPower = getDevicePrefs().getConnectionPriorityLowPower();
|
||||||
// request. Else low power would become a set once option.
|
// have to explicitly request normal ("balanced") as some Android devices remember the last
|
||||||
builder.requestConnectionPriority(lowPower ? BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER : BluetoothGatt.CONNECTION_PRIORITY_BALANCED);
|
// 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();
|
builder.queue();
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-4
@@ -366,10 +366,13 @@ public abstract class AbstractBTLESingleDeviceSupport extends AbstractBTLEDevice
|
|||||||
|
|
||||||
initializeDevice(builder);
|
initializeDevice(builder);
|
||||||
|
|
||||||
boolean lowPower = getDevicePrefs().getConnectionPriorityLowPower();
|
if (getDevice().getDeviceCoordinator().supportsConnectionPriority()) {
|
||||||
// have to explicitly request normal ("balanced") as some Android devices remember the last
|
final boolean lowPower = getDevicePrefs().getConnectionPriorityLowPower();
|
||||||
// request. Else low power would become a set once option.
|
// have to explicitly request normal ("balanced") as some Android devices remember the last
|
||||||
builder.requestConnectionPriority(lowPower ? BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER : BluetoothGatt.CONNECTION_PRIORITY_BALANCED);
|
// 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();
|
builder.queue();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user