- public static SignalAccount createOrUpdateLinkedAccount(
- File dataPath,
- String accountPath,
- String number,
- ServiceEnvironment serviceEnvironment,
- ACI aci,
- PNI pni,
- String password,
- String encryptedDeviceName,
- int deviceId,
- IdentityKeyPair aciIdentityKey,
- IdentityKeyPair pniIdentityKey,
- int registrationId,
- int pniRegistrationId,
- ProfileKey profileKey,
- final Settings settings
- ) throws IOException {
- IOUtils.createPrivateDirectories(dataPath);
- var fileName = getFileName(dataPath, accountPath);
- if (!fileName.exists()) {
- return createLinkedAccount(dataPath,
- accountPath,
- number,
- serviceEnvironment,
- aci,
- pni,
- password,
- encryptedDeviceName,
- deviceId,
- aciIdentityKey,
- pniIdentityKey,
- registrationId,
- pniRegistrationId,
- profileKey,
- settings);
- }
-
- final var signalAccount = load(dataPath, accountPath, true, settings);
- signalAccount.setProvisioningData(number,
- aci,
- pni,
- password,
- encryptedDeviceName,
- deviceId,
- aciIdentityKey,
- pniIdentityKey,
- profileKey);
- signalAccount.getRecipientTrustedResolver()
- .resolveSelfRecipientTrusted(signalAccount.getSelfRecipientAddress());
- signalAccount.aciAccountData.getSessionStore().archiveAllSessions();
- signalAccount.pniAccountData.getSessionStore().archiveAllSessions();
- signalAccount.getSenderKeyStore().deleteAll();
- signalAccount.clearAllPreKeys();