diff options
| author | 2017-01-07 18:38:08 +0000 | |
|---|---|---|
| committer | 2017-01-07 18:38:08 +0000 | |
| commit | 0232d1880571f546d90233608eb86e13b68f7273 (patch) | |
| tree | 3db08430d1813a636e9525d3b5045faa2842e207 | |
| parent | cea9b99099927dce0943d75b4d3ae4c243488c75 (diff) | |
| parent | 0bad91b5ac2ec07ab861a5d01285ca12986a5be6 (diff) | |
Merge "[AWARE] Simplify Wi-Fi Aware API namespace" am: 834a87d525 am: fd23421472
am: 0bad91b5ac
Change-Id: I10da8332166d94c543ea94519af702961d3a429c
16 files changed, 240 insertions, 217 deletions
diff --git a/wifi/java/android/net/wifi/aware/WifiAwareAttachCallback.java b/wifi/java/android/net/wifi/aware/AttachCallback.java index 1e8dbd945b6e..90216f3f71d3 100644 --- a/wifi/java/android/net/wifi/aware/WifiAwareAttachCallback.java +++ b/wifi/java/android/net/wifi/aware/AttachCallback.java @@ -18,16 +18,16 @@ package android.net.wifi.aware; /** * 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 - - * for that see {@link WifiAwareDiscoverySessionCallback}. + * for that see {@link DiscoverySessionCallback}. * * @hide PROPOSED_AWARE_API */ -public class WifiAwareAttachCallback { +public class AttachCallback { /** * 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. * * @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 - * {@link WifiAwareManager#attach(WifiAwareAttachCallback, android.os.Handler)} failed. + * {@link WifiAwareManager#attach(AttachCallback, android.os.Handler)} failed. */ public void onAttachFailed() { /* empty */ diff --git a/wifi/java/android/net/wifi/aware/WifiAwareCharacteristics.aidl b/wifi/java/android/net/wifi/aware/Characteristics.aidl index a35e71dada09..77305e9dae0a 100644 --- a/wifi/java/android/net/wifi/aware/WifiAwareCharacteristics.aidl +++ b/wifi/java/android/net/wifi/aware/Characteristics.aidl @@ -16,4 +16,4 @@ package android.net.wifi.aware; -parcelable WifiAwareCharacteristics; +parcelable Characteristics; diff --git a/wifi/java/android/net/wifi/aware/WifiAwareCharacteristics.java b/wifi/java/android/net/wifi/aware/Characteristics.java index 092aa341c9b3..1c3e39025439 100644 --- a/wifi/java/android/net/wifi/aware/WifiAwareCharacteristics.java +++ b/wifi/java/android/net/wifi/aware/Characteristics.java @@ -25,7 +25,7 @@ import android.os.Parcelable; * * @hide PROPOSED_AWARE_API */ -public class WifiAwareCharacteristics implements Parcelable { +public class Characteristics implements Parcelable { /** @hide */ public static final String KEY_MAX_SERVICE_NAME_LENGTH = "key_max_service_name_length"; /** @hide */ @@ -37,7 +37,7 @@ public class WifiAwareCharacteristics implements Parcelable { private Bundle mCharacteristics = new Bundle(); /** @hide : should not be created by apps */ - public WifiAwareCharacteristics(Bundle characteristics) { + public Characteristics(Bundle characteristics) { mCharacteristics = characteristics; } @@ -58,7 +58,7 @@ public class WifiAwareCharacteristics implements Parcelable { * message exchange. Restricts the parameters of the * {@link PublishConfig.Builder#setServiceSpecificInfo(byte[])}, * {@link SubscribeConfig.Builder#setServiceSpecificInfo(byte[])}, and - * {@link WifiAwareDiscoveryBaseSession#sendMessage(WifiAwareManager.PeerHandle, int, byte[])} + * {@link DiscoverySession#sendMessage(PeerHandle, int, byte[])} * variants. * * @return A positive integer, maximum length of byte array for Aware messaging. @@ -89,17 +89,17 @@ public class WifiAwareCharacteristics implements Parcelable { return 0; } - public static final Creator<WifiAwareCharacteristics> CREATOR = - new Creator<WifiAwareCharacteristics>() { + public static final Creator<Characteristics> CREATOR = + new Creator<Characteristics>() { @Override - public WifiAwareCharacteristics createFromParcel(Parcel in) { - WifiAwareCharacteristics c = new WifiAwareCharacteristics(in.readBundle()); + public Characteristics createFromParcel(Parcel in) { + Characteristics c = new Characteristics(in.readBundle()); return c; } @Override - public WifiAwareCharacteristics[] newArray(int size) { - return new WifiAwareCharacteristics[size]; + public Characteristics[] newArray(int size) { + return new Characteristics[size]; } }; } diff --git a/wifi/java/android/net/wifi/aware/ConfigRequest.java b/wifi/java/android/net/wifi/aware/ConfigRequest.java index 4b21b15d4994..6a5957badafb 100644 --- a/wifi/java/android/net/wifi/aware/ConfigRequest.java +++ b/wifi/java/android/net/wifi/aware/ConfigRequest.java @@ -22,7 +22,7 @@ import android.os.Parcelable; /** * Defines a request object to configure a Wi-Fi Aware network. Built 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 * requested configuration - since different applications may request different * configurations. diff --git a/wifi/java/android/net/wifi/aware/WifiAwareDiscoveryBaseSession.java b/wifi/java/android/net/wifi/aware/DiscoverySession.java index 2812ad4f147d..e1bfd6546cb2 100644 --- a/wifi/java/android/net/wifi/aware/WifiAwareDiscoveryBaseSession.java +++ b/wifi/java/android/net/wifi/aware/DiscoverySession.java @@ -29,21 +29,21 @@ import java.lang.ref.WeakReference; /** * A class representing a single publish or subscribe Aware session. This object * 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: * <ul> - * <li>Sending messages: {@link #sendMessage(WifiAwareManager.PeerHandle, int, byte[])} or - * {@link #sendMessage(WifiAwareManager.PeerHandle, int, byte[], int)} methods. + * <li>Sending messages: {@link #sendMessage(PeerHandle, int, byte[])} or + * {@link #sendMessage(PeerHandle, int, byte[], int)} methods. * <li>Creating a network-specifier when requesting a Aware connection: - * {@link #createNetworkSpecifier(WifiAwareManager.PeerHandle, byte[])}. + * {@link #createNetworkSpecifier(PeerHandle, byte[])}. * </ul> * The {@link #destroy()} method must be called to destroy discovery sessions once they are * no longer needed. * * @hide PROPOSED_AWARE_API */ -public class WifiAwareDiscoveryBaseSession { - private static final String TAG = "WifiAwareDiscBaseSsn"; +public class DiscoverySession { + private static final String TAG = "DiscoverySession"; private static final boolean DBG = false; 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 - * {@link #sendMessage(WifiAwareManager.PeerHandle, int, byte[], int)}. + * {@link #sendMessage(PeerHandle, int, byte[], int)}. * * @return Maximum retry count when sending messages. */ @@ -71,7 +71,7 @@ public class WifiAwareDiscoveryBaseSession { } /** @hide */ - public WifiAwareDiscoveryBaseSession(WifiAwareManager manager, int clientId, int sessionId) { + public DiscoverySession(WifiAwareManager manager, int clientId, int sessionId) { if (VDBG) { Log.v(TAG, "New discovery session created: manager=" + manager + ", clientId=" + 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 * resources will continue to be utilized until the application exits. The only * exception is a session for which we received a termination callback, - * {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)}. + * {@link DiscoverySessionCallback#onSessionTerminated(int)}. */ public void destroy() { 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 * of a discovery session - executed subsequent to a publish/subscribe - * {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(WifiAwareManager.PeerHandle, + * {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle, * byte[], java.util.List)} event. * <p> * Aware messages are not guaranteed delivery. Callbacks on - * {@link WifiAwareDiscoverySessionCallback} indicate message was transmitted successfully, - * {@link WifiAwareDiscoverySessionCallback#onMessageSendSucceeded(int)}, or transmission + * {@link DiscoverySessionCallback} indicate message was transmitted successfully, + * {@link DiscoverySessionCallback#onMessageSendSucceeded(int)}, or transmission * failed (possibly after several retries) - - * {@link WifiAwareDiscoverySessionCallback#onMessageSendFailed(int)}. + * {@link DiscoverySessionCallback#onMessageSendFailed(int)}. * <p> * The peer will get a callback indicating a message was received using - * {@link WifiAwareDiscoverySessionCallback#onMessageReceived(WifiAwareManager.PeerHandle, + * {@link DiscoverySessionCallback#onMessageReceived(PeerHandle, * byte[])}. * * @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 - * {@link WifiAwareDiscoverySessionCallback#onMessageReceived(WifiAwareManager.PeerHandle, + * {@link DiscoverySessionCallback#onMessageReceived(PeerHandle, * byte[])} events. * @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 @@ -167,7 +167,7 @@ public class WifiAwareDiscoveryBaseSession { * (note: no retransmissions are attempted in other failure cases). A value of 0 * 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) { if (mTerminated) { 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 * of a discovery session - executed subsequent to a publish/subscribe - * {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(WifiAwareManager.PeerHandle, + * {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle, * byte[], java.util.List)} event. * <p> * Aware messages are not guaranteed delivery. Callbacks on - * {@link WifiAwareDiscoverySessionCallback} indicate message was transmitted successfully, - * {@link WifiAwareDiscoverySessionCallback#onMessageSendSucceeded(int)}, or transmission + * {@link DiscoverySessionCallback} indicate message was transmitted successfully, + * {@link DiscoverySessionCallback#onMessageSendSucceeded(int)}, or transmission * failed (possibly after several retries) - - * {@link WifiAwareDiscoverySessionCallback#onMessageSendFailed(int)}. + * {@link DiscoverySessionCallback#onMessageSendFailed(int)}. * <p> * The peer will get a callback indicating a message was received using - * {@link WifiAwareDiscoverySessionCallback#onMessageReceived(WifiAwareManager.PeerHandle, + * {@link DiscoverySessionCallback#onMessageReceived(PeerHandle, * byte[])}. - * Equivalent to {@link #sendMessage(WifiAwareManager.PeerHandle, int, byte[], int)} + * Equivalent to {@link #sendMessage(PeerHandle, int, byte[], int)} * with a {@code retryCount} of 0. * * @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 - * {@link WifiAwareDiscoverySessionCallback#onMessageReceived(WifiAwareManager.PeerHandle, + * {@link DiscoverySessionCallback#onMessageReceived(PeerHandle, * byte[])} events. * @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 @@ -212,16 +212,16 @@ public class WifiAwareDiscoveryBaseSession { * can be arbitrary and non-unique. * @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) { sendMessage(peerHandle, messageId, message, 0); } /** * 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 - * {@link WifiAwareDiscoverySessionCallback#onMessageReceived(WifiAwareManager.PeerHandle, + * {@link DiscoverySessionCallback#onMessageReceived(PeerHandle, * byte[])} operation - can * only range devices which are part of an ongoing discovery session. * @@ -265,9 +265,9 @@ public class WifiAwareDiscoveryBaseSession { * and a Publisher is a RESPONDER. * * @param peerHandle The peer's handle obtained through - * {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(WifiAwareManager.PeerHandle, + * {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle, * 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 * from only that peer. A RESPONDER may specified a null - indicating that * it will accept connection requests from any device. @@ -283,7 +283,7 @@ public class WifiAwareDiscoveryBaseSession { * android.net.ConnectivityManager.NetworkCallback)} * [or other varieties of that API]. */ - public String createNetworkSpecifier(@Nullable WifiAwareManager.PeerHandle peerHandle, + public String createNetworkSpecifier(@Nullable PeerHandle peerHandle, @Nullable byte[] token) { if (mTerminated) { Log.w(TAG, "createNetworkSpecifier: called on terminated session"); @@ -295,7 +295,7 @@ public class WifiAwareDiscoveryBaseSession { 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_RESPONDER; diff --git a/wifi/java/android/net/wifi/aware/WifiAwareDiscoverySessionCallback.java b/wifi/java/android/net/wifi/aware/DiscoverySessionCallback.java index fdf0d013334d..f107ca80ce8f 100644 --- a/wifi/java/android/net/wifi/aware/WifiAwareDiscoverySessionCallback.java +++ b/wifi/java/android/net/wifi/aware/DiscoverySessionCallback.java @@ -27,16 +27,16 @@ import java.util.List; * Base class for Aware session events callbacks. Should be extended by * applications wanting notifications. The callbacks are set when a * publish or subscribe session is created using - * {@link WifiAwareSession#publish(PublishConfig, WifiAwareDiscoverySessionCallback, + * {@link WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback, * android.os.Handler)} or - * {@link WifiAwareSession#subscribe(SubscribeConfig, WifiAwareDiscoverySessionCallback, + * {@link WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback, * android.os.Handler)}. * <p> * A single callback is set at session creation - it cannot be replaced. * * @hide PROPOSED_AWARE_API */ -public class WifiAwareDiscoverySessionCallback { +public class DiscoverySessionCallback { /** @hide */ @IntDef({ TERMINATE_REASON_DONE, TERMINATE_REASON_FAIL }) @@ -48,7 +48,7 @@ public class WifiAwareDiscoverySessionCallback { * Indicates that publish or subscribe session is done - all the * requested operations (per {@link PublishConfig} or * {@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; @@ -56,39 +56,39 @@ public class WifiAwareDiscoverySessionCallback { * Indicates that publish or subscribe session is terminated due to a * failure. * Failure reason flag for - * {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} callback. + * {@link DiscoverySessionCallback#onSessionTerminated(int)} callback. */ public static final int TERMINATE_REASON_FAIL = 101; /** * 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. * - * @param session The {@link WifiAwarePublishDiscoverySession} used to control the + * @param session The {@link PublishDiscoverySession} used to control the * discovery session. */ - public void onPublishStarted(@NonNull WifiAwarePublishDiscoverySession session) { + public void onPublishStarted(@NonNull PublishDiscoverySession session) { /* empty */ } /** * 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. * - * @param session The {@link WifiAwareSubscribeDiscoverySession} used to control the + * @param session The {@link SubscribeDiscoverySession} used to control the * discovery session. */ - public void onSubscribeStarted(@NonNull WifiAwareSubscribeDiscoverySession session) { + public void onSubscribeStarted(@NonNull SubscribeDiscoverySession session) { /* empty */ } /** * Called when a publish or subscribe discovery session configuration update request * succeeds. Called in response to - * {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)} or - * {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. + * {@link PublishDiscoverySession#updatePublish(PublishConfig)} or + * {@link SubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. */ public void onSessionConfigUpdated() { /* empty */ @@ -96,12 +96,12 @@ public class WifiAwareDiscoverySessionCallback { /** * 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 - * {@link WifiAwareSession#subscribe(SubscribeConfig, WifiAwareDiscoverySessionCallback, + * {@link WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback, * android.os.Handler)}, or when a configuration update fails: - * {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)} or - * {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. + * {@link PublishDiscoverySession#updatePublish(PublishConfig)} or + * {@link SubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. * <p> * For discovery session updates failure leaves the session running with its previous * 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 - * 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)} * or {@link SubscribeConfig.Builder#setTtlSec(int)}) or due to a failure. * * @param reason The termination reason using - * {@code WifiAwareDiscoverySessionCallback.TERMINATE_*} codes. + * {@code DiscoverySessionCallback.TERMINATE_*} codes. */ public void onSessionTerminated(@SessionTerminateCodes int reason) { /* empty */ @@ -133,19 +133,19 @@ public class WifiAwareDiscoverySessionCallback { * configuration. * @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) { /* empty */ } /** * 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 * peer (corresponds to an ACK being received). * <p> * Note that either this callback or - * {@link WifiAwareDiscoverySessionCallback#onMessageSendFailed(int)} will be + * {@link DiscoverySessionCallback#onMessageSendFailed(int)} will be * received - never both. * * @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. * 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. * <p> * Note that either this callback or - * {@link WifiAwareDiscoverySessionCallback#onMessageSendSucceeded(int)} will be received + * {@link DiscoverySessionCallback#onMessageSendSucceeded(int)} will be received * - never both. * * @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 - * peer's {@link WifiAwareDiscoveryBaseSession#sendMessage(WifiAwareManager.PeerHandle, int, - * byte[])} or {@link WifiAwareDiscoveryBaseSession#sendMessage(WifiAwareManager.PeerHandle, + * peer's {@link DiscoverySession#sendMessage(PeerHandle, int, + * byte[])} or {@link DiscoverySession#sendMessage(PeerHandle, * int, byte[], int)}. * * @param peerHandle An opaque handle to the peer matching our discovery operation. * @param message A byte array containing the message. */ - public void onMessageReceived(WifiAwareManager.PeerHandle peerHandle, byte[] message) { + public void onMessageReceived(PeerHandle peerHandle, byte[] message) { /* empty */ } } diff --git a/wifi/java/android/net/wifi/aware/IWifiAwareManager.aidl b/wifi/java/android/net/wifi/aware/IWifiAwareManager.aidl index 9c92807c63b5..794c142775f3 100644 --- a/wifi/java/android/net/wifi/aware/IWifiAwareManager.aidl +++ b/wifi/java/android/net/wifi/aware/IWifiAwareManager.aidl @@ -23,7 +23,7 @@ import android.net.wifi.aware.IWifiAwareDiscoverySessionCallback; import android.net.wifi.aware.IWifiAwareEventCallback; import android.net.wifi.aware.PublishConfig; import android.net.wifi.aware.SubscribeConfig; -import android.net.wifi.aware.WifiAwareCharacteristics; +import android.net.wifi.aware.Characteristics; import android.net.wifi.RttManager; /** @@ -37,7 +37,7 @@ interface IWifiAwareManager void enableUsage(); void disableUsage(); boolean isUsageEnabled(); - WifiAwareCharacteristics getCharacteristics(); + Characteristics getCharacteristics(); // client API void connect(in IBinder binder, in String callingPackage, in IWifiAwareEventCallback callback, diff --git a/wifi/java/android/net/wifi/aware/WifiAwareIdentityChangedListener.java b/wifi/java/android/net/wifi/aware/IdentityChangedListener.java index e8f52cd4bdeb..b0f97bda0339 100644 --- a/wifi/java/android/net/wifi/aware/WifiAwareIdentityChangedListener.java +++ b/wifi/java/android/net/wifi/aware/IdentityChangedListener.java @@ -28,7 +28,7 @@ package android.net.wifi.aware; * * @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 * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} to get the actual MAC address, diff --git a/wifi/java/android/net/wifi/aware/PeerHandle.java b/wifi/java/android/net/wifi/aware/PeerHandle.java new file mode 100644 index 000000000000..777d9a376fdf --- /dev/null +++ b/wifi/java/android/net/wifi/aware/PeerHandle.java @@ -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; +} diff --git a/wifi/java/android/net/wifi/aware/PublishConfig.java b/wifi/java/android/net/wifi/aware/PublishConfig.java index 3925bd71ab9e..f218c086dfbb 100644 --- a/wifi/java/android/net/wifi/aware/PublishConfig.java +++ b/wifi/java/android/net/wifi/aware/PublishConfig.java @@ -33,9 +33,9 @@ import java.util.List; /** * Defines the configuration of a Aware publish session. Built 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 - * {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)}. + * {@link PublishDiscoverySession#updatePublish(PublishConfig)}. * * @hide PROPOSED_AWARE_API */ @@ -184,7 +184,7 @@ public final class PublishConfig implements Parcelable { * * @hide */ - public void assertValid(WifiAwareCharacteristics characteristics) + public void assertValid(Characteristics characteristics) throws IllegalArgumentException { WifiAwareUtils.validateServiceName(mServiceName); @@ -322,12 +322,12 @@ public final class PublishConfig implements Parcelable { * Sets the number of times an unsolicited (configured using * {@link PublishConfig.Builder#setPublishType(int)}) publish session * will be broadcast. When the count is reached an event will be - * generated for {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} - * with {@link WifiAwareDiscoverySessionCallback#TERMINATE_REASON_DONE} [unless + * generated for {@link DiscoverySessionCallback#onSessionTerminated(int)} + * with {@link DiscoverySessionCallback#TERMINATE_REASON_DONE} [unless * {@link #setTerminateNotificationEnabled(boolean)} disables the callback]. * <p> * 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. * * @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 * will be alive - broadcasting a packet. When the TTL is reached * an event will be generated for - * {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} with - * {@link WifiAwareDiscoverySessionCallback#TERMINATE_REASON_DONE} [unless + * {@link DiscoverySessionCallback#onSessionTerminated(int)} with + * {@link DiscoverySessionCallback#TERMINATE_REASON_DONE} [unless * {@link #setTerminateNotificationEnabled(boolean)} disables the callback]. * <p> * 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. * * @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 - * {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} is reported + * {@link DiscoverySessionCallback#onSessionTerminated(int)} is reported * back to the callback. * * @param enable If true the terminate callback will be called when the diff --git a/wifi/java/android/net/wifi/aware/WifiAwarePublishDiscoverySession.java b/wifi/java/android/net/wifi/aware/PublishDiscoverySession.java index 68786d17d38d..f2355b382e8d 100644 --- a/wifi/java/android/net/wifi/aware/WifiAwarePublishDiscoverySession.java +++ b/wifi/java/android/net/wifi/aware/PublishDiscoverySession.java @@ -21,32 +21,32 @@ import android.util.Log; /** * 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 - * {@link WifiAwareDiscoverySessionCallback#onPublishStarted(WifiAwarePublishDiscoverySession)}. See - * baseline functionality of all discovery sessions in {@link WifiAwareDiscoveryBaseSession}. This + * {@link DiscoverySessionCallback#onPublishStarted(PublishDiscoverySession)}. See + * baseline functionality of all discovery sessions in {@link DiscoverySession}. This * object allows updating an existing/running publish discovery session using * {@link #updatePublish(PublishConfig)}. * * @hide PROPOSED_AWARE_API */ -public class WifiAwarePublishDiscoverySession extends WifiAwareDiscoveryBaseSession { - private static final String TAG = "WifiAwarePublishDiscSsn"; +public class PublishDiscoverySession extends DiscoverySession { + private static final String TAG = "PublishDiscoverySession"; /** @hide */ - public WifiAwarePublishDiscoverySession(WifiAwareManager manager, int clientId, int sessionId) { + public PublishDiscoverySession(WifiAwareManager manager, int clientId, int sessionId) { super(manager, clientId, sessionId); } /** * 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 - * {@link WifiAwareDiscoverySessionCallback}: + * {@link DiscoverySessionCallback}: * <ul> - * <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigUpdated()}: configuration + * <li>{@link DiscoverySessionCallback#onSessionConfigUpdated()}: configuration * update succeeded. - * <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigFailed()}: configuration + * <li>{@link DiscoverySessionCallback#onSessionConfigFailed()}: configuration * update failed. The publish discovery session is still running using its previous * configuration (i.e. update failure does not terminate the session). * </ul> diff --git a/wifi/java/android/net/wifi/aware/SubscribeConfig.java b/wifi/java/android/net/wifi/aware/SubscribeConfig.java index 0fe69a81d218..7b91ea3eb5f4 100644 --- a/wifi/java/android/net/wifi/aware/SubscribeConfig.java +++ b/wifi/java/android/net/wifi/aware/SubscribeConfig.java @@ -33,9 +33,9 @@ import java.util.List; /** * Defines the configuration of a Aware subscribe session. Built using * {@link SubscribeConfig.Builder}. Subscribe is done using - * {@link WifiAwareSession#subscribe(SubscribeConfig, WifiAwareDiscoverySessionCallback, + * {@link WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback, * android.os.Handler)} or - * {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. + * {@link SubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. * * @hide PROPOSED_AWARE_API */ @@ -212,7 +212,7 @@ public final class SubscribeConfig implements Parcelable { * * @hide */ - public void assertValid(WifiAwareCharacteristics characteristics) + public void assertValid(Characteristics characteristics) throws IllegalArgumentException { WifiAwareUtils.validateServiceName(mServiceName); @@ -355,11 +355,11 @@ public final class SubscribeConfig implements Parcelable { * Sets the number of times an active ( * {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session * will broadcast. When the count is reached an event will be - * generated for {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} - * with {@link WifiAwareDiscoverySessionCallback#TERMINATE_REASON_DONE}. + * generated for {@link DiscoverySessionCallback#onSessionTerminated(int)} + * with {@link DiscoverySessionCallback#TERMINATE_REASON_DONE}. * <p> * 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. * * @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 * will be alive - i.e. broadcasting a packet. When the TTL is reached * an event will be generated for - * {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} with - * {@link WifiAwareDiscoverySessionCallback#TERMINATE_REASON_DONE}. + * {@link DiscoverySessionCallback#onSessionTerminated(int)} with + * {@link DiscoverySessionCallback#TERMINATE_REASON_DONE}. * <p> * 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. * * @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 * single match session (corresponding to the same publish action on the * peer) reported to the host (using the - * {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(WifiAwareManager.PeerHandle, - * byte[], List)}). The options are: only report the first match and ignore the rest + * {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle, byte[], + * 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 * match {@link SubscribeConfig#MATCH_STYLE_ALL} (the default). * @@ -424,7 +424,7 @@ public final class SubscribeConfig implements Parcelable { /** * Configure whether a subscribe terminate notification - * {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} is reported + * {@link DiscoverySessionCallback#onSessionTerminated(int)} is reported * back to the callback. * * @param enable If true the terminate callback will be called when the diff --git a/wifi/java/android/net/wifi/aware/WifiAwareSubscribeDiscoverySession.java b/wifi/java/android/net/wifi/aware/SubscribeDiscoverySession.java index a0ec8093a3ab..cf01f91872cf 100644 --- a/wifi/java/android/net/wifi/aware/WifiAwareSubscribeDiscoverySession.java +++ b/wifi/java/android/net/wifi/aware/SubscribeDiscoverySession.java @@ -22,35 +22,35 @@ import android.util.Log; /** * A class representing a Aware subscribe session. Created when * {@link WifiAwareSession#subscribe(SubscribeConfig, - * WifiAwareDiscoverySessionCallback, android.os.Handler)} + * DiscoverySessionCallback, android.os.Handler)} * is called and a discovery session is created and returned in - * {@link WifiAwareDiscoverySessionCallback#onSubscribeStarted(WifiAwareSubscribeDiscoverySession)}. - * See baseline functionality of all discovery sessions in {@link WifiAwareDiscoveryBaseSession}. + * {@link DiscoverySessionCallback#onSubscribeStarted(SubscribeDiscoverySession)}. + * See baseline functionality of all discovery sessions in {@link DiscoverySession}. * This object allows updating an existing/running subscribe discovery session using * {@link #updateSubscribe(SubscribeConfig)}. * * @hide PROPOSED_AWARE_API */ -public class WifiAwareSubscribeDiscoverySession extends WifiAwareDiscoveryBaseSession { - private static final String TAG = "WifiAwareSubsDiscSsn"; +public class SubscribeDiscoverySession extends DiscoverySession { + private static final String TAG = "SubscribeDiscoverySession"; /** * {@hide} */ - public WifiAwareSubscribeDiscoverySession(WifiAwareManager manager, int clientId, + public SubscribeDiscoverySession(WifiAwareManager manager, int clientId, int sessionId) { super(manager, clientId, sessionId); } /** * 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 - * {@link WifiAwareDiscoverySessionCallback}: + * {@link DiscoverySessionCallback}: * <ul> - * <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigUpdated()}: configuration + * <li>{@link DiscoverySessionCallback#onSessionConfigUpdated()}: configuration * update succeeded. - * <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigFailed()}: configuration + * <li>{@link DiscoverySessionCallback#onSessionConfigFailed()}: configuration * update failed. The subscribe discovery session is still running using its previous * configuration (i.e. update failure does not terminate the session). * </ul> diff --git a/wifi/java/android/net/wifi/aware/WifiAwareManager.java b/wifi/java/android/net/wifi/aware/WifiAwareManager.java index 029794dfa380..7a866ad38974 100644 --- a/wifi/java/android/net/wifi/aware/WifiAwareManager.java +++ b/wifi/java/android/net/wifi/aware/WifiAwareManager.java @@ -58,14 +58,14 @@ import java.util.List; * The class provides access to: * <ul> * <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 - * {@link WifiAwareSession#publish(PublishConfig, WifiAwareDiscoverySessionCallback, Handler)} and - * {@link WifiAwareSession#subscribe(SubscribeConfig, WifiAwareDiscoverySessionCallback, Handler)}. + * {@link WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback, Handler)} and + * {@link WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback, Handler)}. * <li>Create a Aware network specifier to be used with * {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)} * to set-up a Aware connection with a peer. Refer to - * {@link WifiAwareDiscoveryBaseSession#createNetworkSpecifier(PeerHandle, byte[])} and + * {@link DiscoverySession#createNetworkSpecifier(PeerHandle, byte[])} and * {@link WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])}. * </ul> * <p> @@ -75,37 +75,37 @@ import java.util.List; * broadcast. Note that this broadcast is not sticky - you should register for it and then * check the above API to avoid a race condition. * <p> - * An application must use {@link #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 * 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 - * 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 - * 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 * {@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 * application detaches. * <p> * Once a Aware attach is confirmed use the - * {@link WifiAwareSession#publish(PublishConfig, WifiAwareDiscoverySessionCallback, Handler)} + * {@link WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback, Handler)} * 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 - * provided callback object {@link WifiAwareDiscoverySessionCallback}. Specifically, the - * {@link WifiAwareDiscoverySessionCallback#onPublishStarted(WifiAwarePublishDiscoverySession)} + * provided callback object {@link DiscoverySessionCallback}. Specifically, the + * {@link DiscoverySessionCallback#onPublishStarted(PublishDiscoverySession)} * and - * {@link WifiAwareDiscoverySessionCallback#onSubscribeStarted( - * WifiAwareSubscribeDiscoverySession)} - * return {@link WifiAwarePublishDiscoverySession} and - * {@link WifiAwareSubscribeDiscoverySession} + * {@link DiscoverySessionCallback#onSubscribeStarted( + *SubscribeDiscoverySession)} + * return {@link PublishDiscoverySession} and + * {@link SubscribeDiscoverySession} * objects respectively on which additional session operations can be performed, e.g. updating - * the session {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)} and - * {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. Sessions can + * the session {@link PublishDiscoverySession#updatePublish(PublishConfig)} and + * {@link SubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. Sessions can * 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 - * {@link WifiAwareDiscoveryBaseSession#destroy()} API. + * {@link DiscoverySession#destroy()} API. * <p> * Creating connections between Aware devices is managed by the standard * {@link ConnectivityManager#requestNetwork(NetworkRequest, @@ -116,7 +116,7 @@ import java.util.List; * {@link android.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE}. * <li>{@link NetworkRequest.Builder#setNetworkSpecifier(String)} using * {@link WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])} or - * {@link WifiAwareDiscoveryBaseSession#createNetworkSpecifier(PeerHandle, byte[])}. + * {@link DiscoverySession#createNetworkSpecifier(PeerHandle, byte[])}. * </ul> * * @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 * when requesting a Aware network. * - * @see WifiAwareDiscoveryBaseSession#createNetworkSpecifier(PeerHandle, byte[]) + * @see DiscoverySession#createNetworkSpecifier(PeerHandle, byte[]) * @see WifiAwareSession#createNetworkSpecifier(int, byte[], byte[]) */ 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 * when requesting a Aware network. * - * @see WifiAwareDiscoveryBaseSession#createNetworkSpecifier(PeerHandle, byte[]) + * @see DiscoverySession#createNetworkSpecifier(PeerHandle, byte[]) * @see WifiAwareSession#createNetworkSpecifier(int, byte[], byte[]) */ 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. * @hide PROPOSED_AWARE_API */ - public WifiAwareCharacteristics getCharacteristics() { + public Characteristics getCharacteristics() { try { return mService.getCharacteristics(); } catch (RemoteException e) { @@ -328,12 +328,12 @@ public class WifiAwareManager { * attachCallback}. * * @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 * attachCallback} object. If a null is provided then the application's main thread will be * used. */ - public void attach(@NonNull WifiAwareAttachCallback attachCallback, @Nullable Handler handler) { + public void attach(@NonNull AttachCallback attachCallback, @Nullable Handler handler) { 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). * The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} * 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 * consumption, do not use it unless the information is necessary (e.g. for OOB discovery). * * @param attachCallback A callback for attach events, extended from - * {@link WifiAwareAttachCallback}. + * {@link AttachCallback}. * @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 * attachCallback} and {@code identityChangedListener} objects. If a null is provided then the * application's main thread will be used. */ - public void attach(@NonNull WifiAwareAttachCallback attachCallback, - @NonNull WifiAwareIdentityChangedListener identityChangedListener, + public void attach(@NonNull AttachCallback attachCallback, + @NonNull IdentityChangedListener identityChangedListener, @Nullable Handler handler) { attach(handler, null, attachCallback, identityChangedListener); } /** @hide */ public void attach(Handler handler, ConfigRequest configRequest, - WifiAwareAttachCallback attachCallback, - WifiAwareIdentityChangedListener identityChangedListener) { + AttachCallback attachCallback, + IdentityChangedListener identityChangedListener) { if (VDBG) { Log.v(TAG, "attach(): handler=" + handler + ", callback=" + attachCallback + ", configRequest=" + configRequest + ", identityChangedListener=" @@ -409,7 +409,7 @@ public class WifiAwareManager { /** @hide */ public void publish(int clientId, Looper looper, PublishConfig publishConfig, - WifiAwareDiscoverySessionCallback callback) { + DiscoverySessionCallback callback) { if (VDBG) Log.v(TAG, "publish(): clientId=" + clientId + ", config=" + publishConfig); try { @@ -437,7 +437,7 @@ public class WifiAwareManager { /** @hide */ public void subscribe(int clientId, Looper looper, SubscribeConfig subscribeConfig, - WifiAwareDiscoverySessionCallback callback) { + DiscoverySessionCallback callback) { if (VDBG) { if (VDBG) { 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. * * @param looper The looper on which to execute the callbacks. */ WifiAwareEventCallbackProxy(WifiAwareManager mgr, Looper looper, Binder binder, - final WifiAwareAttachCallback attachCallback, - final WifiAwareIdentityChangedListener identityChangedListener) { + final AttachCallback attachCallback, + final IdentityChangedListener identityChangedListener) { mAwareManager = new WeakReference<>(mgr); mLooper = looper; mBinder = binder; @@ -828,14 +828,14 @@ public class WifiAwareManager { private final WeakReference<WifiAwareManager> mAwareManager; private final boolean mIsPublish; - private final WifiAwareDiscoverySessionCallback mOriginalCallback; + private final DiscoverySessionCallback mOriginalCallback; private final int mClientId; private final Handler mHandler; - private WifiAwareDiscoveryBaseSession mSession; + private DiscoverySession mSession; WifiAwareDiscoverySessionCallbackProxy(WifiAwareManager mgr, Looper looper, - boolean isPublish, WifiAwareDiscoverySessionCallback originalCallback, + boolean isPublish, DiscoverySessionCallback originalCallback, int clientId) { mAwareManager = new WeakReference<>(mgr); mIsPublish = isPublish; @@ -1006,13 +1006,13 @@ public class WifiAwareManager { } if (mIsPublish) { - WifiAwarePublishDiscoverySession session = new WifiAwarePublishDiscoverySession(mgr, + PublishDiscoverySession session = new PublishDiscoverySession(mgr, mClientId, sessionId); mSession = session; mOriginalCallback.onPublishStarted(session); } else { - WifiAwareSubscribeDiscoverySession - session = new WifiAwareSubscribeDiscoverySession(mgr, mClientId, sessionId); + SubscribeDiscoverySession + session = new SubscribeDiscoverySession(mgr, mClientId, sessionId); mSession = session; mOriginalCallback.onSubscribeStarted(session); } @@ -1030,15 +1030,4 @@ public class WifiAwareManager { mOriginalCallback.onSessionTerminated(reason); } } - - /** @hide PROPOSED_AWARE_API */ - public static class PeerHandle { - /** @hide */ - public PeerHandle(int peerId) { - this.peerId = peerId; - } - - /** @hide */ - public int peerId; - } } diff --git a/wifi/java/android/net/wifi/aware/WifiAwareSession.java b/wifi/java/android/net/wifi/aware/WifiAwareSession.java index 005895a28043..e3ebe860f55f 100644 --- a/wifi/java/android/net/wifi/aware/WifiAwareSession.java +++ b/wifi/java/android/net/wifi/aware/WifiAwareSession.java @@ -65,7 +65,7 @@ public class WifiAwareSession { * session-wide destroy. * <p> * An application may re-attach after a destroy using - * {@link WifiAwareManager#attach(WifiAwareAttachCallback, Handler)} . + * {@link WifiAwareManager#attach(AttachCallback, Handler)} . */ public void destroy() { 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 * 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> * <li> - * {@link WifiAwareDiscoverySessionCallback#onPublishStarted( - * WifiAwarePublishDiscoverySession)} + * {@link DiscoverySessionCallback#onPublishStarted( + *PublishDiscoverySession)} * 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. - * <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigFailed()} is called if the + * <li>{@link DiscoverySessionCallback#onSessionConfigFailed()} is called if the * publish operation failed. * </ul> * <p> * 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 - * {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)}. + * {@link PublishDiscoverySession#updatePublish(PublishConfig)}. * <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 * resources as well terminate any on-air transmissions. * <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 * 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. * @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. */ public void publish(@NonNull PublishConfig publishConfig, - @NonNull WifiAwareDiscoverySessionCallback callback, @Nullable Handler handler) { + @NonNull DiscoverySessionCallback callback, @Nullable Handler handler) { WifiAwareManager mgr = mMgr.get(); if (mgr == null) { 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 * 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> * <li> - * {@link WifiAwareDiscoverySessionCallback#onSubscribeStarted( - * WifiAwareSubscribeDiscoverySession)} + * {@link DiscoverySessionCallback#onSubscribeStarted( + *SubscribeDiscoverySession)} * 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. - * <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigFailed()} is called if the + * <li>{@link DiscoverySessionCallback#onSessionConfigFailed()} is called if the * subscribe operation failed. * </ul> * <p> * 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 - * {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. + * {@link SubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. * <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 * resources as well terminate any on-air transmissions. * <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 * 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. * @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. */ public void subscribe(@NonNull SubscribeConfig subscribeConfig, - @NonNull WifiAwareDiscoverySessionCallback callback, @Nullable Handler handler) { + @NonNull DiscoverySessionCallback callback, @Nullable Handler handler) { WifiAwareManager mgr = mMgr.get(); if (mgr == null) { 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 * (out-of-band) discovery. Aware discovery does not provide the MAC address of the peer - * when using Aware discovery use the alternative network specifier method - - * {@link WifiAwareDiscoveryBaseSession#createNetworkSpecifier(WifiAwareManager.PeerHandle, + * {@link DiscoverySession#createNetworkSpecifier(PeerHandle, * byte[])}. * * @param role The role of this device: diff --git a/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java b/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java index 24c0127cb11b..bcd7772b263d 100644 --- a/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java +++ b/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java @@ -67,19 +67,19 @@ public class WifiAwareManagerTest { public Context mockContext; @Mock - public WifiAwareAttachCallback mockCallback; + public AttachCallback mockCallback; @Mock - public WifiAwareDiscoverySessionCallback mockSessionCallback; + public DiscoverySessionCallback mockSessionCallback; @Mock public IWifiAwareManager mockAwareService; @Mock - public WifiAwarePublishDiscoverySession mockPublishSession; + public PublishDiscoverySession mockPublishSession; @Mock - public WifiAwareSubscribeDiscoverySession mockSubscribeSession; + public SubscribeDiscoverySession mockSubscribeSession; @Mock public RttManager.RttListener mockRttListener; @@ -276,7 +276,7 @@ public class WifiAwareManagerTest { final int sessionId = 123; final ConfigRequest configRequest = new ConfigRequest.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 byte[] matchFilter = { 1, 12, 2, 31, 32 }; final int messageId = 2123; @@ -290,10 +290,9 @@ public class WifiAwareManagerTest { .forClass(IWifiAwareEventCallback.class); ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor .forClass(IWifiAwareDiscoverySessionCallback.class); - ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor - .forClass(WifiAwarePublishDiscoverySession.class); - ArgumentCaptor<WifiAwareManager.PeerHandle> peerIdCaptor = ArgumentCaptor.forClass( - WifiAwareManager.PeerHandle.class); + ArgumentCaptor<PublishDiscoverySession> publishSession = ArgumentCaptor + .forClass(PublishDiscoverySession.class); + ArgumentCaptor<PeerHandle> peerIdCaptor = ArgumentCaptor.forClass(PeerHandle.class); ArgumentCaptor<List<byte[]>> matchFilterCaptor = ArgumentCaptor.forClass( (Class) List.class); @@ -377,7 +376,7 @@ public class WifiAwareManagerTest { final int sessionId = 123; final ConfigRequest configRequest = new ConfigRequest.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, mockPublishSession); @@ -387,8 +386,8 @@ public class WifiAwareManagerTest { .forClass(IWifiAwareEventCallback.class); ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor .forClass(IWifiAwareDiscoverySessionCallback.class); - ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor - .forClass(WifiAwarePublishDiscoverySession.class); + ArgumentCaptor<PublishDiscoverySession> publishSession = ArgumentCaptor + .forClass(PublishDiscoverySession.class); // (1) connect successfully mDut.attach(mMockLooperHandler, configRequest, mockCallback, null); @@ -428,7 +427,7 @@ public class WifiAwareManagerTest { final int sessionId = 123; final ConfigRequest configRequest = new ConfigRequest.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 byte[] matchFilter = { 1, 12, 3, 31, 32 }; // bad data! final int messageId = 2123; @@ -442,10 +441,9 @@ public class WifiAwareManagerTest { .forClass(IWifiAwareEventCallback.class); ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor .forClass(IWifiAwareDiscoverySessionCallback.class); - ArgumentCaptor<WifiAwareSubscribeDiscoverySession> subscribeSession = ArgumentCaptor - .forClass(WifiAwareSubscribeDiscoverySession.class); - ArgumentCaptor<WifiAwareManager.PeerHandle> peerIdCaptor = ArgumentCaptor.forClass( - WifiAwareManager.PeerHandle.class); + ArgumentCaptor<SubscribeDiscoverySession> subscribeSession = ArgumentCaptor + .forClass(SubscribeDiscoverySession.class); + ArgumentCaptor<PeerHandle> peerIdCaptor = ArgumentCaptor.forClass(PeerHandle.class); // (0) connect + success mDut.attach(mMockLooperHandler, configRequest, mockCallback, null); @@ -516,7 +514,7 @@ public class WifiAwareManagerTest { final int sessionId = 123; final ConfigRequest configRequest = new ConfigRequest.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, mockSubscribeSession); @@ -526,8 +524,8 @@ public class WifiAwareManagerTest { .forClass(IWifiAwareEventCallback.class); ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor .forClass(IWifiAwareDiscoverySessionCallback.class); - ArgumentCaptor<WifiAwareSubscribeDiscoverySession> subscribeSession = ArgumentCaptor - .forClass(WifiAwareSubscribeDiscoverySession.class); + ArgumentCaptor<SubscribeDiscoverySession> subscribeSession = ArgumentCaptor + .forClass(SubscribeDiscoverySession.class); // (1) connect successfully mDut.attach(mMockLooperHandler, configRequest, mockCallback, null); @@ -892,8 +890,8 @@ public class WifiAwareManagerTest { .forClass(IWifiAwareEventCallback.class); ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor .forClass(IWifiAwareDiscoverySessionCallback.class); - ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor - .forClass(WifiAwarePublishDiscoverySession.class); + ArgumentCaptor<PublishDiscoverySession> publishSession = ArgumentCaptor + .forClass(PublishDiscoverySession.class); ArgumentCaptor<RttManager.ParcelableRttParams> rttParamCaptor = ArgumentCaptor .forClass(RttManager.ParcelableRttParams.class); ArgumentCaptor<RttManager.RttResult[]> rttResultsCaptor = ArgumentCaptor @@ -953,7 +951,7 @@ public class WifiAwareManagerTest { public void testNetworkSpecifierWithClient() throws Exception { final int clientId = 4565; 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 String token = "Some arbitrary token string - can really be anything"; final ConfigRequest configRequest = new ConfigRequest.Builder().build(); @@ -967,8 +965,8 @@ public class WifiAwareManagerTest { .forClass(IWifiAwareEventCallback.class); ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor .forClass(IWifiAwareDiscoverySessionCallback.class); - ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor - .forClass(WifiAwarePublishDiscoverySession.class); + ArgumentCaptor<PublishDiscoverySession> publishSession = ArgumentCaptor + .forClass(PublishDiscoverySession.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService, mockPublishSession, mockRttListener); |