OSDN Git Service

[NAN] API changes/fixes addressing apilint issues
authorEtan Cohen <etancohen@google.com>
Mon, 22 Aug 2016 18:27:57 +0000 (11:27 -0700)
committerEtan Cohen <etancohen@google.com>
Tue, 23 Aug 2016 00:30:07 +0000 (17:30 -0700)
Bug: 30983968
Change-Id: I2189442755380ad5d04f80bcb5978ca0c28e6420

wifi/java/android/net/wifi/nan/ConfigRequest.java
wifi/java/android/net/wifi/nan/WifiNanEventCallback.java
wifi/java/android/net/wifi/nan/WifiNanManager.java
wifi/java/android/net/wifi/nan/WifiNanSession.java

index 55e568a..44544de 100644 (file)
@@ -23,7 +23,7 @@ import android.os.Parcelable;
 /**
  * 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.
index 7dd879e..6e714f1 100644 (file)
@@ -46,7 +46,7 @@ public class WifiNanEventCallback {
 
     /**
      * 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 @@ public class WifiNanEventCallback {
      * <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.
      *
index a0d5987..ceb8ca7 100644 (file)
@@ -73,7 +73,7 @@ import java.util.Arrays;
  * <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 @@ public class WifiNanManager {
      * @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 @@ public class WifiNanManager {
      * @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 @@ public class WifiNanManager {
 
     /**
      * 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 @@ public class WifiNanManager {
 
     /**
      * 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 @@ public class WifiNanManager {
 
     /**
      * 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).
@@ -350,7 +351,7 @@ public class WifiNanManager {
      * @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);
     }
 
     /**
@@ -369,11 +370,11 @@ public class WifiNanManager {
      * @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);
index 5c118b5..005ca29 100644 (file)
@@ -46,11 +46,7 @@ public class WifiNanSession {
     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 @@ public class WifiNanSession {
 
     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 @@ public class WifiNanSession {
      * @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) {