Initial work to support Change Number.

This commit is contained in:
Cody Henthorne
2021-09-03 17:07:05 -04:00
parent e09d162c1e
commit f2ab0b6423
61 changed files with 3177 additions and 1176 deletions

View File

@@ -2034,6 +2034,25 @@ public class RecipientDatabase extends Database {
}
}
public void updateSelfPhone(@NonNull String e164) {
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
db.beginTransaction();
try {
RecipientId id = Recipient.self().getId();
RecipientId newId = getAndPossiblyMerge(Recipient.self().requireUuid(), e164, true);
if (id.equals(newId)) {
Log.i(TAG, "[updateSelfPhone] Phone updated for self");
} else {
throw new AssertionError("[updateSelfPhone] Self recipient id changed when updating phone. old: " + id + " new: " + newId);
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
public void setUsername(@NonNull RecipientId id, @Nullable String username) {
if (username != null) {
Optional<RecipientId> existingUsername = getByUsername(username);