mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 19:29:54 +01:00
Migrate linked device status to the SignalStore.
This commit is contained in:
@@ -76,6 +76,8 @@ class AccountValues internal constructor(store: KeyValueStore, context: Context)
|
||||
private const val KEY_ACI = "account.aci"
|
||||
private const val KEY_PNI = "account.pni"
|
||||
private const val KEY_IS_REGISTERED = "account.is_registered"
|
||||
|
||||
private const val KEY_HAS_LINKED_DEVICES = "account.has_linked_devices"
|
||||
}
|
||||
|
||||
init {
|
||||
@@ -87,6 +89,10 @@ class AccountValues internal constructor(store: KeyValueStore, context: Context)
|
||||
migrateFromSharedPrefsV2(context)
|
||||
}
|
||||
|
||||
if (!store.containsKey(KEY_HAS_LINKED_DEVICES)) {
|
||||
migrateFromSharedPrefsV3(context)
|
||||
}
|
||||
|
||||
store.getString(KEY_PNI, null)?.let { pni ->
|
||||
if (!pni.startsWith("PNI:")) {
|
||||
store.beginWrite().putString(KEY_PNI, "PNI:$pni").commit()
|
||||
@@ -445,6 +451,12 @@ class AccountValues internal constructor(store: KeyValueStore, context: Context)
|
||||
AppDependencies.groupsV2Authorization.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the user has linked devices.
|
||||
*/
|
||||
@get:JvmName("hasLinkedDevices")
|
||||
var hasLinkedDevices by booleanValue(KEY_HAS_LINKED_DEVICES, false)
|
||||
|
||||
/** Do not alter. If you need to migrate more stuff, create a new method. */
|
||||
private fun migrateFromSharedPrefsV1(context: Context) {
|
||||
Log.i(TAG, "[V1] Migrating account values from shared prefs.")
|
||||
@@ -528,6 +540,13 @@ class AccountValues internal constructor(store: KeyValueStore, context: Context)
|
||||
.commit()
|
||||
}
|
||||
|
||||
/** Do not alter. If you need to migrate more stuff, create a new method. */
|
||||
private fun migrateFromSharedPrefsV3(context: Context) {
|
||||
Log.i(TAG, "[V3] Migrating account values from shared prefs.")
|
||||
|
||||
putBoolean(KEY_HAS_LINKED_DEVICES, TextSecurePreferences.getBooleanPreference(context, "pref_multi_device", false))
|
||||
}
|
||||
|
||||
private fun SharedPreferences.hasStringData(key: String): Boolean {
|
||||
return this.getString(key, null) != null
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ class MiscellaneousValues internal constructor(store: KeyValueStore) : SignalSto
|
||||
private const val LINKED_DEVICE_LAST_ACTIVE_CHECK_TIME = "misc.linked_device.last_active_check_time"
|
||||
private const val LEAST_ACTIVE_LINKED_DEVICE = "misc.linked_device.least_active"
|
||||
private const val NEXT_DATABASE_ANALYSIS_TIME = "misc.next_database_analysis_time"
|
||||
private const val LOCK_SCREEN_ATTEMPT_COUNT = "misc.lock_screen_attempt_count"
|
||||
private const val LAST_NETWORK_RESET_TIME = "misc.last_network_reset_time"
|
||||
private const val LAST_WEBSOCKET_CONNECT_TIME = "misc.last_websocket_connect_time"
|
||||
private const val LAST_CONNECTIVITY_WARNING_TIME = "misc.last_connectivity_warning_time"
|
||||
@@ -165,6 +164,7 @@ class MiscellaneousValues internal constructor(store: KeyValueStore) : SignalSto
|
||||
/**
|
||||
* Whether or not the user has linked devices.
|
||||
*/
|
||||
@get:JvmName("hasLinkedDevices")
|
||||
var hasLinkedDevices by booleanValue(HAS_LINKED_DEVICES, false)
|
||||
|
||||
/**
|
||||
@@ -253,15 +253,6 @@ class MiscellaneousValues internal constructor(store: KeyValueStore) : SignalSto
|
||||
*/
|
||||
var nextDatabaseAnalysisTime: Long by longValue(NEXT_DATABASE_ANALYSIS_TIME, 0)
|
||||
|
||||
/**
|
||||
* How many times the lock screen has been seen and _not_ unlocked. Used to determine if the user is confused by how to bypass the lock screen.
|
||||
*/
|
||||
var lockScreenAttemptCount: Int by integerValue(LOCK_SCREEN_ATTEMPT_COUNT, 0)
|
||||
|
||||
fun incrementLockScreenAttemptCount() {
|
||||
lockScreenAttemptCount++
|
||||
}
|
||||
|
||||
var lastNetworkResetDueToStreamResets: Long by longValue(LAST_NETWORK_RESET_TIME, 0L)
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user