mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-25 05:27:42 +00:00
Fix issues around all-zero UUIDs.
This commit is contained in:
@@ -13,10 +13,18 @@ import java.util.UUID;
|
||||
*/
|
||||
public final class DistributionId {
|
||||
|
||||
public static final DistributionId MY_STORY = DistributionId.from("00000000-0000-0000-0000-000000000000");
|
||||
private static final String MY_STORY_STRING = "00000000-0000-0000-0000-000000000000";
|
||||
|
||||
public static final DistributionId MY_STORY = DistributionId.from(MY_STORY_STRING);
|
||||
|
||||
private final UUID uuid;
|
||||
|
||||
/**
|
||||
* Some devices appear to have a bad UUID.toString() that misrenders an all-zero UUID as "0000-0000".
|
||||
* To account for this, we will keep our own string value, to prevent queries from going awry and such.
|
||||
*/
|
||||
private final String stringValue;
|
||||
|
||||
public static DistributionId from(String id) {
|
||||
return new DistributionId(UuidUtil.parseOrThrow(id));
|
||||
}
|
||||
@@ -31,6 +39,12 @@ public final class DistributionId {
|
||||
|
||||
private DistributionId(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
|
||||
if (uuid.getLeastSignificantBits() == 0 && uuid.getMostSignificantBits() == 0) {
|
||||
this.stringValue = MY_STORY_STRING;
|
||||
} else {
|
||||
this.stringValue = this.uuid.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public UUID asUuid() {
|
||||
@@ -39,7 +53,7 @@ public final class DistributionId {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return uuid.toString();
|
||||
return stringValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user