Store device name in account file and prevent it from becoming null on the server

This commit is contained in:
AsamK 2021-05-08 15:29:00 +02:00
parent a4e34e600e
commit 6eb486e858
3 changed files with 15 additions and 1 deletions

View file

@ -341,7 +341,8 @@ public class Manager implements Closeable {
} }
public void updateAccountAttributes() throws IOException { public void updateAccountAttributes() throws IOException {
accountManager.setAccountAttributes(null, accountManager.setAccountAttributes(account.getDeviceName(),
null,
account.getLocalRegistrationId(), account.getLocalRegistrationId(),
true, true,
// set legacy pin only if no KBS master key is set // set legacy pin only if no KBS master key is set

View file

@ -113,6 +113,7 @@ public class ProvisioningManager {
number, number,
ret.getUuid(), ret.getUuid(),
password, password,
deviceName,
deviceId, deviceId,
ret.getIdentity(), ret.getIdentity(),
registrationId, registrationId,

View file

@ -74,6 +74,7 @@ public class SignalAccount implements Closeable {
private String username; private String username;
private UUID uuid; private UUID uuid;
private String deviceName;
private int deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID; private int deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
private boolean isMultiDevice = false; private boolean isMultiDevice = false;
private String password; private String password;
@ -171,6 +172,7 @@ public class SignalAccount implements Closeable {
String username, String username,
UUID uuid, UUID uuid,
String password, String password,
String deviceName,
int deviceId, int deviceId,
IdentityKeyPair identityKey, IdentityKeyPair identityKey,
int registrationId, int registrationId,
@ -189,6 +191,7 @@ public class SignalAccount implements Closeable {
account.uuid = uuid; account.uuid = uuid;
account.password = password; account.password = password;
account.profileKey = profileKey; account.profileKey = profileKey;
account.deviceName = deviceName;
account.deviceId = deviceId; account.deviceId = deviceId;
account.initStores(dataPath, identityKey, registrationId); account.initStores(dataPath, identityKey, registrationId);
@ -303,6 +306,9 @@ public class SignalAccount implements Closeable {
throw new IOException("Config file contains an invalid uuid, needs to be a valid UUID", e); throw new IOException("Config file contains an invalid uuid, needs to be a valid UUID", e);
} }
} }
if (rootNode.hasNonNull("deviceName")) {
deviceName = rootNode.get("deviceName").asText();
}
if (rootNode.hasNonNull("deviceId")) { if (rootNode.hasNonNull("deviceId")) {
deviceId = rootNode.get("deviceId").asInt(); deviceId = rootNode.get("deviceId").asInt();
} }
@ -573,6 +579,7 @@ public class SignalAccount implements Closeable {
rootNode.put("version", CURRENT_STORAGE_VERSION) rootNode.put("version", CURRENT_STORAGE_VERSION)
.put("username", username) .put("username", username)
.put("uuid", uuid == null ? null : uuid.toString()) .put("uuid", uuid == null ? null : uuid.toString())
.put("deviceName", deviceName)
.put("deviceId", deviceId) .put("deviceId", deviceId)
.put("isMultiDevice", isMultiDevice) .put("isMultiDevice", isMultiDevice)
.put("password", password) .put("password", password)
@ -701,6 +708,10 @@ public class SignalAccount implements Closeable {
return recipientStore.resolveRecipientTrusted(getSelfAddress()); return recipientStore.resolveRecipientTrusted(getSelfAddress());
} }
public String getDeviceName() {
return deviceName;
}
public int getDeviceId() { public int getDeviceId() {
return deviceId; return deviceId;
} }
@ -812,6 +823,7 @@ public class SignalAccount implements Closeable {
public void finishRegistration(final UUID uuid, final MasterKey masterKey, final String pin) { public void finishRegistration(final UUID uuid, final MasterKey masterKey, final String pin) {
this.pinMasterKey = masterKey; this.pinMasterKey = masterKey;
this.deviceName = null;
this.deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID; this.deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
this.isMultiDevice = false; this.isMultiDevice = false;
this.registered = true; this.registered = true;