1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-01 06:22:55 +01:00

Fix a recent regression that caused the database migration dialog to never pop up

This commit is contained in:
Andreas Shimokawa 2016-11-27 22:50:21 +01:00
parent 109a032f1e
commit 2677dad873

View File

@ -173,9 +173,13 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
if (device.isInitialized()) { if (device.isInitialized()) {
try (DBHandler dbHandler = GBApplication.acquireDB()) { try (DBHandler dbHandler = GBApplication.acquireDB()) {
DaoSession session = dbHandler.getDaoSession(); DaoSession session = dbHandler.getDaoSession();
DBHelper dbHelper = new DBHelper(context); boolean askForDBMigration = false;
DBHelper.getDevice(device, session); // implicitly creates it :P if (DBHelper.findDevice(device, session) == null && device.getType() != DeviceType.VIBRATISSIMO) {
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) { 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);