PhoneFactory: add makeSipPhone()
Change-Id: I8e7abb0623724d24c6f82829ff06663a31ba32fb
This commit is contained in:
@ -24,6 +24,8 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.android.internal.telephony.cdma.CDMAPhone;
|
import com.android.internal.telephony.cdma.CDMAPhone;
|
||||||
import com.android.internal.telephony.gsm.GSMPhone;
|
import com.android.internal.telephony.gsm.GSMPhone;
|
||||||
|
import com.android.internal.telephony.sip.SipPhone;
|
||||||
|
import com.android.internal.telephony.sip.SipPhoneFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@hide}
|
* {@hide}
|
||||||
@ -175,4 +177,13 @@ public class PhoneFactory {
|
|||||||
return phone;
|
return phone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a {@link SipPhone} object.
|
||||||
|
* @param sipUri the local SIP URI the phone runs on
|
||||||
|
* @return the {@code SipPhone} object or null if the SIP URI is not valid
|
||||||
|
*/
|
||||||
|
public static SipPhone makeSipPhone(String sipUri) {
|
||||||
|
return SipPhoneFactory.makePhone(sipUri, sContext, sPhoneNotifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.internal.telephony.sip;
|
package com.android.internal.telephony.sip;
|
||||||
|
|
||||||
import com.android.internal.telephony.Phone;
|
|
||||||
import com.android.internal.telephony.PhoneNotifier;
|
import com.android.internal.telephony.PhoneNotifier;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -26,42 +25,25 @@ import android.util.Log;
|
|||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
public class SipPhoneFactory {
|
public class SipPhoneFactory {
|
||||||
private static PhoneNotifier sPhoneNotifier = makeDefaultPhoneNotifier();
|
/**
|
||||||
private static Context sContext;
|
* Makes a {@link SipPhone} object.
|
||||||
|
* @param sipUri the local SIP URI the phone runs on
|
||||||
public static void makeDefaultPhones(Context context) {
|
* @param context {@code Context} needed to create a Phone object
|
||||||
makeDefaultPhone(context);
|
* @param phoneNotifier {@code PhoneNotifier} needed to create a Phone
|
||||||
}
|
* object
|
||||||
|
* @return the {@code SipPhone} object or null if the SIP URI is not valid
|
||||||
public static void makeDefaultPhone(Context context) {
|
*/
|
||||||
sContext = context;
|
public static SipPhone makePhone(String sipUri, Context context,
|
||||||
SipPhoneProxy.getInstance().setPhone(
|
PhoneNotifier phoneNotifier) {
|
||||||
makePhone("sip:anonymous@localhost"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Phone getDefaultPhone() {
|
|
||||||
return SipPhoneProxy.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SipPhone makePhone(String sipProfileUri) {
|
|
||||||
try {
|
try {
|
||||||
SipProfile profile = new SipProfile.Builder(sipProfileUri).build();
|
SipProfile profile = new SipProfile.Builder(sipUri).build();
|
||||||
return new SipPhone(sContext, sPhoneNotifier, profile);
|
return new SipPhone(context, phoneNotifier, profile);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
Log.v("SipPhoneProxy", "setPhone", e);
|
Log.w("SipPhoneProxy", "setPhone", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PhoneNotifier makeDefaultPhoneNotifier() {
|
|
||||||
try {
|
|
||||||
return new com.android.internal.telephony.SipPhoneNotifier();
|
|
||||||
} catch (Error e) {
|
|
||||||
Log.e("SipPhoneProxy", "makeDefaultPhoneNotifier", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user