mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-08 05:28:34 +00:00
Read the new GV1 Migration capability.
This commit is contained in:
parent
3357475fc4
commit
d21782696a
@ -9,12 +9,13 @@ public final class AppCapabilities {
|
|||||||
|
|
||||||
private static final boolean UUID_CAPABLE = false;
|
private static final boolean UUID_CAPABLE = false;
|
||||||
private static final boolean GV2_CAPABLE = true;
|
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
|
* @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.
|
* asking if the user has set a Signal PIN or not.
|
||||||
*/
|
*/
|
||||||
public static AccountAttributes.Capabilities getCapabilities(boolean storageCapable) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,9 @@ public class RecipientDatabase extends Database {
|
|||||||
|
|
||||||
private static final class Capabilities {
|
private static final class Capabilities {
|
||||||
static final int BIT_LENGTH = 2;
|
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[] {
|
private static final String[] RECIPIENT_PROJECTION = new String[] {
|
||||||
@ -1411,6 +1413,7 @@ public class RecipientDatabase extends Database {
|
|||||||
long value = 0;
|
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);
|
ContentValues values = new ContentValues(1);
|
||||||
values.put(CAPABILITIES, value);
|
values.put(CAPABILITIES, value);
|
||||||
@ -2599,6 +2602,7 @@ public class RecipientDatabase extends Database {
|
|||||||
private final boolean forceSmsSelection;
|
private final boolean forceSmsSelection;
|
||||||
private final long capabilities;
|
private final long capabilities;
|
||||||
private final Recipient.Capability groupsV2Capability;
|
private final Recipient.Capability groupsV2Capability;
|
||||||
|
private final Recipient.Capability groupsV1MigrationCapability;
|
||||||
private final InsightsBannerTier insightsBannerTier;
|
private final InsightsBannerTier insightsBannerTier;
|
||||||
private final byte[] storageId;
|
private final byte[] storageId;
|
||||||
private final MentionSetting mentionSetting;
|
private final MentionSetting mentionSetting;
|
||||||
@ -2674,6 +2678,7 @@ public class RecipientDatabase extends Database {
|
|||||||
this.forceSmsSelection = forceSmsSelection;
|
this.forceSmsSelection = forceSmsSelection;
|
||||||
this.capabilities = capabilities;
|
this.capabilities = capabilities;
|
||||||
this.groupsV2Capability = Recipient.Capability.deserialize((int) Bitmask.read(capabilities, Capabilities.GROUPS_V2, Capabilities.BIT_LENGTH));
|
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.insightsBannerTier = insightsBannerTier;
|
||||||
this.storageId = storageId;
|
this.storageId = storageId;
|
||||||
this.mentionSetting = mentionSetting;
|
this.mentionSetting = mentionSetting;
|
||||||
@ -2808,10 +2813,14 @@ public class RecipientDatabase extends Database {
|
|||||||
return forceSmsSelection;
|
return forceSmsSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Recipient.Capability getGroupsV2Capability() {
|
public @NonNull Recipient.Capability getGroupsV2Capability() {
|
||||||
return groupsV2Capability;
|
return groupsV2Capability;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @NonNull Recipient.Capability getGroupsV1MigrationCapability() {
|
||||||
|
return groupsV1MigrationCapability;
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable byte[] getStorageId() {
|
public @Nullable byte[] getStorageId() {
|
||||||
return storageId;
|
return storageId;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,7 @@ public class RefreshAttributesJob extends BaseJob {
|
|||||||
"\n Capabilities:" +
|
"\n Capabilities:" +
|
||||||
"\n Storage? " + capabilities.isStorage() +
|
"\n Storage? " + capabilities.isStorage() +
|
||||||
"\n GV2? " + capabilities.isGv2() +
|
"\n GV2? " + capabilities.isGv2() +
|
||||||
|
"\n GV1 Migration? " + capabilities.isGv1Migration() +
|
||||||
"\n UUID? " + capabilities.isUuid());
|
"\n UUID? " + capabilities.isUuid());
|
||||||
|
|
||||||
SignalServiceAccountManager signalAccountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
SignalServiceAccountManager signalAccountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||||
|
@ -30,7 +30,12 @@ public final class LogSectionCapabilities implements LogSection {
|
|||||||
|
|
||||||
AccountAttributes.Capabilities capabilities = AppCapabilities.getCapabilities(false);
|
AccountAttributes.Capabilities capabilities = AppCapabilities.getCapabilities(false);
|
||||||
|
|
||||||
return new StringBuilder().append("Local device GV2: ").append(capabilities.isGv2()).append("\n")
|
return new StringBuilder().append("-- Local").append("\n")
|
||||||
.append("Global GV2 : ").append(self.getGroupsV2Capability()).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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,7 @@ public class Recipient {
|
|||||||
private final UnidentifiedAccessMode unidentifiedAccessMode;
|
private final UnidentifiedAccessMode unidentifiedAccessMode;
|
||||||
private final boolean forceSmsSelection;
|
private final boolean forceSmsSelection;
|
||||||
private final Capability groupsV2Capability;
|
private final Capability groupsV2Capability;
|
||||||
|
private final Capability groupsV1MigrationCapability;
|
||||||
private final InsightsBannerTier insightsBannerTier;
|
private final InsightsBannerTier insightsBannerTier;
|
||||||
private final byte[] storageId;
|
private final byte[] storageId;
|
||||||
private final MentionSetting mentionSetting;
|
private final MentionSetting mentionSetting;
|
||||||
@ -311,6 +312,7 @@ public class Recipient {
|
|||||||
this.unidentifiedAccessMode = UnidentifiedAccessMode.DISABLED;
|
this.unidentifiedAccessMode = UnidentifiedAccessMode.DISABLED;
|
||||||
this.forceSmsSelection = false;
|
this.forceSmsSelection = false;
|
||||||
this.groupsV2Capability = Capability.UNKNOWN;
|
this.groupsV2Capability = Capability.UNKNOWN;
|
||||||
|
this.groupsV1MigrationCapability = Capability.UNKNOWN;
|
||||||
this.storageId = null;
|
this.storageId = null;
|
||||||
this.mentionSetting = MentionSetting.ALWAYS_NOTIFY;
|
this.mentionSetting = MentionSetting.ALWAYS_NOTIFY;
|
||||||
}
|
}
|
||||||
@ -352,6 +354,7 @@ public class Recipient {
|
|||||||
this.unidentifiedAccessMode = details.unidentifiedAccessMode;
|
this.unidentifiedAccessMode = details.unidentifiedAccessMode;
|
||||||
this.forceSmsSelection = details.forceSmsSelection;
|
this.forceSmsSelection = details.forceSmsSelection;
|
||||||
this.groupsV2Capability = details.groupsV2Capability;
|
this.groupsV2Capability = details.groupsV2Capability;
|
||||||
|
this.groupsV1MigrationCapability = details.groupsV1MigrationCapability;
|
||||||
this.storageId = details.storageId;
|
this.storageId = details.storageId;
|
||||||
this.mentionSetting = details.mentionSetting;
|
this.mentionSetting = details.mentionSetting;
|
||||||
}
|
}
|
||||||
@ -737,10 +740,14 @@ public class Recipient {
|
|||||||
return forceSmsSelection;
|
return forceSmsSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Capability getGroupsV2Capability() {
|
public @NonNull Capability getGroupsV2Capability() {
|
||||||
return groupsV2Capability;
|
return groupsV2Capability;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @NonNull Capability getGroupsV1MigrationCapability() {
|
||||||
|
return groupsV1MigrationCapability;
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable byte[] getProfileKey() {
|
public @Nullable byte[] getProfileKey() {
|
||||||
return profileKey;
|
return profileKey;
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@ public class RecipientDetails {
|
|||||||
final UnidentifiedAccessMode unidentifiedAccessMode;
|
final UnidentifiedAccessMode unidentifiedAccessMode;
|
||||||
final boolean forceSmsSelection;
|
final boolean forceSmsSelection;
|
||||||
final Recipient.Capability groupsV2Capability;
|
final Recipient.Capability groupsV2Capability;
|
||||||
|
final Recipient.Capability groupsV1MigrationCapability;
|
||||||
final InsightsBannerTier insightsBannerTier;
|
final InsightsBannerTier insightsBannerTier;
|
||||||
final byte[] storageId;
|
final byte[] storageId;
|
||||||
final MentionSetting mentionSetting;
|
final MentionSetting mentionSetting;
|
||||||
@ -104,6 +105,7 @@ public class RecipientDetails {
|
|||||||
this.unidentifiedAccessMode = settings.getUnidentifiedAccessMode();
|
this.unidentifiedAccessMode = settings.getUnidentifiedAccessMode();
|
||||||
this.forceSmsSelection = settings.isForceSmsSelection();
|
this.forceSmsSelection = settings.isForceSmsSelection();
|
||||||
this.groupsV2Capability = settings.getGroupsV2Capability();
|
this.groupsV2Capability = settings.getGroupsV2Capability();
|
||||||
|
this.groupsV1MigrationCapability = settings.getGroupsV1MigrationCapability();
|
||||||
this.insightsBannerTier = settings.getInsightsBannerTier();
|
this.insightsBannerTier = settings.getInsightsBannerTier();
|
||||||
this.storageId = settings.getStorageId();
|
this.storageId = settings.getStorageId();
|
||||||
this.mentionSetting = settings.getMentionSetting();
|
this.mentionSetting = settings.getMentionSetting();
|
||||||
@ -151,6 +153,7 @@ public class RecipientDetails {
|
|||||||
this.forceSmsSelection = false;
|
this.forceSmsSelection = false;
|
||||||
this.name = null;
|
this.name = null;
|
||||||
this.groupsV2Capability = Recipient.Capability.UNKNOWN;
|
this.groupsV2Capability = Recipient.Capability.UNKNOWN;
|
||||||
|
this.groupsV1MigrationCapability = Recipient.Capability.UNKNOWN;
|
||||||
this.storageId = null;
|
this.storageId = null;
|
||||||
this.mentionSetting = MentionSetting.ALWAYS_NOTIFY;
|
this.mentionSetting = MentionSetting.ALWAYS_NOTIFY;
|
||||||
}
|
}
|
||||||
|
@ -125,13 +125,17 @@ public class AccountAttributes {
|
|||||||
@JsonProperty
|
@JsonProperty
|
||||||
private boolean storage;
|
private boolean storage;
|
||||||
|
|
||||||
|
@JsonProperty("gv1-migration")
|
||||||
|
private boolean gv1Migration;
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public Capabilities() {}
|
public Capabilities() {}
|
||||||
|
|
||||||
public Capabilities(boolean uuid, boolean gv2, boolean storage) {
|
public Capabilities(boolean uuid, boolean gv2, boolean storage, boolean gv1Migration) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.gv2 = gv2;
|
this.gv2 = gv2;
|
||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
|
this.gv1Migration = gv1Migration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUuid() {
|
public boolean isUuid() {
|
||||||
@ -145,5 +149,9 @@ public class AccountAttributes {
|
|||||||
public boolean isStorage() {
|
public boolean isStorage() {
|
||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isGv1Migration() {
|
||||||
|
return gv1Migration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,9 @@ public class SignalServiceProfile {
|
|||||||
@JsonProperty
|
@JsonProperty
|
||||||
private boolean storage;
|
private boolean storage;
|
||||||
|
|
||||||
|
@JsonProperty("gv1-migration")
|
||||||
|
private boolean gv1Migration;
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public Capabilities() {}
|
public Capabilities() {}
|
||||||
|
|
||||||
@ -107,6 +110,10 @@ public class SignalServiceProfile {
|
|||||||
public boolean isStorage() {
|
public boolean isStorage() {
|
||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isGv1Migration() {
|
||||||
|
return gv1Migration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileKeyCredentialResponse getProfileKeyCredentialResponse() {
|
public ProfileKeyCredentialResponse getProfileKeyCredentialResponse() {
|
||||||
|
@ -16,7 +16,7 @@ public final class AccountAttributesTest {
|
|||||||
"reglock1234",
|
"reglock1234",
|
||||||
new byte[10],
|
new byte[10],
|
||||||
false,
|
false,
|
||||||
new AccountAttributes.Capabilities(true, true, true),
|
new AccountAttributes.Capabilities(true, true, true, true),
|
||||||
false));
|
false));
|
||||||
assertEquals("{\"signalingKey\":\"skey\"," +
|
assertEquals("{\"signalingKey\":\"skey\"," +
|
||||||
"\"registrationId\":123," +
|
"\"registrationId\":123," +
|
||||||
@ -28,19 +28,19 @@ public final class AccountAttributesTest {
|
|||||||
"\"unidentifiedAccessKey\":\"AAAAAAAAAAAAAA==\"," +
|
"\"unidentifiedAccessKey\":\"AAAAAAAAAAAAAA==\"," +
|
||||||
"\"unrestrictedUnidentifiedAccess\":false," +
|
"\"unrestrictedUnidentifiedAccess\":false," +
|
||||||
"\"discoverableByPhoneNumber\":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
|
@Test
|
||||||
public void gv2_true() {
|
public void gv2_true() {
|
||||||
String json = JsonUtil.toJson(new AccountAttributes.Capabilities(false, true, false));
|
String json = JsonUtil.toJson(new AccountAttributes.Capabilities(false, true, false, false));
|
||||||
assertEquals("{\"uuid\":false,\"storage\":false,\"gv2-3\":true}", json);
|
assertEquals("{\"uuid\":false,\"storage\":false,\"gv2-3\":true,\"gv1-migration\":false}", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void gv2_false() {
|
public void gv2_false() {
|
||||||
String json = JsonUtil.toJson(new AccountAttributes.Capabilities(false, false, false));
|
String json = JsonUtil.toJson(new AccountAttributes.Capabilities(false, false, false, false));
|
||||||
assertEquals("{\"uuid\":false,\"storage\":false,\"gv2-3\":false}", json);
|
assertEquals("{\"uuid\":false,\"storage\":false,\"gv2-3\":false,\"gv1-migration\":false}", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user