honor autoreconnect

We should also honor autoreconnect option before we auto connect on startup. Pressing Connect button does not check autoreconnect, it just sets autoreconnect and connects.
This commit is contained in:
lazarosfs 2017-07-31 18:39:54 +03:00
parent b961397597
commit 6c79bbb730
1 changed files with 3 additions and 2 deletions

View File

@ -281,8 +281,9 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
Prefs prefs = getPrefs();
switch (action) {
case ACTION_START:
boolean autoReconnect = getGBPrefs().getAutoReconnect();
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter.isEnabled()) {
if ((mBluetoothAdapter.isEnabled())&&(autoReconnect == true)) {
intent.setAction(ACTION_CONNECT); // if bt is enabled go to connect so after reboot we autoconnect wihout prompts
onStartCommand(intent,flags,startId);
break;
@ -324,7 +325,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
btDeviceAddress = gbDevice.getAddress();
}
boolean autoReconnect = GBPrefs.AUTO_RECONNECT_DEFAULT;
autoReconnect = GBPrefs.AUTO_RECONNECT_DEFAULT;
if (prefs != null && prefs.getPreferences() != null) {
prefs.getPreferences().edit().putString("last_device_address", btDeviceAddress).apply();
autoReconnect = getGBPrefs().getAutoReconnect();