summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wifi/java/android/net/wifi/nan/ConfigRequest.java2
-rw-r--r--wifi/java/android/net/wifi/nan/WifiNanEventCallback.java10
-rw-r--r--wifi/java/android/net/wifi/nan/WifiNanManager.java31
3 files changed, 22 insertions, 21 deletions
diff --git a/wifi/java/android/net/wifi/nan/ConfigRequest.java b/wifi/java/android/net/wifi/nan/ConfigRequest.java
index 5d41579ed665..78e40526ba5b 100644
--- a/wifi/java/android/net/wifi/nan/ConfigRequest.java
+++ b/wifi/java/android/net/wifi/nan/ConfigRequest.java
@@ -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, ConfigRequest, WifiNanEventCallback)}.
+ * {@link WifiNanManager#connect(android.os.Handler, 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 6e714f14ee63..029e36a41be6 100644
--- a/wifi/java/android/net/wifi/nan/WifiNanEventCallback.java
+++ b/wifi/java/android/net/wifi/nan/WifiNanEventCallback.java
@@ -23,7 +23,7 @@ import java.lang.annotation.RetentionPolicy;
/**
* Base class for NAN events callbacks. Should be extended by applications and set when calling
- * {@link WifiNanManager#connect(android.os.Looper, WifiNanEventCallback)}. These are callbacks
+ * {@link WifiNanManager#connect(android.os.Handler, WifiNanEventCallback)}. These are callbacks
* applying to the NAN connection as a whole - not to specific publish or subscribe sessions -
* for that see {@link WifiNanSessionCallback}.
*
@@ -46,7 +46,7 @@ public class WifiNanEventCallback {
/**
* Indicates that a {@link ConfigRequest} passed in
- * {@link WifiNanManager#connect(android.os.Looper, ConfigRequest, WifiNanEventCallback)}
+ * {@link WifiNanManager#connect(android.os.Handler, ConfigRequest, WifiNanEventCallback)}
* couldn't be applied since other connections already exist with an incompatible
* configurations. Failure reason flag for {@link WifiNanEventCallback#onConnectFail(int)}.
*/
@@ -60,7 +60,7 @@ public class WifiNanEventCallback {
/**
* Called when NAN connect operation
- * {@link WifiNanManager#connect(android.os.Looper, WifiNanEventCallback)}
+ * {@link WifiNanManager#connect(android.os.Handler, WifiNanEventCallback)}
* is completed and that we can now start discovery sessions or connections.
*/
public void onConnectSuccess() {
@@ -69,7 +69,7 @@ public class WifiNanEventCallback {
/**
* Called when NAN connect operation
- * {@link WifiNanManager#connect(android.os.Looper, WifiNanEventCallback)} failed.
+ * {@link WifiNanManager#connect(android.os.Handler, WifiNanEventCallback)} failed.
*
* @param reason Failure reason code, see
* {@code WifiNanEventCallback.REASON_*}.
@@ -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, ConfigRequest, WifiNanEventCallback)}
+ * {@link WifiNanManager#connect(android.os.Handler, 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 82d22bce4328..24ee640a63df 100644
--- a/wifi/java/android/net/wifi/nan/WifiNanManager.java
+++ b/wifi/java/android/net/wifi/nan/WifiNanManager.java
@@ -60,7 +60,7 @@ import java.util.Arrays;
* The class provides access to:
* <ul>
* <li>Initialize a NAN cluster (peer-to-peer synchronization). Refer to
- * {@link #connect(Looper, WifiNanEventCallback)}.
+ * {@link #connect(Handler, WifiNanEventCallback)}.
* <li>Create discovery sessions (publish or subscribe sessions).
* Refer to {@link #publish(PublishConfig, WifiNanSessionCallback)} and
* {@link #subscribe(SubscribeConfig, WifiNanSessionCallback)}.
@@ -77,7 +77,7 @@ import java.util.Arrays;
* Note that this broadcast is not sticky - you should register for it and then check the
* above API to avoid a race condition.
* <p>
- * An application must use {@link #connect(Looper, WifiNanEventCallback)} to initialize a NAN
+ * An application must use {@link #connect(Handler, WifiNanEventCallback)} to initialize a NAN
* cluster - before making any other NAN operation. NAN cluster membership is a device-wide
* operation - the API guarantees that the device is in a cluster or joins a NAN cluster (or
* starts one if none can be found). Information about connection success (or failure) are
@@ -343,13 +343,13 @@ public class WifiNanManager {
* Note: a NAN cluster is a shared resource - if the device is already connected to a cluster
* than this function will simply indicate success immediately.
*
- * @param looper The Looper on which to execute all callbacks related to the
+ * @param handler The Handler on whose thread to execute all callbacks related to the
* connection - including all sessions opened as part of this
- * connection.
+ * connection. If a null is provided then the application's main thread will be used.
* @param callback A callback extended from {@link WifiNanEventCallback}.
*/
- public void connect(@NonNull Looper looper, @NonNull WifiNanEventCallback callback) {
- connect(looper, null, callback);
+ public void connect(@Nullable Handler handler, @NonNull WifiNanEventCallback callback) {
+ connect(handler, null, callback);
}
/**
@@ -360,30 +360,31 @@ public class WifiNanManager {
* An application <b>must</b> call {@link #disconnect()} when done with the Wi-Fi NAN
* connection. Allows requesting a specific configuration using {@link ConfigRequest}. If not
* necessary (default configuration should usually work) use the
- * {@link #connect(Looper, WifiNanEventCallback)} method instead.
+ * {@link #connect(Handler, WifiNanEventCallback)} method instead.
* <p>
* Note: a NAN cluster is a shared resource - if the device is already connected to a cluster
* than this function will simply indicate success immediately.
*
- * @param looper The Looper on which to execute all callbacks related to the
+ * @param handler The Handler on whose thread to execute all callbacks related to the
* connection - including all sessions opened as part of this
- * connection.
+ * connection. If a null is provided then the application's main thread will be used.
* @param configRequest The requested NAN configuration.
* @param callback A callback extended from {@link WifiNanEventCallback}.
*/
- public void connect(@NonNull Looper looper, @Nullable ConfigRequest configRequest,
+ public void connect(@Nullable Handler handler, @Nullable ConfigRequest configRequest,
@NonNull WifiNanEventCallback callback) {
if (VDBG) {
- Log.v(TAG, "connect(): looper=" + looper + ", callback=" + callback + ", configRequest="
- + configRequest);
+ Log.v(TAG,
+ "connect(): handler=" + handler + ", callback=" + callback + ", configRequest="
+ + configRequest);
}
synchronized (mLock) {
- mLooper = looper;
+ mLooper = (handler == null) ? Looper.getMainLooper() : handler.getLooper();
try {
mClientId = mService.connect(mBinder, mContext.getOpPackageName(),
- new WifiNanEventCallbackProxy(this, looper, callback), configRequest);
+ new WifiNanEventCallbackProxy(this, mLooper, callback), configRequest);
} catch (RemoteException e) {
mClientId = INVALID_CLIENT_ID;
mLooper = null;
@@ -402,7 +403,7 @@ public class WifiNanManager {
* connections explicitly before a disconnect.
* <p>
* An application may re-connect after a disconnect using
- * {@link WifiNanManager#connect(Looper, WifiNanEventCallback)} .
+ * {@link WifiNanManager#connect(Handler, WifiNanEventCallback)} .
*/
public void disconnect() {
if (VDBG) Log.v(TAG, "disconnect()");