mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
Don't use AsyncTask for beta calling capabilities refresh
Also, actually store the result in the directory db. Fixes #6212 // FREEBIE
This commit is contained in:
parent
6b737a3d48
commit
0efd6d9341
@ -917,7 +917,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
UserCapabilities capabilities = DirectoryHelper.getUserCapabilities(context, recipients);
|
||||
|
||||
if (capabilities.getTextCapability() == Capability.UNKNOWN ||
|
||||
capabilities.getVoiceCapability() == Capability.UNKNOWN)
|
||||
capabilities.getVideoCapability() == Capability.UNKNOWN)
|
||||
{
|
||||
try {
|
||||
capabilities = DirectoryHelper.refreshDirectoryFor(context, masterSecret, recipients,
|
||||
@ -928,7 +928,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
return new boolean[] {capabilities.getTextCapability() == Capability.SUPPORTED,
|
||||
capabilities.getVoiceCapability() == Capability.SUPPORTED && !isSelfConversation(),
|
||||
capabilities.getVideoCapability() == Capability.SUPPORTED && !isSelfConversation(),
|
||||
Util.isDefaultSmsProvider(context)};
|
||||
}
|
||||
|
||||
@ -950,31 +950,32 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
return;
|
||||
}
|
||||
|
||||
new AsyncTask<Void, Void, boolean[]>() {
|
||||
new Thread() {
|
||||
@Override
|
||||
protected boolean[] doInBackground(Void... params) {
|
||||
public void run() {
|
||||
try {
|
||||
Context context = ConversationActivity.this;
|
||||
Context context = ConversationActivity.this;
|
||||
UserCapabilities userCapabilities = DirectoryHelper.refreshDirectoryFor(context, masterSecret, recipients,
|
||||
TextSecurePreferences.getLocalNumber(context));
|
||||
|
||||
|
||||
return new boolean[] {userCapabilities.getTextCapability() == Capability.SUPPORTED,
|
||||
userCapabilities.getVideoCapability() == Capability.SUPPORTED && !isSelfConversation(),
|
||||
Util.isDefaultSmsProvider(context)};
|
||||
final boolean secureText = userCapabilities.getTextCapability() == Capability.SUPPORTED;
|
||||
final boolean secureVideo = userCapabilities.getVideoCapability() == Capability.SUPPORTED;
|
||||
final boolean defaultSms = Util.isDefaultSmsProvider(context);
|
||||
|
||||
Util.runOnMain(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (secureText != isSecureText || secureVideo != isSecureVideo || defaultSms != isDefaultSms) {
|
||||
handleSecurityChange(secureText, secureVideo, defaultSms);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(boolean[] result) {
|
||||
if (result != null && (result[0] != isSecureText || result[1] != isSecureVideo || result[2] != isDefaultSms)) {
|
||||
handleSecurityChange(result[0], result[1], result[2]);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}.start();
|
||||
}
|
||||
|
||||
private void onSecurityUpdated() {
|
||||
|
@ -166,9 +166,11 @@ public class TextSecureDirectory {
|
||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(NUMBER, token.getNumber());
|
||||
values.put(RELAY, token.getRelay());
|
||||
values.put(REGISTERED, active ? 1 : 0);
|
||||
values.put(TIMESTAMP, System.currentTimeMillis());
|
||||
values.put(RELAY, token.getRelay());
|
||||
values.put(VOICE, token.isVoice());
|
||||
values.put(VIDEO, token.isVideo());
|
||||
db.replace(TABLE_NAME, null, values);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user