mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-25 16:15:55 +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);
|
mBlueToothConnectReceiver = new BluetoothConnectReceiver(this);
|
||||||
registerReceiver(mBlueToothConnectReceiver, new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));
|
registerReceiver(mBlueToothConnectReceiver, new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));
|
||||||
|
|
||||||
|
mAutoConnectInvervalReceiver= new AutoConnectIntervalReceiver(this);
|
||||||
|
registerReceiver(mAutoConnectInvervalReceiver, new IntentFilter("GB_RECONNECT"));
|
||||||
|
|
||||||
if (hasPrefs()) {
|
if (hasPrefs()) {
|
||||||
getPrefs().getPreferences().registerOnSharedPreferenceChangeListener(this);
|
getPrefs().getPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
@ -1095,10 +1098,6 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
|||||||
mGBAutoFetchReceiver = new GBAutoFetchReceiver();
|
mGBAutoFetchReceiver = new GBAutoFetchReceiver();
|
||||||
registerReceiver(mGBAutoFetchReceiver, new IntentFilter("android.intent.action.USER_PRESENT"));
|
registerReceiver(mGBAutoFetchReceiver, new IntentFilter("android.intent.action.USER_PRESENT"));
|
||||||
}
|
}
|
||||||
if (mAutoConnectInvervalReceiver == null) {
|
|
||||||
mAutoConnectInvervalReceiver= new AutoConnectIntervalReceiver(this);
|
|
||||||
registerReceiver(mAutoConnectInvervalReceiver, new IntentFilter("GB_RECONNECT"));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (mPhoneCallReceiver != null) {
|
if (mPhoneCallReceiver != null) {
|
||||||
unregisterReceiver(mPhoneCallReceiver);
|
unregisterReceiver(mPhoneCallReceiver);
|
||||||
@ -1149,11 +1148,6 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
|||||||
unregisterReceiver(mGBAutoFetchReceiver);
|
unregisterReceiver(mGBAutoFetchReceiver);
|
||||||
mGBAutoFetchReceiver = null;
|
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
|
setReceiversEnableState(false, false, null, null); // disable BroadcastReceivers
|
||||||
|
|
||||||
unregisterReceiver(mBlueToothConnectReceiver);
|
unregisterReceiver(mBlueToothConnectReceiver);
|
||||||
|
mBlueToothConnectReceiver = null;
|
||||||
|
|
||||||
|
unregisterReceiver(mAutoConnectInvervalReceiver);
|
||||||
|
mAutoConnectInvervalReceiver.destroy();
|
||||||
|
mAutoConnectInvervalReceiver = null;
|
||||||
|
|
||||||
for(GBDevice device : getGBDevices()){
|
for(GBDevice device : getGBDevices()){
|
||||||
try {
|
try {
|
||||||
|
@ -63,10 +63,11 @@ public class AutoConnectIntervalReceiver extends BroadcastReceiver {
|
|||||||
boolean scheduleAutoConnect = false;
|
boolean scheduleAutoConnect = false;
|
||||||
boolean allDevicesInitialized = true;
|
boolean allDevicesInitialized = true;
|
||||||
for(GBDevice device : devices){
|
for(GBDevice device : devices){
|
||||||
if(!device.isInitialized()){
|
if(!device.isInitialized()) {
|
||||||
allDevicesInitialized = false;
|
allDevicesInitialized = false;
|
||||||
}else if(device.getState() == GBDevice.State.WAITING_FOR_RECONNECT){
|
if (device.getState() == GBDevice.State.WAITING_FOR_RECONNECT) {
|
||||||
scheduleAutoConnect = true;
|
scheduleAutoConnect = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user