mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Fix regression with active auto connect sice multi-device got merged
1) The AutoConnectIntervalReceiver was completely disabled when a device went into WAITING_FOR_RECONNECT state 2) The logic inside AutoConnectIntervalReceiver was broken, so that a timer never got started
This commit is contained in:
parent
80d2bbf3dd
commit
226d75d366
@ -405,6 +405,9 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
mBlueToothConnectReceiver = new BluetoothConnectReceiver(this);
|
||||
registerReceiver(mBlueToothConnectReceiver, new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));
|
||||
|
||||
mAutoConnectInvervalReceiver= new AutoConnectIntervalReceiver(this);
|
||||
registerReceiver(mAutoConnectInvervalReceiver, new IntentFilter("GB_RECONNECT"));
|
||||
|
||||
if (hasPrefs()) {
|
||||
getPrefs().getPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
@ -1095,10 +1098,6 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
mGBAutoFetchReceiver = new GBAutoFetchReceiver();
|
||||
registerReceiver(mGBAutoFetchReceiver, new IntentFilter("android.intent.action.USER_PRESENT"));
|
||||
}
|
||||
if (mAutoConnectInvervalReceiver == null) {
|
||||
mAutoConnectInvervalReceiver= new AutoConnectIntervalReceiver(this);
|
||||
registerReceiver(mAutoConnectInvervalReceiver, new IntentFilter("GB_RECONNECT"));
|
||||
}
|
||||
} else {
|
||||
if (mPhoneCallReceiver != null) {
|
||||
unregisterReceiver(mPhoneCallReceiver);
|
||||
@ -1149,11 +1148,6 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
unregisterReceiver(mGBAutoFetchReceiver);
|
||||
mGBAutoFetchReceiver = null;
|
||||
}
|
||||
if (mAutoConnectInvervalReceiver != null) {
|
||||
unregisterReceiver(mAutoConnectInvervalReceiver);
|
||||
mAutoConnectInvervalReceiver.destroy();
|
||||
mAutoConnectInvervalReceiver = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1170,6 +1164,11 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
setReceiversEnableState(false, false, null, null); // disable BroadcastReceivers
|
||||
|
||||
unregisterReceiver(mBlueToothConnectReceiver);
|
||||
mBlueToothConnectReceiver = null;
|
||||
|
||||
unregisterReceiver(mAutoConnectInvervalReceiver);
|
||||
mAutoConnectInvervalReceiver.destroy();
|
||||
mAutoConnectInvervalReceiver = null;
|
||||
|
||||
for(GBDevice device : getGBDevices()){
|
||||
try {
|
||||
|
@ -63,10 +63,11 @@ public class AutoConnectIntervalReceiver extends BroadcastReceiver {
|
||||
boolean scheduleAutoConnect = false;
|
||||
boolean allDevicesInitialized = true;
|
||||
for(GBDevice device : devices){
|
||||
if(!device.isInitialized()){
|
||||
if(!device.isInitialized()) {
|
||||
allDevicesInitialized = false;
|
||||
}else if(device.getState() == GBDevice.State.WAITING_FOR_RECONNECT){
|
||||
scheduleAutoConnect = true;
|
||||
if (device.getState() == GBDevice.State.WAITING_FOR_RECONNECT) {
|
||||
scheduleAutoConnect = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user