Skip to content

Commit 1112632

Browse files
scottamainAndroid (Google) Code Review
authored andcommitted
Merge "docs: revise javadocs for sip add a package description, revise class descriptions and edit some method docs" into gingerbread
2 parents ed3c7be + 02b1d68 commit 1112632

8 files changed

Lines changed: 118 additions & 69 deletions

File tree

voip/java/android/net/sip/SipAudioCall.java

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,30 @@
3737
import java.util.Map;
3838

3939
/**
40-
* Class that handles an Internet audio call over SIP. {@link SipManager}
41-
* facilitates instantiating a {@code SipAudioCall} object for making/receiving
42-
* calls. See {@link SipManager#makeAudioCall} and
43-
* {@link SipManager#takeAudioCall}.
40+
* Handles an Internet audio call over SIP. You can instantiate this class with {@link SipManager},
41+
* using {@link SipManager#makeAudioCall makeAudioCall()} and {@link SipManager#takeAudioCall
42+
* takeAudioCall()}.
4443
*
45-
* <p>Requires permissions to use this class:
44+
* <p class="note"><strong>Note:</strong> Using this class require the
4645
* {@link android.Manifest.permission#INTERNET} and
47-
* {@link android.Manifest.permission#USE_SIP}.
48-
* <br/>Requires permissions to {@link #startAudio}:
46+
* {@link android.Manifest.permission#USE_SIP} permissions.<br/><br/>In addition, {@link
47+
* #startAudio} requires the
4948
* {@link android.Manifest.permission#RECORD_AUDIO},
50-
* {@link android.Manifest.permission#ACCESS_WIFI_STATE} and
51-
* {@link android.Manifest.permission#WAKE_LOCK}.
52-
* <br/>Requires permissions to {@link #setSpeakerMode}:
53-
* {@link android.Manifest.permission#MODIFY_AUDIO_SETTINGS}.
49+
* {@link android.Manifest.permission#ACCESS_WIFI_STATE}, and
50+
* {@link android.Manifest.permission#WAKE_LOCK} permissions; and {@link #setSpeakerMode
51+
* setSpeakerMode()} requires the
52+
* {@link android.Manifest.permission#MODIFY_AUDIO_SETTINGS} permission.</p>
5453
*/
5554
public class SipAudioCall {
5655
private static final String TAG = SipAudioCall.class.getSimpleName();
5756
private static final boolean RELEASE_SOCKET = true;
5857
private static final boolean DONT_RELEASE_SOCKET = false;
5958
private static final int SESSION_TIMEOUT = 5; // in seconds
6059

61-
/** Listener class for all event callbacks. */
60+
/** Listener for events relating to a SIP call, such as when a call is being
61+
* recieved ("on ringing") or a call is outgoing ("on calling").
62+
* <p>Many of these events are also received by {@link SipSession.Listener}.</p>
63+
*/
6264
public static class Listener {
6365
/**
6466
* Called when the call object is ready to make another call.
@@ -199,7 +201,7 @@ public SipAudioCall(Context context, SipProfile localProfile) {
199201

200202
/**
201203
* Sets the listener to listen to the audio call events. The method calls
202-
* {@code setListener(listener, false)}.
204+
* {@link #setListener setListener(listener, false)}.
203205
*
204206
* @param listener to listen to the audio call events of this object
205207
* @see #setListener(Listener, boolean)
@@ -537,14 +539,14 @@ public void attachCall(SipSession session, String sessionDescription)
537539
/**
538540
* Initiates an audio call to the specified profile. The attempt will be
539541
* timed out if the call is not established within {@code timeout} seconds
540-
* and {@code Listener.onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
542+
* and {@link Listener#onError onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
541543
* will be called.
542544
*
543545
* @param peerProfile the SIP profile to make the call to
544546
* @param sipSession the {@link SipSession} for carrying out the call
545547
* @param timeout the timeout value in seconds. Default value (defined by
546548
* SIP protocol) is used if {@code timeout} is zero or negative.
547-
* @see Listener.onError
549+
* @see Listener#onError
548550
* @throws SipException if the SIP service fails to create a session for the
549551
* call
550552
*/
@@ -582,12 +584,12 @@ public void endCall() throws SipException {
582584
* Puts a call on hold. When succeeds, {@link Listener#onCallHeld} is
583585
* called. The attempt will be timed out if the call is not established
584586
* within {@code timeout} seconds and
585-
* {@code Listener.onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
587+
* {@link Listener#onError onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
586588
* will be called.
587589
*
588590
* @param timeout the timeout value in seconds. Default value (defined by
589591
* SIP protocol) is used if {@code timeout} is zero or negative.
590-
* @see Listener.onError
592+
* @see Listener#onError
591593
* @throws SipException if the SIP service fails to hold the call
592594
*/
593595
public void holdCall(int timeout) throws SipException {
@@ -604,12 +606,12 @@ public void holdCall(int timeout) throws SipException {
604606
/**
605607
* Answers a call. The attempt will be timed out if the call is not
606608
* established within {@code timeout} seconds and
607-
* {@code Listener.onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
609+
* {@link Listener#onError onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
608610
* will be called.
609611
*
610612
* @param timeout the timeout value in seconds. Default value (defined by
611613
* SIP protocol) is used if {@code timeout} is zero or negative.
612-
* @see Listener.onError
614+
* @see Listener#onError
613615
* @throws SipException if the SIP service fails to answer the call
614616
*/
615617
public void answerCall(int timeout) throws SipException {
@@ -628,12 +630,12 @@ public void answerCall(int timeout) throws SipException {
628630
* Continues a call that's on hold. When succeeds,
629631
* {@link Listener#onCallEstablished} is called. The attempt will be timed
630632
* out if the call is not established within {@code timeout} seconds and
631-
* {@code Listener.onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
633+
* {@link Listener#onError onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
632634
* will be called.
633635
*
634636
* @param timeout the timeout value in seconds. Default value (defined by
635637
* SIP protocol) is used if {@code timeout} is zero or negative.
636-
* @see Listener.onError
638+
* @see Listener#onError
637639
* @throws SipException if the SIP service fails to unhold the call
638640
*/
639641
public void continueCall(int timeout) throws SipException {
@@ -786,8 +788,8 @@ public boolean isMuted() {
786788

787789
/**
788790
* Puts the device to speaker mode.
789-
* <p>Requires permission:
790-
* {@link android.Manifest.permission#MODIFY_AUDIO_SETTINGS}.
791+
* <p class="note"><strong>Note:</strong> Requires the
792+
* {@link android.Manifest.permission#MODIFY_AUDIO_SETTINGS} permission.</p>
791793
*/
792794
public void setSpeakerMode(boolean speakerMode) {
793795
synchronized (this) {
@@ -797,20 +799,21 @@ public void setSpeakerMode(boolean speakerMode) {
797799
}
798800

799801
/**
800-
* Sends a DTMF code. According to RFC2833, event 0--9 maps to decimal
802+
* Sends a DTMF code. According to <a href="http://tools.ietf.org/html/rfc2833">RFC 2883</a>,
803+
* event 0--9 maps to decimal
801804
* value 0--9, '*' to 10, '#' to 11, event 'A'--'D' to 12--15, and event
802805
* flash to 16. Currently, event flash is not supported.
803806
*
804807
* @param code the DTMF code to send. Value 0 to 15 (inclusive) are valid
805808
* inputs.
806-
* @see http://tools.ietf.org/html/rfc2833
807809
*/
808810
public void sendDtmf(int code) {
809811
sendDtmf(code, null);
810812
}
811813

812814
/**
813-
* Sends a DTMF code. According to RFC2833, event 0--9 maps to decimal
815+
* Sends a DTMF code. According to <a href="http://tools.ietf.org/html/rfc2833">RFC 2883</a>,
816+
* event 0--9 maps to decimal
814817
* value 0--9, '*' to 10, '#' to 11, event 'A'--'D' to 12--15, and event
815818
* flash to 16. Currently, event flash is not supported.
816819
*
@@ -888,10 +891,10 @@ public void setAudioGroup(AudioGroup group) {
888891
/**
889892
* Starts the audio for the established call. This method should be called
890893
* after {@link Listener#onCallEstablished} is called.
891-
* <p>Requires permission:
894+
* <p class="note"><strong>Note:</strong> Requires the
892895
* {@link android.Manifest.permission#RECORD_AUDIO},
893896
* {@link android.Manifest.permission#ACCESS_WIFI_STATE} and
894-
* {@link android.Manifest.permission#WAKE_LOCK}.
897+
* {@link android.Manifest.permission#WAKE_LOCK} permissions.</p>
895898
*/
896899
public void startAudio() {
897900
try {

voip/java/android/net/sip/SipErrorCode.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
package android.net.sip;
1818

1919
/**
20-
* Defines error code returned in
21-
* {@link SipRegistrationListener#onRegistrationFailed},
22-
* {@link SipSession.Listener#onError},
23-
* {@link SipSession.Listener#onCallChangeFailed} and
24-
* {@link SipSession.Listener#onRegistrationFailed}.
20+
* Defines error codes returned during SIP actions. For example, during
21+
* {@link SipRegistrationListener#onRegistrationFailed onRegistrationFailed()},
22+
* {@link SipSession.Listener#onError onError()},
23+
* {@link SipSession.Listener#onCallChangeFailed onCallChangeFailed()} and
24+
* {@link SipSession.Listener#onRegistrationFailed onRegistrationFailed()}.
2525
*/
2626
public class SipErrorCode {
2727
/** Not an error. */

voip/java/android/net/sip/SipException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package android.net.sip;
1818

1919
/**
20-
* General SIP-related exception class.
20+
* Indicates a general SIP-related exception.
2121
*/
2222
public class SipException extends Exception {
2323
public SipException() {

voip/java/android/net/sip/SipManager.java

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,29 @@
2929
import java.text.ParseException;
3030

3131
/**
32-
* The class provides API for various SIP related tasks. Specifically, the API
33-
* allows an application to:
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>
3436
* <ul>
35-
* <li>open a {@link SipProfile} to get ready for making outbound calls or have
36-
* the background SIP service listen to incoming calls and broadcast them
37-
* with registered command string. See
38-
* {@link #open(SipProfile, PendingIntent, SipRegistrationListener)},
39-
* {@link #open(SipProfile)}, {@link #close}, {@link #isOpened} and
40-
* {@link #isRegistered}. It also facilitates handling of the incoming call
41-
* broadcast intent. See
42-
* {@link #isIncomingCallIntent}, {@link #getCallId},
43-
* {@link #getOfferSessionDescription} and {@link #takeAudioCall}.</li>
44-
* <li>make/take SIP-based audio calls. See
45-
* {@link #makeAudioCall} and {@link #takeAudioCall}.</li>
46-
* <li>register/unregister with a SIP service provider manually. See
47-
* {@link #register} and {@link #unregister}.</li>
48-
* <li>process SIP events directly with a {@link SipSession} created by
49-
* {@link #createSipSession}.</li>
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>
5047
* </ul>
51-
* {@code SipManager} can only be instantiated if SIP API is supported by the
52-
* device. (See {@link #isApiSupported}).
53-
* <p>Requires permissions to use this class:
54-
* {@link android.Manifest.permission#INTERNET} and
55-
* {@link android.Manifest.permission#USE_SIP}.
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
52+
* the SIP APIs.<br/><br/>Your application must also request the {@link
53+
* android.Manifest.permission#INTERNET} and {@link android.Manifest.permission#USE_SIP}
54+
* permissions.</p>
5655
*/
5756
public class SipManager {
5857
/**
@@ -160,7 +159,7 @@ private void createSipService() {
160159
}
161160

162161
/**
163-
* Opens the profile for making calls. The caller may make subsequent calls
162+
* Opens the profile for making generic SIP calls. The caller may make subsequent calls
164163
* through {@link #makeAudioCall}. If one also wants to receive calls on the
165164
* profile, use
166165
* {@link #open(SipProfile, PendingIntent, SipRegistrationListener)}
@@ -179,7 +178,7 @@ public void open(SipProfile localProfile) throws SipException {
179178
}
180179

181180
/**
182-
* Opens the profile for making calls and/or receiving calls. The caller may
181+
* Opens the profile for making calls and/or receiving generic SIP calls. The caller may
183182
* make subsequent calls through {@link #makeAudioCall}. If the
184183
* auto-registration option is enabled in the profile, the SIP service
185184
* will register the profile to the corresponding SIP provider periodically
@@ -296,7 +295,7 @@ public boolean isRegistered(String localProfileUri) throws SipException {
296295
/**
297296
* Creates a {@link SipAudioCall} to make a call. The attempt will be timed
298297
* out if the call is not established within {@code timeout} seconds and
299-
* {@code SipAudioCall.Listener.onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
298+
* {@link SipAudioCall.Listener#onError onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
300299
* will be called.
301300
*
302301
* @param localProfile the SIP profile to make the call from
@@ -307,7 +306,7 @@ public boolean isRegistered(String localProfileUri) throws SipException {
307306
* SIP protocol) is used if {@code timeout} is zero or negative.
308307
* @return a {@link SipAudioCall} object
309308
* @throws SipException if calling the SIP service results in an error
310-
* @see SipAudioCall.Listener.onError
309+
* @see SipAudioCall.Listener#onError
311310
*/
312311
public SipAudioCall makeAudioCall(SipProfile localProfile,
313312
SipProfile peerProfile, SipAudioCall.Listener listener, int timeout)
@@ -327,7 +326,7 @@ public SipAudioCall makeAudioCall(SipProfile localProfile,
327326
* Creates a {@link SipAudioCall} to make an audio call. The attempt will be
328327
* timed out if the call is not established within {@code timeout} seconds
329328
* and
330-
* {@code SipAudioCall.Listener.onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
329+
* {@link SipAudioCall.Listener#onError onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
331330
* will be called.
332331
*
333332
* @param localProfileUri URI of the SIP profile to make the call from
@@ -338,7 +337,7 @@ public SipAudioCall makeAudioCall(SipProfile localProfile,
338337
* SIP protocol) is used if {@code timeout} is zero or negative.
339338
* @return a {@link SipAudioCall} object
340339
* @throws SipException if calling the SIP service results in an error
341-
* @see SipAudioCall.Listener.onError
340+
* @see SipAudioCall.Listener#onError
342341
*/
343342
public SipAudioCall makeAudioCall(String localProfileUri,
344343
String peerProfileUri, SipAudioCall.Listener listener, int timeout)
@@ -449,7 +448,7 @@ public static Intent createIncomingCallBroadcast(String callId,
449448
* receiving calls.
450449
* {@link #open(SipProfile, PendingIntent, SipRegistrationListener)} is
451450
* still needed to be called at least once in order for the SIP service to
452-
* notify the caller with the {@code PendingIntent} when an incoming call is
451+
* notify the caller with the {@link android.app.PendingIntent} when an incoming call is
453452
* received.
454453
*
455454
* @param localProfile the SIP profile to register with

voip/java/android/net/sip/SipProfile.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
import javax.sip.address.URI;
3333

3434
/**
35-
* Class containing a SIP account, domain and server information.
35+
* Defines a SIP profile, including a SIP account, domain and server information.
36+
* <p>You can create a {@link SipProfile} using {@link
37+
* SipProfile.Builder}. You can also retrieve one from a {@link SipSession}, using {@link
38+
* SipSession#getLocalProfile} and {@link SipSession#getPeerProfile}.</p>
3639
*/
3740
public class SipProfile implements Parcelable, Serializable, Cloneable {
3841
private static final long serialVersionUID = 1L;
@@ -59,7 +62,7 @@ public SipProfile[] newArray(int size) {
5962
};
6063

6164
/**
62-
* Class to help create a {@code SipProfile}.
65+
* Helper class for creating a {@link SipProfile}.
6366
*/
6467
public static class Builder {
6568
private AddressFactory mAddressFactory;

voip/java/android/net/sip/SipRegistrationListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package android.net.sip;
1818

1919
/**
20-
* Listener class to listen to SIP registration events.
20+
* Listener for SIP registration events.
2121
*/
2222
public interface SipRegistrationListener {
2323
/**

voip/java/android/net/sip/SipSession.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@
2020
import android.util.Log;
2121

2222
/**
23-
* A SIP session that is associated with a SIP dialog or a standalone
23+
* Represents a SIP session that is associated with a SIP dialog or a standalone
2424
* transaction not within a dialog.
25+
* <p>You can get a {@link SipSession} from {@link SipManager} with {@link
26+
* SipManager#createSipSession createSipSession()} (when initiating calls) or {@link
27+
* SipManager#getSessionFor getSessionFor()} (when receiving calls).</p>
2528
*/
2629
public final class SipSession {
2730
private static final String TAG = "SipSession";
2831

2932
/**
30-
* Defines {@link SipSession} states.
33+
* Defines SIP session states, such as "registering", "outgoing call", and "in call".
3134
*/
3235
public static class State {
3336
/** When session is ready to initiate a call or transaction. */
@@ -98,7 +101,9 @@ private State() {
98101
}
99102

100103
/**
101-
* Listener class that listens to {@link SipSession} events.
104+
* Listener for events relating to a SIP session, such as when a session is being registered
105+
* ("on registering") or a call is outgoing ("on calling").
106+
* <p>Many of these events are also received by {@link SipAudioCall.Listener}.</p>
102107
*/
103108
public static class Listener {
104109
/**

0 commit comments

Comments
 (0)