Temporary fix for Signal contact displaying as SMS for N seconds

The whole recipient pipeline needs to be changed more subsantially,
particularly given the way directory discovery works with it. This
will temporarily solve the problem though.
This commit is contained in:
Moxie Marlinspike 2017-11-25 09:50:36 -08:00
parent 6ff0a62338
commit 7eb089c9de
3 changed files with 22 additions and 2 deletions

View File

@ -1053,7 +1053,16 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
Context context = ConversationActivity.this; Context context = ConversationActivity.this;
Recipient recipient = params[0]; Recipient recipient = params[0];
Log.w(TAG, "Resolving registered state..."); Log.w(TAG, "Resolving registered state...");
RegisteredState registeredState = recipient.resolve().getRegistered(); RegisteredState registeredState;
if (recipient.isResolving()) {
Log.w(TAG, "Talking to DB directly.");
registeredState = DatabaseFactory.getRecipientDatabase(ConversationActivity.this).isRegistered(recipient.getAddress());
} else {
Log.w(TAG, "Checking through resolved recipient");
registeredState = recipient.resolve().getRegistered();
}
Log.w(TAG, "Resolved registered state: " + registeredState); Log.w(TAG, "Resolved registered state: " + registeredState);
boolean signalEnabled = TextSecurePreferences.isPushRegistered(context); boolean signalEnabled = TextSecurePreferences.isPushRegistered(context);

View File

@ -345,6 +345,16 @@ public class RecipientDatabase extends Database {
return results; return results;
} }
// XXX This shouldn't be here, and is just a temporary workaround
public RegisteredState isRegistered(@NonNull Address address) {
SQLiteDatabase db = databaseHelper.getReadableDatabase();
try (Cursor cursor = db.query(TABLE_NAME, new String[] {REGISTERED}, ADDRESS + " = ?", new String[] {address.serialize()}, null, null, null)) {
if (cursor != null && cursor.moveToFirst()) return RegisteredState.fromId(cursor.getInt(0));
else return RegisteredState.UNKNOWN;
}
}
private void updateOrInsert(Address address, ContentValues contentValues) { private void updateOrInsert(Address address, ContentValues contentValues) {
SQLiteDatabase database = databaseHelper.getWritableDatabase(); SQLiteDatabase database = databaseHelper.getWritableDatabase();

View File

@ -529,7 +529,8 @@ public class Recipient implements RecipientModifiedListener {
this.stale = true; this.stale = true;
} }
synchronized boolean isResolving() { // XXX This shouldn't be public, temporary workaround
public synchronized boolean isResolving() {
return resolving; return resolving;
} }