1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +01:00

Call getDevice always when connected

This fixes a longstanding bug where device attributes where ONLY updated when fetching activity data or when pairing a new device
This commit is contained in:
Andreas Shimokawa 2016-11-27 10:32:56 +01:00
parent 24752d3455
commit 723ad53588

View File

@ -169,12 +169,13 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
boolean enableReceivers = mDeviceSupport != null && (mDeviceSupport.useAutoConnect() || mGBDevice.isInitialized()); boolean enableReceivers = mDeviceSupport != null && (mDeviceSupport.useAutoConnect() || mGBDevice.isInitialized());
setReceiversEnableState(enableReceivers); setReceiversEnableState(enableReceivers);
GB.updateNotification(mGBDevice.getName() + " " + mGBDevice.getStateString(), mGBDevice.isInitialized(), context); GB.updateNotification(mGBDevice.getName() + " " + mGBDevice.getStateString(), mGBDevice.isInitialized(), context);
if (device.isInitialized() && (device.getType() != DeviceType.VIBRATISSIMO)) {
if (device.isInitialized()) {
try (DBHandler dbHandler = GBApplication.acquireDB()) { try (DBHandler dbHandler = GBApplication.acquireDB()) {
DaoSession session = dbHandler.getDaoSession(); DaoSession session = dbHandler.getDaoSession();
if (DBHelper.findDevice(device, session) == null) { DBHelper dbHelper = new DBHelper(context);
DBHelper dbHelper = new DBHelper(context); DBHelper.getDevice(device, session); // implicitly creates it :P
DBHelper.getDevice(device, session); // implicitly creates it :P if (DBHelper.findDevice(device, session) == null && (device.getType() != DeviceType.VIBRATISSIMO)) {
if (dbHelper.getOldActivityDatabaseHandler() != null) { if (dbHelper.getOldActivityDatabaseHandler() != null) {
Intent startIntent = new Intent(context, OnboardingActivity.class); Intent startIntent = new Intent(context, OnboardingActivity.class);
startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@ -182,7 +183,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
startActivity(startIntent); startActivity(startIntent);
} }
} }
} catch (Exception _ignore) { } catch (Exception ignore) {
} }
} }
} else { } else {
@ -426,11 +427,11 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
break; break;
case ACTION_SETMUSICSTATE: case ACTION_SETMUSICSTATE:
MusicStateSpec stateSpec = new MusicStateSpec(); MusicStateSpec stateSpec = new MusicStateSpec();
stateSpec.shuffle = intent.getByteExtra(EXTRA_MUSIC_SHUFFLE, (byte)0); stateSpec.shuffle = intent.getByteExtra(EXTRA_MUSIC_SHUFFLE, (byte) 0);
stateSpec.repeat = intent.getByteExtra(EXTRA_MUSIC_REPEAT, (byte)0); stateSpec.repeat = intent.getByteExtra(EXTRA_MUSIC_REPEAT, (byte) 0);
stateSpec.position = intent.getIntExtra(EXTRA_MUSIC_POSITION, 0); stateSpec.position = intent.getIntExtra(EXTRA_MUSIC_POSITION, 0);
stateSpec.playRate = intent.getIntExtra(EXTRA_MUSIC_RATE, 0); stateSpec.playRate = intent.getIntExtra(EXTRA_MUSIC_RATE, 0);
stateSpec.state = intent.getByteExtra(EXTRA_MUSIC_STATE, (byte)0); stateSpec.state = intent.getByteExtra(EXTRA_MUSIC_STATE, (byte) 0);
mDeviceSupport.onSetMusicState(stateSpec); mDeviceSupport.onSetMusicState(stateSpec);
break; break;
case ACTION_REQUEST_APPINFO: case ACTION_REQUEST_APPINFO: