]> nmode's Git Repositories - signal-cli/commitdiff
Store device name in account file and prevent it from becoming null on the server
authorAsamK <asamk@gmx.de>
Sat, 8 May 2021 13:29:00 +0000 (15:29 +0200)
committerAsamK <asamk@gmx.de>
Sat, 8 May 2021 13:29:00 +0000 (15:29 +0200)
lib/src/main/java/org/asamk/signal/manager/Manager.java
lib/src/main/java/org/asamk/signal/manager/ProvisioningManager.java
lib/src/main/java/org/asamk/signal/manager/storage/SignalAccount.java

index f1639eabdcbf8aba8369cd45f9c2d7db8232100a..a1a4b278f8160ac9d7bb9cf899b08913ffc81f33 100644 (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(),
                 true,
                 // set legacy pin only if no KBS master key is set
                 account.getLocalRegistrationId(),
                 true,
                 // set legacy pin only if no KBS master key is set
index f20afc46331d8f2427da73c23e4361b7de9fd8cc..d27d911e4b3185b5616d515c0c8136acf0bc5bec 100644 (file)
@@ -113,6 +113,7 @@ public class ProvisioningManager {
                     number,
                     ret.getUuid(),
                     password,
                     number,
                     ret.getUuid(),
                     password,
+                    deviceName,
                     deviceId,
                     ret.getIdentity(),
                     registrationId,
                     deviceId,
                     ret.getIdentity(),
                     registrationId,
index 15dfb2002d19052a4d1eeb9655833f054cbcb86f..f12361a1532ccab1130998806373fab70a05cfc1 100644 (file)
@@ -74,6 +74,7 @@ public class SignalAccount implements Closeable {
 
     private String username;
     private UUID uuid;
 
     private String username;
     private UUID uuid;
+    private String deviceName;
     private int deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
     private boolean isMultiDevice = false;
     private String password;
     private int deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
     private boolean isMultiDevice = false;
     private String password;
@@ -171,6 +172,7 @@ public class SignalAccount implements Closeable {
             String username,
             UUID uuid,
             String password,
             String username,
             UUID uuid,
             String password,
+            String deviceName,
             int deviceId,
             IdentityKeyPair identityKey,
             int registrationId,
             int deviceId,
             IdentityKeyPair identityKey,
             int registrationId,
@@ -189,6 +191,7 @@ public class SignalAccount implements Closeable {
         account.uuid = uuid;
         account.password = password;
         account.profileKey = profileKey;
         account.uuid = uuid;
         account.password = password;
         account.profileKey = profileKey;
+        account.deviceName = deviceName;
         account.deviceId = deviceId;
 
         account.initStores(dataPath, identityKey, registrationId);
         account.deviceId = deviceId;
 
         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")) {
             deviceId = rootNode.get("deviceId").asInt();
         }
         if (rootNode.hasNonNull("deviceId")) {
             deviceId = rootNode.get("deviceId").asInt();
         }
@@ -573,6 +579,7 @@ public class SignalAccount implements Closeable {
             rootNode.put("version", CURRENT_STORAGE_VERSION)
                     .put("username", username)
                     .put("uuid", uuid == null ? null : uuid.toString())
             rootNode.put("version", CURRENT_STORAGE_VERSION)
                     .put("username", username)
                     .put("uuid", uuid == null ? null : uuid.toString())
+                    .put("deviceName", deviceName)
                     .put("deviceId", deviceId)
                     .put("isMultiDevice", isMultiDevice)
                     .put("password", password)
                     .put("deviceId", deviceId)
                     .put("isMultiDevice", isMultiDevice)
                     .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() {
         return deviceId;
     }
     public int getDeviceId() {
         return deviceId;
     }
@@ -812,6 +823,7 @@ public class SignalAccount implements Closeable {
 
     public void finishRegistration(final UUID uuid, final MasterKey masterKey, final String pin) {
         this.pinMasterKey = masterKey;
 
     public void finishRegistration(final UUID uuid, final MasterKey masterKey, final String pin) {
         this.pinMasterKey = masterKey;
+        this.deviceName = null;
         this.deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
         this.isMultiDevice = false;
         this.registered = true;
         this.deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
         this.isMultiDevice = false;
         this.registered = true;