am d07833f5: Don\'t manually create CallerInfo objects from SipPhone
Merge commit 'd07833f54b6e8e361b666ae16efa15fdf60159de' into gingerbread-plus-aosp * commit 'd07833f54b6e8e361b666ae16efa15fdf60159de': Don't manually create CallerInfo objects from SipPhone
This commit is contained in:
@@ -1692,12 +1692,19 @@ public class PhoneNumberUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Determines if the specified number is actually a URI
|
||||||
|
* (i.e. a SIP address) rather than a regular PSTN phone number,
|
||||||
|
* based on whether or not the number contains an "@" character.
|
||||||
|
*
|
||||||
* @hide
|
* @hide
|
||||||
* @param number
|
* @param number
|
||||||
* @return true if number contains @
|
* @return true if number contains @
|
||||||
*/
|
*/
|
||||||
public static boolean isUriNumber(String number) {
|
public static boolean isUriNumber(String number) {
|
||||||
return number != null && number.contains("@");
|
// Note we allow either "@" or "%40" to indicate a URI, in case
|
||||||
|
// the passed-in string is URI-escaped. (Neither "@" nor "%40"
|
||||||
|
// will ever be found in a legal PSTN number.)
|
||||||
|
return number != null && (number.contains("@") || number.contains("%40"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package com.android.internal.telephony.sip;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.rtp.AudioGroup;
|
import android.net.rtp.AudioGroup;
|
||||||
import android.net.rtp.AudioStream;
|
|
||||||
import android.net.sip.SipAudioCall;
|
import android.net.sip.SipAudioCall;
|
||||||
import android.net.sip.SipErrorCode;
|
import android.net.sip.SipErrorCode;
|
||||||
import android.net.sip.SipException;
|
import android.net.sip.SipException;
|
||||||
@@ -29,11 +28,9 @@ import android.os.AsyncResult;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.telephony.PhoneNumberUtils;
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.telephony.Call;
|
import com.android.internal.telephony.Call;
|
||||||
import com.android.internal.telephony.CallerInfo;
|
|
||||||
import com.android.internal.telephony.CallStateException;
|
import com.android.internal.telephony.CallStateException;
|
||||||
import com.android.internal.telephony.Connection;
|
import com.android.internal.telephony.Connection;
|
||||||
import com.android.internal.telephony.Phone;
|
import com.android.internal.telephony.Phone;
|
||||||
@@ -382,40 +379,6 @@ public class SipPhone extends SipPhoneBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CallerInfo createCallerInfo(String number, SipProfile callee) {
|
|
||||||
SipProfile p = callee;
|
|
||||||
String name = p.getDisplayName();
|
|
||||||
if (TextUtils.isEmpty(name)) name = p.getUserName();
|
|
||||||
CallerInfo info = new CallerInfo();
|
|
||||||
info.name = name;
|
|
||||||
info.phoneNumber = number;
|
|
||||||
if (DEBUG) {
|
|
||||||
Log.d(LOG_TAG, "create caller info from scratch:");
|
|
||||||
Log.d(LOG_TAG, " name: " + info.name);
|
|
||||||
Log.d(LOG_TAG, " numb: " + info.phoneNumber);
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
// from contacts
|
|
||||||
private CallerInfo findCallerInfo(String number) {
|
|
||||||
CallerInfo info = CallerInfo.getCallerInfo(mContext, number);
|
|
||||||
if ((info == null) || (info.name == null)) return null;
|
|
||||||
if (DEBUG) {
|
|
||||||
Log.d(LOG_TAG, "got caller info from contact:");
|
|
||||||
Log.d(LOG_TAG, " name: " + info.name);
|
|
||||||
Log.d(LOG_TAG, " numb: " + info.phoneNumber);
|
|
||||||
Log.d(LOG_TAG, " pres: " + info.numberPresentation);
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CallerInfo getCallerInfo(String number, SipProfile callee) {
|
|
||||||
CallerInfo info = findCallerInfo(number);
|
|
||||||
if (info == null) info = createCallerInfo(number, callee);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
Connection dial(String originalNumber) throws SipException {
|
Connection dial(String originalNumber) throws SipException {
|
||||||
String calleeSipUri = originalNumber;
|
String calleeSipUri = originalNumber;
|
||||||
if (!calleeSipUri.contains("@")) {
|
if (!calleeSipUri.contains("@")) {
|
||||||
@@ -424,8 +387,7 @@ public class SipPhone extends SipPhoneBase {
|
|||||||
try {
|
try {
|
||||||
SipProfile callee =
|
SipProfile callee =
|
||||||
new SipProfile.Builder(calleeSipUri).build();
|
new SipProfile.Builder(calleeSipUri).build();
|
||||||
CallerInfo info = getCallerInfo(originalNumber, callee);
|
SipConnection c = new SipConnection(this, callee);
|
||||||
SipConnection c = new SipConnection(this, callee, info);
|
|
||||||
connections.add(c);
|
connections.add(c);
|
||||||
c.dial();
|
c.dial();
|
||||||
setState(Call.State.DIALING);
|
setState(Call.State.DIALING);
|
||||||
@@ -461,10 +423,7 @@ public class SipPhone extends SipPhoneBase {
|
|||||||
|
|
||||||
void initIncomingCall(SipAudioCall sipAudioCall, boolean makeCallWait) {
|
void initIncomingCall(SipAudioCall sipAudioCall, boolean makeCallWait) {
|
||||||
SipProfile callee = sipAudioCall.getPeerProfile();
|
SipProfile callee = sipAudioCall.getPeerProfile();
|
||||||
CallerInfo info = findCallerInfo(getUriString(callee));
|
SipConnection c = new SipConnection(this, callee);
|
||||||
if (info == null) info = findCallerInfo(callee.getUserName());
|
|
||||||
if (info == null) info = findCallerInfo(callee.getDisplayName());
|
|
||||||
SipConnection c = new SipConnection(this, callee, info);
|
|
||||||
connections.add(c);
|
connections.add(c);
|
||||||
|
|
||||||
Call.State newState = makeCallWait ? State.WAITING : State.INCOMING;
|
Call.State newState = makeCallWait ? State.WAITING : State.INCOMING;
|
||||||
@@ -700,12 +659,10 @@ public class SipPhone extends SipPhoneBase {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public SipConnection(SipCall owner, SipProfile callee,
|
public SipConnection(SipCall owner, SipProfile callee) {
|
||||||
CallerInfo info) {
|
|
||||||
super(getUriString(callee));
|
super(getUriString(callee));
|
||||||
mOwner = owner;
|
mOwner = owner;
|
||||||
mPeer = callee;
|
mPeer = callee;
|
||||||
setUserData(info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initIncomingCall(SipAudioCall sipAudioCall, Call.State newState) {
|
void initIncomingCall(SipAudioCall sipAudioCall, Call.State newState) {
|
||||||
|
|||||||
Reference in New Issue
Block a user