Migrate linked device status to the SignalStore.

This commit is contained in:
Greyson Parrelli 2024-10-28 10:55:46 -04:00
parent 2cd15ae879
commit ead66cdfc0
46 changed files with 96 additions and 317 deletions

View file

@ -36,7 +36,6 @@ public final class AppInitialization {
SignalStore.settings().setPassphraseDisabled(true);
TextSecurePreferences.setReadReceiptsEnabled(context, true);
TextSecurePreferences.setTypingIndicatorsEnabled(context, true);
TextSecurePreferences.setHasSeenWelcomeScreen(context, false);
AppDependencies.getMegaphoneRepository().onFirstEverAppLaunch();
SignalStore.onFirstEverAppLaunch();
AppDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.ZOZO.getPackId(), BlessedPacks.ZOZO.getPackKey(), false));

View file

@ -30,10 +30,8 @@ import org.signal.core.ui.Previews
import org.signal.core.ui.SignalPreview
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.compose.ComposeBottomSheetDialogFragment
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.util.TextSecurePreferences
/**
* Show educational info about delete syncing to linked devices. This dialog uses a subject to convey when
@ -46,7 +44,7 @@ class DeleteSyncEducationDialog : ComposeBottomSheetDialogFragment() {
@JvmStatic
fun shouldShow(): Boolean {
return TextSecurePreferences.isMultiDevice(AppDependencies.application) &&
return SignalStore.account.hasLinkedDevices &&
!SignalStore.uiHints.hasSeenDeleteSyncEducationSheet &&
Recipient.self().deleteSyncCapability.isSupported
}

View file

@ -33,7 +33,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.integerArrayResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.pluralStringResource
@ -68,11 +67,11 @@ import org.thoughtcrime.securesms.billing.upgrade.UpgradeToPaidTierBottomSheet
import org.thoughtcrime.securesms.compose.ComposeFragment
import org.thoughtcrime.securesms.database.MediaTable
import org.thoughtcrime.securesms.keyvalue.KeepMessagesDuration
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.mediaoverview.MediaOverviewActivity
import org.thoughtcrime.securesms.preferences.widgets.StorageGraphView
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.util.BottomSheetUtil
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.thoughtcrime.securesms.util.Util
import org.thoughtcrime.securesms.util.viewModel
import java.text.NumberFormat
@ -159,7 +158,7 @@ class ManageStorageSettingsFragment : ComposeFragment() {
dialog("confirm-delete-chat-history") {
Dialogs.SimpleAlertDialog(
title = stringResource(id = R.string.preferences_storage__delete_message_history),
body = if (TextSecurePreferences.isMultiDevice(LocalContext.current) && Recipient.self().deleteSyncCapability.isSupported) {
body = if (SignalStore.account.hasLinkedDevices && Recipient.self().deleteSyncCapability.isSupported) {
stringResource(id = R.string.preferences_storage__this_will_delete_all_message_history_and_media_from_your_device_linked_device)
} else {
stringResource(id = R.string.preferences_storage__this_will_delete_all_message_history_and_media_from_your_device)
@ -175,7 +174,7 @@ class ManageStorageSettingsFragment : ComposeFragment() {
dialog("double-confirm-delete-chat-history", dialogProperties = DialogProperties(dismissOnBackPress = true, dismissOnClickOutside = true)) {
Dialogs.SimpleAlertDialog(
title = stringResource(id = R.string.preferences_storage__are_you_sure_you_want_to_delete_all_message_history),
body = if (TextSecurePreferences.isMultiDevice(LocalContext.current) && Recipient.self().deleteSyncCapability.isSupported) {
body = if (SignalStore.account.hasLinkedDevices && Recipient.self().deleteSyncCapability.isSupported) {
stringResource(id = R.string.preferences_storage__all_message_history_will_be_permanently_removed_this_action_cannot_be_undone_linked_device)
} else {
stringResource(id = R.string.preferences_storage__all_message_history_will_be_permanently_removed_this_action_cannot_be_undone)

View file

@ -1229,7 +1229,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
alert.setTitle(context.getResources().getQuantityString(R.plurals.ConversationListFragment_delete_selected_conversations,
conversationsCount, conversationsCount));
if (TextSecurePreferences.isMultiDevice(context) && Recipient.self().getDeleteSyncCapability().isSupported()) {
if (SignalStore.account().hasLinkedDevices() && Recipient.self().getDeleteSyncCapability().isSupported()) {
alert.setMessage(context.getResources().getQuantityString(R.plurals.ConversationListFragment_this_will_permanently_delete_all_n_selected_conversations_linked_device,
conversationsCount, conversationsCount));
} else {

View file

@ -14,6 +14,7 @@ import org.signal.libsignal.protocol.state.KyberPreKeyRecord;
import org.signal.libsignal.protocol.state.PreKeyRecord;
import org.signal.libsignal.protocol.state.SessionRecord;
import org.signal.libsignal.protocol.state.SignedPreKeyRecord;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.signalservice.api.SignalServiceAccountDataStore;
import org.whispersystems.signalservice.api.push.DistributionId;
@ -53,7 +54,7 @@ public class SignalServiceAccountDataStoreImpl implements SignalServiceAccountDa
@Override
public boolean isMultiDevice() {
return TextSecurePreferences.isMultiDevice(context);
return SignalStore.account().hasLinkedDevices();
}
@Override

View file

@ -47,6 +47,6 @@ public final class SignalServiceDataStoreImpl implements SignalServiceDataStore
@Override
public boolean isMultiDevice() {
return TextSecurePreferences.isMultiDevice(context);
return SignalStore.account().hasLinkedDevices();
}
}

View file

@ -76,7 +76,7 @@ class LinkedDeviceInactiveCheckJob private constructor(
if (devices.isEmpty()) {
Log.i(TAG, "No linked devices found.")
SignalStore.misc.hasLinkedDevices = false
SignalStore.account.hasLinkedDevices = false
SignalStore.misc.leastActiveLinkedDevice = null
SignalStore.misc.linkedDeviceLastActiveCheckTime = System.currentTimeMillis()
@ -100,7 +100,7 @@ class LinkedDeviceInactiveCheckJob private constructor(
if (leastActiveDevice == null) {
Log.w(TAG, "Failed to decrypt linked device name.")
SignalStore.misc.hasLinkedDevices = true
SignalStore.account.hasLinkedDevices = true
SignalStore.misc.leastActiveLinkedDevice = null
SignalStore.misc.linkedDeviceLastActiveCheckTime = System.currentTimeMillis()
return Result.success()
@ -109,7 +109,7 @@ class LinkedDeviceInactiveCheckJob private constructor(
val timeSinceActive = System.currentTimeMillis() - leastActiveDevice.lastActiveTimestamp
Log.i(TAG, "Least active linked device was last active ${timeSinceActive.milliseconds.toDouble(DurationUnit.DAYS).roundedString(2)} days ago ($timeSinceActive ms).")
SignalStore.misc.hasLinkedDevices = true
SignalStore.account.hasLinkedDevices = true
SignalStore.misc.leastActiveLinkedDevice = leastActiveDevice
SignalStore.misc.linkedDeviceLastActiveCheckTime = System.currentTimeMillis()

View file

@ -10,6 +10,7 @@ import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientUtil;
@ -65,7 +66,7 @@ public class MultiDeviceBlockedUpdateJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device, aborting...");
return;
}

View file

@ -91,7 +91,7 @@ public class MultiDeviceConfigurationUpdateJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device, aborting...");
return;
}

View file

@ -123,7 +123,7 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device, aborting...");
return;
}

View file

@ -22,10 +22,10 @@ import org.thoughtcrime.securesms.jobs.protos.DeleteSyncJobData
import org.thoughtcrime.securesms.jobs.protos.DeleteSyncJobData.AddressableMessage
import org.thoughtcrime.securesms.jobs.protos.DeleteSyncJobData.AttachmentDelete
import org.thoughtcrime.securesms.jobs.protos.DeleteSyncJobData.ThreadDelete
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.pad
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.recipients.RecipientId
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException
import org.whispersystems.signalservice.api.util.UuidUtil
import org.whispersystems.signalservice.internal.push.Content
@ -57,7 +57,7 @@ class MultiDeviceDeleteSyncJob private constructor(
@WorkerThread
@JvmStatic
fun enqueueMessageDeletes(messageRecords: Set<MessageRecord>) {
if (!TextSecurePreferences.isMultiDevice(AppDependencies.application)) {
if (!SignalStore.account.hasLinkedDevices) {
return
}
@ -79,7 +79,7 @@ class MultiDeviceDeleteSyncJob private constructor(
@WorkerThread
@JvmStatic
fun enqueueAttachmentDelete(message: MessageRecord?, attachment: DatabaseAttachment) {
if (!TextSecurePreferences.isMultiDevice(AppDependencies.application)) {
if (!SignalStore.account.hasLinkedDevices) {
return
}
@ -98,7 +98,7 @@ class MultiDeviceDeleteSyncJob private constructor(
@WorkerThread
fun enqueueThreadDeletes(threads: List<ThreadTable.ThreadDeleteSyncInfo>, isFullDelete: Boolean) {
if (!TextSecurePreferences.isMultiDevice(AppDependencies.application)) {
if (!SignalStore.account.hasLinkedDevices) {
return
}
@ -245,7 +245,7 @@ class MultiDeviceDeleteSyncJob private constructor(
return Result.failure()
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account.hasLinkedDevices) {
Log.w(TAG, "Not multi-device")
return Result.failure()
}

View file

@ -59,7 +59,7 @@ public class MultiDeviceKeysUpdateJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device, aborting...");
return;
}

View file

@ -9,6 +9,7 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.JsonJobData;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
@ -97,7 +98,7 @@ public class MultiDeviceMessageRequestResponseJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device, aborting...");
return;
}

View file

@ -10,6 +10,7 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.JsonJobData;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
import org.thoughtcrime.securesms.payments.proto.PaymentMetaData;
import org.thoughtcrime.securesms.recipients.Recipient;
@ -74,7 +75,7 @@ public final class MultiDeviceOutgoingPaymentSyncJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device, aborting...");
return;
}

View file

@ -7,6 +7,7 @@ import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
@ -50,7 +51,7 @@ public class MultiDeviceProfileContentUpdateJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device, aborting...");
return;
}

View file

@ -66,7 +66,7 @@ public class MultiDeviceProfileKeyUpdateJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device...");
return;
}

View file

@ -14,6 +14,7 @@ import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.JobManager;
import org.thoughtcrime.securesms.jobmanager.JsonJobData;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
@ -105,7 +106,7 @@ public class MultiDeviceReadUpdateJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device...");
return;
}

View file

@ -9,6 +9,7 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.JsonJobData;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
@ -73,7 +74,7 @@ public class MultiDeviceStickerPackOperationJob extends BaseJob {
@Override
protected void onRun() throws Exception {
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device, aborting...");
return;
}

View file

@ -11,6 +11,7 @@ import org.thoughtcrime.securesms.database.model.StickerPackRecord;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
@ -61,7 +62,7 @@ public class MultiDeviceStickerPackSyncJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device, aborting...");
return;
}

View file

@ -7,6 +7,7 @@ import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
@ -50,7 +51,7 @@ public class MultiDeviceStorageSyncRequestJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device, aborting...");
return;
}

View file

@ -4,9 +4,9 @@ import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.net.NotPushRegisteredException
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException
import org.whispersystems.signalservice.api.push.exceptions.ServerRejectedException
@ -49,7 +49,7 @@ class MultiDeviceSubscriptionSyncRequestJob private constructor(parameters: Para
throw NotPushRegisteredException()
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account.hasLinkedDevices) {
Log.i(TAG, "Not multi device, aborting...")
return
}

View file

@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.JsonJobData;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
@ -93,7 +94,7 @@ public class MultiDeviceVerifiedUpdateJob extends BaseJob {
}
try {
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device...");
return;
}

View file

@ -11,6 +11,7 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.JsonJobData;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
@ -76,7 +77,7 @@ public class MultiDeviceViewOnceOpenJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device...");
return;
}

View file

@ -14,6 +14,7 @@ import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.JobManager;
import org.thoughtcrime.securesms.jobmanager.JsonJobData;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
@ -105,7 +106,7 @@ public class MultiDeviceViewedUpdateJob extends BaseJob {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Not multi device...");
return;
}

View file

@ -19,7 +19,6 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.whispersystems.signalservice.api.NetworkResult
import org.whispersystems.signalservice.api.account.PniKeyDistributionRequest
import org.whispersystems.signalservice.api.push.SignalServiceAddress
@ -72,7 +71,7 @@ class PnpInitializeDevicesJob private constructor(parameters: Parameters) : Base
return
}
if (!TextSecurePreferences.isMultiDevice(context)) {
if (!SignalStore.account.hasLinkedDevices) {
Log.i(TAG, "Not multi device, aborting...")
SignalStore.misc.hasPniInitializedDevices = true
return

View file

@ -194,7 +194,7 @@ public class StorageSyncJob extends BaseJob {
try {
boolean needsMultiDeviceSync = performSync();
if (TextSecurePreferences.isMultiDevice(context) && needsMultiDeviceSync) {
if (SignalStore.account().hasLinkedDevices() && needsMultiDeviceSync) {
AppDependencies.getJobManager().add(new MultiDeviceStorageSyncRequestJob());
}

View file

@ -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
}

View file

@ -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)
/**

View file

@ -16,7 +16,6 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.net.SignalNetwork
import org.thoughtcrime.securesms.providers.BlobProvider
import org.thoughtcrime.securesms.registration.secondary.DeviceNameCipher
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.whispersystems.signalservice.api.NetworkResult
import org.whispersystems.signalservice.api.backup.BackupKey
import org.whispersystems.signalservice.api.link.LinkedDeviceVerificationCodeResponse
@ -161,7 +160,7 @@ object LinkDeviceRepository {
return when (deviceLinkResult) {
is NetworkResult.Success -> {
TextSecurePreferences.setMultiDevice(AppDependencies.application, true)
SignalStore.account.hasLinkedDevices = true
LinkDeviceResult.Success(verificationCodeResult.tokenIdentifier)
}
is NetworkResult.ApplicationError -> throw deviceLinkResult.throwable

View file

@ -80,7 +80,7 @@ public class LogSectionSystemInfo implements LogSection {
builder.append("Play Services : ").append(getPlayServicesString(context)).append("\n");
builder.append("FCM : ").append(SignalStore.account().isFcmEnabled()).append("\n");
builder.append("Locale : ").append(Locale.getDefault()).append("\n");
builder.append("Linked Devices : ").append(TextSecurePreferences.isMultiDevice(context)).append("\n");
builder.append("Linked Devices : ").append(SignalStore.account().hasLinkedDevices()).append("\n");
builder.append("First Version : ").append(TextSecurePreferences.getFirstInstallVersion(context)).append("\n");
builder.append("Days Installed : ").append(VersionTracker.getDaysSinceFirstInstalled(context)).append("\n");
builder.append("Build Variant : ").append(BuildConfig.BUILD_DISTRIBUTION_TYPE).append(BuildConfig.BUILD_ENVIRONMENT_TYPE).append(BuildConfig.BUILD_VARIANT_TYPE).append("\n");

View file

@ -23,6 +23,7 @@ import org.thoughtcrime.securesms.groups.ui.GroupChangeFailureReason;
import org.thoughtcrime.securesms.jobs.MultiDeviceMessageRequestResponseJob;
import org.thoughtcrime.securesms.jobs.ReportSpamJob;
import org.thoughtcrime.securesms.jobs.SendViewedReceiptJob;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.mms.MmsException;
import org.thoughtcrime.securesms.mms.OutgoingMessage;
import org.thoughtcrime.securesms.notifications.MarkReadReceiver;
@ -207,7 +208,7 @@ public final class MessageRequestRepository {
SendViewedReceiptJob.enqueue(threadId, recipientId, viewedInfos);
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forAccept(recipientId));
}
@ -269,7 +270,7 @@ public final class MessageRequestRepository {
}
}
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forDelete(recipientId));
}
@ -307,7 +308,7 @@ public final class MessageRequestRepository {
}
Recipient.live(recipientId).refresh();
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forBlock(recipientId));
}
@ -367,7 +368,7 @@ public final class MessageRequestRepository {
AppDependencies.getJobManager().add(new ReportSpamJob(threadId, System.currentTimeMillis()));
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forBlockAndReportSpam(recipientId));
}
@ -394,7 +395,7 @@ public final class MessageRequestRepository {
AppDependencies.getJobManager().add(new ReportSpamJob(threadId, System.currentTimeMillis()));
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forReportSpam(recipientId));
}
@ -419,7 +420,7 @@ public final class MessageRequestRepository {
RecipientUtil.unblock(recipient);
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forAccept(recipientId));
}

View file

@ -459,7 +459,7 @@ public final class GroupSendUtil {
throw new CancelationException();
}
boolean onlyTargetIsSelfWithLinkedDevice = legacyTargets.isEmpty() && senderKeyTargets.isEmpty() && TextSecurePreferences.isMultiDevice(context);
boolean onlyTargetIsSelfWithLinkedDevice = legacyTargets.isEmpty() && senderKeyTargets.isEmpty() && SignalStore.account().hasLinkedDevices();
if (legacyTargets.size() > 0 || onlyTargetIsSelfWithLinkedDevice) {
if (legacyTargets.size() > 0) {

View file

@ -441,7 +441,7 @@ open class MessageContentProcessor(private val context: Context) {
}
content.syncMessage != null -> {
TextSecurePreferences.setMultiDevice(context, true)
SignalStore.account.hasLinkedDevices = true
SyncMessageProcessor.process(
context,

View file

@ -12,6 +12,7 @@ import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.JobManager;
import org.thoughtcrime.securesms.jobs.MultiDeviceStickerPackOperationJob;
import org.thoughtcrime.securesms.jobs.StickerPackDownloadJob;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.stickers.BlessedPacks;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
@ -58,7 +59,7 @@ public class StickerLaunchMigrationJob extends MigrationJob {
jobManager.add(StickerPackDownloadJob.forInstall(pack.getPackId(), pack.getPackKey(), false));
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
jobManager.add(new MultiDeviceStickerPackOperationJob(pack.getPackId(), pack.getPackKey(), MultiDeviceStickerPackOperationJob.Type.INSTALL));
}
}

View file

@ -12,6 +12,7 @@ import org.thoughtcrime.securesms.jobs.MultiDeviceStorageSyncRequestJob;
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob;
import org.thoughtcrime.securesms.jobs.RefreshOwnProfileJob;
import org.thoughtcrime.securesms.jobs.StorageForcePushJob;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
/**
@ -53,7 +54,7 @@ public class StorageCapabilityMigrationJob extends MigrationJob {
jobManager.startChain(new RefreshAttributesJob()).then(new RefreshOwnProfileJob()).enqueue();
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Multi-device.");
jobManager.startChain(new StorageForcePushJob())
.then(new MultiDeviceKeysUpdateJob())

View file

@ -8,7 +8,6 @@ import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.jobs.MultiDeviceKeysUpdateJob
import org.thoughtcrime.securesms.jobs.StorageSyncJob
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.util.TextSecurePreferences
/**
* Remove local unknown storage ids not in local storage service manifest.
@ -44,7 +43,7 @@ internal class StorageFixLocalUnknownMigrationJob(
val jobManager = AppDependencies.jobManager
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account.hasLinkedDevices) {
Log.i(TAG, "Multi-device.")
jobManager.startChain(StorageSyncJob())
.then(MultiDeviceKeysUpdateJob())

View file

@ -52,7 +52,7 @@ public class StorageServiceMigrationJob extends MigrationJob {
JobManager jobManager = AppDependencies.getJobManager();
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
Log.i(TAG, "Multi-device.");
jobManager.startChain(new StorageSyncJob())
.then(new MultiDeviceKeysUpdateJob())

View file

@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.migrations
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.jobs.MultiDeviceKeysUpdateJob
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.thoughtcrime.securesms.keyvalue.SignalStore
/**
* Migration to sync keys with linked devices.
@ -21,7 +21,7 @@ internal class SyncKeysMigrationJob(
override fun isUiBlocking(): Boolean = false
override fun performMigration() {
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account.hasLinkedDevices) {
AppDependencies.jobManager.add(MultiDeviceKeysUpdateJob())
}
}

View file

@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.groups.GroupChangeException;
import org.thoughtcrime.securesms.groups.GroupId;
import org.thoughtcrime.securesms.groups.GroupManager;
import org.thoughtcrime.securesms.jobs.MultiDeviceMessageRequestResponseJob;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.recipients.RecipientUtil;
@ -76,7 +77,7 @@ class ReviewCardRepository {
if (resolved.isGroup()) throw new AssertionError();
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forDelete(recipientId));
}

View file

@ -64,7 +64,7 @@ class RegistrationActivity : BaseActivity() {
}
private fun handleSuccessfulVerify() {
if (SignalStore.misc.hasLinkedDevices) {
if (SignalStore.account.hasLinkedDevices) {
SignalStore.misc.shouldShowLinkedDevicesReminder = sharedViewModel.isReregister
}

View file

@ -28,7 +28,6 @@ import org.thoughtcrime.securesms.registration.ui.grantpermissions.GrantPermissi
import org.thoughtcrime.securesms.restore.RestoreActivity
import org.thoughtcrime.securesms.util.BackupUtil
import org.thoughtcrime.securesms.util.CommunicationActions
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.thoughtcrime.securesms.util.navigation.safeNavigate
/**
@ -61,7 +60,6 @@ class WelcomeFragment : LoggingFragment(R.layout.fragment_registration_welcome)
}
private fun onContinueClicked() {
TextSecurePreferences.setHasSeenWelcomeScreen(requireContext(), true)
if (Permissions.isRuntimePermissionsRequired() && !hasAllPermissions()) {
findNavController().safeNavigate(WelcomeFragmentDirections.actionWelcomeFragmentToGrantPermissionsFragment(GrantPermissionsFragment.WelcomeAction.CONTINUE))
} else {

View file

@ -1199,7 +1199,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
.calls()
.updateOneToOneCall(remotePeer.getCallId().longValue(), CallTable.Event.ACCEPTED);
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
networkExecutor.execute(() -> {
try {
SyncMessage.CallEvent callEvent = CallEventSyncMessageUtil.createAcceptedSyncMessage(remotePeer, System.currentTimeMillis(), isOutgoing, isVideoCall);
@ -1216,7 +1216,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
.calls()
.updateOneToOneCall(remotePeer.getCallId().longValue(), CallTable.Event.NOT_ACCEPTED);
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
networkExecutor.execute(() -> {
try {
SyncMessage.CallEvent callEvent = CallEventSyncMessageUtil.createNotAcceptedSyncMessage(remotePeer, System.currentTimeMillis(), isOutgoing, isVideoCall);
@ -1229,7 +1229,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
}
public void sendGroupCallNotAcceptedCallEventSyncMessage(@NonNull RemotePeer remotePeer, boolean isOutgoing) {
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
networkExecutor.execute(() -> {
try {
SyncMessage.CallEvent callEvent = CallEventSyncMessageUtil.createNotAcceptedSyncMessage(remotePeer, System.currentTimeMillis(), isOutgoing, true);

View file

@ -614,7 +614,7 @@ public class MessageSender {
recipient.isSelf() &&
sendType == SendType.SIGNAL &&
SignalStore.account().isRegistered() &&
!TextSecurePreferences.isMultiDevice(context);
!SignalStore.account().hasLinkedDevices();
}
private static void sendLocalMediaSelf(long messageId) {

View file

@ -15,6 +15,7 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.jobmanager.JobManager;
import org.thoughtcrime.securesms.jobs.MultiDeviceStickerPackOperationJob;
import org.thoughtcrime.securesms.jobs.StickerPackDownloadJob;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import java.util.ArrayList;
@ -78,7 +79,7 @@ final class StickerManagementRepository {
SignalExecutors.SERIAL.execute(() -> {
stickerDatabase.uninstallPack(packId);
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
AppDependencies.getJobManager().add(new MultiDeviceStickerPackOperationJob(packId, packKey, MultiDeviceStickerPackOperationJob.Type.REMOVE));
}
});
@ -94,7 +95,7 @@ final class StickerManagementRepository {
jobManager.add(StickerPackDownloadJob.forInstall(packId, packKey, notify));
if (TextSecurePreferences.isMultiDevice(context)) {
if (SignalStore.account().hasLinkedDevices()) {
jobManager.add(new MultiDeviceStickerPackOperationJob(packId, packKey, MultiDeviceStickerPackOperationJob.Type.INSTALL));
}
});

View file

@ -60,7 +60,7 @@ object DeleteDialog {
}.executeOnExecutor(SignalExecutors.BOUNDED)
}
val canDeleteForEveryoneInNoteToSelf = isNoteToSelfDelete && TextSecurePreferences.isMultiDevice(context) && !deleteSyncEnabled
val canDeleteForEveryoneInNoteToSelf = isNoteToSelfDelete && SignalStore.account.hasLinkedDevices && !deleteSyncEnabled
if (MessageConstraintsUtil.isValidRemoteDeleteSend(messageRecords, System.currentTimeMillis()) && (!isNoteToSelfDelete || canDeleteForEveryoneInNoteToSelf)) {
builder.setNeutralButton(if (isNoteToSelfDelete) R.string.ConversationFragment_delete_everywhere else R.string.ConversationFragment_delete_for_everyone) { _, _ -> handleDeleteForEveryone(context, messageRecords, emitter) }

View file

@ -45,20 +45,8 @@ public class TextSecurePreferences {
private static final String TAG = Log.tag(TextSecurePreferences.class);
public static final String CHANGE_PASSPHRASE_PREF = "pref_change_passphrase";
public static final String DISABLE_PASSPHRASE_PREF = "pref_disable_passphrase";
public static final String THEME_PREF = "pref_theme";
public static final String LANGUAGE_PREF = "pref_language";
private static final String MMSC_CUSTOM_HOST_PREF = "pref_apn_mmsc_custom_host";
public static final String MMSC_HOST_PREF = "pref_apn_mmsc_host";
private static final String MMSC_CUSTOM_PROXY_PREF = "pref_apn_mms_custom_proxy";
public static final String MMSC_PROXY_HOST_PREF = "pref_apn_mms_proxy";
private static final String MMSC_CUSTOM_PROXY_PORT_PREF = "pref_apn_mms_custom_proxy_port";
public static final String MMSC_PROXY_PORT_PREF = "pref_apn_mms_proxy_port";
private static final String MMSC_CUSTOM_USERNAME_PREF = "pref_apn_mmsc_custom_username";
public static final String MMSC_USERNAME_PREF = "pref_apn_mmsc_username";
private static final String MMSC_CUSTOM_PASSWORD_PREF = "pref_apn_mmsc_custom_password";
public static final String MMSC_PASSWORD_PREF = "pref_apn_mmsc_password";
public static final String ENABLE_MANUAL_MMS_PREF = "pref_enable_manual_mms";
private static final String LAST_VERSION_CODE_PREF = "last_version_code";
@ -68,17 +56,9 @@ public class TextSecurePreferences {
public static final String LED_COLOR_PREF = "pref_led_color";
public static final String LED_BLINK_PREF = "pref_led_blink";
private static final String LED_BLINK_PREF_CUSTOM = "pref_led_blink_custom";
public static final String ALL_MMS_PREF = "pref_all_mms";
public static final String ALL_SMS_PREF = "pref_all_sms";
public static final String PASSPHRASE_TIMEOUT_INTERVAL_PREF = "pref_timeout_interval";
public static final String PASSPHRASE_TIMEOUT_PREF = "pref_timeout_passphrase";
public static final String SCREEN_SECURITY_PREF = "pref_screen_security";
private static final String ENTER_SENDS_PREF = "pref_enter_sends";
private static final String ENTER_PRESENT_PREF = "pref_enter_key";
private static final String SMS_DELIVERY_REPORT_PREF = "pref_delivery_report_sms";
public static final String MMS_USER_AGENT = "pref_mms_user_agent";
private static final String MMS_CUSTOM_USER_AGENT = "pref_custom_mms_user_agent";
private static final String SEEN_WELCOME_SCREEN_PREF = "pref_seen_welcome_screen";
private static final String PROMPTED_PUSH_REGISTRATION_PREF = "pref_prompted_push_registration";
private static final String PROMPTED_OPTIMIZE_DOZE_PREF = "pref_prompted_optimize_doze";
private static final String DIRECTORY_FRESH_TIME_PREF = "pref_directory_refresh_time";
@ -98,7 +78,6 @@ public class TextSecurePreferences {
public static final String NOTIFICATION_PRIVACY_PREF = "pref_notification_privacy";
public static final String NOTIFICATION_PRIORITY_PREF = "pref_notification_priority";
public static final String NEW_CONTACTS_NOTIFICATIONS = "pref_enable_new_contacts_notifications";
public static final String WEBRTC_CALLING_PREF = "pref_webrtc_calling";
public static final String MEDIA_DOWNLOAD_MOBILE_PREF = "pref_media_download_mobile";
public static final String MEDIA_DOWNLOAD_WIFI_PREF = "pref_media_download_wifi";
@ -129,23 +108,14 @@ public class TextSecurePreferences {
private static final String ENCRYPTED_BACKUP_PASSPHRASE = "pref_encrypted_backup_passphrase";
private static final String BACKUP_TIME = "pref_backup_next_time";
public static final String TRANSFER = "pref_transfer";
public static final String SCREEN_LOCK = "pref_android_screen_lock";
public static final String SCREEN_LOCK_TIMEOUT = "pref_android_screen_lock_timeout";
@Deprecated
public static final String REGISTRATION_LOCK_PREF_V1 = "pref_registration_lock";
@Deprecated
private static final String REGISTRATION_LOCK_PIN_PREF_V1 = "pref_registration_lock_pin";
public static final String REGISTRATION_LOCK_PREF_V2 = "pref_registration_lock_v2";
private static final String REGISTRATION_LOCK_LAST_REMINDER_TIME_POST_KBS = "pref_registration_lock_last_reminder_time_post_kbs";
private static final String REGISTRATION_LOCK_NEXT_REMINDER_INTERVAL = "pref_registration_lock_next_reminder_interval";
public static final String SIGNAL_PIN_CHANGE = "pref_kbs_change";
public static final String SERVICE_OUTAGE = "pref_service_outage";
private static final String LAST_OUTAGE_CHECK_TIME = "pref_last_outage_check_time";
@ -174,10 +144,6 @@ public class TextSecurePreferences {
private static final String MEDIA_KEYBOARD_MODE = "pref_media_keyboard_mode";
public static final String RECENT_STORAGE_KEY = "pref_recent_emoji2";
private static final String VIEW_ONCE_TOOLTIP_SEEN = "pref_revealable_message_tooltip_seen";
private static final String SEEN_CAMERA_FIRST_TOOLTIP = "pref_seen_camera_first_tooltip";
private static final String JOB_MANAGER_VERSION = "pref_job_manager_version";
private static final String APP_MIGRATION_VERSION = "pref_app_migration_version";
@ -188,10 +154,6 @@ public class TextSecurePreferences {
private static final String HAS_SEEN_VIDEO_RECORDING_TOOLTIP = "camerax.fragment.has.dismissed.video.recording.tooltip";
private static final String STORAGE_MANIFEST_VERSION = "pref_storage_manifest_version";
private static final String ARGON2_TESTED = "argon2_tested";
private static final String[] booleanPreferencesToBackup = {SCREEN_SECURITY_PREF,
INCOGNITO_KEYBORAD_PREF,
ALWAYS_RELAY_CALLS_PREF,
@ -301,27 +263,6 @@ public class TextSecurePreferences {
getSharedPreferences(context).unregisterOnSharedPreferenceChangeListener(listener);
}
public static boolean isScreenLockEnabled(@NonNull Context context) {
return getBooleanPreference(context, SCREEN_LOCK, false);
}
public static void setScreenLockEnabled(@NonNull Context context, boolean value) {
setBooleanPreference(context, SCREEN_LOCK, value);
}
public static long getScreenLockTimeout(@NonNull Context context) {
return getLongPreference(context, SCREEN_LOCK_TIMEOUT, 0);
}
public static void setScreenLockTimeout(@NonNull Context context, long value) {
setLongPreference(context, SCREEN_LOCK_TIMEOUT, value);
}
public static boolean isV1RegistrationLockEnabled(@NonNull Context context) {
//noinspection deprecation
return getBooleanPreference(context, REGISTRATION_LOCK_PREF_V1, false);
}
/**
* @deprecated Use only during re-reg where user had pinV1.
*/
@ -512,14 +453,6 @@ public class TextSecurePreferences {
return getBooleanPreference(context, ALWAYS_RELAY_CALLS_PREF, false);
}
public static boolean isWebrtcCallingEnabled(Context context) {
return getBooleanPreference(context, WEBRTC_CALLING_PREF, false);
}
public static void setWebrtcCallingEnabled(Context context, boolean enabled) {
setBooleanPreference(context, WEBRTC_CALLING_PREF, enabled);
}
public static void setDirectCaptureCameraId(Context context, int value) {
setIntegerPrefrence(context, DIRECT_CAPTURE_CAMERA_ID, value);
}
@ -529,14 +462,6 @@ public class TextSecurePreferences {
return getIntegerPreference(context, DIRECT_CAPTURE_CAMERA_ID, CameraInfo.CAMERA_FACING_FRONT);
}
public static void setMultiDevice(Context context, boolean value) {
setBooleanPreference(context, MULTI_DEVICE_PROVISIONED_PREF, value);
}
public static boolean isMultiDevice(Context context) {
return getBooleanPreference(context, MULTI_DEVICE_PROVISIONED_PREF, false);
}
@Deprecated
public static NotificationPrivacyPreference getNotificationPrivacy(Context context) {
return new NotificationPrivacyPreference(getStringPreference(context, NOTIFICATION_PRIVACY_PREF, "all"));
@ -630,115 +555,11 @@ public class TextSecurePreferences {
setLongPreference(context, UPDATE_APK_REFRESH_TIME_PREF, value);
}
public static boolean isEnterImeKeyEnabled(Context context) {
return getBooleanPreference(context, ENTER_PRESENT_PREF, false);
}
@Deprecated
public static boolean isEnterSendsEnabled(Context context) {
return getBooleanPreference(context, ENTER_SENDS_PREF, false);
}
public static boolean isPasswordDisabled(Context context) {
return getBooleanPreference(context, DISABLE_PASSPHRASE_PREF, true);
}
public static void setPasswordDisabled(Context context, boolean disabled) {
setBooleanPreference(context, DISABLE_PASSPHRASE_PREF, disabled);
}
public static boolean getUseCustomMmsc(Context context) {
boolean legacy = TextSecurePreferences.isLegacyUseLocalApnsEnabled(context);
return getBooleanPreference(context, MMSC_CUSTOM_HOST_PREF, legacy);
}
public static void setUseCustomMmsc(Context context, boolean value) {
setBooleanPreference(context, MMSC_CUSTOM_HOST_PREF, value);
}
public static String getMmscUrl(Context context) {
return getStringPreference(context, MMSC_HOST_PREF, "");
}
public static void setMmscUrl(Context context, String mmsc) {
setStringPreference(context, MMSC_HOST_PREF, mmsc);
}
public static boolean getUseCustomMmscProxy(Context context) {
boolean legacy = TextSecurePreferences.isLegacyUseLocalApnsEnabled(context);
return getBooleanPreference(context, MMSC_CUSTOM_PROXY_PREF, legacy);
}
public static void setUseCustomMmscProxy(Context context, boolean value) {
setBooleanPreference(context, MMSC_CUSTOM_PROXY_PREF, value);
}
public static String getMmscProxy(Context context) {
return getStringPreference(context, MMSC_PROXY_HOST_PREF, "");
}
public static void setMmscProxy(Context context, String value) {
setStringPreference(context, MMSC_PROXY_HOST_PREF, value);
}
public static boolean getUseCustomMmscProxyPort(Context context) {
boolean legacy = TextSecurePreferences.isLegacyUseLocalApnsEnabled(context);
return getBooleanPreference(context, MMSC_CUSTOM_PROXY_PORT_PREF, legacy);
}
public static void setUseCustomMmscProxyPort(Context context, boolean value) {
setBooleanPreference(context, MMSC_CUSTOM_PROXY_PORT_PREF, value);
}
public static String getMmscProxyPort(Context context) {
return getStringPreference(context, MMSC_PROXY_PORT_PREF, "");
}
public static void setMmscProxyPort(Context context, String value) {
setStringPreference(context, MMSC_PROXY_PORT_PREF, value);
}
public static boolean getUseCustomMmscUsername(Context context) {
boolean legacy = TextSecurePreferences.isLegacyUseLocalApnsEnabled(context);
return getBooleanPreference(context, MMSC_CUSTOM_USERNAME_PREF, legacy);
}
public static void setUseCustomMmscUsername(Context context, boolean value) {
setBooleanPreference(context, MMSC_CUSTOM_USERNAME_PREF, value);
}
public static String getMmscUsername(Context context) {
return getStringPreference(context, MMSC_USERNAME_PREF, "");
}
public static void setMmscUsername(Context context, String value) {
setStringPreference(context, MMSC_USERNAME_PREF, value);
}
public static boolean getUseCustomMmscPassword(Context context) {
boolean legacy = TextSecurePreferences.isLegacyUseLocalApnsEnabled(context);
return getBooleanPreference(context, MMSC_CUSTOM_PASSWORD_PREF, legacy);
}
public static void setUseCustomMmscPassword(Context context, boolean value) {
setBooleanPreference(context, MMSC_CUSTOM_PASSWORD_PREF, value);
}
public static String getMmscPassword(Context context) {
return getStringPreference(context, MMSC_PASSWORD_PREF, "");
}
public static void setMmscPassword(Context context, String value) {
setStringPreference(context, MMSC_PASSWORD_PREF, value);
}
public static String getMmsUserAgent(Context context, String defaultUserAgent) {
boolean useCustom = getBooleanPreference(context, MMS_CUSTOM_USER_AGENT, false);
if (useCustom) return getStringPreference(context, MMS_USER_AGENT, defaultUserAgent);
else return defaultUserAgent;
}
public static void setScreenSecurityEnabled(Context context, boolean value) {
setBooleanPreference(context, SCREEN_SECURITY_PREF, value);
}
@ -769,22 +590,6 @@ public class TextSecurePreferences {
return getStringPreference(context, THEME_PREF, DynamicTheme.systemThemeAvailable() ? "system" : "light");
}
public static boolean isShowInviteReminders(Context context) {
return getBooleanPreference(context, SHOW_INVITE_REMINDER_PREF, true);
}
public static boolean isPassphraseTimeoutEnabled(Context context) {
return getBooleanPreference(context, PASSPHRASE_TIMEOUT_PREF, false);
}
public static int getPassphraseTimeoutInterval(Context context) {
return getIntegerPreference(context, PASSPHRASE_TIMEOUT_INTERVAL_PREF, 5 * 60);
}
public static void setPassphraseTimeoutInterval(Context context, int interval) {
setIntegerPrefrence(context, PASSPHRASE_TIMEOUT_INTERVAL_PREF, interval);
}
/**
* @deprecated Use {@link SettingsValues#getLanguage()} via {@link org.thoughtcrime.securesms.keyvalue.SignalStore} instead.
*/
@ -806,14 +611,6 @@ public class TextSecurePreferences {
return getBooleanPreference(context, SMS_DELIVERY_REPORT_PREF, false);
}
public static boolean hasSeenWelcomeScreen(Context context) {
return getBooleanPreference(context, SEEN_WELCOME_SCREEN_PREF, true);
}
public static void setHasSeenWelcomeScreen(Context context, boolean value) {
setBooleanPreference(context, SEEN_WELCOME_SCREEN_PREF, value);
}
public static boolean hasPromptedPushRegistration(Context context) {
return getBooleanPreference(context, PROMPTED_PUSH_REGISTRATION_PREF, false);
}
@ -830,14 +627,6 @@ public class TextSecurePreferences {
return getBooleanPreference(context, PROMPTED_OPTIMIZE_DOZE_PREF, false);
}
public static boolean isInterceptAllMmsEnabled(Context context) {
return getBooleanPreference(context, ALL_MMS_PREF, true);
}
public static boolean isInterceptAllSmsEnabled(Context context) {
return getBooleanPreference(context, ALL_SMS_PREF, true);
}
@Deprecated
public static boolean isNotificationsEnabled(Context context) {
return getBooleanPreference(context, NOTIFICATION_PREF, true);
@ -1016,22 +805,6 @@ public class TextSecurePreferences {
return MediaKeyboardMode.valueOf(name);
}
public static void setHasSeenViewOnceTooltip(Context context, boolean value) {
setBooleanPreference(context, VIEW_ONCE_TOOLTIP_SEEN, value);
}
public static boolean hasSeenViewOnceTooltip(Context context) {
return getBooleanPreference(context, VIEW_ONCE_TOOLTIP_SEEN, false);
}
public static void setHasSeenCameraFirstTooltip(Context context, boolean value) {
setBooleanPreference(context, SEEN_CAMERA_FIRST_TOOLTIP, value);
}
public static boolean hasSeenCameraFirstTooltip(Context context) {
return getBooleanPreference(context, SEEN_CAMERA_FIRST_TOOLTIP, false);
}
public static void setJobManagerVersion(Context context, int version) {
setIntegerPrefrence(context, JOB_MANAGER_VERSION, version);
}
@ -1072,18 +845,6 @@ public class TextSecurePreferences {
setBooleanPreference(context, HAS_SEEN_VIDEO_RECORDING_TOOLTIP, value);
}
public static void setStorageManifestVersion(Context context, long version) {
setLongPreference(context, STORAGE_MANIFEST_VERSION, version);
}
public static boolean isArgon2Tested(Context context) {
return getBooleanPreference(context, ARGON2_TESTED, false);
}
public static void setArgon2Tested(Context context, boolean tested) {
setBooleanPreference(context, ARGON2_TESTED, tested);
}
public static void setBooleanPreference(Context context, String key, boolean value) {
getSharedPreferences(context).edit().putBoolean(key, value).apply();
}