From d21782696a5b7c1cf7751fccda8593e7eb0a9262 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Tue, 20 Oct 2020 10:48:12 -0400 Subject: [PATCH] Read the new GV1 Migration capability. --- .../securesms/AppCapabilities.java | 7 +- .../securesms/database/RecipientDatabase.java | 89 +++++----- .../securesms/jobs/RefreshAttributesJob.java | 1 + .../logsubmit/LogSectionCapabilities.java | 9 +- .../securesms/recipients/Recipient.java | 161 +++++++++--------- .../recipients/RecipientDetails.java | 149 ++++++++-------- .../api/account/AccountAttributes.java | 16 +- .../api/profiles/SignalServiceProfile.java | 7 + .../api/account/AccountAttributesTest.java | 12 +- 9 files changed, 246 insertions(+), 205 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/AppCapabilities.java b/app/src/main/java/org/thoughtcrime/securesms/AppCapabilities.java index 1227a4486b..60fe02f632 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/AppCapabilities.java +++ b/app/src/main/java/org/thoughtcrime/securesms/AppCapabilities.java @@ -7,14 +7,15 @@ public final class AppCapabilities { private AppCapabilities() { } - private static final boolean UUID_CAPABLE = false; - private static final boolean GV2_CAPABLE = true; + private static final boolean UUID_CAPABLE = false; + private static final boolean GV2_CAPABLE = true; + private static final boolean GV1_MIGRATION_CAPABLE = false; /** * @param storageCapable Whether or not the user can use storage service. This is another way of * asking if the user has set a Signal PIN or not. */ public static AccountAttributes.Capabilities getCapabilities(boolean storageCapable) { - return new AccountAttributes.Capabilities(UUID_CAPABLE, GV2_CAPABLE, storageCapable); + return new AccountAttributes.Capabilities(UUID_CAPABLE, GV2_CAPABLE, storageCapable, GV1_MIGRATION_CAPABLE); } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/RecipientDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/RecipientDatabase.java index afbdf76584..75bb660ef1 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/RecipientDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/RecipientDatabase.java @@ -132,7 +132,9 @@ public class RecipientDatabase extends Database { private static final class Capabilities { static final int BIT_LENGTH = 2; - static final int GROUPS_V2 = 0; + + static final int GROUPS_V2 = 0; + static final int GROUPS_V1_MIGRATION = 1; } private static final String[] RECIPIENT_PROJECTION = new String[] { @@ -1410,7 +1412,8 @@ public class RecipientDatabase extends Database { public void setCapabilities(@NonNull RecipientId id, @NonNull SignalServiceProfile.Capabilities capabilities) { long value = 0; - value = Bitmask.update(value, Capabilities.GROUPS_V2, Capabilities.BIT_LENGTH, Recipient.Capability.fromBoolean(capabilities.isGv2()).serialize()); + value = Bitmask.update(value, Capabilities.GROUPS_V2, Capabilities.BIT_LENGTH, Recipient.Capability.fromBoolean(capabilities.isGv2()).serialize()); + value = Bitmask.update(value, Capabilities.GROUPS_V1_MIGRATION, Capabilities.BIT_LENGTH, Recipient.Capability.fromBoolean(capabilities.isGv1Migration()).serialize()); ContentValues values = new ContentValues(1); values.put(CAPABILITIES, value); @@ -2599,6 +2602,7 @@ public class RecipientDatabase extends Database { private final boolean forceSmsSelection; private final long capabilities; private final Recipient.Capability groupsV2Capability; + private final Recipient.Capability groupsV1MigrationCapability; private final InsightsBannerTier insightsBannerTier; private final byte[] storageId; private final MentionSetting mentionSetting; @@ -2641,43 +2645,44 @@ public class RecipientDatabase extends Database { @NonNull MentionSetting mentionSetting, @NonNull SyncExtras syncExtras) { - this.id = id; - this.uuid = uuid; - this.username = username; - this.e164 = e164; - this.email = email; - this.groupId = groupId; - this.groupType = groupType; - this.blocked = blocked; - this.muteUntil = muteUntil; - this.messageVibrateState = messageVibrateState; - this.callVibrateState = callVibrateState; - this.messageRingtone = messageRingtone; - this.callRingtone = callRingtone; - this.color = color; - this.defaultSubscriptionId = defaultSubscriptionId; - this.expireMessages = expireMessages; - this.registered = registered; - this.profileKey = profileKey; - this.profileKeyCredential = profileKeyCredential; - this.systemDisplayName = systemDisplayName; - this.systemContactPhoto = systemContactPhoto; - this.systemPhoneLabel = systemPhoneLabel; - this.systemContactUri = systemContactUri; - this.signalProfileName = signalProfileName; - this.signalProfileAvatar = signalProfileAvatar; - this.hasProfileImage = hasProfileImage; - this.profileSharing = profileSharing; - this.lastProfileFetch = lastProfileFetch; - this.notificationChannel = notificationChannel; - this.unidentifiedAccessMode = unidentifiedAccessMode; - this.forceSmsSelection = forceSmsSelection; - this.capabilities = capabilities; - this.groupsV2Capability = Recipient.Capability.deserialize((int) Bitmask.read(capabilities, Capabilities.GROUPS_V2, Capabilities.BIT_LENGTH)); - this.insightsBannerTier = insightsBannerTier; - this.storageId = storageId; - this.mentionSetting = mentionSetting; - this.syncExtras = syncExtras; + this.id = id; + this.uuid = uuid; + this.username = username; + this.e164 = e164; + this.email = email; + this.groupId = groupId; + this.groupType = groupType; + this.blocked = blocked; + this.muteUntil = muteUntil; + this.messageVibrateState = messageVibrateState; + this.callVibrateState = callVibrateState; + this.messageRingtone = messageRingtone; + this.callRingtone = callRingtone; + this.color = color; + this.defaultSubscriptionId = defaultSubscriptionId; + this.expireMessages = expireMessages; + this.registered = registered; + this.profileKey = profileKey; + this.profileKeyCredential = profileKeyCredential; + this.systemDisplayName = systemDisplayName; + this.systemContactPhoto = systemContactPhoto; + this.systemPhoneLabel = systemPhoneLabel; + this.systemContactUri = systemContactUri; + this.signalProfileName = signalProfileName; + this.signalProfileAvatar = signalProfileAvatar; + this.hasProfileImage = hasProfileImage; + this.profileSharing = profileSharing; + this.lastProfileFetch = lastProfileFetch; + this.notificationChannel = notificationChannel; + this.unidentifiedAccessMode = unidentifiedAccessMode; + this.forceSmsSelection = forceSmsSelection; + this.capabilities = capabilities; + this.groupsV2Capability = Recipient.Capability.deserialize((int) Bitmask.read(capabilities, Capabilities.GROUPS_V2, Capabilities.BIT_LENGTH)); + this.groupsV1MigrationCapability = Recipient.Capability.deserialize((int) Bitmask.read(capabilities, Capabilities.GROUPS_V1_MIGRATION, Capabilities.BIT_LENGTH)); + this.insightsBannerTier = insightsBannerTier; + this.storageId = storageId; + this.mentionSetting = mentionSetting; + this.syncExtras = syncExtras; } public RecipientId getId() { @@ -2808,10 +2813,14 @@ public class RecipientDatabase extends Database { return forceSmsSelection; } - public Recipient.Capability getGroupsV2Capability() { + public @NonNull Recipient.Capability getGroupsV2Capability() { return groupsV2Capability; } + public @NonNull Recipient.Capability getGroupsV1MigrationCapability() { + return groupsV1MigrationCapability; + } + public @Nullable byte[] getStorageId() { return storageId; } diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshAttributesJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshAttributesJob.java index 2af0325c42..be5c6dd7ad 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshAttributesJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshAttributesJob.java @@ -79,6 +79,7 @@ public class RefreshAttributesJob extends BaseJob { "\n Capabilities:" + "\n Storage? " + capabilities.isStorage() + "\n GV2? " + capabilities.isGv2() + + "\n GV1 Migration? " + capabilities.isGv1Migration() + "\n UUID? " + capabilities.isUuid()); SignalServiceAccountManager signalAccountManager = ApplicationDependencies.getSignalServiceAccountManager(); diff --git a/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionCapabilities.java b/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionCapabilities.java index 7a7a8b4377..ce6b2be747 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionCapabilities.java +++ b/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionCapabilities.java @@ -30,7 +30,12 @@ public final class LogSectionCapabilities implements LogSection { AccountAttributes.Capabilities capabilities = AppCapabilities.getCapabilities(false); - return new StringBuilder().append("Local device GV2: ").append(capabilities.isGv2()).append("\n") - .append("Global GV2 : ").append(self.getGroupsV2Capability()).append("\n"); + return new StringBuilder().append("-- Local").append("\n") + .append("GV2 : ").append(capabilities.isGv2()).append("\n") + .append("GV1 Migration: ").append(capabilities.isGv1Migration()).append("\n") + .append("\n") + .append("-- Global").append("\n") + .append("GV2 : ").append(self.getGroupsV2Capability()).append("\n") + .append("GV1 Migration: ").append(self.getGroupsV1MigrationCapability()).append("\n"); } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/recipients/Recipient.java b/app/src/main/java/org/thoughtcrime/securesms/recipients/Recipient.java index 852676d22a..70fb272760 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/recipients/Recipient.java +++ b/app/src/main/java/org/thoughtcrime/securesms/recipients/Recipient.java @@ -98,6 +98,7 @@ public class Recipient { private final UnidentifiedAccessMode unidentifiedAccessMode; private final boolean forceSmsSelection; private final Capability groupsV2Capability; + private final Capability groupsV1MigrationCapability; private final InsightsBannerTier insightsBannerTier; private final byte[] storageId; private final MentionSetting mentionSetting; @@ -275,85 +276,87 @@ public class Recipient { } Recipient(@NonNull RecipientId id) { - this.id = id; - this.resolving = true; - this.uuid = null; - this.username = null; - this.e164 = null; - this.email = null; - this.groupId = null; - this.participants = Collections.emptyList(); - this.groupAvatarId = Optional.absent(); - this.isSelf = false; - this.blocked = false; - this.muteUntil = 0; - this.messageVibrate = VibrateState.DEFAULT; - this.callVibrate = VibrateState.DEFAULT; - this.messageRingtone = null; - this.callRingtone = null; - this.color = null; - this.insightsBannerTier = InsightsBannerTier.TIER_TWO; - this.defaultSubscriptionId = Optional.absent(); - this.expireMessages = 0; - this.registered = RegisteredState.UNKNOWN; - this.profileKey = null; - this.profileKeyCredential = null; - this.name = null; - this.systemContactPhoto = null; - this.customLabel = null; - this.contactUri = null; - this.profileName = ProfileName.EMPTY; - this.profileAvatar = null; - this.hasProfileImage = false; - this.profileSharing = false; - this.lastProfileFetch = 0; - this.notificationChannel = null; - this.unidentifiedAccessMode = UnidentifiedAccessMode.DISABLED; - this.forceSmsSelection = false; - this.groupsV2Capability = Capability.UNKNOWN; - this.storageId = null; - this.mentionSetting = MentionSetting.ALWAYS_NOTIFY; + this.id = id; + this.resolving = true; + this.uuid = null; + this.username = null; + this.e164 = null; + this.email = null; + this.groupId = null; + this.participants = Collections.emptyList(); + this.groupAvatarId = Optional.absent(); + this.isSelf = false; + this.blocked = false; + this.muteUntil = 0; + this.messageVibrate = VibrateState.DEFAULT; + this.callVibrate = VibrateState.DEFAULT; + this.messageRingtone = null; + this.callRingtone = null; + this.color = null; + this.insightsBannerTier = InsightsBannerTier.TIER_TWO; + this.defaultSubscriptionId = Optional.absent(); + this.expireMessages = 0; + this.registered = RegisteredState.UNKNOWN; + this.profileKey = null; + this.profileKeyCredential = null; + this.name = null; + this.systemContactPhoto = null; + this.customLabel = null; + this.contactUri = null; + this.profileName = ProfileName.EMPTY; + this.profileAvatar = null; + this.hasProfileImage = false; + this.profileSharing = false; + this.lastProfileFetch = 0; + this.notificationChannel = null; + this.unidentifiedAccessMode = UnidentifiedAccessMode.DISABLED; + this.forceSmsSelection = false; + this.groupsV2Capability = Capability.UNKNOWN; + this.groupsV1MigrationCapability = Capability.UNKNOWN; + this.storageId = null; + this.mentionSetting = MentionSetting.ALWAYS_NOTIFY; } public Recipient(@NonNull RecipientId id, @NonNull RecipientDetails details, boolean resolved) { - this.id = id; - this.resolving = !resolved; - this.uuid = details.uuid; - this.username = details.username; - this.e164 = details.e164; - this.email = details.email; - this.groupId = details.groupId; - this.participants = details.participants; - this.groupAvatarId = details.groupAvatarId; - this.isSelf = details.isSelf; - this.blocked = details.blocked; - this.muteUntil = details.mutedUntil; - this.messageVibrate = details.messageVibrateState; - this.callVibrate = details.callVibrateState; - this.messageRingtone = details.messageRingtone; - this.callRingtone = details.callRingtone; - this.color = details.color; - this.insightsBannerTier = details.insightsBannerTier; - this.defaultSubscriptionId = details.defaultSubscriptionId; - this.expireMessages = details.expireMessages; - this.registered = details.registered; - this.profileKey = details.profileKey; - this.profileKeyCredential = details.profileKeyCredential; - this.name = details.name; - this.systemContactPhoto = details.systemContactPhoto; - this.customLabel = details.customLabel; - this.contactUri = details.contactUri; - this.profileName = details.profileName; - this.profileAvatar = details.profileAvatar; - this.hasProfileImage = details.hasProfileImage; - this.profileSharing = details.profileSharing; - this.lastProfileFetch = details.lastProfileFetch; - this.notificationChannel = details.notificationChannel; - this.unidentifiedAccessMode = details.unidentifiedAccessMode; - this.forceSmsSelection = details.forceSmsSelection; - this.groupsV2Capability = details.groupsV2Capability; - this.storageId = details.storageId; - this.mentionSetting = details.mentionSetting; + this.id = id; + this.resolving = !resolved; + this.uuid = details.uuid; + this.username = details.username; + this.e164 = details.e164; + this.email = details.email; + this.groupId = details.groupId; + this.participants = details.participants; + this.groupAvatarId = details.groupAvatarId; + this.isSelf = details.isSelf; + this.blocked = details.blocked; + this.muteUntil = details.mutedUntil; + this.messageVibrate = details.messageVibrateState; + this.callVibrate = details.callVibrateState; + this.messageRingtone = details.messageRingtone; + this.callRingtone = details.callRingtone; + this.color = details.color; + this.insightsBannerTier = details.insightsBannerTier; + this.defaultSubscriptionId = details.defaultSubscriptionId; + this.expireMessages = details.expireMessages; + this.registered = details.registered; + this.profileKey = details.profileKey; + this.profileKeyCredential = details.profileKeyCredential; + this.name = details.name; + this.systemContactPhoto = details.systemContactPhoto; + this.customLabel = details.customLabel; + this.contactUri = details.contactUri; + this.profileName = details.profileName; + this.profileAvatar = details.profileAvatar; + this.hasProfileImage = details.hasProfileImage; + this.profileSharing = details.profileSharing; + this.lastProfileFetch = details.lastProfileFetch; + this.notificationChannel = details.notificationChannel; + this.unidentifiedAccessMode = details.unidentifiedAccessMode; + this.forceSmsSelection = details.forceSmsSelection; + this.groupsV2Capability = details.groupsV2Capability; + this.groupsV1MigrationCapability = details.groupsV1MigrationCapability; + this.storageId = details.storageId; + this.mentionSetting = details.mentionSetting; } public @NonNull RecipientId getId() { @@ -737,10 +740,14 @@ public class Recipient { return forceSmsSelection; } - public Capability getGroupsV2Capability() { + public @NonNull Capability getGroupsV2Capability() { return groupsV2Capability; } + public @NonNull Capability getGroupsV1MigrationCapability() { + return groupsV1MigrationCapability; + } + public @Nullable byte[] getProfileKey() { return profileKey; } diff --git a/app/src/main/java/org/thoughtcrime/securesms/recipients/RecipientDetails.java b/app/src/main/java/org/thoughtcrime/securesms/recipients/RecipientDetails.java index b2cc7152db..faf4c6a82c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/recipients/RecipientDetails.java +++ b/app/src/main/java/org/thoughtcrime/securesms/recipients/RecipientDetails.java @@ -60,6 +60,7 @@ public class RecipientDetails { final UnidentifiedAccessMode unidentifiedAccessMode; final boolean forceSmsSelection; final Recipient.Capability groupsV2Capability; + final Recipient.Capability groupsV1MigrationCapability; final InsightsBannerTier insightsBannerTier; final byte[] storageId; final MentionSetting mentionSetting; @@ -71,42 +72,43 @@ public class RecipientDetails { @NonNull RecipientSettings settings, @Nullable List participants) { - this.groupAvatarId = groupAvatarId; - this.systemContactPhoto = Util.uri(settings.getSystemContactPhotoUri()); - this.customLabel = settings.getSystemPhoneLabel(); - this.contactUri = Util.uri(settings.getSystemContactUri()); - this.uuid = settings.getUuid(); - this.username = settings.getUsername(); - this.e164 = settings.getE164(); - this.email = settings.getEmail(); - this.groupId = settings.getGroupId(); - this.color = settings.getColor(); - this.messageRingtone = settings.getMessageRingtone(); - this.callRingtone = settings.getCallRingtone(); - this.mutedUntil = settings.getMuteUntil(); - this.messageVibrateState = settings.getMessageVibrateState(); - this.callVibrateState = settings.getCallVibrateState(); - this.blocked = settings.isBlocked(); - this.expireMessages = settings.getExpireMessages(); - this.participants = participants == null ? new LinkedList<>() : participants; - this.profileName = settings.getProfileName(); - this.defaultSubscriptionId = settings.getDefaultSubscriptionId(); - this.registered = settings.getRegistered(); - this.profileKey = settings.getProfileKey(); - this.profileKeyCredential = settings.getProfileKeyCredential(); - this.profileAvatar = settings.getProfileAvatar(); - this.hasProfileImage = settings.hasProfileImage(); - this.profileSharing = settings.isProfileSharing(); - this.lastProfileFetch = settings.getLastProfileFetch(); - this.systemContact = systemContact; - this.isSelf = isSelf; - this.notificationChannel = settings.getNotificationChannel(); - this.unidentifiedAccessMode = settings.getUnidentifiedAccessMode(); - this.forceSmsSelection = settings.isForceSmsSelection(); - this.groupsV2Capability = settings.getGroupsV2Capability(); - this.insightsBannerTier = settings.getInsightsBannerTier(); - this.storageId = settings.getStorageId(); - this.mentionSetting = settings.getMentionSetting(); + this.groupAvatarId = groupAvatarId; + this.systemContactPhoto = Util.uri(settings.getSystemContactPhotoUri()); + this.customLabel = settings.getSystemPhoneLabel(); + this.contactUri = Util.uri(settings.getSystemContactUri()); + this.uuid = settings.getUuid(); + this.username = settings.getUsername(); + this.e164 = settings.getE164(); + this.email = settings.getEmail(); + this.groupId = settings.getGroupId(); + this.color = settings.getColor(); + this.messageRingtone = settings.getMessageRingtone(); + this.callRingtone = settings.getCallRingtone(); + this.mutedUntil = settings.getMuteUntil(); + this.messageVibrateState = settings.getMessageVibrateState(); + this.callVibrateState = settings.getCallVibrateState(); + this.blocked = settings.isBlocked(); + this.expireMessages = settings.getExpireMessages(); + this.participants = participants == null ? new LinkedList<>() : participants; + this.profileName = settings.getProfileName(); + this.defaultSubscriptionId = settings.getDefaultSubscriptionId(); + this.registered = settings.getRegistered(); + this.profileKey = settings.getProfileKey(); + this.profileKeyCredential = settings.getProfileKeyCredential(); + this.profileAvatar = settings.getProfileAvatar(); + this.hasProfileImage = settings.hasProfileImage(); + this.profileSharing = settings.isProfileSharing(); + this.lastProfileFetch = settings.getLastProfileFetch(); + this.systemContact = systemContact; + this.isSelf = isSelf; + this.notificationChannel = settings.getNotificationChannel(); + this.unidentifiedAccessMode = settings.getUnidentifiedAccessMode(); + this.forceSmsSelection = settings.isForceSmsSelection(); + this.groupsV2Capability = settings.getGroupsV2Capability(); + this.groupsV1MigrationCapability = settings.getGroupsV1MigrationCapability(); + this.insightsBannerTier = settings.getInsightsBannerTier(); + this.storageId = settings.getStorageId(); + this.mentionSetting = settings.getMentionSetting(); if (name == null) this.name = settings.getSystemDisplayName(); else this.name = name; @@ -116,43 +118,44 @@ public class RecipientDetails { * Only used for {@link Recipient#UNKNOWN}. */ RecipientDetails() { - this.groupAvatarId = null; - this.systemContactPhoto = null; - this.customLabel = null; - this.contactUri = null; - this.uuid = null; - this.username = null; - this.e164 = null; - this.email = null; - this.groupId = null; - this.color = null; - this.messageRingtone = null; - this.callRingtone = null; - this.mutedUntil = 0; - this.messageVibrateState = VibrateState.DEFAULT; - this.callVibrateState = VibrateState.DEFAULT; - this.blocked = false; - this.expireMessages = 0; - this.participants = new LinkedList<>(); - this.profileName = ProfileName.EMPTY; - this.insightsBannerTier = InsightsBannerTier.TIER_TWO; - this.defaultSubscriptionId = Optional.absent(); - this.registered = RegisteredState.UNKNOWN; - this.profileKey = null; - this.profileKeyCredential = null; - this.profileAvatar = null; - this.hasProfileImage = false; - this.profileSharing = false; - this.lastProfileFetch = 0; - this.systemContact = true; - this.isSelf = false; - this.notificationChannel = null; - this.unidentifiedAccessMode = UnidentifiedAccessMode.UNKNOWN; - this.forceSmsSelection = false; - this.name = null; - this.groupsV2Capability = Recipient.Capability.UNKNOWN; - this.storageId = null; - this.mentionSetting = MentionSetting.ALWAYS_NOTIFY; + this.groupAvatarId = null; + this.systemContactPhoto = null; + this.customLabel = null; + this.contactUri = null; + this.uuid = null; + this.username = null; + this.e164 = null; + this.email = null; + this.groupId = null; + this.color = null; + this.messageRingtone = null; + this.callRingtone = null; + this.mutedUntil = 0; + this.messageVibrateState = VibrateState.DEFAULT; + this.callVibrateState = VibrateState.DEFAULT; + this.blocked = false; + this.expireMessages = 0; + this.participants = new LinkedList<>(); + this.profileName = ProfileName.EMPTY; + this.insightsBannerTier = InsightsBannerTier.TIER_TWO; + this.defaultSubscriptionId = Optional.absent(); + this.registered = RegisteredState.UNKNOWN; + this.profileKey = null; + this.profileKeyCredential = null; + this.profileAvatar = null; + this.hasProfileImage = false; + this.profileSharing = false; + this.lastProfileFetch = 0; + this.systemContact = true; + this.isSelf = false; + this.notificationChannel = null; + this.unidentifiedAccessMode = UnidentifiedAccessMode.UNKNOWN; + this.forceSmsSelection = false; + this.name = null; + this.groupsV2Capability = Recipient.Capability.UNKNOWN; + this.groupsV1MigrationCapability = Recipient.Capability.UNKNOWN; + this.storageId = null; + this.mentionSetting = MentionSetting.ALWAYS_NOTIFY; } public static @NonNull RecipientDetails forIndividual(@NonNull Context context, @NonNull RecipientSettings settings) { diff --git a/libsignal/service/src/main/java/org/whispersystems/signalservice/api/account/AccountAttributes.java b/libsignal/service/src/main/java/org/whispersystems/signalservice/api/account/AccountAttributes.java index 1cee9efb95..be9342fe2e 100644 --- a/libsignal/service/src/main/java/org/whispersystems/signalservice/api/account/AccountAttributes.java +++ b/libsignal/service/src/main/java/org/whispersystems/signalservice/api/account/AccountAttributes.java @@ -125,13 +125,17 @@ public class AccountAttributes { @JsonProperty private boolean storage; + @JsonProperty("gv1-migration") + private boolean gv1Migration; + @JsonCreator public Capabilities() {} - public Capabilities(boolean uuid, boolean gv2, boolean storage) { - this.uuid = uuid; - this.gv2 = gv2; - this.storage = storage; + public Capabilities(boolean uuid, boolean gv2, boolean storage, boolean gv1Migration) { + this.uuid = uuid; + this.gv2 = gv2; + this.storage = storage; + this.gv1Migration = gv1Migration; } public boolean isUuid() { @@ -145,5 +149,9 @@ public class AccountAttributes { public boolean isStorage() { return storage; } + + public boolean isGv1Migration() { + return gv1Migration; + } } } diff --git a/libsignal/service/src/main/java/org/whispersystems/signalservice/api/profiles/SignalServiceProfile.java b/libsignal/service/src/main/java/org/whispersystems/signalservice/api/profiles/SignalServiceProfile.java index 210a89e37a..9f614f8e52 100644 --- a/libsignal/service/src/main/java/org/whispersystems/signalservice/api/profiles/SignalServiceProfile.java +++ b/libsignal/service/src/main/java/org/whispersystems/signalservice/api/profiles/SignalServiceProfile.java @@ -97,6 +97,9 @@ public class SignalServiceProfile { @JsonProperty private boolean storage; + @JsonProperty("gv1-migration") + private boolean gv1Migration; + @JsonCreator public Capabilities() {} @@ -107,6 +110,10 @@ public class SignalServiceProfile { public boolean isStorage() { return storage; } + + public boolean isGv1Migration() { + return gv1Migration; + } } public ProfileKeyCredentialResponse getProfileKeyCredentialResponse() { diff --git a/libsignal/service/src/test/java/org/whispersystems/signalservice/api/account/AccountAttributesTest.java b/libsignal/service/src/test/java/org/whispersystems/signalservice/api/account/AccountAttributesTest.java index 35f044abaf..4ff895d450 100644 --- a/libsignal/service/src/test/java/org/whispersystems/signalservice/api/account/AccountAttributesTest.java +++ b/libsignal/service/src/test/java/org/whispersystems/signalservice/api/account/AccountAttributesTest.java @@ -16,7 +16,7 @@ public final class AccountAttributesTest { "reglock1234", new byte[10], false, - new AccountAttributes.Capabilities(true, true, true), + new AccountAttributes.Capabilities(true, true, true, true), false)); assertEquals("{\"signalingKey\":\"skey\"," + "\"registrationId\":123," + @@ -28,19 +28,19 @@ public final class AccountAttributesTest { "\"unidentifiedAccessKey\":\"AAAAAAAAAAAAAA==\"," + "\"unrestrictedUnidentifiedAccess\":false," + "\"discoverableByPhoneNumber\":false," + - "\"capabilities\":{\"uuid\":true,\"storage\":true,\"gv2-3\":true}}", json); + "\"capabilities\":{\"uuid\":true,\"storage\":true,\"gv2-3\":true,\"gv1-migration\":true}}", json); } @Test public void gv2_true() { - String json = JsonUtil.toJson(new AccountAttributes.Capabilities(false, true, false)); - assertEquals("{\"uuid\":false,\"storage\":false,\"gv2-3\":true}", json); + String json = JsonUtil.toJson(new AccountAttributes.Capabilities(false, true, false, false)); + assertEquals("{\"uuid\":false,\"storage\":false,\"gv2-3\":true,\"gv1-migration\":false}", json); } @Test public void gv2_false() { - String json = JsonUtil.toJson(new AccountAttributes.Capabilities(false, false, false)); - assertEquals("{\"uuid\":false,\"storage\":false,\"gv2-3\":false}", json); + String json = JsonUtil.toJson(new AccountAttributes.Capabilities(false, false, false, false)); + assertEquals("{\"uuid\":false,\"storage\":false,\"gv2-3\":false,\"gv1-migration\":false}", json); } } \ No newline at end of file