Refactor Manager and SignalAccount to implement Closeable

Should make sure that file lock and web socket connections are closed
reliably.
This commit is contained in:
AsamK 2020-05-13 23:33:40 +02:00
parent 87f65de0c5
commit d520023fc7
4 changed files with 224 additions and 164 deletions

View file

@ -83,19 +83,22 @@ public class ProvisioningManager {
throw new IOException("Received invalid profileKey", e);
}
}
SignalAccount account = SignalAccount.createLinkedAccount(pathConfig.getDataPath(), username, ret.getUuid(), password, ret.getDeviceId(), ret.getIdentity(), registrationId, signalingKey, profileKey);
account.save();
Manager m = new Manager(account, pathConfig, serviceConfiguration, userAgent);
try (SignalAccount account = SignalAccount.createLinkedAccount(pathConfig.getDataPath(), username, ret.getUuid(), password, ret.getDeviceId(), ret.getIdentity(), registrationId, signalingKey, profileKey)) {
account.save();
m.refreshPreKeys();
try (Manager m = new Manager(account, pathConfig, serviceConfiguration, userAgent)) {
m.requestSyncGroups();
m.requestSyncContacts();
m.requestSyncBlocked();
m.requestSyncConfiguration();
m.refreshPreKeys();
m.saveAccount();
m.requestSyncGroups();
m.requestSyncContacts();
m.requestSyncBlocked();
m.requestSyncConfiguration();
m.saveAccount();
}
}
return username;
}