Loading wifi/java/android/net/wifi/nan/WifiNanManager.java +13 −12 Original line number Diff line number Diff line Loading @@ -58,8 +58,8 @@ import java.util.Arrays; * <li>Initialize a NAN cluster (peer-to-peer synchronization). Refer to * {@link #attach(Handler, WifiNanAttachCallback)}. * <li>Create discovery sessions (publish or subscribe sessions). Refer to * {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} and * {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)}. * {@link WifiNanSession#publish(Handler, PublishConfig, WifiNanDiscoverySessionCallback)} and * {@link WifiNanSession#subscribe(Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)}. * <li>Create a NAN network specifier to be used with * {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)} * to set-up a NAN connection with a peer. Refer to Loading @@ -85,8 +85,8 @@ import java.util.Arrays; * device will actually disable NAN once the last application detaches. * <p> * Once a NAN attach is confirmed use the * {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or * {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} to * {@link WifiNanSession#publish(Handler, PublishConfig, WifiNanDiscoverySessionCallback)} or * {@link WifiNanSession#subscribe(Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)} to * create publish or subscribe NAN discovery sessions. Events are called on the provided * callback object {@link WifiNanDiscoverySessionCallback}. Specifically, the * {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)} Loading Loading @@ -330,9 +330,9 @@ public class WifiNanManager { * then this function will simply indicate success immediately using the same {@code * attachCallback}. * * @param handler The Handler on whose thread to execute all callbacks related to the * attach request - including all sessions opened as part of this * attach. If a null is provided then the application's main thread will be used. * @param handler The Handler on whose thread to execute the callbacks of the {@code * attachCallback} object. If a null is provided then the application's main thread will be * used. * @param attachCallback A callback for attach events, extended from * {@link WifiNanAttachCallback}. */ Loading Loading @@ -360,12 +360,13 @@ public class WifiNanManager { * requirements this listener will wake up the host at regular intervals causing higher power * consumption, do not use it unless the information is necessary (e.g. for OOB discovery). * * @param handler The Handler on whose thread to execute all callbacks related to the * attach request - including all sessions opened as part of this * attach. If a null is provided then the application's main thread will be used. * @param handler The Handler on whose thread to execute the callbacks of the {@code * attachCallback} and {@code identityChangedListener} objects. If a null is provided then the * application's main thread will be used. * @param attachCallback A callback for attach events, extended from * {@link WifiNanAttachCallback}. * @param identityChangedListener A listener for changed identity. * @param identityChangedListener A listener for changed identity, extended from * {@link WifiNanIdentityChangedListener}. */ public void attach(@Nullable Handler handler, @NonNull WifiNanAttachCallback attachCallback, @NonNull WifiNanIdentityChangedListener identityChangedListener) { Loading Loading @@ -695,7 +696,7 @@ public class WifiNanManager { switch (msg.what) { case CALLBACK_CONNECT_SUCCESS: attachCallback.onAttached( new WifiNanSession(mgr, mBinder, mLooper, msg.arg1)); new WifiNanSession(mgr, mBinder, msg.arg1)); break; case CALLBACK_CONNECT_FAIL: mNanManager.clear(); Loading wifi/java/android/net/wifi/nan/WifiNanSession.java +12 −8 Original line number Diff line number Diff line Loading @@ -41,19 +41,17 @@ public class WifiNanSession { private final WeakReference<WifiNanManager> mMgr; private final Binder mBinder; private final Looper mLooper; private final int mClientId; private boolean mTerminated = true; private final CloseGuard mCloseGuard = CloseGuard.get(); /** @hide */ public WifiNanSession(WifiNanManager manager, Binder binder, Looper looper, int clientId) { public WifiNanSession(WifiNanManager manager, Binder binder, int clientId) { if (VDBG) Log.v(TAG, "New session created: manager=" + manager + ", clientId=" + clientId); mMgr = new WeakReference<>(manager); mBinder = binder; mLooper = looper; mClientId = clientId; mTerminated = false; Loading @@ -68,7 +66,7 @@ public class WifiNanSession { * session-wide destroy. * <p> * An application may re-attach after a destroy using * {@link WifiNanManager#attach(Handler, WifiNanEventCallback)} . * {@link WifiNanManager#attach(Handler, WifiNanAttachCallback)} . */ public void destroy() { WifiNanManager mgr = mMgr.get(); Loading Loading @@ -115,12 +113,14 @@ public class WifiNanSession { * terminate the publish discovery session once it isn't needed. This will free * resources as well terminate any on-air transmissions. * * @param handler The Handler on whose thread to execute the callbacks of the {@code * callback} object. If a null is provided then the application's main thread will be used. * @param publishConfig The {@link PublishConfig} specifying the * configuration of the requested publish session. * @param callback A {@link WifiNanDiscoverySessionCallback} derived object to be used for * session event callbacks. */ public void publish(@NonNull PublishConfig publishConfig, public void publish(@Nullable Handler handler, @NonNull PublishConfig publishConfig, @NonNull WifiNanDiscoverySessionCallback callback) { WifiNanManager mgr = mMgr.get(); if (mgr == null) { Loading @@ -131,7 +131,8 @@ public class WifiNanSession { Log.e(TAG, "publish: called after termination"); return; } mgr.publish(mClientId, mLooper, publishConfig, callback); mgr.publish(mClientId, (handler == null) ? Looper.getMainLooper() : handler.getLooper(), publishConfig, callback); } /** Loading @@ -154,12 +155,14 @@ public class WifiNanSession { * terminate the subscribe discovery session once it isn't needed. This will free * resources as well terminate any on-air transmissions. * * @param handler The Handler on whose thread to execute the callbacks of the {@code * callback} object. If a null is provided then the application's main thread will be used. * @param subscribeConfig The {@link SubscribeConfig} specifying the * configuration of the requested subscribe session. * @param callback A {@link WifiNanDiscoverySessionCallback} derived object to be used for * session event callbacks. */ public void subscribe(@NonNull SubscribeConfig subscribeConfig, public void subscribe(@Nullable Handler handler, @NonNull SubscribeConfig subscribeConfig, @NonNull WifiNanDiscoverySessionCallback callback) { WifiNanManager mgr = mMgr.get(); if (mgr == null) { Loading @@ -170,7 +173,8 @@ public class WifiNanSession { Log.e(TAG, "publish: called after termination"); return; } mgr.subscribe(mClientId, mLooper, subscribeConfig, callback); mgr.subscribe(mClientId, (handler == null) ? Looper.getMainLooper() : handler.getLooper(), subscribeConfig, callback); } /** Loading Loading
wifi/java/android/net/wifi/nan/WifiNanManager.java +13 −12 Original line number Diff line number Diff line Loading @@ -58,8 +58,8 @@ import java.util.Arrays; * <li>Initialize a NAN cluster (peer-to-peer synchronization). Refer to * {@link #attach(Handler, WifiNanAttachCallback)}. * <li>Create discovery sessions (publish or subscribe sessions). Refer to * {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} and * {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)}. * {@link WifiNanSession#publish(Handler, PublishConfig, WifiNanDiscoverySessionCallback)} and * {@link WifiNanSession#subscribe(Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)}. * <li>Create a NAN network specifier to be used with * {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)} * to set-up a NAN connection with a peer. Refer to Loading @@ -85,8 +85,8 @@ import java.util.Arrays; * device will actually disable NAN once the last application detaches. * <p> * Once a NAN attach is confirmed use the * {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or * {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} to * {@link WifiNanSession#publish(Handler, PublishConfig, WifiNanDiscoverySessionCallback)} or * {@link WifiNanSession#subscribe(Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)} to * create publish or subscribe NAN discovery sessions. Events are called on the provided * callback object {@link WifiNanDiscoverySessionCallback}. Specifically, the * {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)} Loading Loading @@ -330,9 +330,9 @@ public class WifiNanManager { * then this function will simply indicate success immediately using the same {@code * attachCallback}. * * @param handler The Handler on whose thread to execute all callbacks related to the * attach request - including all sessions opened as part of this * attach. If a null is provided then the application's main thread will be used. * @param handler The Handler on whose thread to execute the callbacks of the {@code * attachCallback} object. If a null is provided then the application's main thread will be * used. * @param attachCallback A callback for attach events, extended from * {@link WifiNanAttachCallback}. */ Loading Loading @@ -360,12 +360,13 @@ public class WifiNanManager { * requirements this listener will wake up the host at regular intervals causing higher power * consumption, do not use it unless the information is necessary (e.g. for OOB discovery). * * @param handler The Handler on whose thread to execute all callbacks related to the * attach request - including all sessions opened as part of this * attach. If a null is provided then the application's main thread will be used. * @param handler The Handler on whose thread to execute the callbacks of the {@code * attachCallback} and {@code identityChangedListener} objects. If a null is provided then the * application's main thread will be used. * @param attachCallback A callback for attach events, extended from * {@link WifiNanAttachCallback}. * @param identityChangedListener A listener for changed identity. * @param identityChangedListener A listener for changed identity, extended from * {@link WifiNanIdentityChangedListener}. */ public void attach(@Nullable Handler handler, @NonNull WifiNanAttachCallback attachCallback, @NonNull WifiNanIdentityChangedListener identityChangedListener) { Loading Loading @@ -695,7 +696,7 @@ public class WifiNanManager { switch (msg.what) { case CALLBACK_CONNECT_SUCCESS: attachCallback.onAttached( new WifiNanSession(mgr, mBinder, mLooper, msg.arg1)); new WifiNanSession(mgr, mBinder, msg.arg1)); break; case CALLBACK_CONNECT_FAIL: mNanManager.clear(); Loading
wifi/java/android/net/wifi/nan/WifiNanSession.java +12 −8 Original line number Diff line number Diff line Loading @@ -41,19 +41,17 @@ public class WifiNanSession { private final WeakReference<WifiNanManager> mMgr; private final Binder mBinder; private final Looper mLooper; private final int mClientId; private boolean mTerminated = true; private final CloseGuard mCloseGuard = CloseGuard.get(); /** @hide */ public WifiNanSession(WifiNanManager manager, Binder binder, Looper looper, int clientId) { public WifiNanSession(WifiNanManager manager, Binder binder, int clientId) { if (VDBG) Log.v(TAG, "New session created: manager=" + manager + ", clientId=" + clientId); mMgr = new WeakReference<>(manager); mBinder = binder; mLooper = looper; mClientId = clientId; mTerminated = false; Loading @@ -68,7 +66,7 @@ public class WifiNanSession { * session-wide destroy. * <p> * An application may re-attach after a destroy using * {@link WifiNanManager#attach(Handler, WifiNanEventCallback)} . * {@link WifiNanManager#attach(Handler, WifiNanAttachCallback)} . */ public void destroy() { WifiNanManager mgr = mMgr.get(); Loading Loading @@ -115,12 +113,14 @@ public class WifiNanSession { * terminate the publish discovery session once it isn't needed. This will free * resources as well terminate any on-air transmissions. * * @param handler The Handler on whose thread to execute the callbacks of the {@code * callback} object. If a null is provided then the application's main thread will be used. * @param publishConfig The {@link PublishConfig} specifying the * configuration of the requested publish session. * @param callback A {@link WifiNanDiscoverySessionCallback} derived object to be used for * session event callbacks. */ public void publish(@NonNull PublishConfig publishConfig, public void publish(@Nullable Handler handler, @NonNull PublishConfig publishConfig, @NonNull WifiNanDiscoverySessionCallback callback) { WifiNanManager mgr = mMgr.get(); if (mgr == null) { Loading @@ -131,7 +131,8 @@ public class WifiNanSession { Log.e(TAG, "publish: called after termination"); return; } mgr.publish(mClientId, mLooper, publishConfig, callback); mgr.publish(mClientId, (handler == null) ? Looper.getMainLooper() : handler.getLooper(), publishConfig, callback); } /** Loading @@ -154,12 +155,14 @@ public class WifiNanSession { * terminate the subscribe discovery session once it isn't needed. This will free * resources as well terminate any on-air transmissions. * * @param handler The Handler on whose thread to execute the callbacks of the {@code * callback} object. If a null is provided then the application's main thread will be used. * @param subscribeConfig The {@link SubscribeConfig} specifying the * configuration of the requested subscribe session. * @param callback A {@link WifiNanDiscoverySessionCallback} derived object to be used for * session event callbacks. */ public void subscribe(@NonNull SubscribeConfig subscribeConfig, public void subscribe(@Nullable Handler handler, @NonNull SubscribeConfig subscribeConfig, @NonNull WifiNanDiscoverySessionCallback callback) { WifiNanManager mgr = mMgr.get(); if (mgr == null) { Loading @@ -170,7 +173,8 @@ public class WifiNanSession { Log.e(TAG, "publish: called after termination"); return; } mgr.subscribe(mClientId, mLooper, subscribeConfig, callback); mgr.subscribe(mClientId, (handler == null) ? Looper.getMainLooper() : handler.getLooper(), subscribeConfig, callback); } /** Loading