+ private void finishAccountRegistration(
+ final VerifyAccountResponse response,
+ final String pin,
+ final MasterKey masterKey,
+ final PreKeyCollection aciPreKeys,
+ final PreKeyCollection pniPreKeys
+ ) throws IOException {
+ //accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
+ final var aci = ACI.parseOrThrow(response.getUuid());
+ final var pni = PNI.parseOrThrow(response.getPni());
+ account.finishRegistration(aci, pni, masterKey, pin, aciPreKeys, pniPreKeys);
+ accountFileUpdater.updateAccountIdentifiers(account.getNumber(), aci);
+
+ ManagerImpl m = null;
+ try {
+ m = new ManagerImpl(account, pathConfig, accountFileUpdater, serviceEnvironmentConfig, userAgent);
+ account = null;
+
+ m.refreshPreKeys();
+ if (response.isStorageCapable()) {
+ m.syncRemoteStorage();
+ }
+ // Set an initial empty profile so user can be added to groups
+ try {
+ m.updateProfile(UpdateProfile.newBuilder().build());
+ } catch (NoClassDefFoundError e) {
+ logger.warn("Failed to set default profile: {}", e.getMessage());
+ }
+
+ try {
+ m.refreshCurrentUsername();
+ } catch (IOException | BaseUsernameException e) {
+ logger.warn("Failed to refresh current username", e);
+ }
+
+ if (newManagerListener != null) {
+ newManagerListener.accept(m);
+ m = null;
+ }
+ } finally {
+ if (m != null) {
+ m.close();
+ }
+ }
+ }
+