Force capability refresh on conversation load if in webrtc beta

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-01-30 13:31:38 -08:00
parent ea0945d406
commit 53d590947e

View File

@ -259,6 +259,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
initializeDraft();
}
});
initializeBetaCalling();
}
@Override
@ -944,6 +945,38 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
return future;
}
private void initializeBetaCalling() {
if (!TextSecurePreferences.isWebrtcCallingEnabled(this)) {
return;
}
new AsyncTask<Void, Void, boolean[]>() {
@Override
protected boolean[] doInBackground(Void... params) {
try {
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)};
} 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();
}
private void onSecurityUpdated() {
updateRecipientPreferences();
}