Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.net.sip; |
| 18 | |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 19 | import android.app.PendingIntent; |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 20 | import android.content.Context; |
| 21 | import android.content.Intent; |
Hung-ying Tyan | 3424c02 | 2010-08-27 18:08:19 +0800 | [diff] [blame] | 22 | import android.content.pm.PackageManager; |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 23 | import android.os.IBinder; |
| 24 | import android.os.Looper; |
| 25 | import android.os.RemoteException; |
| 26 | import android.os.ServiceManager; |
Hung-ying Tyan | 9ea96c6 | 2010-10-03 20:35:02 +0800 | [diff] [blame] | 27 | import android.util.Log; |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 28 | |
| 29 | import java.text.ParseException; |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 30 | |
| 31 | /** |
Scott Main | 02b1d68 | 2010-10-22 11:29:57 -0700 | [diff] [blame] | 32 | * Provides APIs for SIP tasks, such as initiating SIP connections, and provides access to related |
| 33 | * SIP services. This class is the starting point for any SIP actions. You can acquire an instance |
| 34 | * of it with {@link #newInstance newInstance()}.</p> |
| 35 | * <p>The APIs in this class allows you to:</p> |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 36 | * <ul> |
Scott Main | 02b1d68 | 2010-10-22 11:29:57 -0700 | [diff] [blame] | 37 | * <li>Create a {@link SipSession} to get ready for making calls or listen for incoming calls. See |
| 38 | * {@link #createSipSession createSipSession()} and {@link #getSessionFor getSessionFor()}.</li> |
| 39 | * <li>Initiate and receive generic SIP calls or audio-only SIP calls. Generic SIP calls may |
| 40 | * be video, audio, or other, and are initiated with {@link #open open()}. Audio-only SIP calls |
| 41 | * should be handled with a {@link SipAudioCall}, which you can acquire with {@link |
| 42 | * #makeAudioCall makeAudioCall()} and {@link #takeAudioCall takeAudioCall()}.</li> |
| 43 | * <li>Register and unregister with a SIP service provider, with |
| 44 | * {@link #register register()} and {@link #unregister unregister()}.</li> |
| 45 | * <li>Verify session connectivity, with {@link #isOpened isOpened()} and |
| 46 | * {@link #isRegistered isRegistered()}.</li> |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 47 | * </ul> |
Scott Main | 02b1d68 | 2010-10-22 11:29:57 -0700 | [diff] [blame] | 48 | * <p class="note"><strong>Note:</strong> Not all Android-powered devices support VOIP calls using |
| 49 | * SIP. You should always call {@link android.net.sip.SipManager#isVoipSupported |
| 50 | * isVoipSupported()} to verify that the device supports VOIP calling and {@link |
| 51 | * android.net.sip.SipManager#isApiSupported isApiSupported()} to verify that the device supports |
Joe Fernandez | 3aef8e1d | 2011-12-20 10:38:34 -0800 | [diff] [blame] | 52 | * the SIP APIs. Your application must also request the {@link |
Scott Main | 02b1d68 | 2010-10-22 11:29:57 -0700 | [diff] [blame] | 53 | * android.Manifest.permission#INTERNET} and {@link android.Manifest.permission#USE_SIP} |
| 54 | * permissions.</p> |
Joe Fernandez | 3aef8e1d | 2011-12-20 10:38:34 -0800 | [diff] [blame] | 55 | * |
| 56 | * <div class="special reference"> |
| 57 | * <h3>Developer Guides</h3> |
| 58 | * <p>For more information about using SIP, read the |
| 59 | * <a href="{@docRoot}guide/topics/network/sip.html">Session Initiation Protocol</a> |
| 60 | * developer guide.</p> |
| 61 | * </div> |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 62 | */ |
| 63 | public class SipManager { |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 64 | /** |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 65 | * The result code to be sent back with the incoming call |
| 66 | * {@link PendingIntent}. |
| 67 | * @see #open(SipProfile, PendingIntent, SipRegistrationListener) |
| 68 | */ |
| 69 | public static final int INCOMING_CALL_RESULT_CODE = 101; |
| 70 | |
Hung-ying Tyan | 08faac3 | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 71 | /** |
| 72 | * Key to retrieve the call ID from an incoming call intent. |
| 73 | * @see #open(SipProfile, PendingIntent, SipRegistrationListener) |
| 74 | */ |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 75 | public static final String EXTRA_CALL_ID = "android:sipCallID"; |
| 76 | |
Hung-ying Tyan | 08faac3 | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 77 | /** |
| 78 | * Key to retrieve the offered session description from an incoming call |
| 79 | * intent. |
| 80 | * @see #open(SipProfile, PendingIntent, SipRegistrationListener) |
| 81 | */ |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 82 | public static final String EXTRA_OFFER_SD = "android:sipOfferSD"; |
| 83 | |
| 84 | /** |
Hung-ying Tyan | 9db99a4 | 2010-10-07 09:14:57 +0800 | [diff] [blame] | 85 | * Action to broadcast when SipService is up. |
| 86 | * Internal use only. |
| 87 | * @hide |
| 88 | */ |
| 89 | public static final String ACTION_SIP_SERVICE_UP = |
| 90 | "android.net.sip.SIP_SERVICE_UP"; |
| 91 | /** |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 92 | * Action string for the incoming call intent for the Phone app. |
| 93 | * Internal use only. |
| 94 | * @hide |
| 95 | */ |
| 96 | public static final String ACTION_SIP_INCOMING_CALL = |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 97 | "com.android.phone.SIP_INCOMING_CALL"; |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 98 | /** |
| 99 | * Action string for the add-phone intent. |
| 100 | * Internal use only. |
| 101 | * @hide |
| 102 | */ |
| 103 | public static final String ACTION_SIP_ADD_PHONE = |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 104 | "com.android.phone.SIP_ADD_PHONE"; |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 105 | /** |
| 106 | * Action string for the remove-phone intent. |
| 107 | * Internal use only. |
| 108 | * @hide |
| 109 | */ |
| 110 | public static final String ACTION_SIP_REMOVE_PHONE = |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 111 | "com.android.phone.SIP_REMOVE_PHONE"; |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 112 | /** |
| 113 | * Part of the ACTION_SIP_ADD_PHONE and ACTION_SIP_REMOVE_PHONE intents. |
| 114 | * Internal use only. |
| 115 | * @hide |
| 116 | */ |
| 117 | public static final String EXTRA_LOCAL_URI = "android:localSipUri"; |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 118 | |
Hung-ying Tyan | 9ea96c6 | 2010-10-03 20:35:02 +0800 | [diff] [blame] | 119 | private static final String TAG = "SipManager"; |
| 120 | |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 121 | private ISipService mSipService; |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 122 | private Context mContext; |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 123 | |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 124 | /** |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 125 | * Creates a manager instance. Returns null if SIP API is not supported. |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 126 | * |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 127 | * @param context application context for creating the manager object |
Hung-ying Tyan | 3424c02 | 2010-08-27 18:08:19 +0800 | [diff] [blame] | 128 | * @return the manager instance or null if SIP API is not supported |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 129 | */ |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 130 | public static SipManager newInstance(Context context) { |
| 131 | return (isApiSupported(context) ? new SipManager(context) : null); |
Hung-ying Tyan | 3424c02 | 2010-08-27 18:08:19 +0800 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Returns true if the SIP API is supported by the system. |
| 136 | */ |
| 137 | public static boolean isApiSupported(Context context) { |
| 138 | return context.getPackageManager().hasSystemFeature( |
| 139 | PackageManager.FEATURE_SIP); |
| 140 | } |
| 141 | |
| 142 | /** |
Hung-ying Tyan | 5bd3782 | 2010-12-20 19:08:24 +0800 | [diff] [blame] | 143 | * Returns true if the system supports SIP-based VOIP API. |
Hung-ying Tyan | 3424c02 | 2010-08-27 18:08:19 +0800 | [diff] [blame] | 144 | */ |
| 145 | public static boolean isVoipSupported(Context context) { |
| 146 | return context.getPackageManager().hasSystemFeature( |
| 147 | PackageManager.FEATURE_SIP_VOIP) && isApiSupported(context); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 148 | } |
| 149 | |
Hung-ying Tyan | c4b8747 | 2010-09-19 18:23:44 +0800 | [diff] [blame] | 150 | /** |
| 151 | * Returns true if SIP is only available on WIFI. |
| 152 | */ |
| 153 | public static boolean isSipWifiOnly(Context context) { |
| 154 | return context.getResources().getBoolean( |
| 155 | com.android.internal.R.bool.config_sip_wifi_only); |
| 156 | } |
| 157 | |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 158 | private SipManager(Context context) { |
| 159 | mContext = context; |
Hung-ying Tyan | 3424c02 | 2010-08-27 18:08:19 +0800 | [diff] [blame] | 160 | createSipService(); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 161 | } |
| 162 | |
Hung-ying Tyan | 3424c02 | 2010-08-27 18:08:19 +0800 | [diff] [blame] | 163 | private void createSipService() { |
Chung-yih Wang | cde66df | 2010-08-05 13:25:38 +0800 | [diff] [blame] | 164 | IBinder b = ServiceManager.getService(Context.SIP_SERVICE); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 165 | mSipService = ISipService.Stub.asInterface(b); |
| 166 | } |
| 167 | |
| 168 | /** |
Scott Main | 02b1d68 | 2010-10-22 11:29:57 -0700 | [diff] [blame] | 169 | * Opens the profile for making generic SIP calls. The caller may make subsequent calls |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 170 | * through {@link #makeAudioCall}. If one also wants to receive calls on the |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 171 | * profile, use |
| 172 | * {@link #open(SipProfile, PendingIntent, SipRegistrationListener)} |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 173 | * instead. |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 174 | * |
| 175 | * @param localProfile the SIP profile to make calls from |
| 176 | * @throws SipException if the profile contains incorrect settings or |
| 177 | * calling the SIP service results in an error |
| 178 | */ |
| 179 | public void open(SipProfile localProfile) throws SipException { |
| 180 | try { |
| 181 | mSipService.open(localProfile); |
| 182 | } catch (RemoteException e) { |
| 183 | throw new SipException("open()", e); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | /** |
Scott Main | 02b1d68 | 2010-10-22 11:29:57 -0700 | [diff] [blame] | 188 | * Opens the profile for making calls and/or receiving generic SIP calls. The caller may |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 189 | * make subsequent calls through {@link #makeAudioCall}. If the |
| 190 | * auto-registration option is enabled in the profile, the SIP service |
| 191 | * will register the profile to the corresponding SIP provider periodically |
Hung-ying Tyan | 08faac3 | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 192 | * in order to receive calls from the provider. When the SIP service |
| 193 | * receives a new call, it will send out an intent with the provided action |
| 194 | * string. The intent contains a call ID extra and an offer session |
| 195 | * description string extra. Use {@link #getCallId} and |
| 196 | * {@link #getOfferSessionDescription} to retrieve those extras. |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 197 | * |
| 198 | * @param localProfile the SIP profile to receive incoming calls for |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 199 | * @param incomingCallPendingIntent When an incoming call is received, the |
| 200 | * SIP service will call |
| 201 | * {@link PendingIntent#send(Context, int, Intent)} to send back the |
| 202 | * intent to the caller with {@link #INCOMING_CALL_RESULT_CODE} as the |
| 203 | * result code and the intent to fill in the call ID and session |
| 204 | * description information. It cannot be null. |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 205 | * @param listener to listen to registration events; can be null |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 206 | * @see #getCallId |
| 207 | * @see #getOfferSessionDescription |
| 208 | * @see #takeAudioCall |
| 209 | * @throws NullPointerException if {@code incomingCallPendingIntent} is null |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 210 | * @throws SipException if the profile contains incorrect settings or |
| 211 | * calling the SIP service results in an error |
Hung-ying Tyan | 08faac3 | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 212 | * @see #isIncomingCallIntent |
| 213 | * @see #getCallId |
| 214 | * @see #getOfferSessionDescription |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 215 | */ |
| 216 | public void open(SipProfile localProfile, |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 217 | PendingIntent incomingCallPendingIntent, |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 218 | SipRegistrationListener listener) throws SipException { |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 219 | if (incomingCallPendingIntent == null) { |
| 220 | throw new NullPointerException( |
| 221 | "incomingCallPendingIntent cannot be null"); |
| 222 | } |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 223 | try { |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 224 | mSipService.open3(localProfile, incomingCallPendingIntent, |
Hung-ying Tyan | 9e1d308 | 2010-09-30 15:00:34 +0800 | [diff] [blame] | 225 | createRelay(listener, localProfile.getUriString())); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 226 | } catch (RemoteException e) { |
| 227 | throw new SipException("open()", e); |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Sets the listener to listen to registration events. No effect if the |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 233 | * profile has not been opened to receive calls (see |
| 234 | * {@link #open(SipProfile, PendingIntent, SipRegistrationListener)}). |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 235 | * |
| 236 | * @param localProfileUri the URI of the profile |
| 237 | * @param listener to listen to registration events; can be null |
| 238 | * @throws SipException if calling the SIP service results in an error |
| 239 | */ |
| 240 | public void setRegistrationListener(String localProfileUri, |
| 241 | SipRegistrationListener listener) throws SipException { |
| 242 | try { |
| 243 | mSipService.setRegistrationListener( |
Hung-ying Tyan | 9e1d308 | 2010-09-30 15:00:34 +0800 | [diff] [blame] | 244 | localProfileUri, createRelay(listener, localProfileUri)); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 245 | } catch (RemoteException e) { |
| 246 | throw new SipException("setRegistrationListener()", e); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Closes the specified profile to not make/receive calls. All the resources |
| 252 | * that were allocated to the profile are also released. |
| 253 | * |
| 254 | * @param localProfileUri the URI of the profile to close |
| 255 | * @throws SipException if calling the SIP service results in an error |
| 256 | */ |
| 257 | public void close(String localProfileUri) throws SipException { |
| 258 | try { |
| 259 | mSipService.close(localProfileUri); |
| 260 | } catch (RemoteException e) { |
| 261 | throw new SipException("close()", e); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | /** |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 266 | * Checks if the specified profile is opened in the SIP service for |
| 267 | * making and/or receiving calls. |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 268 | * |
| 269 | * @param localProfileUri the URI of the profile in question |
| 270 | * @return true if the profile is enabled to receive calls |
| 271 | * @throws SipException if calling the SIP service results in an error |
| 272 | */ |
| 273 | public boolean isOpened(String localProfileUri) throws SipException { |
| 274 | try { |
| 275 | return mSipService.isOpened(localProfileUri); |
| 276 | } catch (RemoteException e) { |
| 277 | throw new SipException("isOpened()", e); |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | /** |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 282 | * Checks if the SIP service has successfully registered the profile to the |
| 283 | * SIP provider (specified in the profile) for receiving calls. Returning |
| 284 | * true from this method also implies the profile is opened |
| 285 | * ({@link #isOpened}). |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 286 | * |
| 287 | * @param localProfileUri the URI of the profile in question |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 288 | * @return true if the profile is registered to the SIP provider; false if |
| 289 | * the profile has not been opened in the SIP service or the SIP |
| 290 | * service has not yet successfully registered the profile to the SIP |
| 291 | * provider |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 292 | * @throws SipException if calling the SIP service results in an error |
| 293 | */ |
| 294 | public boolean isRegistered(String localProfileUri) throws SipException { |
| 295 | try { |
| 296 | return mSipService.isRegistered(localProfileUri); |
| 297 | } catch (RemoteException e) { |
| 298 | throw new SipException("isRegistered()", e); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | /** |
Hung-ying Tyan | 9352cf1 | 2010-09-16 20:14:18 +0800 | [diff] [blame] | 303 | * Creates a {@link SipAudioCall} to make a call. The attempt will be timed |
| 304 | * out if the call is not established within {@code timeout} seconds and |
Scott Main | 02b1d68 | 2010-10-22 11:29:57 -0700 | [diff] [blame] | 305 | * {@link SipAudioCall.Listener#onError onError(SipAudioCall, SipErrorCode.TIME_OUT, String)} |
Hung-ying Tyan | 9352cf1 | 2010-09-16 20:14:18 +0800 | [diff] [blame] | 306 | * will be called. |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 307 | * |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 308 | * @param localProfile the SIP profile to make the call from |
| 309 | * @param peerProfile the SIP profile to make the call to |
| 310 | * @param listener to listen to the call events from {@link SipAudioCall}; |
| 311 | * can be null |
Hung-ying Tyan | 08faac3 | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 312 | * @param timeout the timeout value in seconds. Default value (defined by |
| 313 | * SIP protocol) is used if {@code timeout} is zero or negative. |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 314 | * @return a {@link SipAudioCall} object |
Hung-ying Tyan | 5bd3782 | 2010-12-20 19:08:24 +0800 | [diff] [blame] | 315 | * @throws SipException if calling the SIP service results in an error or |
| 316 | * VOIP API is not supported by the device |
Scott Main | 02b1d68 | 2010-10-22 11:29:57 -0700 | [diff] [blame] | 317 | * @see SipAudioCall.Listener#onError |
Hung-ying Tyan | 5bd3782 | 2010-12-20 19:08:24 +0800 | [diff] [blame] | 318 | * @see #isVoipSupported |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 319 | */ |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 320 | public SipAudioCall makeAudioCall(SipProfile localProfile, |
Hung-ying Tyan | 9352cf1 | 2010-09-16 20:14:18 +0800 | [diff] [blame] | 321 | SipProfile peerProfile, SipAudioCall.Listener listener, int timeout) |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 322 | throws SipException { |
Hung-ying Tyan | 5bd3782 | 2010-12-20 19:08:24 +0800 | [diff] [blame] | 323 | if (!isVoipSupported(mContext)) { |
| 324 | throw new SipException("VOIP API is not supported"); |
| 325 | } |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 326 | SipAudioCall call = new SipAudioCall(mContext, localProfile); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 327 | call.setListener(listener); |
Hung-ying Tyan | 3a4197e | 2010-09-24 23:27:40 +0800 | [diff] [blame] | 328 | SipSession s = createSipSession(localProfile, null); |
Hung-ying Tyan | 3a4197e | 2010-09-24 23:27:40 +0800 | [diff] [blame] | 329 | call.makeCall(peerProfile, s, timeout); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 330 | return call; |
| 331 | } |
| 332 | |
| 333 | /** |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 334 | * Creates a {@link SipAudioCall} to make an audio call. The attempt will be |
| 335 | * timed out if the call is not established within {@code timeout} seconds |
| 336 | * and |
Scott Main | 02b1d68 | 2010-10-22 11:29:57 -0700 | [diff] [blame] | 337 | * {@link SipAudioCall.Listener#onError onError(SipAudioCall, SipErrorCode.TIME_OUT, String)} |
Hung-ying Tyan | 9352cf1 | 2010-09-16 20:14:18 +0800 | [diff] [blame] | 338 | * will be called. |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 339 | * |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 340 | * @param localProfileUri URI of the SIP profile to make the call from |
| 341 | * @param peerProfileUri URI of the SIP profile to make the call to |
| 342 | * @param listener to listen to the call events from {@link SipAudioCall}; |
| 343 | * can be null |
Hung-ying Tyan | 08faac3 | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 344 | * @param timeout the timeout value in seconds. Default value (defined by |
| 345 | * SIP protocol) is used if {@code timeout} is zero or negative. |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 346 | * @return a {@link SipAudioCall} object |
Hung-ying Tyan | 5bd3782 | 2010-12-20 19:08:24 +0800 | [diff] [blame] | 347 | * @throws SipException if calling the SIP service results in an error or |
| 348 | * VOIP API is not supported by the device |
Scott Main | 02b1d68 | 2010-10-22 11:29:57 -0700 | [diff] [blame] | 349 | * @see SipAudioCall.Listener#onError |
Hung-ying Tyan | 5bd3782 | 2010-12-20 19:08:24 +0800 | [diff] [blame] | 350 | * @see #isVoipSupported |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 351 | */ |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 352 | public SipAudioCall makeAudioCall(String localProfileUri, |
Hung-ying Tyan | 9352cf1 | 2010-09-16 20:14:18 +0800 | [diff] [blame] | 353 | String peerProfileUri, SipAudioCall.Listener listener, int timeout) |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 354 | throws SipException { |
Hung-ying Tyan | 5bd3782 | 2010-12-20 19:08:24 +0800 | [diff] [blame] | 355 | if (!isVoipSupported(mContext)) { |
| 356 | throw new SipException("VOIP API is not supported"); |
| 357 | } |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 358 | try { |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 359 | return makeAudioCall( |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 360 | new SipProfile.Builder(localProfileUri).build(), |
Hung-ying Tyan | 9352cf1 | 2010-09-16 20:14:18 +0800 | [diff] [blame] | 361 | new SipProfile.Builder(peerProfileUri).build(), listener, |
| 362 | timeout); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 363 | } catch (ParseException e) { |
| 364 | throw new SipException("build SipProfile", e); |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | /** |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 369 | * Creates a {@link SipAudioCall} to take an incoming call. Before the call |
| 370 | * is returned, the listener will receive a |
Hung-ying Tyan | 286bb5a | 2010-09-14 20:43:54 +0800 | [diff] [blame] | 371 | * {@link SipAudioCall.Listener#onRinging} |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 372 | * callback. |
| 373 | * |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 374 | * @param incomingCallIntent the incoming call broadcast intent |
| 375 | * @param listener to listen to the call events from {@link SipAudioCall}; |
| 376 | * can be null |
| 377 | * @return a {@link SipAudioCall} object |
| 378 | * @throws SipException if calling the SIP service results in an error |
| 379 | */ |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 380 | public SipAudioCall takeAudioCall(Intent incomingCallIntent, |
Hung-ying Tyan | 9b449e5 | 2010-10-20 18:07:01 +0800 | [diff] [blame] | 381 | SipAudioCall.Listener listener) throws SipException { |
Hung-ying Tyan | 8d1b2a1 | 2010-11-03 11:50:05 +0800 | [diff] [blame] | 382 | if (incomingCallIntent == null) { |
| 383 | throw new SipException("Cannot retrieve session with null intent"); |
| 384 | } |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 385 | |
| 386 | String callId = getCallId(incomingCallIntent); |
| 387 | if (callId == null) { |
| 388 | throw new SipException("Call ID missing in incoming call intent"); |
| 389 | } |
| 390 | |
Chia-chi Yeh | 95b15c3 | 2010-09-02 22:15:26 +0800 | [diff] [blame] | 391 | String offerSd = getOfferSessionDescription(incomingCallIntent); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 392 | if (offerSd == null) { |
| 393 | throw new SipException("Session description missing in incoming " |
| 394 | + "call intent"); |
| 395 | } |
| 396 | |
| 397 | try { |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 398 | ISipSession session = mSipService.getPendingSession(callId); |
Hung-ying Tyan | 8d1b2a1 | 2010-11-03 11:50:05 +0800 | [diff] [blame] | 399 | if (session == null) { |
| 400 | throw new SipException("No pending session for the call"); |
| 401 | } |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 402 | SipAudioCall call = new SipAudioCall( |
| 403 | mContext, session.getLocalProfile()); |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 404 | call.attachCall(new SipSession(session), offerSd); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 405 | call.setListener(listener); |
| 406 | return call; |
| 407 | } catch (Throwable t) { |
| 408 | throw new SipException("takeAudioCall()", t); |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | /** |
| 413 | * Checks if the intent is an incoming call broadcast intent. |
| 414 | * |
| 415 | * @param intent the intent in question |
| 416 | * @return true if the intent is an incoming call broadcast intent |
| 417 | */ |
| 418 | public static boolean isIncomingCallIntent(Intent intent) { |
| 419 | if (intent == null) return false; |
| 420 | String callId = getCallId(intent); |
Chia-chi Yeh | 95b15c3 | 2010-09-02 22:15:26 +0800 | [diff] [blame] | 421 | String offerSd = getOfferSessionDescription(intent); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 422 | return ((callId != null) && (offerSd != null)); |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * Gets the call ID from the specified incoming call broadcast intent. |
| 427 | * |
| 428 | * @param incomingCallIntent the incoming call broadcast intent |
| 429 | * @return the call ID or null if the intent does not contain it |
| 430 | */ |
| 431 | public static String getCallId(Intent incomingCallIntent) { |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 432 | return incomingCallIntent.getStringExtra(EXTRA_CALL_ID); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | /** |
| 436 | * Gets the offer session description from the specified incoming call |
| 437 | * broadcast intent. |
| 438 | * |
| 439 | * @param incomingCallIntent the incoming call broadcast intent |
| 440 | * @return the offer session description or null if the intent does not |
| 441 | * have it |
| 442 | */ |
Chia-chi Yeh | 95b15c3 | 2010-09-02 22:15:26 +0800 | [diff] [blame] | 443 | public static String getOfferSessionDescription(Intent incomingCallIntent) { |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 444 | return incomingCallIntent.getStringExtra(EXTRA_OFFER_SD); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | /** |
| 448 | * Creates an incoming call broadcast intent. |
| 449 | * |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 450 | * @param callId the call ID of the incoming call |
| 451 | * @param sessionDescription the session description of the incoming call |
| 452 | * @return the incoming call intent |
| 453 | * @hide |
| 454 | */ |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 455 | public static Intent createIncomingCallBroadcast(String callId, |
| 456 | String sessionDescription) { |
| 457 | Intent intent = new Intent(); |
| 458 | intent.putExtra(EXTRA_CALL_ID, callId); |
| 459 | intent.putExtra(EXTRA_OFFER_SD, sessionDescription); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 460 | return intent; |
| 461 | } |
| 462 | |
| 463 | /** |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 464 | * Manually registers the profile to the corresponding SIP provider for |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 465 | * receiving calls. |
| 466 | * {@link #open(SipProfile, PendingIntent, SipRegistrationListener)} is |
| 467 | * still needed to be called at least once in order for the SIP service to |
Scott Main | 02b1d68 | 2010-10-22 11:29:57 -0700 | [diff] [blame] | 468 | * notify the caller with the {@link android.app.PendingIntent} when an incoming call is |
Hung-ying Tyan | 323d367 | 2010-10-05 09:35:38 +0800 | [diff] [blame] | 469 | * received. |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 470 | * |
| 471 | * @param localProfile the SIP profile to register with |
Hung-ying Tyan | 286bb5a | 2010-09-14 20:43:54 +0800 | [diff] [blame] | 472 | * @param expiryTime registration expiration time (in seconds) |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 473 | * @param listener to listen to the registration events |
| 474 | * @throws SipException if calling the SIP service results in an error |
| 475 | */ |
| 476 | public void register(SipProfile localProfile, int expiryTime, |
| 477 | SipRegistrationListener listener) throws SipException { |
| 478 | try { |
Hung-ying Tyan | 9e1d308 | 2010-09-30 15:00:34 +0800 | [diff] [blame] | 479 | ISipSession session = mSipService.createSession(localProfile, |
| 480 | createRelay(listener, localProfile.getUriString())); |
Masahiko Endo | 25ccbb9 | 2011-07-28 21:51:43 +0900 | [diff] [blame] | 481 | if (session == null) { |
| 482 | throw new SipException( |
| 483 | "SipService.createSession() returns null"); |
| 484 | } |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 485 | session.register(expiryTime); |
| 486 | } catch (RemoteException e) { |
| 487 | throw new SipException("register()", e); |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | /** |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 492 | * Manually unregisters the profile from the corresponding SIP provider for |
| 493 | * stop receiving further calls. This may interference with the auto |
| 494 | * registration process in the SIP service if the auto-registration option |
| 495 | * in the profile is enabled. |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 496 | * |
| 497 | * @param localProfile the SIP profile to register with |
| 498 | * @param listener to listen to the registration events |
| 499 | * @throws SipException if calling the SIP service results in an error |
| 500 | */ |
| 501 | public void unregister(SipProfile localProfile, |
| 502 | SipRegistrationListener listener) throws SipException { |
| 503 | try { |
Hung-ying Tyan | 9e1d308 | 2010-09-30 15:00:34 +0800 | [diff] [blame] | 504 | ISipSession session = mSipService.createSession(localProfile, |
| 505 | createRelay(listener, localProfile.getUriString())); |
Masahiko Endo | 25ccbb9 | 2011-07-28 21:51:43 +0900 | [diff] [blame] | 506 | if (session == null) { |
| 507 | throw new SipException( |
| 508 | "SipService.createSession() returns null"); |
| 509 | } |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 510 | session.unregister(); |
| 511 | } catch (RemoteException e) { |
| 512 | throw new SipException("unregister()", e); |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | /** |
Hung-ying Tyan | 08faac3 | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 517 | * Gets the {@link SipSession} that handles the incoming call. For audio |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 518 | * calls, consider to use {@link SipAudioCall} to handle the incoming call. |
Hung-ying Tyan | 286bb5a | 2010-09-14 20:43:54 +0800 | [diff] [blame] | 519 | * See {@link #takeAudioCall}. Note that the method may be called only once |
| 520 | * for the same intent. For subsequent calls on the same intent, the method |
| 521 | * returns null. |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 522 | * |
| 523 | * @param incomingCallIntent the incoming call broadcast intent |
| 524 | * @return the session object that handles the incoming call |
| 525 | */ |
Hung-ying Tyan | 08faac3 | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 526 | public SipSession getSessionFor(Intent incomingCallIntent) |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 527 | throws SipException { |
| 528 | try { |
| 529 | String callId = getCallId(incomingCallIntent); |
Hung-ying Tyan | 08faac3 | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 530 | ISipSession s = mSipService.getPendingSession(callId); |
Masahiko Endo | 25ccbb9 | 2011-07-28 21:51:43 +0900 | [diff] [blame] | 531 | return ((s == null) ? null : new SipSession(s)); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 532 | } catch (RemoteException e) { |
| 533 | throw new SipException("getSessionFor()", e); |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | private static ISipSessionListener createRelay( |
Hung-ying Tyan | 9e1d308 | 2010-09-30 15:00:34 +0800 | [diff] [blame] | 538 | SipRegistrationListener listener, String uri) { |
| 539 | return ((listener == null) ? null : new ListenerRelay(listener, uri)); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | /** |
Hung-ying Tyan | 08faac3 | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 543 | * Creates a {@link SipSession} with the specified profile. Use other |
| 544 | * methods, if applicable, instead of interacting with {@link SipSession} |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 545 | * directly. |
| 546 | * |
| 547 | * @param localProfile the SIP profile the session is associated with |
| 548 | * @param listener to listen to SIP session events |
| 549 | */ |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 550 | public SipSession createSipSession(SipProfile localProfile, |
| 551 | SipSession.Listener listener) throws SipException { |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 552 | try { |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 553 | ISipSession s = mSipService.createSession(localProfile, null); |
Hung-ying Tyan | 8d1b2a1 | 2010-11-03 11:50:05 +0800 | [diff] [blame] | 554 | if (s == null) { |
| 555 | throw new SipException( |
| 556 | "Failed to create SipSession; network unavailable?"); |
| 557 | } |
Hung-ying Tyan | 84a357b | 2010-09-16 04:11:32 +0800 | [diff] [blame] | 558 | return new SipSession(s, listener); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 559 | } catch (RemoteException e) { |
| 560 | throw new SipException("createSipSession()", e); |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | /** |
| 565 | * Gets the list of profiles hosted by the SIP service. The user information |
| 566 | * (username, password and display name) are crossed out. |
| 567 | * @hide |
| 568 | */ |
| 569 | public SipProfile[] getListOfProfiles() { |
| 570 | try { |
| 571 | return mSipService.getListOfProfiles(); |
| 572 | } catch (RemoteException e) { |
Hung-ying Tyan | 8d1b2a1 | 2010-11-03 11:50:05 +0800 | [diff] [blame] | 573 | return new SipProfile[0]; |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 574 | } |
| 575 | } |
| 576 | |
| 577 | private static class ListenerRelay extends SipSessionAdapter { |
| 578 | private SipRegistrationListener mListener; |
Hung-ying Tyan | 9e1d308 | 2010-09-30 15:00:34 +0800 | [diff] [blame] | 579 | private String mUri; |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 580 | |
| 581 | // listener must not be null |
Hung-ying Tyan | 9e1d308 | 2010-09-30 15:00:34 +0800 | [diff] [blame] | 582 | public ListenerRelay(SipRegistrationListener listener, String uri) { |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 583 | mListener = listener; |
Hung-ying Tyan | 9e1d308 | 2010-09-30 15:00:34 +0800 | [diff] [blame] | 584 | mUri = uri; |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | private String getUri(ISipSession session) { |
| 588 | try { |
Hung-ying Tyan | fb3a98b | 2010-09-30 07:49:35 +0800 | [diff] [blame] | 589 | return ((session == null) |
Hung-ying Tyan | 9e1d308 | 2010-09-30 15:00:34 +0800 | [diff] [blame] | 590 | ? mUri |
Hung-ying Tyan | fb3a98b | 2010-09-30 07:49:35 +0800 | [diff] [blame] | 591 | : session.getLocalProfile().getUriString()); |
Hung-ying Tyan | 9ea96c6 | 2010-10-03 20:35:02 +0800 | [diff] [blame] | 592 | } catch (Throwable e) { |
| 593 | // SipService died? SIP stack died? |
| 594 | Log.w(TAG, "getUri(): " + e); |
| 595 | return null; |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 596 | } |
| 597 | } |
| 598 | |
| 599 | @Override |
| 600 | public void onRegistering(ISipSession session) { |
| 601 | mListener.onRegistering(getUri(session)); |
| 602 | } |
| 603 | |
| 604 | @Override |
| 605 | public void onRegistrationDone(ISipSession session, int duration) { |
| 606 | long expiryTime = duration; |
| 607 | if (duration > 0) expiryTime += System.currentTimeMillis(); |
| 608 | mListener.onRegistrationDone(getUri(session), expiryTime); |
| 609 | } |
| 610 | |
| 611 | @Override |
Hung-ying Tyan | 9796379 | 2010-09-17 16:58:51 +0800 | [diff] [blame] | 612 | public void onRegistrationFailed(ISipSession session, int errorCode, |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 613 | String message) { |
Hung-ying Tyan | 9796379 | 2010-09-17 16:58:51 +0800 | [diff] [blame] | 614 | mListener.onRegistrationFailed(getUri(session), errorCode, message); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | @Override |
| 618 | public void onRegistrationTimeout(ISipSession session) { |
| 619 | mListener.onRegistrationFailed(getUri(session), |
Hung-ying Tyan | 99bf4e4 | 2010-09-14 20:12:59 +0800 | [diff] [blame] | 620 | SipErrorCode.TIME_OUT, "registration timed out"); |
Chung-yih Wang | 363c2ab | 2010-08-05 10:21:20 +0800 | [diff] [blame] | 621 | } |
| 622 | } |
| 623 | } |