Fields Summary |
---|
public static final int | INCOMING_CALL_RESULT_CODEThe result code to be sent back with the incoming call
{@link PendingIntent}. |
public static final String | EXTRA_CALL_IDKey to retrieve the call ID from an incoming call intent. |
public static final String | EXTRA_OFFER_SDKey to retrieve the offered session description from an incoming call
intent. |
public static final String | ACTION_SIP_SERVICE_UPAction to broadcast when SipService is up.
Internal use only. |
public static final String | ACTION_SIP_INCOMING_CALLAction string for the incoming call intent for the Phone app.
Internal use only. |
public static final String | ACTION_SIP_ADD_PHONEAction string for the add-phone intent.
Internal use only. |
public static final String | ACTION_SIP_REMOVE_PHONEAction string for the remove-phone intent.
Internal use only. |
public static final String | ACTION_SIP_CALL_OPTION_CHANGEDAction string for the SIP call option configuration changed intent.
This is used to communicate change to the SIP call option, triggering re-registration of
the SIP phone accounts.
Internal use only. |
public static final String | EXTRA_LOCAL_URIPart of the ACTION_SIP_ADD_PHONE and ACTION_SIP_REMOVE_PHONE intents.
Internal use only. |
private static final String | TAG |
private ISipService | mSipService |
private android.content.Context | mContext |
Methods Summary |
---|
public void | close(java.lang.String localProfileUri)Closes the specified profile to not make/receive calls. All the resources
that were allocated to the profile are also released.
try {
mSipService.close(localProfileUri);
} catch (RemoteException e) {
throw new SipException("close()", e);
}
|
public static android.content.Intent | createIncomingCallBroadcast(java.lang.String callId, java.lang.String sessionDescription)Creates an incoming call broadcast intent.
Intent intent = new Intent();
intent.putExtra(EXTRA_CALL_ID, callId);
intent.putExtra(EXTRA_OFFER_SD, sessionDescription);
return intent;
|
private static ISipSessionListener | createRelay(SipRegistrationListener listener, java.lang.String uri)
return ((listener == null) ? null : new ListenerRelay(listener, uri));
|
private void | createSipService()
IBinder b = ServiceManager.getService(Context.SIP_SERVICE);
mSipService = ISipService.Stub.asInterface(b);
|
public SipSession | createSipSession(SipProfile localProfile, SipSession.Listener listener)Creates a {@link SipSession} with the specified profile. Use other
methods, if applicable, instead of interacting with {@link SipSession}
directly.
try {
ISipSession s = mSipService.createSession(localProfile, null);
if (s == null) {
throw new SipException(
"Failed to create SipSession; network unavailable?");
}
return new SipSession(s, listener);
} catch (RemoteException e) {
throw new SipException("createSipSession()", e);
}
|
public static java.lang.String | getCallId(android.content.Intent incomingCallIntent)Gets the call ID from the specified incoming call broadcast intent.
return incomingCallIntent.getStringExtra(EXTRA_CALL_ID);
|
public SipProfile[] | getListOfProfiles()Gets the list of profiles hosted by the SIP service. The user information
(username, password and display name) are crossed out.
try {
return mSipService.getListOfProfiles();
} catch (RemoteException e) {
return new SipProfile[0];
}
|
public static java.lang.String | getOfferSessionDescription(android.content.Intent incomingCallIntent)Gets the offer session description from the specified incoming call
broadcast intent.
return incomingCallIntent.getStringExtra(EXTRA_OFFER_SD);
|
public SipSession | getSessionFor(android.content.Intent incomingCallIntent)Gets the {@link SipSession} that handles the incoming call. For audio
calls, consider to use {@link SipAudioCall} to handle the incoming call.
See {@link #takeAudioCall}. Note that the method may be called only once
for the same intent. For subsequent calls on the same intent, the method
returns null.
try {
String callId = getCallId(incomingCallIntent);
ISipSession s = mSipService.getPendingSession(callId);
return ((s == null) ? null : new SipSession(s));
} catch (RemoteException e) {
throw new SipException("getSessionFor()", e);
}
|
public static boolean | isApiSupported(android.content.Context context)Returns true if the SIP API is supported by the system.
return context.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_SIP);
|
public static boolean | isIncomingCallIntent(android.content.Intent intent)Checks if the intent is an incoming call broadcast intent.
if (intent == null) return false;
String callId = getCallId(intent);
String offerSd = getOfferSessionDescription(intent);
return ((callId != null) && (offerSd != null));
|
public boolean | isOpened(java.lang.String localProfileUri)Checks if the specified profile is opened in the SIP service for
making and/or receiving calls.
try {
return mSipService.isOpened(localProfileUri);
} catch (RemoteException e) {
throw new SipException("isOpened()", e);
}
|
public boolean | isRegistered(java.lang.String localProfileUri)Checks if the SIP service has successfully registered the profile to the
SIP provider (specified in the profile) for receiving calls. Returning
true from this method also implies the profile is opened
({@link #isOpened}).
try {
return mSipService.isRegistered(localProfileUri);
} catch (RemoteException e) {
throw new SipException("isRegistered()", e);
}
|
public static boolean | isSipWifiOnly(android.content.Context context)Returns true if SIP is only available on WIFI.
return context.getResources().getBoolean(
com.android.internal.R.bool.config_sip_wifi_only);
|
public static boolean | isVoipSupported(android.content.Context context)Returns true if the system supports SIP-based VOIP API.
return context.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_SIP_VOIP) && isApiSupported(context);
|
public SipAudioCall | makeAudioCall(SipProfile localProfile, SipProfile peerProfile, SipAudioCall.Listener listener, int timeout)Creates a {@link SipAudioCall} to make a call. The attempt will be timed
out if the call is not established within {@code timeout} seconds and
{@link SipAudioCall.Listener#onError onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
will be called.
if (!isVoipSupported(mContext)) {
throw new SipException("VOIP API is not supported");
}
SipAudioCall call = new SipAudioCall(mContext, localProfile);
call.setListener(listener);
SipSession s = createSipSession(localProfile, null);
call.makeCall(peerProfile, s, timeout);
return call;
|
public SipAudioCall | makeAudioCall(java.lang.String localProfileUri, java.lang.String peerProfileUri, SipAudioCall.Listener listener, int timeout)Creates a {@link SipAudioCall} to make an audio call. The attempt will be
timed out if the call is not established within {@code timeout} seconds
and
{@link SipAudioCall.Listener#onError onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
will be called.
if (!isVoipSupported(mContext)) {
throw new SipException("VOIP API is not supported");
}
try {
return makeAudioCall(
new SipProfile.Builder(localProfileUri).build(),
new SipProfile.Builder(peerProfileUri).build(), listener,
timeout);
} catch (ParseException e) {
throw new SipException("build SipProfile", e);
}
|
public static android.net.sip.SipManager | newInstance(android.content.Context context)Creates a manager instance. Returns null if SIP API is not supported.
return (isApiSupported(context) ? new SipManager(context) : null);
|
public void | open(SipProfile localProfile)Opens the profile for making generic SIP calls. The caller may make subsequent calls
through {@link #makeAudioCall}. If one also wants to receive calls on the
profile, use
{@link #open(SipProfile, PendingIntent, SipRegistrationListener)}
instead.
try {
mSipService.open(localProfile);
} catch (RemoteException e) {
throw new SipException("open()", e);
}
|
public void | open(SipProfile localProfile, android.app.PendingIntent incomingCallPendingIntent, SipRegistrationListener listener)Opens the profile for making calls and/or receiving generic SIP calls. The caller may
make subsequent calls through {@link #makeAudioCall}. If the
auto-registration option is enabled in the profile, the SIP service
will register the profile to the corresponding SIP provider periodically
in order to receive calls from the provider. When the SIP service
receives a new call, it will send out an intent with the provided action
string. The intent contains a call ID extra and an offer session
description string extra. Use {@link #getCallId} and
{@link #getOfferSessionDescription} to retrieve those extras.
if (incomingCallPendingIntent == null) {
throw new NullPointerException(
"incomingCallPendingIntent cannot be null");
}
try {
mSipService.open3(localProfile, incomingCallPendingIntent,
createRelay(listener, localProfile.getUriString()));
} catch (RemoteException e) {
throw new SipException("open()", e);
}
|
public void | register(SipProfile localProfile, int expiryTime, SipRegistrationListener listener)Manually registers the profile to the corresponding SIP provider for
receiving calls.
{@link #open(SipProfile, PendingIntent, SipRegistrationListener)} is
still needed to be called at least once in order for the SIP service to
notify the caller with the {@link android.app.PendingIntent} when an incoming call is
received.
try {
ISipSession session = mSipService.createSession(localProfile,
createRelay(listener, localProfile.getUriString()));
if (session == null) {
throw new SipException(
"SipService.createSession() returns null");
}
session.register(expiryTime);
} catch (RemoteException e) {
throw new SipException("register()", e);
}
|
public void | setRegistrationListener(java.lang.String localProfileUri, SipRegistrationListener listener)Sets the listener to listen to registration events. No effect if the
profile has not been opened to receive calls (see
{@link #open(SipProfile, PendingIntent, SipRegistrationListener)}).
try {
mSipService.setRegistrationListener(
localProfileUri, createRelay(listener, localProfileUri));
} catch (RemoteException e) {
throw new SipException("setRegistrationListener()", e);
}
|
public SipAudioCall | takeAudioCall(android.content.Intent incomingCallIntent, SipAudioCall.Listener listener)Creates a {@link SipAudioCall} to take an incoming call. Before the call
is returned, the listener will receive a
{@link SipAudioCall.Listener#onRinging}
callback.
if (incomingCallIntent == null) {
throw new SipException("Cannot retrieve session with null intent");
}
String callId = getCallId(incomingCallIntent);
if (callId == null) {
throw new SipException("Call ID missing in incoming call intent");
}
String offerSd = getOfferSessionDescription(incomingCallIntent);
if (offerSd == null) {
throw new SipException("Session description missing in incoming "
+ "call intent");
}
try {
ISipSession session = mSipService.getPendingSession(callId);
if (session == null) {
throw new SipException("No pending session for the call");
}
SipAudioCall call = new SipAudioCall(
mContext, session.getLocalProfile());
call.attachCall(new SipSession(session), offerSd);
call.setListener(listener);
return call;
} catch (Throwable t) {
throw new SipException("takeAudioCall()", t);
}
|
public void | unregister(SipProfile localProfile, SipRegistrationListener listener)Manually unregisters the profile from the corresponding SIP provider for
stop receiving further calls. This may interference with the auto
registration process in the SIP service if the auto-registration option
in the profile is enabled.
try {
ISipSession session = mSipService.createSession(localProfile,
createRelay(listener, localProfile.getUriString()));
if (session == null) {
throw new SipException(
"SipService.createSession() returns null");
}
session.unregister();
} catch (RemoteException e) {
throw new SipException("unregister()", e);
}
|