Fix issue where lastVersionCode was unset.

This commit is contained in:
Greyson Parrelli
2022-01-13 10:51:45 -05:00
parent 7551dd77c5
commit c55b0357f1
4 changed files with 15 additions and 28 deletions

View File

@@ -60,7 +60,6 @@ public class TextSecurePreferences {
public static final String ENABLE_MANUAL_MMS_PREF = "pref_enable_manual_mms";
private static final String LAST_VERSION_CODE_PREF = "last_version_code";
private static final String LAST_EXPERIENCE_VERSION_PREF = "last_experience_version_code";
public static final String RINGTONE_PREF = "pref_key_ringtone";
public static final String VIBRATE_PREF = "pref_key_vibrate";
private static final String NOTIFICATION_PREF = "pref_key_enable_notifications";
@@ -814,20 +813,12 @@ public class TextSecurePreferences {
return getIntegerPreference(context, LAST_VERSION_CODE_PREF, Util.getCanonicalVersionCode());
}
public static void setLastVersionCode(Context context, int versionCode) throws IOException {
public static void setLastVersionCode(Context context, int versionCode) {
if (!setIntegerPrefrenceBlocking(context, LAST_VERSION_CODE_PREF, versionCode)) {
throw new IOException("couldn't write version code to sharedpreferences");
throw new AssertionError("couldn't write version code to sharedpreferences");
}
}
public static int getLastExperienceVersionCode(Context context) {
return getIntegerPreference(context, LAST_EXPERIENCE_VERSION_PREF, 0);
}
public static void setLastExperienceVersionCode(Context context, int versionCode) {
setIntegerPrefrence(context, LAST_EXPERIENCE_VERSION_PREF, versionCode);
}
/**
* @deprecated Use {@link SettingsValues#getTheme()} via {@link org.thoughtcrime.securesms.keyvalue.SignalStore} instead.
*/

View File

@@ -22,20 +22,17 @@ public class VersionTracker {
}
public static void updateLastSeenVersion(@NonNull Context context) {
try {
int currentVersionCode = Util.getCanonicalVersionCode();
int lastVersionCode = TextSecurePreferences.getLastVersionCode(context);
int currentVersionCode = Util.getCanonicalVersionCode();
int lastVersionCode = TextSecurePreferences.getLastVersionCode(context);
if (currentVersionCode != lastVersionCode) {
Log.i(TAG, "Upgraded from " + lastVersionCode + " to " + currentVersionCode);
SignalStore.misc().clearClientDeprecated();
TextSecurePreferences.setLastVersionCode(context, currentVersionCode);
ApplicationDependencies.getJobManager().add(new RemoteConfigRefreshJob());
LocalMetrics.getInstance().clear();
}
} catch (IOException ioe) {
throw new AssertionError(ioe);
if (currentVersionCode != lastVersionCode) {
Log.i(TAG, "Upgraded from " + lastVersionCode + " to " + currentVersionCode);
SignalStore.misc().clearClientDeprecated();
ApplicationDependencies.getJobManager().add(new RemoteConfigRefreshJob());
LocalMetrics.getInstance().clear();
}
TextSecurePreferences.setLastVersionCode(context, currentVersionCode);
}
public static long getDaysSinceFirstInstalled(Context context) {