On new outgoing call with only username, try to find the matching contact and resolve alias
This commit is contained in:
parent
b01e60aaed
commit
e7d1dbe51e
2 changed files with 12 additions and 5 deletions
|
@ -222,15 +222,10 @@ public class ContactsManager extends ContentObserver {
|
||||||
|
|
||||||
for (LinphoneContact c: getContacts()) {
|
for (LinphoneContact c: getContacts()) {
|
||||||
for (LinphoneNumberOrAddress noa: c.getNumbersOrAddresses()) {
|
for (LinphoneNumberOrAddress noa: c.getNumbersOrAddresses()) {
|
||||||
if (noa.isSIPAddress()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String normalized = null;
|
String normalized = null;
|
||||||
if (lpc != null) {
|
if (lpc != null) {
|
||||||
normalized = lpc.normalizePhoneNumber(noa.getValue());
|
normalized = lpc.normalizePhoneNumber(noa.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noa.getValue().equals(phoneNumber) || (normalized != null && normalized.equals(phoneNumber))) {
|
if (noa.getValue().equals(phoneNumber) || (normalized != null && normalized.equals(phoneNumber))) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -470,6 +470,18 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
// listenerDispatcher.tryingNewOutgoingCallButAlreadyInCall();
|
// listenerDispatcher.tryingNewOutgoingCallButAlreadyInCall();
|
||||||
// return;
|
// 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();
|
LinphoneProxyConfig lpc = getLc().getDefaultProxyConfig();
|
||||||
if (lpc != null) {
|
if (lpc != null) {
|
||||||
|
|
Loading…
Reference in a new issue