Merge "[AWARE] Data-path creation roles hard-coded for discovery sessions"
am: 47502919ad
Change-Id: If8f7d8e0e039d2d9961de84e5aa8693448b77a26
This commit is contained in:
@@ -35,7 +35,7 @@ import java.lang.ref.WeakReference;
|
||||
* <li>Sending messages: {@link #sendMessage(WifiAwareManager.PeerHandle, int, byte[])} or
|
||||
* {@link #sendMessage(WifiAwareManager.PeerHandle, int, byte[], int)} methods.
|
||||
* <li>Creating a network-specifier when requesting a Aware connection:
|
||||
* {@link #createNetworkSpecifier(int, WifiAwareManager.PeerHandle, byte[])}.
|
||||
* {@link #createNetworkSpecifier(WifiAwareManager.PeerHandle, byte[])}.
|
||||
* </ul>
|
||||
* The {@link #destroy()} method must be called to destroy discovery sessions once they are
|
||||
* no longer needed.
|
||||
@@ -260,10 +260,10 @@ public class WifiAwareDiscoveryBaseSession {
|
||||
* OOB (out-of-band) mechanism then use the alternative
|
||||
* {@link WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])} method - which uses the
|
||||
* peer's MAC address.
|
||||
* <p>
|
||||
* Note: per the Wi-Fi Aware specification the roles are fixed - a Subscriber is an INITIATOR
|
||||
* and a Publisher is a RESPONDER.
|
||||
*
|
||||
* @param role The role of this device:
|
||||
* {@link WifiAwareManager#WIFI_AWARE_DATA_PATH_ROLE_INITIATOR} or
|
||||
* {@link WifiAwareManager#WIFI_AWARE_DATA_PATH_ROLE_RESPONDER}
|
||||
* @param peerHandle The peer's handle obtained through
|
||||
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(WifiAwareManager.PeerHandle,
|
||||
* byte[], byte[])} or
|
||||
@@ -283,8 +283,8 @@ public class WifiAwareDiscoveryBaseSession {
|
||||
* android.net.ConnectivityManager.NetworkCallback)}
|
||||
* [or other varieties of that API].
|
||||
*/
|
||||
public String createNetworkSpecifier(@WifiAwareManager.DataPathRole int role,
|
||||
@Nullable WifiAwareManager.PeerHandle peerHandle, @Nullable byte[] token) {
|
||||
public String createNetworkSpecifier(@Nullable WifiAwareManager.PeerHandle peerHandle,
|
||||
@Nullable byte[] token) {
|
||||
if (mTerminated) {
|
||||
Log.w(TAG, "createNetworkSpecifier: called on terminated session");
|
||||
return null;
|
||||
@@ -295,6 +295,10 @@ public class WifiAwareDiscoveryBaseSession {
|
||||
return null;
|
||||
}
|
||||
|
||||
int role = this instanceof WifiAwareSubscribeDiscoverySession
|
||||
? WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR
|
||||
: WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER;
|
||||
|
||||
return mgr.createNetworkSpecifier(mClientId, role, mSessionId, peerHandle, token);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ import java.util.Arrays;
|
||||
* <li>Create a Aware network specifier to be used with
|
||||
* {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}
|
||||
* to set-up a Aware connection with a peer. Refer to
|
||||
* {@link WifiAwareDiscoveryBaseSession#createNetworkSpecifier(int, PeerHandle, byte[])} and
|
||||
* {@link WifiAwareDiscoveryBaseSession#createNetworkSpecifier(PeerHandle, byte[])} and
|
||||
* {@link WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])}.
|
||||
* </ul>
|
||||
* <p>
|
||||
@@ -114,7 +114,7 @@ import java.util.Arrays;
|
||||
* {@link android.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE}.
|
||||
* <li>{@link NetworkRequest.Builder#setNetworkSpecifier(String)} using
|
||||
* {@link WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])} or
|
||||
* {@link WifiAwareDiscoveryBaseSession#createNetworkSpecifier(int, PeerHandle, byte[])}.
|
||||
* {@link WifiAwareDiscoveryBaseSession#createNetworkSpecifier(PeerHandle, byte[])}.
|
||||
* </ul>
|
||||
*
|
||||
* @hide PROPOSED_AWARE_API
|
||||
@@ -224,7 +224,7 @@ public class WifiAwareManager {
|
||||
* Connection creation role is that of INITIATOR. Used to create a network specifier string
|
||||
* when requesting a Aware network.
|
||||
*
|
||||
* @see WifiAwareDiscoveryBaseSession#createNetworkSpecifier(int, PeerHandle, byte[])
|
||||
* @see WifiAwareDiscoveryBaseSession#createNetworkSpecifier(PeerHandle, byte[])
|
||||
* @see WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])
|
||||
*/
|
||||
public static final int WIFI_AWARE_DATA_PATH_ROLE_INITIATOR = 0;
|
||||
@@ -233,7 +233,7 @@ public class WifiAwareManager {
|
||||
* Connection creation role is that of RESPONDER. Used to create a network specifier string
|
||||
* when requesting a Aware network.
|
||||
*
|
||||
* @see WifiAwareDiscoveryBaseSession#createNetworkSpecifier(int, PeerHandle, byte[])
|
||||
* @see WifiAwareDiscoveryBaseSession#createNetworkSpecifier(PeerHandle, byte[])
|
||||
* @see WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])
|
||||
*/
|
||||
public static final int WIFI_AWARE_DATA_PATH_ROLE_RESPONDER = 1;
|
||||
|
||||
@@ -193,8 +193,8 @@ public class WifiAwareSession {
|
||||
* This API is targeted for applications which can obtain the peer MAC address using OOB
|
||||
* (out-of-band) discovery. Aware discovery does not provide the MAC address of the peer -
|
||||
* when using Aware discovery use the alternative network specifier method -
|
||||
* {@link WifiAwareDiscoveryBaseSession#createNetworkSpecifier(int,
|
||||
* WifiAwareManager.PeerHandle, byte[])}.
|
||||
* {@link WifiAwareDiscoveryBaseSession#createNetworkSpecifier(WifiAwareManager.PeerHandle,
|
||||
* byte[])}.
|
||||
*
|
||||
* @param role The role of this device:
|
||||
* {@link WifiAwareManager#WIFI_AWARE_DATA_PATH_ROLE_INITIATOR} or
|
||||
@@ -211,7 +211,7 @@ public class WifiAwareSession {
|
||||
*
|
||||
* @return A string to be used to construct
|
||||
* {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(String)} to pass to
|
||||
* {@link android.net.ConnectivityManager#requestNetwork(NetworkRequest,
|
||||
* {@link android.net.ConnectivityManager#requestNetwork(android.net.NetworkRequest,
|
||||
* android.net.ConnectivityManager.NetworkCallback)}
|
||||
* [or other varieties of that API].
|
||||
*/
|
||||
|
||||
@@ -945,7 +945,7 @@ public class WifiAwareManagerTest {
|
||||
final int clientId = 4565;
|
||||
final int sessionId = 123;
|
||||
final WifiAwareManager.PeerHandle peerHandle = new WifiAwareManager.PeerHandle(123412);
|
||||
final int role = WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR;
|
||||
final int role = WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER;
|
||||
final String token = "Some arbitrary token string - can really be anything";
|
||||
final ConfigRequest configRequest = new ConfigRequest.Builder().build();
|
||||
final PublishConfig publishConfig = new PublishConfig.Builder().build();
|
||||
@@ -982,7 +982,7 @@ public class WifiAwareManagerTest {
|
||||
inOrder.verify(mockSessionCallback).onPublishStarted(publishSession.capture());
|
||||
|
||||
// (3) request a network specifier from the session
|
||||
String networkSpecifier = publishSession.getValue().createNetworkSpecifier(role, peerHandle,
|
||||
String networkSpecifier = publishSession.getValue().createNetworkSpecifier(peerHandle,
|
||||
token.getBytes());
|
||||
|
||||
// validate format
|
||||
|
||||
Reference in New Issue
Block a user