/**
* Indicates that a {@link ConfigRequest} passed in
- * {@link WifiNanManager#connect(android.os.Looper, WifiNanEventCallback, ConfigRequest)}
+ * {@link WifiNanManager#connect(android.os.Looper, ConfigRequest, WifiNanEventCallback)}
* couldn't be applied since other connections already exist with an incompatible
* configurations. Failure reason flag for {@link WifiNanEventCallback#onConnectFail(int)}.
*/
* <p>
* This callback is only called if the NAN connection enables it using
* {@link ConfigRequest.Builder#setEnableIdentityChangeCallback(boolean)} in
- * {@link WifiNanManager#connect(android.os.Looper, WifiNanEventCallback, ConfigRequest)}
+ * {@link WifiNanManager#connect(android.os.Looper, ConfigRequest, WifiNanEventCallback)}
* . It is disabled by default since it may result in additional wake-ups of the host -
* increasing power.
*
* <p>
* NAN may not be usable when Wi-Fi is disabled (and other conditions). To validate that
* the functionality is available use the {@link #isUsageEnabled()} function. To track
- * changes in NAN usability register for the {@link #WIFI_NAN_STATE_CHANGED_ACTION} broadcast.
+ * changes in NAN usability register for the {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast.
* Note that this broadcast is not sticky - you should register for it and then check the
* above API to avoid a race condition.
* <p>
* @see #EXTRA_WIFI_STATE
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String WIFI_NAN_STATE_CHANGED_ACTION = "android.net.wifi.nan.STATE_CHANGED";
+ public static final String ACTION_WIFI_NAN_STATE_CHANGED =
+ "android.net.wifi.nan.action.WIFI_NAN_STATE_CHANGED";
/**
* The lookup key for an int value indicating whether Wi-Fi NAN is enabled or
* @see #WIFI_NAN_STATE_DISABLED
* @see #WIFI_NAN_STATE_ENABLED
*/
- public static final String EXTRA_WIFI_STATE = "wifi_nan_state";
+ public static final String EXTRA_WIFI_STATE = "android.net.wifi.nan.extra.WIFI_STATE";
/**
* Wi-Fi NAN is disabled.
*
- * @see #WIFI_NAN_STATE_CHANGED_ACTION
+ * @see #ACTION_WIFI_NAN_STATE_CHANGED
*/
public static final int WIFI_NAN_STATE_DISABLED = 1;
/**
* Wi-Fi NAN is enabled.
*
- * @see #WIFI_NAN_STATE_CHANGED_ACTION
+ * @see #ACTION_WIFI_NAN_STATE_CHANGED
*/
public static final int WIFI_NAN_STATE_ENABLED = 2;
/**
* Enable the usage of the NAN API. Doesn't actually turn on NAN cluster formation - that only
- * happens when a connection is made. {@link #WIFI_NAN_STATE_CHANGED_ACTION} broadcast will be
+ * happens when a connection is made. {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast will be
* triggered.
*
* @hide
/**
* Disable the usage of the NAN API. All attempts to connect() will be rejected. All open
- * connections and sessions will be terminated. {@link #WIFI_NAN_STATE_CHANGED_ACTION} broadcast
+ * connections and sessions will be terminated. {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast
* will be triggered.
*
* @hide
/**
* Returns the current status of NAN API: whether or not usage is enabled. To track changes
- * in the state of NAN API register for the {@link #WIFI_NAN_STATE_CHANGED_ACTION} broadcast.
+ * in the state of NAN API register for the {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast.
*
* @return A boolean indicating whether the app can use the NAN API (true)
* or not (false).
* @param callback A callback extended from {@link WifiNanEventCallback}.
*/
public void connect(@NonNull Looper looper, @NonNull WifiNanEventCallback callback) {
- connect(looper, callback, null);
+ connect(looper, null, callback);
}
/**
* @param looper The Looper on which to execute all callbacks related to the
* connection - including all sessions opened as part of this
* connection.
- * @param callback A callback extended from {@link WifiNanEventCallback}.
* @param configRequest The requested NAN configuration.
+ * @param callback A callback extended from {@link WifiNanEventCallback}.
*/
- public void connect(@NonNull Looper looper, @NonNull WifiNanEventCallback callback,
- @Nullable ConfigRequest configRequest) {
+ public void connect(@NonNull Looper looper, @Nullable ConfigRequest configRequest,
+ @NonNull WifiNanEventCallback callback) {
if (VDBG) {
Log.v(TAG, "connect(): looper=" + looper + ", callback=" + callback + ", configRequest="
+ configRequest);
private static final boolean DBG = false;
private static final boolean VDBG = false; // STOPSHIP if true
- /**
- * The maximum permitted retry count when sending messages using
- * {@link #sendMessage(int, byte[], int, int)}.
- */
- public static final int MAX_SEND_RETRY_COUNT = 5;
+ private static final int MAX_SEND_RETRY_COUNT = 5;
/** @hide */
protected WeakReference<WifiNanManager> mMgr;
private final CloseGuard mCloseGuard = CloseGuard.get();
+ /**
+ * Return the maximum permitted retry count when sending messages using
+ * {@link #sendMessage(int, byte[], int, int)}.
+ *
+ * @return Maximum retry count when sending messages.
+ */
+ public static int getMaxSendRetryCount() {
+ return MAX_SEND_RETRY_COUNT;
+ }
+
/** @hide */
public WifiNanSession(WifiNanManager manager, int sessionId) {
if (VDBG) Log.v(TAG, "New client created: manager=" + manager + ", sessionId=" + sessionId);
* @param retryCount An integer specifying how many additional service-level (as opposed to PHY
* or MAC level) retries should be attempted if there is no ACK from the receiver
* (note: no retransmissions are attempted in other failure cases). A value of 0
- * indicates no retries. Max permitted value is {@link #MAX_SEND_RETRY_COUNT}.
+ * indicates no retries. Max permitted value is {@link #getMaxSendRetryCount()}.
*/
public void sendMessage(int peerId, @Nullable byte[] message, int messageId, int retryCount) {
if (mTerminated) {