mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Initial pass to properly check multi-device environment in various spots.
This commit is contained in:
@@ -43,8 +43,7 @@ class DeleteSyncEducationDialog : ComposeBottomSheetDialogFragment() {
|
||||
|
||||
@JvmStatic
|
||||
fun shouldShow(): Boolean {
|
||||
return SignalStore.account.hasLinkedDevices &&
|
||||
!SignalStore.uiHints.hasSeenDeleteSyncEducationSheet
|
||||
return SignalStore.account.isMultiDevice && !SignalStore.uiHints.hasSeenDeleteSyncEducationSheet
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@@ -159,7 +159,7 @@ class ManageStorageSettingsFragment : ComposeFragment() {
|
||||
dialog("confirm-delete-chat-history") {
|
||||
Dialogs.SimpleAlertDialog(
|
||||
title = stringResource(id = R.string.preferences_storage__delete_message_history),
|
||||
body = if (SignalStore.account.hasLinkedDevices) {
|
||||
body = if (SignalStore.account.isMultiDevice) {
|
||||
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 +175,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 (SignalStore.account.hasLinkedDevices) {
|
||||
body = if (SignalStore.account.isMultiDevice) {
|
||||
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)
|
||||
|
||||
@@ -1012,7 +1012,7 @@ public class ConversationListFragment extends MainFragment implements Conversati
|
||||
alert.setTitle(context.getResources().getQuantityString(R.plurals.ConversationListFragment_delete_selected_conversations,
|
||||
conversationsCount, conversationsCount));
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
alert.setMessage(context.getResources().getQuantityString(R.plurals.ConversationListFragment_this_will_permanently_delete_all_n_selected_conversations_linked_device,
|
||||
conversationsCount, conversationsCount));
|
||||
} else {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class SignalServiceAccountDataStoreImpl implements SignalServiceAccountDa
|
||||
|
||||
@Override
|
||||
public boolean isMultiDevice() {
|
||||
return SignalStore.account().hasLinkedDevices();
|
||||
return SignalStore.account().isMultiDevice();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,6 +47,6 @@ public final class SignalServiceDataStoreImpl implements SignalServiceDataStore
|
||||
|
||||
@Override
|
||||
public boolean isMultiDevice() {
|
||||
return SignalStore.account().hasLinkedDevices();
|
||||
return SignalStore.account().isMultiDevice();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,11 @@ class InAppPaymentKeepAliveJob private constructor(
|
||||
return
|
||||
}
|
||||
|
||||
if (SignalStore.account.isLinkedDevice) {
|
||||
info(type, "Not primary, skipping")
|
||||
return
|
||||
}
|
||||
|
||||
if (SignalDatabase.inAppPayments.hasPrePendingRecurringTransaction(type.inAppPaymentType)) {
|
||||
info(type, "We are currently processing a transaction for this type. Skipping.")
|
||||
return
|
||||
|
||||
@@ -67,6 +67,11 @@ class LinkedDeviceInactiveCheckJob private constructor(
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
if (SignalStore.account.isLinkedDevice) {
|
||||
Log.i(TAG, "Not primary, skipping")
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
val devices = try {
|
||||
AppDependencies
|
||||
.linkDeviceApi
|
||||
@@ -80,7 +85,7 @@ class LinkedDeviceInactiveCheckJob private constructor(
|
||||
if (devices.isEmpty()) {
|
||||
Log.i(TAG, "No linked devices found.")
|
||||
|
||||
SignalStore.account.hasLinkedDevices = false
|
||||
SignalStore.account.isMultiDevice = false
|
||||
SignalStore.misc.leastActiveLinkedDevice = null
|
||||
SignalStore.misc.linkedDeviceLastActiveCheckTime = System.currentTimeMillis()
|
||||
|
||||
@@ -103,7 +108,7 @@ class LinkedDeviceInactiveCheckJob private constructor(
|
||||
|
||||
if (leastActiveDevice == null) {
|
||||
Log.w(TAG, "Failed to decrypt linked device name.")
|
||||
SignalStore.account.hasLinkedDevices = true
|
||||
SignalStore.account.isMultiDevice = true
|
||||
SignalStore.misc.leastActiveLinkedDevice = null
|
||||
SignalStore.misc.linkedDeviceLastActiveCheckTime = System.currentTimeMillis()
|
||||
return Result.success()
|
||||
@@ -112,7 +117,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.account.hasLinkedDevices = true
|
||||
SignalStore.account.isMultiDevice = true
|
||||
SignalStore.misc.leastActiveLinkedDevice = leastActiveDevice
|
||||
SignalStore.misc.linkedDeviceLastActiveCheckTime = System.currentTimeMillis()
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class MultiDeviceBlockedUpdateJob private constructor(parameters: Parameters) :
|
||||
throw NotPushRegisteredException()
|
||||
}
|
||||
|
||||
if (!SignalStore.account.hasLinkedDevices) {
|
||||
if (!SignalStore.account.isMultiDevice) {
|
||||
Log.i(TAG, "Not multi device, aborting...")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class MultiDeviceConfigurationUpdateJob extends BaseJob {
|
||||
throw new NotPushRegisteredException();
|
||||
}
|
||||
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device, aborting...");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
|
||||
throw new NotPushRegisteredException();
|
||||
}
|
||||
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device, aborting...");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class MultiDeviceDeleteSyncJob private constructor(
|
||||
@WorkerThread
|
||||
@JvmStatic
|
||||
fun enqueueMessageDeletes(messageRecords: Set<MessageRecord>) {
|
||||
if (!SignalStore.account.hasLinkedDevices) {
|
||||
if (!SignalStore.account.isMultiDevice) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class MultiDeviceDeleteSyncJob private constructor(
|
||||
@WorkerThread
|
||||
@JvmStatic
|
||||
fun enqueueAttachmentDelete(message: MessageRecord?, attachment: DatabaseAttachment) {
|
||||
if (!SignalStore.account.hasLinkedDevices) {
|
||||
if (!SignalStore.account.isMultiDevice) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class MultiDeviceDeleteSyncJob private constructor(
|
||||
|
||||
@WorkerThread
|
||||
fun enqueueThreadDeletes(threads: List<ThreadTable.ThreadDeleteSyncInfo>, isFullDelete: Boolean) {
|
||||
if (!SignalStore.account.hasLinkedDevices) {
|
||||
if (!SignalStore.account.isMultiDevice) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ class MultiDeviceDeleteSyncJob private constructor(
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
if (!SignalStore.account.hasLinkedDevices) {
|
||||
if (!SignalStore.account.isMultiDevice) {
|
||||
Log.w(TAG, "Not multi-device")
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class MultiDeviceKeysUpdateJob private constructor(parameters: Parameters) : Bas
|
||||
throw NotPushRegisteredException()
|
||||
}
|
||||
|
||||
if (!SignalStore.account.hasLinkedDevices) {
|
||||
if (!SignalStore.account.isMultiDevice) {
|
||||
Log.i(TAG, "Not multi device, aborting...")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class MultiDeviceMessageRequestResponseJob extends BaseJob {
|
||||
throw new NotPushRegisteredException();
|
||||
}
|
||||
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device, aborting...");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public final class MultiDeviceOutgoingPaymentSyncJob extends BaseJob {
|
||||
throw new NotPushRegisteredException();
|
||||
}
|
||||
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device, aborting...");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MultiDeviceProfileContentUpdateJob extends BaseJob {
|
||||
throw new NotPushRegisteredException();
|
||||
}
|
||||
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device, aborting...");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,14 +66,13 @@ public class MultiDeviceProfileKeyUpdateJob extends BaseJob {
|
||||
throw new NotPushRegisteredException();
|
||||
}
|
||||
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device...");
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<ProfileKey> profileKey = Optional.of(ProfileKeyUtil.getSelfProfileKey());
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
DeviceContactsOutputStream out = new DeviceContactsOutputStream(baos);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
DeviceContactsOutputStream out = new DeviceContactsOutputStream(baos);
|
||||
|
||||
out.write(new DeviceContact(Optional.ofNullable(SignalStore.account().getAci()),
|
||||
Optional.ofNullable(SignalStore.account().getE164()),
|
||||
@@ -93,7 +92,7 @@ public class MultiDeviceProfileKeyUpdateJob extends BaseJob {
|
||||
.withResumableUploadSpec(messageSender.getResumableUploadSpec())
|
||||
.build();
|
||||
|
||||
SignalServiceSyncMessage syncMessage = SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, false));
|
||||
SignalServiceSyncMessage syncMessage = SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, false));
|
||||
|
||||
messageSender.sendSyncMessage(syncMessage);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class MultiDeviceReadUpdateJob extends BaseJob {
|
||||
throw new NotPushRegisteredException();
|
||||
}
|
||||
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device...");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class MultiDeviceStickerPackOperationJob extends BaseJob {
|
||||
|
||||
@Override
|
||||
protected void onRun() throws Exception {
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device, aborting...");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MultiDeviceStickerPackSyncJob extends BaseJob {
|
||||
throw new NotPushRegisteredException();
|
||||
}
|
||||
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device, aborting...");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MultiDeviceStorageSyncRequestJob extends BaseJob {
|
||||
throw new NotPushRegisteredException();
|
||||
}
|
||||
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device, aborting...");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class MultiDeviceSubscriptionSyncRequestJob private constructor(parameters: Para
|
||||
throw NotPushRegisteredException()
|
||||
}
|
||||
|
||||
if (!SignalStore.account.hasLinkedDevices) {
|
||||
if (!SignalStore.account.isMultiDevice) {
|
||||
Log.i(TAG, "Not multi device, aborting...")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class MultiDeviceVerifiedUpdateJob extends BaseJob {
|
||||
}
|
||||
|
||||
try {
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device...");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class MultiDeviceViewOnceOpenJob extends BaseJob {
|
||||
throw new NotPushRegisteredException();
|
||||
}
|
||||
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device...");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class MultiDeviceViewedUpdateJob extends BaseJob {
|
||||
throw new NotPushRegisteredException();
|
||||
}
|
||||
|
||||
if (!SignalStore.account().hasLinkedDevices()) {
|
||||
if (!SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Not multi device...");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ class StorageSyncJob private constructor(parameters: Parameters, private var loc
|
||||
AppDependencies.jobManager.add(StorageRotateManifestJob())
|
||||
}
|
||||
|
||||
if (SignalStore.account.hasLinkedDevices && needsMultiDeviceSync) {
|
||||
if (SignalStore.account.isMultiDevice && needsMultiDeviceSync) {
|
||||
AppDependencies.jobManager.add(MultiDeviceStorageSyncRequestJob())
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,11 @@ class Svr2MirrorJob private constructor(parameters: Parameters, private var seri
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun run(): Result {
|
||||
if (SignalStore.account.isLinkedDevice) {
|
||||
Log.i(TAG, "Not primary device, skipping mirror")
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
if (!Svr3Migration.shouldWriteToSvr2) {
|
||||
Log.w(TAG, "Writes to SVR2 are disabled. Skipping.")
|
||||
return Result.success()
|
||||
|
||||
@@ -544,10 +544,10 @@ class AccountValues internal constructor(store: KeyValueStore, context: Context)
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the user has linked devices.
|
||||
* Whether or not the user is a multi-device account (has linked devices or is a linked device).
|
||||
*/
|
||||
@get:JvmName("hasLinkedDevices")
|
||||
var hasLinkedDevices by booleanValue(KEY_HAS_LINKED_DEVICES, false)
|
||||
@get:JvmName("isMultiDevice")
|
||||
var isMultiDevice 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) {
|
||||
|
||||
@@ -180,7 +180,7 @@ object LinkDeviceRepository {
|
||||
|
||||
return when (deviceLinkResult) {
|
||||
is NetworkResult.Success -> {
|
||||
SignalStore.account.hasLinkedDevices = true
|
||||
SignalStore.account.isMultiDevice = true
|
||||
LinkDeviceResult.Success(verificationCodeResult.tokenIdentifier)
|
||||
}
|
||||
is NetworkResult.ApplicationError -> throw deviceLinkResult.throwable
|
||||
|
||||
@@ -17,7 +17,7 @@ data class LinkDeviceSettingsState(
|
||||
val qrCodeState: QrCodeState = QrCodeState.NONE,
|
||||
val linkUri: Uri? = null,
|
||||
val linkDeviceResult: LinkDeviceResult = LinkDeviceResult.None,
|
||||
val seenQrEducationSheet: Boolean = SignalStore.uiHints.hasSeenLinkDeviceQrEducationSheet() || SignalStore.account.hasLinkedDevices,
|
||||
val seenQrEducationSheet: Boolean = SignalStore.uiHints.hasSeenLinkDeviceQrEducationSheet() || SignalStore.account.isMultiDevice,
|
||||
val bottomSheetVisible: Boolean = false,
|
||||
val deviceToEdit: Device? = null,
|
||||
val shouldCancelArchiveUpload: Boolean = false,
|
||||
|
||||
@@ -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(SignalStore.account().hasLinkedDevices()).append("\n");
|
||||
builder.append("Linked Devices : ").append(SignalStore.account().isMultiDevice()).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");
|
||||
|
||||
@@ -216,7 +216,7 @@ public final class MessageRequestRepository {
|
||||
|
||||
SendViewedReceiptJob.enqueue(threadId, recipientId, viewedInfos);
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forAccept(recipientId));
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ public final class MessageRequestRepository {
|
||||
}
|
||||
}
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forDelete(recipientId));
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ public final class MessageRequestRepository {
|
||||
}
|
||||
Recipient.live(recipientId).refresh();
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forBlock(recipientId));
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ public final class MessageRequestRepository {
|
||||
|
||||
AppDependencies.getJobManager().add(new ReportSpamJob(threadId, System.currentTimeMillis()));
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forBlockAndReportSpam(recipientId));
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ public final class MessageRequestRepository {
|
||||
|
||||
AppDependencies.getJobManager().add(new ReportSpamJob(threadId, System.currentTimeMillis()));
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forReportSpam(recipientId));
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ public final class MessageRequestRepository {
|
||||
|
||||
RecipientUtil.unblock(recipient);
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forAccept(recipientId));
|
||||
}
|
||||
|
||||
|
||||
@@ -449,7 +449,7 @@ public final class GroupSendUtil {
|
||||
throw new CancelationException();
|
||||
}
|
||||
|
||||
boolean onlyTargetIsSelfWithLinkedDevice = legacyTargets.isEmpty() && senderKeyTargets.isEmpty() && SignalStore.account().hasLinkedDevices();
|
||||
boolean onlyTargetIsSelfWithLinkedDevice = legacyTargets.isEmpty() && senderKeyTargets.isEmpty() && SignalStore.account().isMultiDevice();
|
||||
|
||||
if (legacyTargets.size() > 0 || onlyTargetIsSelfWithLinkedDevice) {
|
||||
if (legacyTargets.size() > 0) {
|
||||
|
||||
@@ -446,7 +446,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
}
|
||||
|
||||
content.syncMessage != null -> {
|
||||
SignalStore.account.hasLinkedDevices = true
|
||||
SignalStore.account.isMultiDevice = true
|
||||
|
||||
SyncMessageProcessor.process(
|
||||
context,
|
||||
|
||||
@@ -30,8 +30,13 @@ internal class AepMigrationJob(
|
||||
return
|
||||
}
|
||||
|
||||
if (SignalStore.account.isLinkedDevice) {
|
||||
Log.i(TAG, "Not primary, skipping.")
|
||||
return
|
||||
}
|
||||
|
||||
AppDependencies.jobManager.add(Svr2MirrorJob())
|
||||
if (SignalStore.account.hasLinkedDevices) {
|
||||
if (SignalStore.account.isMultiDevice) {
|
||||
AppDependencies.jobManager.add(MultiDeviceKeysUpdateJob())
|
||||
}
|
||||
AppDependencies.jobManager.add(StorageForcePushJob())
|
||||
|
||||
@@ -59,7 +59,7 @@ public class StickerLaunchMigrationJob extends MigrationJob {
|
||||
|
||||
jobManager.add(StickerPackDownloadJob.forInstall(pack.getPackId(), pack.getPackKey(), false));
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
jobManager.add(new MultiDeviceStickerPackOperationJob(pack.getPackId(), pack.getPackKey(), MultiDeviceStickerPackOperationJob.Type.INSTALL));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,11 +50,15 @@ public class StorageCapabilityMigrationJob extends MigrationJob {
|
||||
|
||||
@Override
|
||||
public void performMigration() {
|
||||
if (SignalStore.account().isLinkedDevice()) {
|
||||
return;
|
||||
}
|
||||
|
||||
JobManager jobManager = AppDependencies.getJobManager();
|
||||
|
||||
jobManager.startChain(new RefreshAttributesJob()).then(new RefreshOwnProfileJob()).enqueue();
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Multi-device.");
|
||||
jobManager.startChain(new StorageForcePushJob())
|
||||
.then(new MultiDeviceKeysUpdateJob())
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.signal.core.util.withinTransaction
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceKeysUpdateJob
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceStorageSyncRequestJob
|
||||
import org.thoughtcrime.securesms.jobs.StorageSyncJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
|
||||
@@ -43,10 +43,10 @@ internal class StorageFixLocalUnknownMigrationJob(
|
||||
|
||||
val jobManager = AppDependencies.jobManager
|
||||
|
||||
if (SignalStore.account.hasLinkedDevices) {
|
||||
if (SignalStore.account.isMultiDevice) {
|
||||
Log.i(TAG, "Multi-device.")
|
||||
jobManager.startChain(StorageSyncJob.forLocalChange())
|
||||
.then(MultiDeviceKeysUpdateJob())
|
||||
.then(MultiDeviceStorageSyncRequestJob())
|
||||
.enqueue()
|
||||
} else {
|
||||
Log.i(TAG, "Single-device.")
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceKeysUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceStorageSyncRequestJob;
|
||||
import org.thoughtcrime.securesms.jobs.StorageSyncJob;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
@@ -52,10 +53,10 @@ public class StorageServiceMigrationJob extends MigrationJob {
|
||||
|
||||
JobManager jobManager = AppDependencies.getJobManager();
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
Log.i(TAG, "Multi-device.");
|
||||
jobManager.startChain(StorageSyncJob.forLocalChange())
|
||||
.then(new MultiDeviceKeysUpdateJob())
|
||||
.then(new MultiDeviceStorageSyncRequestJob())
|
||||
.enqueue();
|
||||
} else {
|
||||
Log.i(TAG, "Single-device.");
|
||||
|
||||
@@ -21,7 +21,11 @@ internal class SyncKeysMigrationJob(
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun performMigration() {
|
||||
if (SignalStore.account.hasLinkedDevices) {
|
||||
if (SignalStore.account.isLinkedDevice) {
|
||||
return
|
||||
}
|
||||
|
||||
if (SignalStore.account.isMultiDevice) {
|
||||
AppDependencies.jobManager.add(MultiDeviceKeysUpdateJob())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class ReviewCardRepository {
|
||||
|
||||
if (resolved.isGroup()) throw new AssertionError();
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forDelete(recipientId));
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class RegistrationActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun handleSuccessfulVerify() {
|
||||
if (SignalStore.account.hasLinkedDevices) {
|
||||
if (SignalStore.account.isPrimaryDevice && SignalStore.account.isMultiDevice) {
|
||||
SignalStore.misc.shouldShowLinkedDevicesReminder = sharedViewModel.isReregister
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class RegistrationActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun handleSuccessfulVerify() {
|
||||
if (SignalStore.account.hasLinkedDevices) {
|
||||
if (SignalStore.account.isPrimaryDevice && SignalStore.account.isMultiDevice) {
|
||||
SignalStore.misc.shouldShowLinkedDevicesReminder = sharedViewModel.isReregister
|
||||
}
|
||||
|
||||
|
||||
@@ -1233,7 +1233,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
|
||||
.calls()
|
||||
.updateOneToOneCall(remotePeer.getCallId().longValue(), CallTable.Event.ACCEPTED);
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
networkExecutor.execute(() -> {
|
||||
try {
|
||||
SyncMessage.CallEvent callEvent = CallEventSyncMessageUtil.createAcceptedSyncMessage(remotePeer, System.currentTimeMillis(), isOutgoing, isVideoCall);
|
||||
@@ -1250,7 +1250,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
|
||||
.calls()
|
||||
.updateOneToOneCall(remotePeer.getCallId().longValue(), CallTable.Event.NOT_ACCEPTED);
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
networkExecutor.execute(() -> {
|
||||
try {
|
||||
SyncMessage.CallEvent callEvent = CallEventSyncMessageUtil.createNotAcceptedSyncMessage(remotePeer, System.currentTimeMillis(), isOutgoing, isVideoCall);
|
||||
@@ -1263,7 +1263,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
|
||||
}
|
||||
|
||||
public void sendGroupCallNotAcceptedCallEventSyncMessage(@NonNull RemotePeer remotePeer, boolean isOutgoing) {
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
if (SignalStore.account().isMultiDevice()) {
|
||||
networkExecutor.execute(() -> {
|
||||
try {
|
||||
SyncMessage.CallEvent callEvent = CallEventSyncMessageUtil.createNotAcceptedSyncMessage(remotePeer, System.currentTimeMillis(), isOutgoing, true);
|
||||
|
||||
@@ -110,7 +110,7 @@ object StickerManagementRepository {
|
||||
|
||||
jobManager.add(StickerPackDownloadJob.forInstall(packId.value, packKey.value, notify))
|
||||
|
||||
if (SignalStore.account.hasLinkedDevices) {
|
||||
if (SignalStore.account.isMultiDevice) {
|
||||
jobManager.add(MultiDeviceStickerPackOperationJob(packId.value, packKey.value, MultiDeviceStickerPackOperationJob.Type.INSTALL))
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ object StickerManagementRepository {
|
||||
suspend fun uninstallStickerPacks(packKeysById: Map<StickerPackId, StickerPackKey>) = withContext(Dispatchers.IO) {
|
||||
stickersDbTable.uninstallPacks(packIds = packKeysById.keys)
|
||||
|
||||
if (SignalStore.account.hasLinkedDevices) {
|
||||
if (SignalStore.account.isMultiDevice) {
|
||||
packKeysById.forEach { (packId, packKey) ->
|
||||
AppDependencies.jobManager.add(MultiDeviceStickerPackOperationJob(packId.value, packKey.value, MultiDeviceStickerPackOperationJob.Type.REMOVE))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user