From 2677dad8732dbe8cb44397217d70d3fe299a539f Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sun, 27 Nov 2016 22:50:21 +0100 Subject: [PATCH] Fix a recent regression that caused the database migration dialog to never pop up --- .../service/DeviceCommunicationService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java index 24388615..18bfb2b7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java @@ -173,9 +173,13 @@ public class DeviceCommunicationService extends Service implements SharedPrefere if (device.isInitialized()) { try (DBHandler dbHandler = GBApplication.acquireDB()) { DaoSession session = dbHandler.getDaoSession(); - DBHelper dbHelper = new DBHelper(context); - DBHelper.getDevice(device, session); // implicitly creates it :P - if (DBHelper.findDevice(device, session) == null && (device.getType() != DeviceType.VIBRATISSIMO)) { + boolean askForDBMigration = false; + if (DBHelper.findDevice(device, session) == null && device.getType() != DeviceType.VIBRATISSIMO) { + askForDBMigration = true; + } + DBHelper.getDevice(device, session); // implicitly creates the device in database if not present, and updates device attributes + if (askForDBMigration) { + DBHelper dbHelper = new DBHelper(context); if (dbHelper.getOldActivityDatabaseHandler() != null) { Intent startIntent = new Intent(context, OnboardingActivity.class); startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);