1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-15 22:49:26 +01:00

Make travis green again

This commit is contained in:
Andreas Shimokawa 2019-05-20 21:53:53 +02:00
parent 61be82a499
commit 81b102654a

View File

@ -59,6 +59,7 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.database.DBOpenHelper; import nodomain.freeyourgadget.gadgetbridge.database.DBOpenHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager; import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoMaster; import nodomain.freeyourgadget.gadgetbridge.entities.DaoMaster;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.entities.Device; import nodomain.freeyourgadget.gadgetbridge.entities.Device;
import nodomain.freeyourgadget.gadgetbridge.externalevents.BluetoothStateChangeReceiver; import nodomain.freeyourgadget.gadgetbridge.externalevents.BluetoothStateChangeReceiver;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -168,7 +169,7 @@ public class GBApplication extends Application {
// slf4j may be implicitly initialized before we properly configured it. // slf4j may be implicitly initialized before we properly configured it.
setupLogging(isFileLoggingEnabled()); setupLogging(isFileLoggingEnabled());
if (getPrefsFileVersion() != CURRENT_PREFS_VERSION) { if (getPrefsFileVersion() != CURRENT_PREFS_VERSION) {
migratePrefs(getPrefsFileVersion()); migratePrefs(getPrefsFileVersion());
} }
@ -618,44 +619,49 @@ public static String packageNameToPebbleMsgSender(String packageName) {
editor.putString(ActivityUser.PREF_USER_GENDER, Integer.toString(legacyGender_1)); editor.putString(ActivityUser.PREF_USER_GENDER, Integer.toString(legacyGender_1));
} }
if (oldVersion < 3) { if (oldVersion < 3) {
List<Device> activeDevices = DBHelper.getActiveDevices(lockHandler.getDaoSession()); try (DBHandler db = acquireDB()) {
for (Device dbDevice : activeDevices) { DaoSession daoSession = db.getDaoSession();
SharedPreferences.Editor deviceSharedPrefsEdit = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier()).edit(); List<Device> activeDevices = DBHelper.getActiveDevices(daoSession);
if (sharedPrefs != null) { for (Device dbDevice : activeDevices) {
String preferenceKey = dbDevice.getIdentifier() + "_lastSportsActivityTimeMillis"; SharedPreferences.Editor deviceSharedPrefsEdit = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier()).edit();
long lastSportsActivityTimeMillis = sharedPrefs.getLong(preferenceKey, 0); if (sharedPrefs != null) {
if (lastSportsActivityTimeMillis != 0) { String preferenceKey = dbDevice.getIdentifier() + "_lastSportsActivityTimeMillis";
deviceSharedPrefsEdit.putLong("lastSportsActivityTimeMillis", lastSportsActivityTimeMillis); long lastSportsActivityTimeMillis = sharedPrefs.getLong(preferenceKey, 0);
editor.remove(preferenceKey); if (lastSportsActivityTimeMillis != 0) {
deviceSharedPrefsEdit.putLong("lastSportsActivityTimeMillis", lastSportsActivityTimeMillis);
editor.remove(preferenceKey);
}
preferenceKey = dbDevice.getIdentifier() + "_lastSyncTimeMillis";
long lastSyncTimeMillis = sharedPrefs.getLong(preferenceKey, 0);
if (lastSyncTimeMillis != 0) {
deviceSharedPrefsEdit.putLong("lastSyncTimeMillis", lastSyncTimeMillis);
editor.remove(preferenceKey);
}
switch (fromKey(dbDevice.getType())) {
case AMAZFITCOR:
case AMAZFITBIP:
case AMAZFITCOR2:
int oldLanguage = prefs.getInt("amazfitbip_language", -1);
String newLanguage = "auto";
String[] oldLanguageLookup = {"zh_CN", "zh_TW", "en_US", "es_ES", "ru_RU", "de_DE", "it_IT", "fr_FR", "tr_TR"};
if (oldLanguage >= 0 && oldLanguage < oldLanguageLookup.length) {
newLanguage = oldLanguageLookup[oldLanguage];
}
deviceSharedPrefsEdit.putString("language", newLanguage);
break;
case MIBAND3:
String language = sharedPrefs.getString("miband3_language", "auto");
deviceSharedPrefsEdit.putString("language", language);
}
} }
preferenceKey = dbDevice.getIdentifier() + "_lastSyncTimeMillis";
long lastSyncTimeMillis = sharedPrefs.getLong(preferenceKey, 0);
if (lastSyncTimeMillis != 0) {
deviceSharedPrefsEdit.putLong("lastSyncTimeMillis", lastSyncTimeMillis);
editor.remove(preferenceKey);
}
switch (fromKey(dbDevice.getType())) {
case AMAZFITCOR:
case AMAZFITBIP:
case AMAZFITCOR2:
int oldLanguage = prefs.getInt("amazfitbip_language", -1);
String newLanguage = "auto";
String[] oldLanguageLookup = {"zh_CN", "zh_TW", "en_US", "es_ES", "ru_RU", "de_DE", "it_IT", "fr_FR", "tr_TR"};
if (oldLanguage >= 0 && oldLanguage < oldLanguageLookup.length) {
newLanguage = oldLanguageLookup[oldLanguage];
}
deviceSharedPrefsEdit.putString("language", newLanguage);
break;
case MIBAND3:
String language = sharedPrefs.getString("miband3_language", "auto");
deviceSharedPrefsEdit.putString("language", language);
}
}
deviceSharedPrefsEdit.apply(); deviceSharedPrefsEdit.apply();
}
editor.remove("miband3_language");
editor.remove("amazfitbip_language");
} catch (Exception e) {
Log.w(TAG, "error acquiring DB lock");
} }
editor.remove("miband3_language");
editor.remove("amazfitbip_language");
} }
editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION)); editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION));
editor.apply(); editor.apply();