mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Add possibility to update the device name
This commit is contained in:
parent
5a2e37a6e2
commit
299671480f
5 changed files with 24 additions and 6 deletions
|
@ -311,7 +311,7 @@ public class Manager implements Closeable {
|
|||
if (account.getUuid() == null) {
|
||||
account.setUuid(dependencies.getAccountManager().getOwnUuid());
|
||||
}
|
||||
updateAccountAttributes();
|
||||
updateAccountAttributes(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -343,14 +343,21 @@ public class Manager implements Closeable {
|
|||
}));
|
||||
}
|
||||
|
||||
public void updateAccountAttributes() throws IOException {
|
||||
public void updateAccountAttributes(String deviceName) throws IOException {
|
||||
final String encryptedDeviceName;
|
||||
if (deviceName == null) {
|
||||
encryptedDeviceName = account.getEncryptedDeviceName();
|
||||
} else {
|
||||
final var privateKey = account.getIdentityKeyPair().getPrivateKey();
|
||||
encryptedDeviceName = DeviceNameUtil.encryptDeviceName(deviceName, privateKey);
|
||||
account.setEncryptedDeviceName(encryptedDeviceName);
|
||||
}
|
||||
dependencies.getAccountManager()
|
||||
.setAccountAttributes(account.getEncryptedDeviceName(),
|
||||
.setAccountAttributes(encryptedDeviceName,
|
||||
null,
|
||||
account.getLocalRegistrationId(),
|
||||
true,
|
||||
// set legacy pin only if no KBS master key is set
|
||||
account.getPinMasterKey() == null ? account.getRegistrationLockPin() : null,
|
||||
null,
|
||||
account.getPinMasterKey() == null ? null : account.getPinMasterKey().deriveRegistrationLock(),
|
||||
account.getSelfUnidentifiedAccessKey(),
|
||||
account.isUnrestrictedUnidentifiedAccess(),
|
||||
|
|
|
@ -818,6 +818,11 @@ public class SignalAccount implements Closeable {
|
|||
return encryptedDeviceName;
|
||||
}
|
||||
|
||||
public void setEncryptedDeviceName(final String encryptedDeviceName) {
|
||||
this.encryptedDeviceName = encryptedDeviceName;
|
||||
save();
|
||||
}
|
||||
|
||||
public int getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue