[NAN] API changes/fixes addressing apilint issues
Bug: 30983968
Change-Id: I2189442755380ad5d04f80bcb5978ca0c28e6420
(cherry picked from commit 9825309424cab3a3efabac0bde79b3c1419f9be9)
diff --git a/wifi/java/android/net/wifi/nan/ConfigRequest.java b/wifi/java/android/net/wifi/nan/ConfigRequest.java
index 55e568a..44544de 100644
--- a/wifi/java/android/net/wifi/nan/ConfigRequest.java
+++ b/wifi/java/android/net/wifi/nan/ConfigRequest.java
@@ -23,7 +23,7 @@
/**
* Defines a request object to configure a Wi-Fi NAN network. Built using
* {@link ConfigRequest.Builder}. Configuration is requested using
- * {@link WifiNanManager#connect(android.os.Looper, WifiNanEventCallback, ConfigRequest)}.
+ * {@link WifiNanManager#connect(android.os.Looper, ConfigRequest, WifiNanEventCallback)}.
* Note that the actual achieved configuration may be different from the
* requested configuration - since different applications may request different
* configurations.
diff --git a/wifi/java/android/net/wifi/nan/WifiNanEventCallback.java b/wifi/java/android/net/wifi/nan/WifiNanEventCallback.java
index 7dd879e..6e714f1 100644
--- a/wifi/java/android/net/wifi/nan/WifiNanEventCallback.java
+++ b/wifi/java/android/net/wifi/nan/WifiNanEventCallback.java
@@ -46,7 +46,7 @@
/**
* 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)}.
*/
@@ -91,7 +91,7 @@
* <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.
*
diff --git a/wifi/java/android/net/wifi/nan/WifiNanManager.java b/wifi/java/android/net/wifi/nan/WifiNanManager.java
index e035333..82d22bc 100644
--- a/wifi/java/android/net/wifi/nan/WifiNanManager.java
+++ b/wifi/java/android/net/wifi/nan/WifiNanManager.java
@@ -73,7 +73,7 @@
* <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>
@@ -211,7 +211,8 @@
* @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
@@ -221,19 +222,19 @@
* @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;
@@ -288,7 +289,7 @@
/**
* 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
@@ -303,7 +304,7 @@
/**
* 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
@@ -318,7 +319,7 @@
/**
* 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).
@@ -348,7 +349,7 @@
* @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);
}
/**
@@ -367,11 +368,11 @@
* @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);
diff --git a/wifi/java/android/net/wifi/nan/WifiNanSession.java b/wifi/java/android/net/wifi/nan/WifiNanSession.java
index 5c118b5..005ca29 100644
--- a/wifi/java/android/net/wifi/nan/WifiNanSession.java
+++ b/wifi/java/android/net/wifi/nan/WifiNanSession.java
@@ -46,11 +46,7 @@
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;
@@ -61,6 +57,16 @@
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);
@@ -148,7 +154,7 @@
* @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) {