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