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
1 changed files with 7 additions and 3 deletions

View File

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