On new outgoing call with only username, try to find the matching contact and resolve alias

This commit is contained in:
Sylvain Berfini 2016-10-13 13:03:26 +02:00
parent b01e60aaed
commit e7d1dbe51e
2 changed files with 12 additions and 5 deletions

View file

@ -222,15 +222,10 @@ public class ContactsManager extends ContentObserver {
for (LinphoneContact c: getContacts()) {
for (LinphoneNumberOrAddress noa: c.getNumbersOrAddresses()) {
if (noa.isSIPAddress()) {
continue;
}
String normalized = null;
if (lpc != null) {
normalized = lpc.normalizePhoneNumber(noa.getValue());
}
if (noa.getValue().equals(phoneNumber) || (normalized != null && normalized.equals(phoneNumber))) {
return c;
}

View file

@ -470,6 +470,18 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
// listenerDispatcher.tryingNewOutgoingCallButAlreadyInCall();
// return;
// }
if (to == null) return;
// If to is only a username, try to find the contact to get an alias if existing
if (!to.startsWith("sip:") || !to.contains("@")) {
LinphoneContact contact = ContactsManager.getInstance().findContactFromPhoneNumber(to);
if (contact != null) {
String alias = contact.getPresenceModelForUri(to);
if (alias != null) {
to = alias;
}
}
}
LinphoneProxyConfig lpc = getLc().getDefaultProxyConfig();
if (lpc != null) {