Merge "[NAN] Remove failure reason codes from API per API review"

This commit is contained in:
Etan Cohen
2016-09-26 14:48:48 +00:00
committed by Gerrit Code Review
7 changed files with 31 additions and 110 deletions

View File

@@ -16,11 +16,6 @@
package android.net.wifi.nan; package android.net.wifi.nan;
import android.annotation.IntDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/** /**
* Base class for NAN attach callbacks. Should be extended by applications and set when calling * Base class for NAN attach callbacks. Should be extended by applications and set when calling
* {@link WifiNanManager#attach(android.os.Handler, WifiNanAttachCallback)}. These are callbacks * {@link WifiNanManager#attach(android.os.Handler, WifiNanAttachCallback)}. These are callbacks
@@ -30,34 +25,6 @@ import java.lang.annotation.RetentionPolicy;
* @hide PROPOSED_NAN_API * @hide PROPOSED_NAN_API
*/ */
public class WifiNanAttachCallback { public class WifiNanAttachCallback {
/** @hide */
@IntDef({
REASON_INVALID_ARGS, REASON_ALREADY_CONNECTED_INCOMPAT_CONFIG, REASON_OTHER
})
@Retention(RetentionPolicy.SOURCE)
public @interface EventReasonCodes {
}
/**
* Indicates invalid argument in the requested operation. Failure reason flag for
* {@link WifiNanAttachCallback#onAttachFailed(int)}.
*/
public static final int REASON_INVALID_ARGS = 1000;
/**
* Indicates that a {@link ConfigRequest} passed in
* {@code WifiNanManager#attach(android.os.Handler, ConfigRequest, WifiNanAttachCallback)}
* couldn't be applied since other connections already exist with an incompatible
* configurations. Failure reason flag for {@link WifiNanAttachCallback#onAttachFailed(int)}.
*/
public static final int REASON_ALREADY_CONNECTED_INCOMPAT_CONFIG = 1001;
/**
* Indicates an unspecified error occurred during the operation. Failure reason flag for
* {@link WifiNanAttachCallback#onAttachFailed(int)}.
*/
public static final int REASON_OTHER = 1002;
/** /**
* Called when NAN attach operation * Called when NAN attach operation
* {@link WifiNanManager#attach(android.os.Handler, WifiNanAttachCallback)} * {@link WifiNanManager#attach(android.os.Handler, WifiNanAttachCallback)}
@@ -73,11 +40,8 @@ public class WifiNanAttachCallback {
/** /**
* Called when NAN attach operation * Called when NAN attach operation
* {@link WifiNanManager#attach(android.os.Handler, WifiNanAttachCallback)} failed. * {@link WifiNanManager#attach(android.os.Handler, WifiNanAttachCallback)} failed.
*
* @param reason Failure reason code, see
* {@code WifiNanEventCallback.REASON_*}.
*/ */
public void onAttachFailed(@EventReasonCodes int reason) { public void onAttachFailed() {
/* empty */ /* empty */
} }
} }

View File

@@ -144,7 +144,7 @@ public class WifiNanDiscoveryBaseSession {
* {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully, * {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully,
* {@link WifiNanDiscoverySessionCallback#onMessageSent(int)}, or transmission failed * {@link WifiNanDiscoverySessionCallback#onMessageSent(int)}, or transmission failed
* (possibly after several retries) - * (possibly after several retries) -
* {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int, int)}. * {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int)}.
* <p> * <p>
* The peer will get a callback indicating a message was received using * The peer will get a callback indicating a message was received using
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}. * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}.
@@ -187,7 +187,7 @@ public class WifiNanDiscoveryBaseSession {
* {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully, * {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully,
* {@link WifiNanDiscoverySessionCallback#onMessageSent(int)}, or transmission failed * {@link WifiNanDiscoverySessionCallback#onMessageSent(int)}, or transmission failed
* (possibly after several retries) - * (possibly after several retries) -
* {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int, int)}. * {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int)}.
* <p> * <p>
* The peer will get a callback indicating a message was received using * The peer will get a callback indicating a message was received using
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}. * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}.

View File

@@ -26,22 +26,15 @@ import java.lang.annotation.RetentionPolicy;
* Base class for NAN session events callbacks. Should be extended by * Base class for NAN session events callbacks. Should be extended by
* applications wanting notifications. The callbacks are set when a * applications wanting notifications. The callbacks are set when a
* publish or subscribe session is created using * publish or subscribe session is created using
* {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or * {@link WifiNanSession#publish(android.os.Handler, PublishConfig, WifiNanDiscoverySessionCallback)}
* {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} . * or
* {@link WifiNanSession#subscribe(android.os.Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)} .
* <p> * <p>
* A single callback is set at session creation - it cannot be replaced. * A single callback is set at session creation - it cannot be replaced.
* *
* @hide PROPOSED_NAN_API * @hide PROPOSED_NAN_API
*/ */
public class WifiNanDiscoverySessionCallback { public class WifiNanDiscoverySessionCallback {
/** @hide */
@IntDef({
REASON_NO_RESOURCES, REASON_INVALID_ARGS, REASON_NO_MATCH_SESSION,
REASON_TX_FAIL, REASON_OTHER })
@Retention(RetentionPolicy.SOURCE)
public @interface SessionReasonCodes {
}
/** @hide */ /** @hide */
@IntDef({ @IntDef({
TERMINATE_REASON_DONE, TERMINATE_REASON_FAIL }) TERMINATE_REASON_DONE, TERMINATE_REASON_FAIL })
@@ -49,39 +42,6 @@ public class WifiNanDiscoverySessionCallback {
public @interface SessionTerminateCodes { public @interface SessionTerminateCodes {
} }
/**
* Indicates no resources to execute the requested operation.
* Failure reason flag for {@link WifiNanDiscoverySessionCallback} callbacks.
*/
public static final int REASON_NO_RESOURCES = 0;
/**
* Indicates invalid argument in the requested operation.
* Failure reason flag for {@link WifiNanDiscoverySessionCallback} callbacks.
*/
public static final int REASON_INVALID_ARGS = 1;
/**
* Indicates a message is transmitted without a match (a discovery) or received message
* from peer occurring first.
* Failure reason flag for {@link WifiNanDiscoverySessionCallback} callbacks.
*/
public static final int REASON_NO_MATCH_SESSION = 2;
/**
* Indicates transmission failure: this may be due to local transmission
* failure or to no ACK received - remote device didn't receive the
* sent message. Failure reason flag for
* {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int, int)} callback.
*/
public static final int REASON_TX_FAIL = 3;
/**
* Indicates an unspecified error occurred during the operation.
* Failure reason flag for {@link WifiNanDiscoverySessionCallback} callbacks.
*/
public static final int REASON_OTHER = 4;
/** /**
* Indicates that publish or subscribe session is done - all the * Indicates that publish or subscribe session is done - all the
* requested operations (per {@link PublishConfig} or * requested operations (per {@link PublishConfig} or
@@ -100,7 +60,8 @@ public class WifiNanDiscoverySessionCallback {
/** /**
* Called when a publish operation is started successfully in response to a * Called when a publish operation is started successfully in response to a
* {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} operation. * {@link WifiNanSession#publish(android.os.Handler, PublishConfig, WifiNanDiscoverySessionCallback)}
* operation.
* *
* @param session The {@link WifiNanPublishDiscoverySession} used to control the * @param session The {@link WifiNanPublishDiscoverySession} used to control the
* discovery session. * discovery session.
@@ -111,7 +72,8 @@ public class WifiNanDiscoverySessionCallback {
/** /**
* Called when a subscribe operation is started successfully in response to a * Called when a subscribe operation is started successfully in response to a
* {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} operation. * {@link WifiNanSession#subscribe(android.os.Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)}
* operation.
* *
* @param session The {@link WifiNanSubscribeDiscoverySession} used to control the * @param session The {@link WifiNanSubscribeDiscoverySession} used to control the
* discovery session. * discovery session.
@@ -132,19 +94,17 @@ public class WifiNanDiscoverySessionCallback {
/** /**
* Called when a publish or subscribe discovery session cannot be created: * Called when a publish or subscribe discovery session cannot be created:
* {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or * {@link WifiNanSession#publish(android.os.Handler, PublishConfig, WifiNanDiscoverySessionCallback)}
* {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)}, * or
* {@link WifiNanSession#subscribe(android.os.Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)},
* or when a configuration update fails: * or when a configuration update fails:
* {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} or * {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} or
* {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. * {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
* <p> * <p>
* For discovery session updates failure leaves the session running with its previous * For discovery session updates failure leaves the session running with its previous
* configuration - the discovery session is not terminated. * configuration - the discovery session is not terminated.
*
* @param reason The failure reason using
* {@code WifiNanDiscoverySessionCallback.REASON_*} codes.
*/ */
public void onSessionConfigFailed(@SessionReasonCodes int reason) { public void onSessionConfigFailed() {
/* empty */ /* empty */
} }
@@ -177,12 +137,12 @@ public class WifiNanDiscoverySessionCallback {
} }
/** /**
* Called in response to {@link WifiNanDiscoveryBaseSession#sendMessage(int, byte[], int)} * Called in response to {@link WifiNanDiscoveryBaseSession#sendMessage(int, int, byte[])}
* when a message is transmitted successfully - i.e. when it was received successfully by the * when a message is transmitted successfully - i.e. when it was received successfully by the
* peer (corresponds to an ACK being received). * peer (corresponds to an ACK being received).
* <p> * <p>
* Note that either this callback or * Note that either this callback or
* {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int, int)} will be * {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int)} will be
* received - never both. * received - never both.
* *
* @param messageId The arbitrary message ID specified when sending the message. * @param messageId The arbitrary message ID specified when sending the message.
@@ -194,7 +154,7 @@ public class WifiNanDiscoverySessionCallback {
/** /**
* Called when message transmission fails - when no ACK is received from the peer. * Called when message transmission fails - when no ACK is received from the peer.
* Retries when ACKs are not received are done by hardware, MAC, and in the NAN stack (using * Retries when ACKs are not received are done by hardware, MAC, and in the NAN stack (using
* the {@link WifiNanDiscoveryBaseSession#sendMessage(int, byte[], int, int)} method) - this * the {@link WifiNanDiscoveryBaseSession#sendMessage(int, int, byte[], int)} method) - this
* event is received after all retries are exhausted. * event is received after all retries are exhausted.
* <p> * <p>
* Note that either this callback or * Note that either this callback or
@@ -202,18 +162,15 @@ public class WifiNanDiscoverySessionCallback {
* - never both. * - never both.
* *
* @param messageId The arbitrary message ID specified when sending the message. * @param messageId The arbitrary message ID specified when sending the message.
* @param reason The failure reason using
* {@code WifiNanDiscoverySessionCallback.REASON_*} codes.
*/ */
public void onMessageSendFailed(@SuppressWarnings("unused") int messageId, public void onMessageSendFailed(@SuppressWarnings("unused") int messageId) {
@SessionReasonCodes int reason) {
/* empty */ /* empty */
} }
/** /**
* Called when a message is received from a discovery session peer - in response to the * Called when a message is received from a discovery session peer - in response to the
* peer's {@link WifiNanDiscoveryBaseSession#sendMessage(int, byte[], int)} or * peer's {@link WifiNanDiscoveryBaseSession#sendMessage(int, int, byte[])} or
* {@link WifiNanDiscoveryBaseSession#sendMessage(int, byte[], int, int)}. * {@link WifiNanDiscoveryBaseSession#sendMessage(int, int, byte[], int)}.
* *
* @param peerId The ID of the peer sending the message. * @param peerId The ID of the peer sending the message.
* @param message A byte array containing the message. * @param message A byte array containing the message.

View File

@@ -700,7 +700,7 @@ public class WifiNanManager {
break; break;
case CALLBACK_CONNECT_FAIL: case CALLBACK_CONNECT_FAIL:
mNanManager.clear(); mNanManager.clear();
attachCallback.onAttachFailed(msg.arg1); attachCallback.onAttachFailed();
break; break;
case CALLBACK_IDENTITY_CHANGED: case CALLBACK_IDENTITY_CHANGED:
identityChangedListener.onIdentityChanged((byte[]) msg.obj); identityChangedListener.onIdentityChanged((byte[]) msg.obj);
@@ -857,7 +857,7 @@ public class WifiNanManager {
mOriginalCallback.onSessionConfigUpdated(); mOriginalCallback.onSessionConfigUpdated();
break; break;
case CALLBACK_SESSION_CONFIG_FAIL: case CALLBACK_SESSION_CONFIG_FAIL:
mOriginalCallback.onSessionConfigFailed(msg.arg1); mOriginalCallback.onSessionConfigFailed();
if (mSession == null) { if (mSession == null) {
/* /*
* creation failed (as opposed to update * creation failed (as opposed to update
@@ -879,7 +879,7 @@ public class WifiNanManager {
mOriginalCallback.onMessageSent(msg.arg1); mOriginalCallback.onMessageSent(msg.arg1);
break; break;
case CALLBACK_MESSAGE_SEND_FAIL: case CALLBACK_MESSAGE_SEND_FAIL:
mOriginalCallback.onMessageSendFailed(msg.arg1, msg.arg2); mOriginalCallback.onMessageSendFailed(msg.arg1);
break; break;
case CALLBACK_MESSAGE_RECEIVED: case CALLBACK_MESSAGE_RECEIVED:
mOriginalCallback.onMessageReceived(msg.arg1, (byte[]) msg.obj); mOriginalCallback.onMessageReceived(msg.arg1, (byte[]) msg.obj);

View File

@@ -21,8 +21,8 @@ import android.util.Log;
/** /**
* A class representing a NAN publish session. Created when * A class representing a NAN publish session. Created when
* {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} is called and a * {@link WifiNanSession#publish(android.os.Handler, PublishConfig, WifiNanDiscoverySessionCallback)}
* discovery session is created and returned in * is called and a discovery session is created and returned in
* {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}. See * {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}. See
* baseline functionality of all discovery sessions in {@link WifiNanDiscoveryBaseSession}. This * baseline functionality of all discovery sessions in {@link WifiNanDiscoveryBaseSession}. This
* object allows updating an existing/running publish discovery session using * object allows updating an existing/running publish discovery session using
@@ -46,7 +46,7 @@ public class WifiNanPublishDiscoverySession extends WifiNanDiscoveryBaseSession
* <ul> * <ul>
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigUpdated()}: configuration * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigUpdated()}: configuration
* update succeeded. * update succeeded.
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed(int)}: configuration * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed()}: configuration
* update failed. The publish discovery session is still running using its previous * update failed. The publish discovery session is still running using its previous
* configuration (i.e. update failure does not terminate the session). * configuration (i.e. update failure does not terminate the session).
* </ul> * </ul>

View File

@@ -101,7 +101,7 @@ public class WifiNanSession {
* <li>{@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)} * <li>{@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}
* is called when the publish session is created and provides a handle to the session. * is called when the publish session is created and provides a handle to the session.
* Further operations on the publish session can be executed on that object. * Further operations on the publish session can be executed on that object.
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed(int)} is called if the * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed()} is called if the
* publish operation failed. * publish operation failed.
* </ul> * </ul>
* <p> * <p>
@@ -143,7 +143,7 @@ public class WifiNanSession {
* <li>{@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)} * <li>{@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}
* is called when the subscribe session is created and provides a handle to the session. * is called when the subscribe session is created and provides a handle to the session.
* Further operations on the subscribe session can be executed on that object. * Further operations on the subscribe session can be executed on that object.
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed(int)} is called if the * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed()} is called if the
* subscribe operation failed. * subscribe operation failed.
* </ul> * </ul>
* <p> * <p>

View File

@@ -21,8 +21,8 @@ import android.util.Log;
/** /**
* A class representing a NAN subscribe session. Created when * A class representing a NAN subscribe session. Created when
* {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} is called * {@link WifiNanSession#subscribe(android.os.Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)}
* and a discovery session is created and returned in * is called and a discovery session is created and returned in
* {@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}. * {@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}.
* See baseline functionality of all discovery sessions in {@link WifiNanDiscoveryBaseSession}. * See baseline functionality of all discovery sessions in {@link WifiNanDiscoveryBaseSession}.
* This object allows updating an existing/running subscribe discovery session using * This object allows updating an existing/running subscribe discovery session using
@@ -48,7 +48,7 @@ public class WifiNanSubscribeDiscoverySession extends WifiNanDiscoveryBaseSessio
* <ul> * <ul>
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigUpdated()}: configuration * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigUpdated()}: configuration
* update succeeded. * update succeeded.
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed(int)}: configuration * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed()}: configuration
* update failed. The subscribe discovery session is still running using its previous * update failed. The subscribe discovery session is still running using its previous
* configuration (i.e. update failure does not terminate the session). * configuration (i.e. update failure does not terminate the session).
* </ul> * </ul>