Merge "[AWARE] Simplify Wi-Fi Aware API namespace"
am: 834a87d525
Change-Id: I243194a658ee8e9c5a21301601a473149eaa8a2f
This commit is contained in:
@@ -18,16 +18,16 @@ package android.net.wifi.aware;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for Aware attach callbacks. Should be extended by applications and set when calling
|
* Base class for Aware attach callbacks. Should be extended by applications and set when calling
|
||||||
* {@link WifiAwareManager#attach(WifiAwareAttachCallback, android.os.Handler)}. These are callbacks
|
* {@link WifiAwareManager#attach(AttachCallback, android.os.Handler)}. These are callbacks
|
||||||
* applying to the Aware connection as a whole - not to specific publish or subscribe sessions -
|
* applying to the Aware connection as a whole - not to specific publish or subscribe sessions -
|
||||||
* for that see {@link WifiAwareDiscoverySessionCallback}.
|
* for that see {@link DiscoverySessionCallback}.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_AWARE_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiAwareAttachCallback {
|
public class AttachCallback {
|
||||||
/**
|
/**
|
||||||
* Called when Aware attach operation
|
* Called when Aware attach operation
|
||||||
* {@link WifiAwareManager#attach(WifiAwareAttachCallback, android.os.Handler)}
|
* {@link WifiAwareManager#attach(AttachCallback, android.os.Handler)}
|
||||||
* is completed and that we can now start discovery sessions or connections.
|
* is completed and that we can now start discovery sessions or connections.
|
||||||
*
|
*
|
||||||
* @param session The Aware object on which we can execute further Aware operations - e.g.
|
* @param session The Aware object on which we can execute further Aware operations - e.g.
|
||||||
@@ -39,7 +39,7 @@ public class WifiAwareAttachCallback {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when Aware attach operation
|
* Called when Aware attach operation
|
||||||
* {@link WifiAwareManager#attach(WifiAwareAttachCallback, android.os.Handler)} failed.
|
* {@link WifiAwareManager#attach(AttachCallback, android.os.Handler)} failed.
|
||||||
*/
|
*/
|
||||||
public void onAttachFailed() {
|
public void onAttachFailed() {
|
||||||
/* empty */
|
/* empty */
|
||||||
@@ -16,4 +16,4 @@
|
|||||||
|
|
||||||
package android.net.wifi.aware;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
parcelable WifiAwareCharacteristics;
|
parcelable Characteristics;
|
||||||
@@ -25,7 +25,7 @@ import android.os.Parcelable;
|
|||||||
*
|
*
|
||||||
* @hide PROPOSED_AWARE_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiAwareCharacteristics implements Parcelable {
|
public class Characteristics implements Parcelable {
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static final String KEY_MAX_SERVICE_NAME_LENGTH = "key_max_service_name_length";
|
public static final String KEY_MAX_SERVICE_NAME_LENGTH = "key_max_service_name_length";
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -37,7 +37,7 @@ public class WifiAwareCharacteristics implements Parcelable {
|
|||||||
private Bundle mCharacteristics = new Bundle();
|
private Bundle mCharacteristics = new Bundle();
|
||||||
|
|
||||||
/** @hide : should not be created by apps */
|
/** @hide : should not be created by apps */
|
||||||
public WifiAwareCharacteristics(Bundle characteristics) {
|
public Characteristics(Bundle characteristics) {
|
||||||
mCharacteristics = characteristics;
|
mCharacteristics = characteristics;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ public class WifiAwareCharacteristics implements Parcelable {
|
|||||||
* message exchange. Restricts the parameters of the
|
* message exchange. Restricts the parameters of the
|
||||||
* {@link PublishConfig.Builder#setServiceSpecificInfo(byte[])},
|
* {@link PublishConfig.Builder#setServiceSpecificInfo(byte[])},
|
||||||
* {@link SubscribeConfig.Builder#setServiceSpecificInfo(byte[])}, and
|
* {@link SubscribeConfig.Builder#setServiceSpecificInfo(byte[])}, and
|
||||||
* {@link WifiAwareDiscoveryBaseSession#sendMessage(WifiAwareManager.PeerHandle, int, byte[])}
|
* {@link DiscoverySession#sendMessage(PeerHandle, int, byte[])}
|
||||||
* variants.
|
* variants.
|
||||||
*
|
*
|
||||||
* @return A positive integer, maximum length of byte array for Aware messaging.
|
* @return A positive integer, maximum length of byte array for Aware messaging.
|
||||||
@@ -89,17 +89,17 @@ public class WifiAwareCharacteristics implements Parcelable {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<WifiAwareCharacteristics> CREATOR =
|
public static final Creator<Characteristics> CREATOR =
|
||||||
new Creator<WifiAwareCharacteristics>() {
|
new Creator<Characteristics>() {
|
||||||
@Override
|
@Override
|
||||||
public WifiAwareCharacteristics createFromParcel(Parcel in) {
|
public Characteristics createFromParcel(Parcel in) {
|
||||||
WifiAwareCharacteristics c = new WifiAwareCharacteristics(in.readBundle());
|
Characteristics c = new Characteristics(in.readBundle());
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WifiAwareCharacteristics[] newArray(int size) {
|
public Characteristics[] newArray(int size) {
|
||||||
return new WifiAwareCharacteristics[size];
|
return new Characteristics[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ import android.os.Parcelable;
|
|||||||
/**
|
/**
|
||||||
* Defines a request object to configure a Wi-Fi Aware network. Built using
|
* Defines a request object to configure a Wi-Fi Aware network. Built using
|
||||||
* {@link ConfigRequest.Builder}. Configuration is requested using
|
* {@link ConfigRequest.Builder}. Configuration is requested using
|
||||||
* {@link WifiAwareManager#attach(WifiAwareAttachCallback, android.os.Handler)}.
|
* {@link WifiAwareManager#attach(AttachCallback, android.os.Handler)}.
|
||||||
* Note that the actual achieved configuration may be different from the
|
* Note that the actual achieved configuration may be different from the
|
||||||
* requested configuration - since different applications may request different
|
* requested configuration - since different applications may request different
|
||||||
* configurations.
|
* configurations.
|
||||||
|
|||||||
@@ -29,21 +29,21 @@ import java.lang.ref.WeakReference;
|
|||||||
/**
|
/**
|
||||||
* A class representing a single publish or subscribe Aware session. This object
|
* A class representing a single publish or subscribe Aware session. This object
|
||||||
* will not be created directly - only its child classes are available:
|
* will not be created directly - only its child classes are available:
|
||||||
* {@link WifiAwarePublishDiscoverySession} and {@link WifiAwareSubscribeDiscoverySession}. This
|
* {@link PublishDiscoverySession} and {@link SubscribeDiscoverySession}. This
|
||||||
* class provides functionality common to both publish and subscribe discovery sessions:
|
* class provides functionality common to both publish and subscribe discovery sessions:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Sending messages: {@link #sendMessage(WifiAwareManager.PeerHandle, int, byte[])} or
|
* <li>Sending messages: {@link #sendMessage(PeerHandle, int, byte[])} or
|
||||||
* {@link #sendMessage(WifiAwareManager.PeerHandle, int, byte[], int)} methods.
|
* {@link #sendMessage(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(WifiAwareManager.PeerHandle, byte[])}.
|
* {@link #createNetworkSpecifier(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.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_AWARE_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiAwareDiscoveryBaseSession {
|
public class DiscoverySession {
|
||||||
private static final String TAG = "WifiAwareDiscBaseSsn";
|
private static final String TAG = "DiscoverySession";
|
||||||
private static final boolean DBG = false;
|
private static final boolean DBG = false;
|
||||||
private static final boolean VDBG = false; // STOPSHIP if true
|
private static final boolean VDBG = false; // STOPSHIP if true
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ public class WifiAwareDiscoveryBaseSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the maximum permitted retry count when sending messages using
|
* Return the maximum permitted retry count when sending messages using
|
||||||
* {@link #sendMessage(WifiAwareManager.PeerHandle, int, byte[], int)}.
|
* {@link #sendMessage(PeerHandle, int, byte[], int)}.
|
||||||
*
|
*
|
||||||
* @return Maximum retry count when sending messages.
|
* @return Maximum retry count when sending messages.
|
||||||
*/
|
*/
|
||||||
@@ -71,7 +71,7 @@ public class WifiAwareDiscoveryBaseSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public WifiAwareDiscoveryBaseSession(WifiAwareManager manager, int clientId, int sessionId) {
|
public DiscoverySession(WifiAwareManager manager, int clientId, int sessionId) {
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
Log.v(TAG, "New discovery session created: manager=" + manager + ", clientId="
|
Log.v(TAG, "New discovery session created: manager=" + manager + ", clientId="
|
||||||
+ clientId + ", sessionId=" + sessionId);
|
+ clientId + ", sessionId=" + sessionId);
|
||||||
@@ -93,7 +93,7 @@ public class WifiAwareDiscoveryBaseSession {
|
|||||||
* This operation must be done on a session which is no longer needed. Otherwise system
|
* This operation must be done on a session which is no longer needed. Otherwise system
|
||||||
* resources will continue to be utilized until the application exits. The only
|
* resources will continue to be utilized until the application exits. The only
|
||||||
* exception is a session for which we received a termination callback,
|
* exception is a session for which we received a termination callback,
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)}.
|
* {@link DiscoverySessionCallback#onSessionTerminated(int)}.
|
||||||
*/
|
*/
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
WifiAwareManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
@@ -139,23 +139,23 @@ public class WifiAwareDiscoveryBaseSession {
|
|||||||
/**
|
/**
|
||||||
* Sends a message to the specified destination. Aware messages are transmitted in the context
|
* Sends a message to the specified destination. Aware messages are transmitted in the context
|
||||||
* of a discovery session - executed subsequent to a publish/subscribe
|
* of a discovery session - executed subsequent to a publish/subscribe
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle,
|
||||||
* byte[], java.util.List)} event.
|
* byte[], java.util.List)} event.
|
||||||
* <p>
|
* <p>
|
||||||
* Aware messages are not guaranteed delivery. Callbacks on
|
* Aware messages are not guaranteed delivery. Callbacks on
|
||||||
* {@link WifiAwareDiscoverySessionCallback} indicate message was transmitted successfully,
|
* {@link DiscoverySessionCallback} indicate message was transmitted successfully,
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onMessageSendSucceeded(int)}, or transmission
|
* {@link DiscoverySessionCallback#onMessageSendSucceeded(int)}, or transmission
|
||||||
* failed (possibly after several retries) -
|
* failed (possibly after several retries) -
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onMessageSendFailed(int)}.
|
* {@link DiscoverySessionCallback#onMessageSendFailed(int)}.
|
||||||
* <p>
|
* <p>
|
||||||
* The peer will get a callback indicating a message was received using
|
* The peer will get a callback indicating a message was received using
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onMessageReceived(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onMessageReceived(PeerHandle,
|
||||||
* byte[])}.
|
* byte[])}.
|
||||||
*
|
*
|
||||||
* @param peerHandle The peer's handle for the message. Must be a result of an
|
* @param peerHandle The peer's handle for the message. Must be a result of an
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle,
|
||||||
* byte[], java.util.List)} or
|
* byte[], java.util.List)} or
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onMessageReceived(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onMessageReceived(PeerHandle,
|
||||||
* byte[])} events.
|
* byte[])} events.
|
||||||
* @param messageId An arbitrary integer used by the caller to identify the message. The same
|
* @param messageId An arbitrary integer used by the caller to identify the message. The same
|
||||||
* integer ID will be returned in the callbacks indicating message send success or
|
* integer ID will be returned in the callbacks indicating message send success or
|
||||||
@@ -167,7 +167,7 @@ public class WifiAwareDiscoveryBaseSession {
|
|||||||
* (note: no retransmissions are attempted in other failure cases). A value of 0
|
* (note: no retransmissions are attempted in other failure cases). A value of 0
|
||||||
* indicates no retries. Max permitted value is {@link #getMaxSendRetryCount()}.
|
* indicates no retries. Max permitted value is {@link #getMaxSendRetryCount()}.
|
||||||
*/
|
*/
|
||||||
public void sendMessage(@NonNull WifiAwareManager.PeerHandle peerHandle, int messageId,
|
public void sendMessage(@NonNull PeerHandle peerHandle, int messageId,
|
||||||
@Nullable byte[] message, int retryCount) {
|
@Nullable byte[] message, int retryCount) {
|
||||||
if (mTerminated) {
|
if (mTerminated) {
|
||||||
Log.w(TAG, "sendMessage: called on terminated session");
|
Log.w(TAG, "sendMessage: called on terminated session");
|
||||||
@@ -186,25 +186,25 @@ public class WifiAwareDiscoveryBaseSession {
|
|||||||
/**
|
/**
|
||||||
* Sends a message to the specified destination. Aware messages are transmitted in the context
|
* Sends a message to the specified destination. Aware messages are transmitted in the context
|
||||||
* of a discovery session - executed subsequent to a publish/subscribe
|
* of a discovery session - executed subsequent to a publish/subscribe
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle,
|
||||||
* byte[], java.util.List)} event.
|
* byte[], java.util.List)} event.
|
||||||
* <p>
|
* <p>
|
||||||
* Aware messages are not guaranteed delivery. Callbacks on
|
* Aware messages are not guaranteed delivery. Callbacks on
|
||||||
* {@link WifiAwareDiscoverySessionCallback} indicate message was transmitted successfully,
|
* {@link DiscoverySessionCallback} indicate message was transmitted successfully,
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onMessageSendSucceeded(int)}, or transmission
|
* {@link DiscoverySessionCallback#onMessageSendSucceeded(int)}, or transmission
|
||||||
* failed (possibly after several retries) -
|
* failed (possibly after several retries) -
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onMessageSendFailed(int)}.
|
* {@link DiscoverySessionCallback#onMessageSendFailed(int)}.
|
||||||
* <p>
|
* <p>
|
||||||
* The peer will get a callback indicating a message was received using
|
* The peer will get a callback indicating a message was received using
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onMessageReceived(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onMessageReceived(PeerHandle,
|
||||||
* byte[])}.
|
* byte[])}.
|
||||||
* Equivalent to {@link #sendMessage(WifiAwareManager.PeerHandle, int, byte[], int)}
|
* Equivalent to {@link #sendMessage(PeerHandle, int, byte[], int)}
|
||||||
* with a {@code retryCount} of 0.
|
* with a {@code retryCount} of 0.
|
||||||
*
|
*
|
||||||
* @param peerHandle The peer's handle for the message. Must be a result of an
|
* @param peerHandle The peer's handle for the message. Must be a result of an
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle,
|
||||||
* byte[], java.util.List)} or
|
* byte[], java.util.List)} or
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onMessageReceived(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onMessageReceived(PeerHandle,
|
||||||
* byte[])} events.
|
* byte[])} events.
|
||||||
* @param messageId An arbitrary integer used by the caller to identify the message. The same
|
* @param messageId An arbitrary integer used by the caller to identify the message. The same
|
||||||
* integer ID will be returned in the callbacks indicating message send success or
|
* integer ID will be returned in the callbacks indicating message send success or
|
||||||
@@ -212,16 +212,16 @@ public class WifiAwareDiscoveryBaseSession {
|
|||||||
* can be arbitrary and non-unique.
|
* can be arbitrary and non-unique.
|
||||||
* @param message The message to be transmitted.
|
* @param message The message to be transmitted.
|
||||||
*/
|
*/
|
||||||
public void sendMessage(@NonNull WifiAwareManager.PeerHandle peerHandle, int messageId,
|
public void sendMessage(@NonNull PeerHandle peerHandle, int messageId,
|
||||||
@Nullable byte[] message) {
|
@Nullable byte[] message) {
|
||||||
sendMessage(peerHandle, messageId, message, 0);
|
sendMessage(peerHandle, messageId, message, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a ranging operation with the specified peers. The peer IDs are obtained from an
|
* Start a ranging operation with the specified peers. The peer IDs are obtained from an
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle,
|
||||||
* byte[], java.util.List)} or
|
* byte[], java.util.List)} or
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onMessageReceived(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onMessageReceived(PeerHandle,
|
||||||
* byte[])} operation - can
|
* byte[])} operation - can
|
||||||
* only range devices which are part of an ongoing discovery session.
|
* only range devices which are part of an ongoing discovery session.
|
||||||
*
|
*
|
||||||
@@ -265,9 +265,9 @@ public class WifiAwareDiscoveryBaseSession {
|
|||||||
* and a Publisher is a RESPONDER.
|
* and a Publisher is a RESPONDER.
|
||||||
*
|
*
|
||||||
* @param peerHandle The peer's handle obtained through
|
* @param peerHandle The peer's handle obtained through
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle,
|
||||||
* byte[], java.util.List)} or
|
* byte[], java.util.List)} or
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onMessageReceived(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onMessageReceived(PeerHandle,
|
||||||
* byte[])}. On a RESPONDER this value is used to gate the acceptance of a connection request
|
* byte[])}. On a RESPONDER this value is used to gate the acceptance of a connection request
|
||||||
* from only that peer. A RESPONDER may specified a null - indicating that
|
* from only that peer. A RESPONDER may specified a null - indicating that
|
||||||
* it will accept connection requests from any device.
|
* it will accept connection requests from any device.
|
||||||
@@ -283,7 +283,7 @@ 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(@Nullable WifiAwareManager.PeerHandle peerHandle,
|
public String createNetworkSpecifier(@Nullable 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");
|
||||||
@@ -295,7 +295,7 @@ public class WifiAwareDiscoveryBaseSession {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int role = this instanceof WifiAwareSubscribeDiscoverySession
|
int role = this instanceof SubscribeDiscoverySession
|
||||||
? WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR
|
? WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR
|
||||||
: WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER;
|
: WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER;
|
||||||
|
|
||||||
@@ -27,16 +27,16 @@ import java.util.List;
|
|||||||
* Base class for Aware session events callbacks. Should be extended by
|
* Base class for Aware session events callbacks. Should be extended by
|
||||||
* applications wanting notifications. The callbacks are set when a
|
* applications wanting notifications. The callbacks are set when a
|
||||||
* publish or subscribe session is created using
|
* publish or subscribe session is created using
|
||||||
* {@link WifiAwareSession#publish(PublishConfig, WifiAwareDiscoverySessionCallback,
|
* {@link WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback,
|
||||||
* android.os.Handler)} or
|
* android.os.Handler)} or
|
||||||
* {@link WifiAwareSession#subscribe(SubscribeConfig, WifiAwareDiscoverySessionCallback,
|
* {@link WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback,
|
||||||
* android.os.Handler)}.
|
* android.os.Handler)}.
|
||||||
* <p>
|
* <p>
|
||||||
* A single callback is set at session creation - it cannot be replaced.
|
* A single callback is set at session creation - it cannot be replaced.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_AWARE_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiAwareDiscoverySessionCallback {
|
public class DiscoverySessionCallback {
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@IntDef({
|
@IntDef({
|
||||||
TERMINATE_REASON_DONE, TERMINATE_REASON_FAIL })
|
TERMINATE_REASON_DONE, TERMINATE_REASON_FAIL })
|
||||||
@@ -48,7 +48,7 @@ public class WifiAwareDiscoverySessionCallback {
|
|||||||
* Indicates that publish or subscribe session is done - all the
|
* Indicates that publish or subscribe session is done - all the
|
||||||
* requested operations (per {@link PublishConfig} or
|
* requested operations (per {@link PublishConfig} or
|
||||||
* {@link SubscribeConfig}) have been executed. Failure reason flag for
|
* {@link SubscribeConfig}) have been executed. Failure reason flag for
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} callback.
|
* {@link DiscoverySessionCallback#onSessionTerminated(int)} callback.
|
||||||
*/
|
*/
|
||||||
public static final int TERMINATE_REASON_DONE = 100;
|
public static final int TERMINATE_REASON_DONE = 100;
|
||||||
|
|
||||||
@@ -56,39 +56,39 @@ public class WifiAwareDiscoverySessionCallback {
|
|||||||
* Indicates that publish or subscribe session is terminated due to a
|
* Indicates that publish or subscribe session is terminated due to a
|
||||||
* failure.
|
* failure.
|
||||||
* Failure reason flag for
|
* Failure reason flag for
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} callback.
|
* {@link DiscoverySessionCallback#onSessionTerminated(int)} callback.
|
||||||
*/
|
*/
|
||||||
public static final int TERMINATE_REASON_FAIL = 101;
|
public static final int TERMINATE_REASON_FAIL = 101;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a publish operation is started successfully in response to a
|
* Called when a publish operation is started successfully in response to a
|
||||||
* {@link WifiAwareSession#publish(PublishConfig, WifiAwareDiscoverySessionCallback,
|
* {@link WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback,
|
||||||
* android.os.Handler)} operation.
|
* android.os.Handler)} operation.
|
||||||
*
|
*
|
||||||
* @param session The {@link WifiAwarePublishDiscoverySession} used to control the
|
* @param session The {@link PublishDiscoverySession} used to control the
|
||||||
* discovery session.
|
* discovery session.
|
||||||
*/
|
*/
|
||||||
public void onPublishStarted(@NonNull WifiAwarePublishDiscoverySession session) {
|
public void onPublishStarted(@NonNull PublishDiscoverySession session) {
|
||||||
/* empty */
|
/* empty */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a subscribe operation is started successfully in response to a
|
* Called when a subscribe operation is started successfully in response to a
|
||||||
* {@link WifiAwareSession#subscribe(SubscribeConfig, WifiAwareDiscoverySessionCallback,
|
* {@link WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback,
|
||||||
* android.os.Handler)} operation.
|
* android.os.Handler)} operation.
|
||||||
*
|
*
|
||||||
* @param session The {@link WifiAwareSubscribeDiscoverySession} used to control the
|
* @param session The {@link SubscribeDiscoverySession} used to control the
|
||||||
* discovery session.
|
* discovery session.
|
||||||
*/
|
*/
|
||||||
public void onSubscribeStarted(@NonNull WifiAwareSubscribeDiscoverySession session) {
|
public void onSubscribeStarted(@NonNull SubscribeDiscoverySession session) {
|
||||||
/* empty */
|
/* empty */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a publish or subscribe discovery session configuration update request
|
* Called when a publish or subscribe discovery session configuration update request
|
||||||
* succeeds. Called in response to
|
* succeeds. Called in response to
|
||||||
* {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)} or
|
* {@link PublishDiscoverySession#updatePublish(PublishConfig)} or
|
||||||
* {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
* {@link SubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
||||||
*/
|
*/
|
||||||
public void onSessionConfigUpdated() {
|
public void onSessionConfigUpdated() {
|
||||||
/* empty */
|
/* empty */
|
||||||
@@ -96,12 +96,12 @@ public class WifiAwareDiscoverySessionCallback {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a publish or subscribe discovery session cannot be created:
|
* Called when a publish or subscribe discovery session cannot be created:
|
||||||
* {@link WifiAwareSession#publish(PublishConfig, WifiAwareDiscoverySessionCallback,
|
* {@link WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback,
|
||||||
* android.os.Handler)} or
|
* android.os.Handler)} or
|
||||||
* {@link WifiAwareSession#subscribe(SubscribeConfig, WifiAwareDiscoverySessionCallback,
|
* {@link WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback,
|
||||||
* android.os.Handler)}, or when a configuration update fails:
|
* android.os.Handler)}, or when a configuration update fails:
|
||||||
* {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)} or
|
* {@link PublishDiscoverySession#updatePublish(PublishConfig)} or
|
||||||
* {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
* {@link SubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
||||||
* <p>
|
* <p>
|
||||||
* For discovery session updates failure leaves the session running with its previous
|
* For discovery session updates failure leaves the session running with its previous
|
||||||
* configuration - the discovery session is not terminated.
|
* configuration - the discovery session is not terminated.
|
||||||
@@ -112,12 +112,12 @@ public class WifiAwareDiscoverySessionCallback {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a discovery session (publish or subscribe) terminates. Termination may be due
|
* Called when a discovery session (publish or subscribe) terminates. Termination may be due
|
||||||
* to user-request (either directly through {@link WifiAwareDiscoveryBaseSession#destroy()} or
|
* to user-request (either directly through {@link DiscoverySession#destroy()} or
|
||||||
* application-specified expiration, e.g. {@link PublishConfig.Builder#setPublishCount(int)}
|
* application-specified expiration, e.g. {@link PublishConfig.Builder#setPublishCount(int)}
|
||||||
* or {@link SubscribeConfig.Builder#setTtlSec(int)}) or due to a failure.
|
* or {@link SubscribeConfig.Builder#setTtlSec(int)}) or due to a failure.
|
||||||
*
|
*
|
||||||
* @param reason The termination reason using
|
* @param reason The termination reason using
|
||||||
* {@code WifiAwareDiscoverySessionCallback.TERMINATE_*} codes.
|
* {@code DiscoverySessionCallback.TERMINATE_*} codes.
|
||||||
*/
|
*/
|
||||||
public void onSessionTerminated(@SessionTerminateCodes int reason) {
|
public void onSessionTerminated(@SessionTerminateCodes int reason) {
|
||||||
/* empty */
|
/* empty */
|
||||||
@@ -133,19 +133,19 @@ public class WifiAwareDiscoverySessionCallback {
|
|||||||
* configuration.
|
* configuration.
|
||||||
* @param matchFilter The filter which resulted in this service discovery.
|
* @param matchFilter The filter which resulted in this service discovery.
|
||||||
*/
|
*/
|
||||||
public void onServiceDiscovered(WifiAwareManager.PeerHandle peerHandle,
|
public void onServiceDiscovered(PeerHandle peerHandle,
|
||||||
byte[] serviceSpecificInfo, List<byte[]> matchFilter) {
|
byte[] serviceSpecificInfo, List<byte[]> matchFilter) {
|
||||||
/* empty */
|
/* empty */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called in response to
|
* Called in response to
|
||||||
* {@link WifiAwareDiscoveryBaseSession#sendMessage(WifiAwareManager.PeerHandle, int, byte[])}
|
* {@link DiscoverySession#sendMessage(PeerHandle, int, byte[])}
|
||||||
* when a message is transmitted successfully - i.e. when it was received successfully by the
|
* when a message is transmitted successfully - i.e. when it was received successfully by the
|
||||||
* peer (corresponds to an ACK being received).
|
* peer (corresponds to an ACK being received).
|
||||||
* <p>
|
* <p>
|
||||||
* Note that either this callback or
|
* Note that either this callback or
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onMessageSendFailed(int)} will be
|
* {@link DiscoverySessionCallback#onMessageSendFailed(int)} will be
|
||||||
* received - never both.
|
* received - never both.
|
||||||
*
|
*
|
||||||
* @param messageId The arbitrary message ID specified when sending the message.
|
* @param messageId The arbitrary message ID specified when sending the message.
|
||||||
@@ -157,11 +157,11 @@ public class WifiAwareDiscoverySessionCallback {
|
|||||||
/**
|
/**
|
||||||
* Called when message transmission fails - when no ACK is received from the peer.
|
* Called when message transmission fails - when no ACK is received from the peer.
|
||||||
* Retries when ACKs are not received are done by hardware, MAC, and in the Aware stack (using
|
* Retries when ACKs are not received are done by hardware, MAC, and in the Aware stack (using
|
||||||
* the {@link WifiAwareDiscoveryBaseSession#sendMessage(WifiAwareManager.PeerHandle, int,
|
* the {@link DiscoverySession#sendMessage(PeerHandle, int,
|
||||||
* byte[], int)} method) - this event is received after all retries are exhausted.
|
* byte[], int)} method) - this event is received after all retries are exhausted.
|
||||||
* <p>
|
* <p>
|
||||||
* Note that either this callback or
|
* Note that either this callback or
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onMessageSendSucceeded(int)} will be received
|
* {@link DiscoverySessionCallback#onMessageSendSucceeded(int)} will be received
|
||||||
* - never both.
|
* - never both.
|
||||||
*
|
*
|
||||||
* @param messageId The arbitrary message ID specified when sending the message.
|
* @param messageId The arbitrary message ID specified when sending the message.
|
||||||
@@ -172,14 +172,14 @@ public class WifiAwareDiscoverySessionCallback {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a message is received from a discovery session peer - in response to the
|
* Called when a message is received from a discovery session peer - in response to the
|
||||||
* peer's {@link WifiAwareDiscoveryBaseSession#sendMessage(WifiAwareManager.PeerHandle, int,
|
* peer's {@link DiscoverySession#sendMessage(PeerHandle, int,
|
||||||
* byte[])} or {@link WifiAwareDiscoveryBaseSession#sendMessage(WifiAwareManager.PeerHandle,
|
* byte[])} or {@link DiscoverySession#sendMessage(PeerHandle,
|
||||||
* int, byte[], int)}.
|
* int, byte[], int)}.
|
||||||
*
|
*
|
||||||
* @param peerHandle An opaque handle to the peer matching our discovery operation.
|
* @param peerHandle An opaque handle to the peer matching our discovery operation.
|
||||||
* @param message A byte array containing the message.
|
* @param message A byte array containing the message.
|
||||||
*/
|
*/
|
||||||
public void onMessageReceived(WifiAwareManager.PeerHandle peerHandle, byte[] message) {
|
public void onMessageReceived(PeerHandle peerHandle, byte[] message) {
|
||||||
/* empty */
|
/* empty */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ import android.net.wifi.aware.IWifiAwareDiscoverySessionCallback;
|
|||||||
import android.net.wifi.aware.IWifiAwareEventCallback;
|
import android.net.wifi.aware.IWifiAwareEventCallback;
|
||||||
import android.net.wifi.aware.PublishConfig;
|
import android.net.wifi.aware.PublishConfig;
|
||||||
import android.net.wifi.aware.SubscribeConfig;
|
import android.net.wifi.aware.SubscribeConfig;
|
||||||
import android.net.wifi.aware.WifiAwareCharacteristics;
|
import android.net.wifi.aware.Characteristics;
|
||||||
import android.net.wifi.RttManager;
|
import android.net.wifi.RttManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +37,7 @@ interface IWifiAwareManager
|
|||||||
void enableUsage();
|
void enableUsage();
|
||||||
void disableUsage();
|
void disableUsage();
|
||||||
boolean isUsageEnabled();
|
boolean isUsageEnabled();
|
||||||
WifiAwareCharacteristics getCharacteristics();
|
Characteristics getCharacteristics();
|
||||||
|
|
||||||
// client API
|
// client API
|
||||||
void connect(in IBinder binder, in String callingPackage, in IWifiAwareEventCallback callback,
|
void connect(in IBinder binder, in String callingPackage, in IWifiAwareEventCallback callback,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ package android.net.wifi.aware;
|
|||||||
*
|
*
|
||||||
* @hide PROPOSED_AWARE_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiAwareIdentityChangedListener {
|
public class IdentityChangedListener {
|
||||||
/**
|
/**
|
||||||
* @param mac The MAC address of the Aware discovery interface. The application must have the
|
* @param mac The MAC address of the Aware discovery interface. The application must have the
|
||||||
* {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} to get the actual MAC address,
|
* {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} to get the actual MAC address,
|
||||||
36
wifi/java/android/net/wifi/aware/PeerHandle.java
Normal file
36
wifi/java/android/net/wifi/aware/PeerHandle.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opaque object used to represent a Wi-Fi Aware peer. Obtained from discovery sessions in
|
||||||
|
* {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle, byte[], java.util.List)}, used
|
||||||
|
* when sending messages e,g, {@link PublishDiscoverySession#sendMessage(PeerHandle, int, byte[])},
|
||||||
|
* or when configuring a network link to a peer, e.g.
|
||||||
|
* {@link PublishDiscoverySession#createNetworkSpecifier(PeerHandle, byte[])}.
|
||||||
|
*
|
||||||
|
* @hide PROPOSED_AWARE_API
|
||||||
|
*/
|
||||||
|
public class PeerHandle {
|
||||||
|
/** @hide */
|
||||||
|
public PeerHandle(int peerId) {
|
||||||
|
this.peerId = peerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public int peerId;
|
||||||
|
}
|
||||||
@@ -33,9 +33,9 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Defines the configuration of a Aware publish session. Built using
|
* Defines the configuration of a Aware publish session. Built using
|
||||||
* {@link PublishConfig.Builder}. A publish session is created using
|
* {@link PublishConfig.Builder}. A publish session is created using
|
||||||
* {@link WifiAwareSession#publish(PublishConfig, WifiAwareDiscoverySessionCallback,
|
* {@link WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback,
|
||||||
* android.os.Handler)} or updated using
|
* android.os.Handler)} or updated using
|
||||||
* {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)}.
|
* {@link PublishDiscoverySession#updatePublish(PublishConfig)}.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_AWARE_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
@@ -184,7 +184,7 @@ public final class PublishConfig implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void assertValid(WifiAwareCharacteristics characteristics)
|
public void assertValid(Characteristics characteristics)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
WifiAwareUtils.validateServiceName(mServiceName);
|
WifiAwareUtils.validateServiceName(mServiceName);
|
||||||
|
|
||||||
@@ -322,12 +322,12 @@ public final class PublishConfig implements Parcelable {
|
|||||||
* Sets the number of times an unsolicited (configured using
|
* Sets the number of times an unsolicited (configured using
|
||||||
* {@link PublishConfig.Builder#setPublishType(int)}) publish session
|
* {@link PublishConfig.Builder#setPublishType(int)}) publish session
|
||||||
* will be broadcast. When the count is reached an event will be
|
* will be broadcast. When the count is reached an event will be
|
||||||
* generated for {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)}
|
* generated for {@link DiscoverySessionCallback#onSessionTerminated(int)}
|
||||||
* with {@link WifiAwareDiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
|
* with {@link DiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
|
||||||
* {@link #setTerminateNotificationEnabled(boolean)} disables the callback].
|
* {@link #setTerminateNotificationEnabled(boolean)} disables the callback].
|
||||||
* <p>
|
* <p>
|
||||||
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
||||||
* Session will be terminated when {@link WifiAwareDiscoveryBaseSession#destroy()} is
|
* Session will be terminated when {@link DiscoverySession#destroy()} is
|
||||||
* called.
|
* called.
|
||||||
*
|
*
|
||||||
* @param publishCount Number of publish packets to broadcast.
|
* @param publishCount Number of publish packets to broadcast.
|
||||||
@@ -348,12 +348,12 @@ public final class PublishConfig implements Parcelable {
|
|||||||
* {@link PublishConfig.Builder#setPublishType(int)}) publish session
|
* {@link PublishConfig.Builder#setPublishType(int)}) publish session
|
||||||
* will be alive - broadcasting a packet. When the TTL is reached
|
* will be alive - broadcasting a packet. When the TTL is reached
|
||||||
* an event will be generated for
|
* an event will be generated for
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} with
|
* {@link DiscoverySessionCallback#onSessionTerminated(int)} with
|
||||||
* {@link WifiAwareDiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
|
* {@link DiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
|
||||||
* {@link #setTerminateNotificationEnabled(boolean)} disables the callback].
|
* {@link #setTerminateNotificationEnabled(boolean)} disables the callback].
|
||||||
* <p>
|
* <p>
|
||||||
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
||||||
* Session will be terminated when {@link WifiAwareDiscoveryBaseSession#destroy()} is
|
* Session will be terminated when {@link DiscoverySession#destroy()} is
|
||||||
* called.
|
* called.
|
||||||
*
|
*
|
||||||
* @param ttlSec Lifetime of a publish session in seconds.
|
* @param ttlSec Lifetime of a publish session in seconds.
|
||||||
@@ -371,7 +371,7 @@ public final class PublishConfig implements Parcelable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure whether a publish terminate notification
|
* Configure whether a publish terminate notification
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} is reported
|
* {@link DiscoverySessionCallback#onSessionTerminated(int)} is reported
|
||||||
* back to the callback.
|
* back to the callback.
|
||||||
*
|
*
|
||||||
* @param enable If true the terminate callback will be called when the
|
* @param enable If true the terminate callback will be called when the
|
||||||
|
|||||||
@@ -21,32 +21,32 @@ import android.util.Log;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representing a Aware publish session. Created when
|
* A class representing a Aware publish session. Created when
|
||||||
* {@link WifiAwareSession#publish(PublishConfig, WifiAwareDiscoverySessionCallback,
|
* {@link WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback,
|
||||||
* android.os.Handler)} is called and a discovery session is created and returned in
|
* android.os.Handler)} is called and a discovery session is created and returned in
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onPublishStarted(WifiAwarePublishDiscoverySession)}. See
|
* {@link DiscoverySessionCallback#onPublishStarted(PublishDiscoverySession)}. See
|
||||||
* baseline functionality of all discovery sessions in {@link WifiAwareDiscoveryBaseSession}. This
|
* baseline functionality of all discovery sessions in {@link DiscoverySession}. This
|
||||||
* object allows updating an existing/running publish discovery session using
|
* object allows updating an existing/running publish discovery session using
|
||||||
* {@link #updatePublish(PublishConfig)}.
|
* {@link #updatePublish(PublishConfig)}.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_AWARE_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiAwarePublishDiscoverySession extends WifiAwareDiscoveryBaseSession {
|
public class PublishDiscoverySession extends DiscoverySession {
|
||||||
private static final String TAG = "WifiAwarePublishDiscSsn";
|
private static final String TAG = "PublishDiscoverySession";
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public WifiAwarePublishDiscoverySession(WifiAwareManager manager, int clientId, int sessionId) {
|
public PublishDiscoverySession(WifiAwareManager manager, int clientId, int sessionId) {
|
||||||
super(manager, clientId, sessionId);
|
super(manager, clientId, sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-configure the currently active publish session. The
|
* Re-configure the currently active publish session. The
|
||||||
* {@link WifiAwareDiscoverySessionCallback} is not replaced - the same listener used
|
* {@link DiscoverySessionCallback} is not replaced - the same listener used
|
||||||
* at creation is still used. The results of the configuration are returned using
|
* at creation is still used. The results of the configuration are returned using
|
||||||
* {@link WifiAwareDiscoverySessionCallback}:
|
* {@link DiscoverySessionCallback}:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigUpdated()}: configuration
|
* <li>{@link DiscoverySessionCallback#onSessionConfigUpdated()}: configuration
|
||||||
* update succeeded.
|
* update succeeded.
|
||||||
* <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigFailed()}: configuration
|
* <li>{@link DiscoverySessionCallback#onSessionConfigFailed()}: configuration
|
||||||
* update failed. The publish discovery session is still running using its previous
|
* update failed. The publish discovery session is still running using its previous
|
||||||
* configuration (i.e. update failure does not terminate the session).
|
* configuration (i.e. update failure does not terminate the session).
|
||||||
* </ul>
|
* </ul>
|
||||||
@@ -33,9 +33,9 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Defines the configuration of a Aware subscribe session. Built using
|
* Defines the configuration of a Aware subscribe session. Built using
|
||||||
* {@link SubscribeConfig.Builder}. Subscribe is done using
|
* {@link SubscribeConfig.Builder}. Subscribe is done using
|
||||||
* {@link WifiAwareSession#subscribe(SubscribeConfig, WifiAwareDiscoverySessionCallback,
|
* {@link WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback,
|
||||||
* android.os.Handler)} or
|
* android.os.Handler)} or
|
||||||
* {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
* {@link SubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_AWARE_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
@@ -212,7 +212,7 @@ public final class SubscribeConfig implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void assertValid(WifiAwareCharacteristics characteristics)
|
public void assertValid(Characteristics characteristics)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
WifiAwareUtils.validateServiceName(mServiceName);
|
WifiAwareUtils.validateServiceName(mServiceName);
|
||||||
|
|
||||||
@@ -355,11 +355,11 @@ public final class SubscribeConfig implements Parcelable {
|
|||||||
* Sets the number of times an active (
|
* Sets the number of times an active (
|
||||||
* {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session
|
* {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session
|
||||||
* will broadcast. When the count is reached an event will be
|
* will broadcast. When the count is reached an event will be
|
||||||
* generated for {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)}
|
* generated for {@link DiscoverySessionCallback#onSessionTerminated(int)}
|
||||||
* with {@link WifiAwareDiscoverySessionCallback#TERMINATE_REASON_DONE}.
|
* with {@link DiscoverySessionCallback#TERMINATE_REASON_DONE}.
|
||||||
* <p>
|
* <p>
|
||||||
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
||||||
* Session will be terminated when {@link WifiAwareDiscoveryBaseSession#destroy()} is
|
* Session will be terminated when {@link DiscoverySession#destroy()} is
|
||||||
* called.
|
* called.
|
||||||
*
|
*
|
||||||
* @param subscribeCount Number of subscribe packets to broadcast.
|
* @param subscribeCount Number of subscribe packets to broadcast.
|
||||||
@@ -380,11 +380,11 @@ public final class SubscribeConfig implements Parcelable {
|
|||||||
* {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session
|
* {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session
|
||||||
* will be alive - i.e. broadcasting a packet. When the TTL is reached
|
* will be alive - i.e. broadcasting a packet. When the TTL is reached
|
||||||
* an event will be generated for
|
* an event will be generated for
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} with
|
* {@link DiscoverySessionCallback#onSessionTerminated(int)} with
|
||||||
* {@link WifiAwareDiscoverySessionCallback#TERMINATE_REASON_DONE}.
|
* {@link DiscoverySessionCallback#TERMINATE_REASON_DONE}.
|
||||||
* <p>
|
* <p>
|
||||||
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
||||||
* Session will be terminated when {@link WifiAwareDiscoveryBaseSession#destroy()} is
|
* Session will be terminated when {@link DiscoverySession#destroy()} is
|
||||||
* called.
|
* called.
|
||||||
*
|
*
|
||||||
* @param ttlSec Lifetime of a subscribe session in seconds.
|
* @param ttlSec Lifetime of a subscribe session in seconds.
|
||||||
@@ -404,8 +404,8 @@ public final class SubscribeConfig implements Parcelable {
|
|||||||
* Sets the match style of the subscription - how are matches from a
|
* Sets the match style of the subscription - how are matches from a
|
||||||
* single match session (corresponding to the same publish action on the
|
* single match session (corresponding to the same publish action on the
|
||||||
* peer) reported to the host (using the
|
* peer) reported to the host (using the
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle, byte[],
|
||||||
* byte[], List)}). The options are: only report the first match and ignore the rest
|
* java.util.List)}). The options are: only report the first match and ignore the rest
|
||||||
* {@link SubscribeConfig#MATCH_STYLE_FIRST_ONLY} or report every single
|
* {@link SubscribeConfig#MATCH_STYLE_FIRST_ONLY} or report every single
|
||||||
* match {@link SubscribeConfig#MATCH_STYLE_ALL} (the default).
|
* match {@link SubscribeConfig#MATCH_STYLE_ALL} (the default).
|
||||||
*
|
*
|
||||||
@@ -424,7 +424,7 @@ public final class SubscribeConfig implements Parcelable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure whether a subscribe terminate notification
|
* Configure whether a subscribe terminate notification
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} is reported
|
* {@link DiscoverySessionCallback#onSessionTerminated(int)} is reported
|
||||||
* back to the callback.
|
* back to the callback.
|
||||||
*
|
*
|
||||||
* @param enable If true the terminate callback will be called when the
|
* @param enable If true the terminate callback will be called when the
|
||||||
|
|||||||
@@ -22,35 +22,35 @@ import android.util.Log;
|
|||||||
/**
|
/**
|
||||||
* A class representing a Aware subscribe session. Created when
|
* A class representing a Aware subscribe session. Created when
|
||||||
* {@link WifiAwareSession#subscribe(SubscribeConfig,
|
* {@link WifiAwareSession#subscribe(SubscribeConfig,
|
||||||
* WifiAwareDiscoverySessionCallback, android.os.Handler)}
|
* DiscoverySessionCallback, android.os.Handler)}
|
||||||
* is called and a discovery session is created and returned in
|
* is called and a discovery session is created and returned in
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onSubscribeStarted(WifiAwareSubscribeDiscoverySession)}.
|
* {@link DiscoverySessionCallback#onSubscribeStarted(SubscribeDiscoverySession)}.
|
||||||
* See baseline functionality of all discovery sessions in {@link WifiAwareDiscoveryBaseSession}.
|
* See baseline functionality of all discovery sessions in {@link DiscoverySession}.
|
||||||
* This object allows updating an existing/running subscribe discovery session using
|
* This object allows updating an existing/running subscribe discovery session using
|
||||||
* {@link #updateSubscribe(SubscribeConfig)}.
|
* {@link #updateSubscribe(SubscribeConfig)}.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_AWARE_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiAwareSubscribeDiscoverySession extends WifiAwareDiscoveryBaseSession {
|
public class SubscribeDiscoverySession extends DiscoverySession {
|
||||||
private static final String TAG = "WifiAwareSubsDiscSsn";
|
private static final String TAG = "SubscribeDiscoverySession";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
public WifiAwareSubscribeDiscoverySession(WifiAwareManager manager, int clientId,
|
public SubscribeDiscoverySession(WifiAwareManager manager, int clientId,
|
||||||
int sessionId) {
|
int sessionId) {
|
||||||
super(manager, clientId, sessionId);
|
super(manager, clientId, sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-configure the currently active subscribe session. The
|
* Re-configure the currently active subscribe session. The
|
||||||
* {@link WifiAwareDiscoverySessionCallback} is not replaced - the same listener used
|
* {@link DiscoverySessionCallback} is not replaced - the same listener used
|
||||||
* at creation is still used. The results of the configuration are returned using
|
* at creation is still used. The results of the configuration are returned using
|
||||||
* {@link WifiAwareDiscoverySessionCallback}:
|
* {@link DiscoverySessionCallback}:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigUpdated()}: configuration
|
* <li>{@link DiscoverySessionCallback#onSessionConfigUpdated()}: configuration
|
||||||
* update succeeded.
|
* update succeeded.
|
||||||
* <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigFailed()}: configuration
|
* <li>{@link DiscoverySessionCallback#onSessionConfigFailed()}: configuration
|
||||||
* update failed. The subscribe discovery session is still running using its previous
|
* update failed. The subscribe discovery session is still running using its previous
|
||||||
* configuration (i.e. update failure does not terminate the session).
|
* configuration (i.e. update failure does not terminate the session).
|
||||||
* </ul>
|
* </ul>
|
||||||
@@ -58,14 +58,14 @@ import java.util.List;
|
|||||||
* The class provides access to:
|
* The class provides access to:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Initialize a Aware cluster (peer-to-peer synchronization). Refer to
|
* <li>Initialize a Aware cluster (peer-to-peer synchronization). Refer to
|
||||||
* {@link #attach(WifiAwareAttachCallback, Handler)}.
|
* {@link #attach(AttachCallback, Handler)}.
|
||||||
* <li>Create discovery sessions (publish or subscribe sessions). Refer to
|
* <li>Create discovery sessions (publish or subscribe sessions). Refer to
|
||||||
* {@link WifiAwareSession#publish(PublishConfig, WifiAwareDiscoverySessionCallback, Handler)} and
|
* {@link WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback, Handler)} and
|
||||||
* {@link WifiAwareSession#subscribe(SubscribeConfig, WifiAwareDiscoverySessionCallback, Handler)}.
|
* {@link WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback, Handler)}.
|
||||||
* <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(PeerHandle, byte[])} and
|
* {@link DiscoverySession#createNetworkSpecifier(PeerHandle, byte[])} and
|
||||||
* {@link WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])}.
|
* {@link WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])}.
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
@@ -75,37 +75,37 @@ import java.util.List;
|
|||||||
* broadcast. Note that this broadcast is not sticky - you should register for it and then
|
* broadcast. Note that this broadcast is not sticky - you should register for it and then
|
||||||
* check the above API to avoid a race condition.
|
* check the above API to avoid a race condition.
|
||||||
* <p>
|
* <p>
|
||||||
* An application must use {@link #attach(WifiAwareAttachCallback, Handler)} to initialize a
|
* An application must use {@link #attach(AttachCallback, Handler)} to initialize a
|
||||||
* Aware cluster - before making any other Aware operation. Aware cluster membership is a
|
* Aware cluster - before making any other Aware operation. Aware cluster membership is a
|
||||||
* device-wide operation - the API guarantees that the device is in a cluster or joins a
|
* device-wide operation - the API guarantees that the device is in a cluster or joins a
|
||||||
* Aware cluster (or starts one if none can be found). Information about attach success (or
|
* Aware cluster (or starts one if none can be found). Information about attach success (or
|
||||||
* failure) are returned in callbacks of {@link WifiAwareAttachCallback}. Proceed with Aware
|
* failure) are returned in callbacks of {@link AttachCallback}. Proceed with Aware
|
||||||
* discovery or connection setup only after receiving confirmation that Aware attach
|
* discovery or connection setup only after receiving confirmation that Aware attach
|
||||||
* succeeded - {@link WifiAwareAttachCallback#onAttached(WifiAwareSession)}. When an
|
* succeeded - {@link AttachCallback#onAttached(WifiAwareSession)}. When an
|
||||||
* application is finished using Aware it <b>must</b> use the
|
* application is finished using Aware it <b>must</b> use the
|
||||||
* {@link WifiAwareSession#destroy()} API to indicate to the Aware service that the device
|
* {@link WifiAwareSession#destroy()} API to indicate to the Aware service that the device
|
||||||
* may detach from the Aware cluster. The device will actually disable Aware once the last
|
* may detach from the Aware cluster. The device will actually disable Aware once the last
|
||||||
* application detaches.
|
* application detaches.
|
||||||
* <p>
|
* <p>
|
||||||
* Once a Aware attach is confirmed use the
|
* Once a Aware attach is confirmed use the
|
||||||
* {@link WifiAwareSession#publish(PublishConfig, WifiAwareDiscoverySessionCallback, Handler)}
|
* {@link WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback, Handler)}
|
||||||
* or
|
* or
|
||||||
* {@link WifiAwareSession#subscribe(SubscribeConfig, WifiAwareDiscoverySessionCallback,
|
* {@link WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback,
|
||||||
* Handler)} to create publish or subscribe Aware discovery sessions. Events are called on the
|
* Handler)} to create publish or subscribe Aware discovery sessions. Events are called on the
|
||||||
* provided callback object {@link WifiAwareDiscoverySessionCallback}. Specifically, the
|
* provided callback object {@link DiscoverySessionCallback}. Specifically, the
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onPublishStarted(WifiAwarePublishDiscoverySession)}
|
* {@link DiscoverySessionCallback#onPublishStarted(PublishDiscoverySession)}
|
||||||
* and
|
* and
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onSubscribeStarted(
|
* {@link DiscoverySessionCallback#onSubscribeStarted(
|
||||||
* WifiAwareSubscribeDiscoverySession)}
|
*SubscribeDiscoverySession)}
|
||||||
* return {@link WifiAwarePublishDiscoverySession} and
|
* return {@link PublishDiscoverySession} and
|
||||||
* {@link WifiAwareSubscribeDiscoverySession}
|
* {@link SubscribeDiscoverySession}
|
||||||
* objects respectively on which additional session operations can be performed, e.g. updating
|
* objects respectively on which additional session operations can be performed, e.g. updating
|
||||||
* the session {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)} and
|
* the session {@link PublishDiscoverySession#updatePublish(PublishConfig)} and
|
||||||
* {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. Sessions can
|
* {@link SubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. Sessions can
|
||||||
* also be used to send messages using the
|
* also be used to send messages using the
|
||||||
* {@link WifiAwareDiscoveryBaseSession#sendMessage(PeerHandle, int, byte[])} APIs. When an
|
* {@link DiscoverySession#sendMessage(PeerHandle, int, byte[])} APIs. When an
|
||||||
* application is finished with a discovery session it <b>must</b> terminate it using the
|
* application is finished with a discovery session it <b>must</b> terminate it using the
|
||||||
* {@link WifiAwareDiscoveryBaseSession#destroy()} API.
|
* {@link DiscoverySession#destroy()} API.
|
||||||
* <p>
|
* <p>
|
||||||
* Creating connections between Aware devices is managed by the standard
|
* Creating connections between Aware devices is managed by the standard
|
||||||
* {@link ConnectivityManager#requestNetwork(NetworkRequest,
|
* {@link ConnectivityManager#requestNetwork(NetworkRequest,
|
||||||
@@ -116,7 +116,7 @@ import java.util.List;
|
|||||||
* {@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(PeerHandle, byte[])}.
|
* {@link DiscoverySession#createNetworkSpecifier(PeerHandle, byte[])}.
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_AWARE_API
|
* @hide PROPOSED_AWARE_API
|
||||||
@@ -226,7 +226,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(PeerHandle, byte[])
|
* @see DiscoverySession#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;
|
||||||
@@ -235,7 +235,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(PeerHandle, byte[])
|
* @see DiscoverySession#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;
|
||||||
@@ -307,7 +307,7 @@ public class WifiAwareManager {
|
|||||||
* @return An object specifying configuration limitations of Aware.
|
* @return An object specifying configuration limitations of Aware.
|
||||||
* @hide PROPOSED_AWARE_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public WifiAwareCharacteristics getCharacteristics() {
|
public Characteristics getCharacteristics() {
|
||||||
try {
|
try {
|
||||||
return mService.getCharacteristics();
|
return mService.getCharacteristics();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -328,12 +328,12 @@ public class WifiAwareManager {
|
|||||||
* attachCallback}.
|
* attachCallback}.
|
||||||
*
|
*
|
||||||
* @param attachCallback A callback for attach events, extended from
|
* @param attachCallback A callback for attach events, extended from
|
||||||
* {@link WifiAwareAttachCallback}.
|
* {@link AttachCallback}.
|
||||||
* @param handler The Handler on whose thread to execute the callbacks of the {@code
|
* @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
|
* attachCallback} object. If a null is provided then the application's main thread will be
|
||||||
* used.
|
* used.
|
||||||
*/
|
*/
|
||||||
public void attach(@NonNull WifiAwareAttachCallback attachCallback, @Nullable Handler handler) {
|
public void attach(@NonNull AttachCallback attachCallback, @Nullable Handler handler) {
|
||||||
attach(handler, null, attachCallback, null);
|
attach(handler, null, attachCallback, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,28 +353,28 @@ public class WifiAwareManager {
|
|||||||
* on startup and whenever it is updated (it is randomized at regular intervals for privacy).
|
* on startup and whenever it is updated (it is randomized at regular intervals for privacy).
|
||||||
* The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
|
* The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
|
||||||
* permission to execute this attach request. Otherwise, use the
|
* permission to execute this attach request. Otherwise, use the
|
||||||
* {@link #attach(WifiAwareAttachCallback, Handler)} version. Note that aside from permission
|
* {@link #attach(AttachCallback, Handler)} version. Note that aside from permission
|
||||||
* requirements this listener will wake up the host at regular intervals causing higher power
|
* 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).
|
* consumption, do not use it unless the information is necessary (e.g. for OOB discovery).
|
||||||
*
|
*
|
||||||
* @param attachCallback A callback for attach events, extended from
|
* @param attachCallback A callback for attach events, extended from
|
||||||
* {@link WifiAwareAttachCallback}.
|
* {@link AttachCallback}.
|
||||||
* @param identityChangedListener A listener for changed identity, extended from
|
* @param identityChangedListener A listener for changed identity, extended from
|
||||||
* {@link WifiAwareIdentityChangedListener}.
|
* {@link IdentityChangedListener}.
|
||||||
* @param handler The Handler on whose thread to execute the callbacks of the {@code
|
* @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
|
* attachCallback} and {@code identityChangedListener} objects. If a null is provided then the
|
||||||
* application's main thread will be used.
|
* application's main thread will be used.
|
||||||
*/
|
*/
|
||||||
public void attach(@NonNull WifiAwareAttachCallback attachCallback,
|
public void attach(@NonNull AttachCallback attachCallback,
|
||||||
@NonNull WifiAwareIdentityChangedListener identityChangedListener,
|
@NonNull IdentityChangedListener identityChangedListener,
|
||||||
@Nullable Handler handler) {
|
@Nullable Handler handler) {
|
||||||
attach(handler, null, attachCallback, identityChangedListener);
|
attach(handler, null, attachCallback, identityChangedListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void attach(Handler handler, ConfigRequest configRequest,
|
public void attach(Handler handler, ConfigRequest configRequest,
|
||||||
WifiAwareAttachCallback attachCallback,
|
AttachCallback attachCallback,
|
||||||
WifiAwareIdentityChangedListener identityChangedListener) {
|
IdentityChangedListener identityChangedListener) {
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
Log.v(TAG, "attach(): handler=" + handler + ", callback=" + attachCallback
|
Log.v(TAG, "attach(): handler=" + handler + ", callback=" + attachCallback
|
||||||
+ ", configRequest=" + configRequest + ", identityChangedListener="
|
+ ", configRequest=" + configRequest + ", identityChangedListener="
|
||||||
@@ -409,7 +409,7 @@ public class WifiAwareManager {
|
|||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void publish(int clientId, Looper looper, PublishConfig publishConfig,
|
public void publish(int clientId, Looper looper, PublishConfig publishConfig,
|
||||||
WifiAwareDiscoverySessionCallback callback) {
|
DiscoverySessionCallback callback) {
|
||||||
if (VDBG) Log.v(TAG, "publish(): clientId=" + clientId + ", config=" + publishConfig);
|
if (VDBG) Log.v(TAG, "publish(): clientId=" + clientId + ", config=" + publishConfig);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -437,7 +437,7 @@ public class WifiAwareManager {
|
|||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void subscribe(int clientId, Looper looper, SubscribeConfig subscribeConfig,
|
public void subscribe(int clientId, Looper looper, SubscribeConfig subscribeConfig,
|
||||||
WifiAwareDiscoverySessionCallback callback) {
|
DiscoverySessionCallback callback) {
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
Log.v(TAG,
|
Log.v(TAG,
|
||||||
@@ -672,14 +672,14 @@ public class WifiAwareManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a {@link WifiAwareAttachCallback} using the specified looper.
|
* Constructs a {@link AttachCallback} using the specified looper.
|
||||||
* All callbacks will delivered on the thread of the specified looper.
|
* All callbacks will delivered on the thread of the specified looper.
|
||||||
*
|
*
|
||||||
* @param looper The looper on which to execute the callbacks.
|
* @param looper The looper on which to execute the callbacks.
|
||||||
*/
|
*/
|
||||||
WifiAwareEventCallbackProxy(WifiAwareManager mgr, Looper looper, Binder binder,
|
WifiAwareEventCallbackProxy(WifiAwareManager mgr, Looper looper, Binder binder,
|
||||||
final WifiAwareAttachCallback attachCallback,
|
final AttachCallback attachCallback,
|
||||||
final WifiAwareIdentityChangedListener identityChangedListener) {
|
final IdentityChangedListener identityChangedListener) {
|
||||||
mAwareManager = new WeakReference<>(mgr);
|
mAwareManager = new WeakReference<>(mgr);
|
||||||
mLooper = looper;
|
mLooper = looper;
|
||||||
mBinder = binder;
|
mBinder = binder;
|
||||||
@@ -828,14 +828,14 @@ public class WifiAwareManager {
|
|||||||
|
|
||||||
private final WeakReference<WifiAwareManager> mAwareManager;
|
private final WeakReference<WifiAwareManager> mAwareManager;
|
||||||
private final boolean mIsPublish;
|
private final boolean mIsPublish;
|
||||||
private final WifiAwareDiscoverySessionCallback mOriginalCallback;
|
private final DiscoverySessionCallback mOriginalCallback;
|
||||||
private final int mClientId;
|
private final int mClientId;
|
||||||
|
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
private WifiAwareDiscoveryBaseSession mSession;
|
private DiscoverySession mSession;
|
||||||
|
|
||||||
WifiAwareDiscoverySessionCallbackProxy(WifiAwareManager mgr, Looper looper,
|
WifiAwareDiscoverySessionCallbackProxy(WifiAwareManager mgr, Looper looper,
|
||||||
boolean isPublish, WifiAwareDiscoverySessionCallback originalCallback,
|
boolean isPublish, DiscoverySessionCallback originalCallback,
|
||||||
int clientId) {
|
int clientId) {
|
||||||
mAwareManager = new WeakReference<>(mgr);
|
mAwareManager = new WeakReference<>(mgr);
|
||||||
mIsPublish = isPublish;
|
mIsPublish = isPublish;
|
||||||
@@ -1006,13 +1006,13 @@ public class WifiAwareManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mIsPublish) {
|
if (mIsPublish) {
|
||||||
WifiAwarePublishDiscoverySession session = new WifiAwarePublishDiscoverySession(mgr,
|
PublishDiscoverySession session = new PublishDiscoverySession(mgr,
|
||||||
mClientId, sessionId);
|
mClientId, sessionId);
|
||||||
mSession = session;
|
mSession = session;
|
||||||
mOriginalCallback.onPublishStarted(session);
|
mOriginalCallback.onPublishStarted(session);
|
||||||
} else {
|
} else {
|
||||||
WifiAwareSubscribeDiscoverySession
|
SubscribeDiscoverySession
|
||||||
session = new WifiAwareSubscribeDiscoverySession(mgr, mClientId, sessionId);
|
session = new SubscribeDiscoverySession(mgr, mClientId, sessionId);
|
||||||
mSession = session;
|
mSession = session;
|
||||||
mOriginalCallback.onSubscribeStarted(session);
|
mOriginalCallback.onSubscribeStarted(session);
|
||||||
}
|
}
|
||||||
@@ -1030,15 +1030,4 @@ public class WifiAwareManager {
|
|||||||
mOriginalCallback.onSessionTerminated(reason);
|
mOriginalCallback.onSessionTerminated(reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide PROPOSED_AWARE_API */
|
|
||||||
public static class PeerHandle {
|
|
||||||
/** @hide */
|
|
||||||
public PeerHandle(int peerId) {
|
|
||||||
this.peerId = peerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public int peerId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class WifiAwareSession {
|
|||||||
* session-wide destroy.
|
* session-wide destroy.
|
||||||
* <p>
|
* <p>
|
||||||
* An application may re-attach after a destroy using
|
* An application may re-attach after a destroy using
|
||||||
* {@link WifiAwareManager#attach(WifiAwareAttachCallback, Handler)} .
|
* {@link WifiAwareManager#attach(AttachCallback, Handler)} .
|
||||||
*/
|
*/
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
WifiAwareManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
@@ -95,22 +95,22 @@ public class WifiAwareSession {
|
|||||||
/**
|
/**
|
||||||
* Issue a request to the Aware service to create a new Aware publish discovery session, using
|
* Issue a request to the Aware service to create a new Aware publish discovery session, using
|
||||||
* the specified {@code publishConfig} configuration. The results of the publish operation
|
* the specified {@code publishConfig} configuration. The results of the publish operation
|
||||||
* are routed to the callbacks of {@link WifiAwareDiscoverySessionCallback}:
|
* are routed to the callbacks of {@link DiscoverySessionCallback}:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>
|
* <li>
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onPublishStarted(
|
* {@link DiscoverySessionCallback#onPublishStarted(
|
||||||
* WifiAwarePublishDiscoverySession)}
|
*PublishDiscoverySession)}
|
||||||
* is called when the publish session is created and provides a handle to the session.
|
* is called when the publish session is created and provides a handle to the session.
|
||||||
* Further operations on the publish session can be executed on that object.
|
* Further operations on the publish session can be executed on that object.
|
||||||
* <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigFailed()} is called if the
|
* <li>{@link DiscoverySessionCallback#onSessionConfigFailed()} is called if the
|
||||||
* publish operation failed.
|
* publish operation failed.
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* Other results of the publish session operations will also be routed to callbacks
|
* Other results of the publish session operations will also be routed to callbacks
|
||||||
* on the {@code callback} object. The resulting publish session can be modified using
|
* on the {@code callback} object. The resulting publish session can be modified using
|
||||||
* {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)}.
|
* {@link PublishDiscoverySession#updatePublish(PublishConfig)}.
|
||||||
* <p>
|
* <p>
|
||||||
* An application must use the {@link WifiAwareDiscoveryBaseSession#destroy()} to
|
* An application must use the {@link DiscoverySession#destroy()} to
|
||||||
* terminate the publish discovery session once it isn't needed. This will free
|
* terminate the publish discovery session once it isn't needed. This will free
|
||||||
* resources as well terminate any on-air transmissions.
|
* resources as well terminate any on-air transmissions.
|
||||||
* <p>The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
|
* <p>The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
|
||||||
@@ -118,13 +118,13 @@ public class WifiAwareSession {
|
|||||||
*
|
*
|
||||||
* @param publishConfig The {@link PublishConfig} specifying the
|
* @param publishConfig The {@link PublishConfig} specifying the
|
||||||
* configuration of the requested publish session.
|
* configuration of the requested publish session.
|
||||||
* @param callback A {@link WifiAwareDiscoverySessionCallback} derived object to be used for
|
* @param callback A {@link DiscoverySessionCallback} derived object to be used for
|
||||||
* session event callbacks.
|
* session event callbacks.
|
||||||
* @param handler The Handler on whose thread to execute the callbacks of the {@code
|
* @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.
|
* callback} object. If a null is provided then the application's main thread will be used.
|
||||||
*/
|
*/
|
||||||
public void publish(@NonNull PublishConfig publishConfig,
|
public void publish(@NonNull PublishConfig publishConfig,
|
||||||
@NonNull WifiAwareDiscoverySessionCallback callback, @Nullable Handler handler) {
|
@NonNull DiscoverySessionCallback callback, @Nullable Handler handler) {
|
||||||
WifiAwareManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.e(TAG, "publish: called post GC on WifiAwareManager");
|
Log.e(TAG, "publish: called post GC on WifiAwareManager");
|
||||||
@@ -141,22 +141,22 @@ public class WifiAwareSession {
|
|||||||
/**
|
/**
|
||||||
* Issue a request to the Aware service to create a new Aware subscribe discovery session, using
|
* Issue a request to the Aware service to create a new Aware subscribe discovery session, using
|
||||||
* the specified {@code subscribeConfig} configuration. The results of the subscribe
|
* the specified {@code subscribeConfig} configuration. The results of the subscribe
|
||||||
* operation are routed to the callbacks of {@link WifiAwareDiscoverySessionCallback}:
|
* operation are routed to the callbacks of {@link DiscoverySessionCallback}:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>
|
* <li>
|
||||||
* {@link WifiAwareDiscoverySessionCallback#onSubscribeStarted(
|
* {@link DiscoverySessionCallback#onSubscribeStarted(
|
||||||
* WifiAwareSubscribeDiscoverySession)}
|
*SubscribeDiscoverySession)}
|
||||||
* is called when the subscribe session is created and provides a handle to the session.
|
* is called when the subscribe session is created and provides a handle to the session.
|
||||||
* Further operations on the subscribe session can be executed on that object.
|
* Further operations on the subscribe session can be executed on that object.
|
||||||
* <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigFailed()} is called if the
|
* <li>{@link DiscoverySessionCallback#onSessionConfigFailed()} is called if the
|
||||||
* subscribe operation failed.
|
* subscribe operation failed.
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* Other results of the subscribe session operations will also be routed to callbacks
|
* Other results of the subscribe session operations will also be routed to callbacks
|
||||||
* on the {@code callback} object. The resulting subscribe session can be modified using
|
* on the {@code callback} object. The resulting subscribe session can be modified using
|
||||||
* {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
* {@link SubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
||||||
* <p>
|
* <p>
|
||||||
* An application must use the {@link WifiAwareDiscoveryBaseSession#destroy()} to
|
* An application must use the {@link DiscoverySession#destroy()} to
|
||||||
* terminate the subscribe discovery session once it isn't needed. This will free
|
* terminate the subscribe discovery session once it isn't needed. This will free
|
||||||
* resources as well terminate any on-air transmissions.
|
* resources as well terminate any on-air transmissions.
|
||||||
* <p>The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
|
* <p>The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
|
||||||
@@ -164,13 +164,13 @@ public class WifiAwareSession {
|
|||||||
*
|
*
|
||||||
* @param subscribeConfig The {@link SubscribeConfig} specifying the
|
* @param subscribeConfig The {@link SubscribeConfig} specifying the
|
||||||
* configuration of the requested subscribe session.
|
* configuration of the requested subscribe session.
|
||||||
* @param callback A {@link WifiAwareDiscoverySessionCallback} derived object to be used for
|
* @param callback A {@link DiscoverySessionCallback} derived object to be used for
|
||||||
* session event callbacks.
|
* session event callbacks.
|
||||||
* @param handler The Handler on whose thread to execute the callbacks of the {@code
|
* @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.
|
* callback} object. If a null is provided then the application's main thread will be used.
|
||||||
*/
|
*/
|
||||||
public void subscribe(@NonNull SubscribeConfig subscribeConfig,
|
public void subscribe(@NonNull SubscribeConfig subscribeConfig,
|
||||||
@NonNull WifiAwareDiscoverySessionCallback callback, @Nullable Handler handler) {
|
@NonNull DiscoverySessionCallback callback, @Nullable Handler handler) {
|
||||||
WifiAwareManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.e(TAG, "publish: called post GC on WifiAwareManager");
|
Log.e(TAG, "publish: called post GC on WifiAwareManager");
|
||||||
@@ -193,7 +193,7 @@ 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(WifiAwareManager.PeerHandle,
|
* {@link DiscoverySession#createNetworkSpecifier(PeerHandle,
|
||||||
* byte[])}.
|
* byte[])}.
|
||||||
*
|
*
|
||||||
* @param role The role of this device:
|
* @param role The role of this device:
|
||||||
|
|||||||
@@ -67,19 +67,19 @@ public class WifiAwareManagerTest {
|
|||||||
public Context mockContext;
|
public Context mockContext;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
public WifiAwareAttachCallback mockCallback;
|
public AttachCallback mockCallback;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
public WifiAwareDiscoverySessionCallback mockSessionCallback;
|
public DiscoverySessionCallback mockSessionCallback;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
public IWifiAwareManager mockAwareService;
|
public IWifiAwareManager mockAwareService;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
public WifiAwarePublishDiscoverySession mockPublishSession;
|
public PublishDiscoverySession mockPublishSession;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
public WifiAwareSubscribeDiscoverySession mockSubscribeSession;
|
public SubscribeDiscoverySession mockSubscribeSession;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
public RttManager.RttListener mockRttListener;
|
public RttManager.RttListener mockRttListener;
|
||||||
@@ -276,7 +276,7 @@ public class WifiAwareManagerTest {
|
|||||||
final int sessionId = 123;
|
final int sessionId = 123;
|
||||||
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();
|
||||||
final WifiAwareManager.PeerHandle peerHandle = new WifiAwareManager.PeerHandle(873);
|
final PeerHandle peerHandle = new PeerHandle(873);
|
||||||
final String string1 = "hey from here...";
|
final String string1 = "hey from here...";
|
||||||
final byte[] matchFilter = { 1, 12, 2, 31, 32 };
|
final byte[] matchFilter = { 1, 12, 2, 31, 32 };
|
||||||
final int messageId = 2123;
|
final int messageId = 2123;
|
||||||
@@ -290,10 +290,9 @@ public class WifiAwareManagerTest {
|
|||||||
.forClass(IWifiAwareEventCallback.class);
|
.forClass(IWifiAwareEventCallback.class);
|
||||||
ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor
|
ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor
|
||||||
.forClass(IWifiAwareDiscoverySessionCallback.class);
|
.forClass(IWifiAwareDiscoverySessionCallback.class);
|
||||||
ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor
|
ArgumentCaptor<PublishDiscoverySession> publishSession = ArgumentCaptor
|
||||||
.forClass(WifiAwarePublishDiscoverySession.class);
|
.forClass(PublishDiscoverySession.class);
|
||||||
ArgumentCaptor<WifiAwareManager.PeerHandle> peerIdCaptor = ArgumentCaptor.forClass(
|
ArgumentCaptor<PeerHandle> peerIdCaptor = ArgumentCaptor.forClass(PeerHandle.class);
|
||||||
WifiAwareManager.PeerHandle.class);
|
|
||||||
ArgumentCaptor<List<byte[]>> matchFilterCaptor = ArgumentCaptor.forClass(
|
ArgumentCaptor<List<byte[]>> matchFilterCaptor = ArgumentCaptor.forClass(
|
||||||
(Class) List.class);
|
(Class) List.class);
|
||||||
|
|
||||||
@@ -377,7 +376,7 @@ public class WifiAwareManagerTest {
|
|||||||
final int sessionId = 123;
|
final int sessionId = 123;
|
||||||
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();
|
||||||
final int reason = WifiAwareDiscoverySessionCallback.TERMINATE_REASON_DONE;
|
final int reason = DiscoverySessionCallback.TERMINATE_REASON_DONE;
|
||||||
|
|
||||||
InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService,
|
InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService,
|
||||||
mockPublishSession);
|
mockPublishSession);
|
||||||
@@ -387,8 +386,8 @@ public class WifiAwareManagerTest {
|
|||||||
.forClass(IWifiAwareEventCallback.class);
|
.forClass(IWifiAwareEventCallback.class);
|
||||||
ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor
|
ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor
|
||||||
.forClass(IWifiAwareDiscoverySessionCallback.class);
|
.forClass(IWifiAwareDiscoverySessionCallback.class);
|
||||||
ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor
|
ArgumentCaptor<PublishDiscoverySession> publishSession = ArgumentCaptor
|
||||||
.forClass(WifiAwarePublishDiscoverySession.class);
|
.forClass(PublishDiscoverySession.class);
|
||||||
|
|
||||||
// (1) connect successfully
|
// (1) connect successfully
|
||||||
mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
|
mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
|
||||||
@@ -428,7 +427,7 @@ public class WifiAwareManagerTest {
|
|||||||
final int sessionId = 123;
|
final int sessionId = 123;
|
||||||
final ConfigRequest configRequest = new ConfigRequest.Builder().build();
|
final ConfigRequest configRequest = new ConfigRequest.Builder().build();
|
||||||
final SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build();
|
final SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build();
|
||||||
final WifiAwareManager.PeerHandle peerHandle = new WifiAwareManager.PeerHandle(873);
|
final PeerHandle peerHandle = new PeerHandle(873);
|
||||||
final String string1 = "hey from here...";
|
final String string1 = "hey from here...";
|
||||||
final byte[] matchFilter = { 1, 12, 3, 31, 32 }; // bad data!
|
final byte[] matchFilter = { 1, 12, 3, 31, 32 }; // bad data!
|
||||||
final int messageId = 2123;
|
final int messageId = 2123;
|
||||||
@@ -442,10 +441,9 @@ public class WifiAwareManagerTest {
|
|||||||
.forClass(IWifiAwareEventCallback.class);
|
.forClass(IWifiAwareEventCallback.class);
|
||||||
ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor
|
ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor
|
||||||
.forClass(IWifiAwareDiscoverySessionCallback.class);
|
.forClass(IWifiAwareDiscoverySessionCallback.class);
|
||||||
ArgumentCaptor<WifiAwareSubscribeDiscoverySession> subscribeSession = ArgumentCaptor
|
ArgumentCaptor<SubscribeDiscoverySession> subscribeSession = ArgumentCaptor
|
||||||
.forClass(WifiAwareSubscribeDiscoverySession.class);
|
.forClass(SubscribeDiscoverySession.class);
|
||||||
ArgumentCaptor<WifiAwareManager.PeerHandle> peerIdCaptor = ArgumentCaptor.forClass(
|
ArgumentCaptor<PeerHandle> peerIdCaptor = ArgumentCaptor.forClass(PeerHandle.class);
|
||||||
WifiAwareManager.PeerHandle.class);
|
|
||||||
|
|
||||||
// (0) connect + success
|
// (0) connect + success
|
||||||
mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
|
mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
|
||||||
@@ -516,7 +514,7 @@ public class WifiAwareManagerTest {
|
|||||||
final int sessionId = 123;
|
final int sessionId = 123;
|
||||||
final ConfigRequest configRequest = new ConfigRequest.Builder().build();
|
final ConfigRequest configRequest = new ConfigRequest.Builder().build();
|
||||||
final SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build();
|
final SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build();
|
||||||
final int reason = WifiAwareDiscoverySessionCallback.TERMINATE_REASON_DONE;
|
final int reason = DiscoverySessionCallback.TERMINATE_REASON_DONE;
|
||||||
|
|
||||||
InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService,
|
InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService,
|
||||||
mockSubscribeSession);
|
mockSubscribeSession);
|
||||||
@@ -526,8 +524,8 @@ public class WifiAwareManagerTest {
|
|||||||
.forClass(IWifiAwareEventCallback.class);
|
.forClass(IWifiAwareEventCallback.class);
|
||||||
ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor
|
ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor
|
||||||
.forClass(IWifiAwareDiscoverySessionCallback.class);
|
.forClass(IWifiAwareDiscoverySessionCallback.class);
|
||||||
ArgumentCaptor<WifiAwareSubscribeDiscoverySession> subscribeSession = ArgumentCaptor
|
ArgumentCaptor<SubscribeDiscoverySession> subscribeSession = ArgumentCaptor
|
||||||
.forClass(WifiAwareSubscribeDiscoverySession.class);
|
.forClass(SubscribeDiscoverySession.class);
|
||||||
|
|
||||||
// (1) connect successfully
|
// (1) connect successfully
|
||||||
mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
|
mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
|
||||||
@@ -892,8 +890,8 @@ public class WifiAwareManagerTest {
|
|||||||
.forClass(IWifiAwareEventCallback.class);
|
.forClass(IWifiAwareEventCallback.class);
|
||||||
ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor
|
ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor
|
||||||
.forClass(IWifiAwareDiscoverySessionCallback.class);
|
.forClass(IWifiAwareDiscoverySessionCallback.class);
|
||||||
ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor
|
ArgumentCaptor<PublishDiscoverySession> publishSession = ArgumentCaptor
|
||||||
.forClass(WifiAwarePublishDiscoverySession.class);
|
.forClass(PublishDiscoverySession.class);
|
||||||
ArgumentCaptor<RttManager.ParcelableRttParams> rttParamCaptor = ArgumentCaptor
|
ArgumentCaptor<RttManager.ParcelableRttParams> rttParamCaptor = ArgumentCaptor
|
||||||
.forClass(RttManager.ParcelableRttParams.class);
|
.forClass(RttManager.ParcelableRttParams.class);
|
||||||
ArgumentCaptor<RttManager.RttResult[]> rttResultsCaptor = ArgumentCaptor
|
ArgumentCaptor<RttManager.RttResult[]> rttResultsCaptor = ArgumentCaptor
|
||||||
@@ -953,7 +951,7 @@ public class WifiAwareManagerTest {
|
|||||||
public void testNetworkSpecifierWithClient() throws Exception {
|
public void testNetworkSpecifierWithClient() throws Exception {
|
||||||
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 PeerHandle peerHandle = new PeerHandle(123412);
|
||||||
final int role = WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER;
|
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();
|
||||||
@@ -967,8 +965,8 @@ public class WifiAwareManagerTest {
|
|||||||
.forClass(IWifiAwareEventCallback.class);
|
.forClass(IWifiAwareEventCallback.class);
|
||||||
ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor
|
ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor
|
||||||
.forClass(IWifiAwareDiscoverySessionCallback.class);
|
.forClass(IWifiAwareDiscoverySessionCallback.class);
|
||||||
ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor
|
ArgumentCaptor<PublishDiscoverySession> publishSession = ArgumentCaptor
|
||||||
.forClass(WifiAwarePublishDiscoverySession.class);
|
.forClass(PublishDiscoverySession.class);
|
||||||
|
|
||||||
InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService,
|
InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService,
|
||||||
mockPublishSession, mockRttListener);
|
mockPublishSession, mockRttListener);
|
||||||
|
|||||||
Reference in New Issue
Block a user