diff options
author | Nate Jiang <qiangjiang@google.com> | 2020-10-14 14:35:52 -0700 |
---|---|---|
committer | Nate Jiang <qiangjiang@google.com> | 2020-10-16 18:11:53 +0000 |
commit | 57188e13c27926902e54ef38bb6427c14469001f (patch) | |
tree | 3426da24a87fd6217c9e18b643d650a3986f88ed /wifi/java | |
parent | 9a64686f26cef761946f7d78545570127a3bc555 (diff) |
[AWARE] update API to comply the API guideline
Update onDataPathConfirm() with reason.
Bug: 168216007
Test: atest android.net.wifi
Change-Id: I70a88d2f017df13f9be6dd3686d663f13e995193
Diffstat (limited to 'wifi/java')
-rw-r--r-- | wifi/java/android/net/wifi/aware/DiscoverySessionCallback.java | 10 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/aware/WifiAwareManager.java | 24 |
2 files changed, 30 insertions, 4 deletions
diff --git a/wifi/java/android/net/wifi/aware/DiscoverySessionCallback.java b/wifi/java/android/net/wifi/aware/DiscoverySessionCallback.java index e3800ad6ef36..da8e17e2f41a 100644 --- a/wifi/java/android/net/wifi/aware/DiscoverySessionCallback.java +++ b/wifi/java/android/net/wifi/aware/DiscoverySessionCallback.java @@ -191,14 +191,18 @@ public class DiscoverySessionCallback { } /** - * Called when the discovered peer is no longer visible. All further operations on this - * discovery session will fail. If the peer is visible again, + * Called when the discovered service is not available. All further operations on this + * discovery session will fail. If the service is available again, * {@link #onServiceDiscovered(PeerHandle, byte[], List)} or * {@link #onServiceDiscoveredWithinRange(PeerHandle, byte[], List, int)} will be called. * * @param peerHandle An opaque handle to the peer matching our discovery operation. + * @param reason Discovered service lost reason code. One of + * {@link WifiAwareManager#WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE}, + * {@link WifiAwareManager#WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN */ - public void onServiceLost(@NonNull PeerHandle peerHandle) { + public void onServiceLost(@NonNull PeerHandle peerHandle, + @WifiAwareManager.DiscoveryLostReasonCode int reason) { /* empty */ } } diff --git a/wifi/java/android/net/wifi/aware/WifiAwareManager.java b/wifi/java/android/net/wifi/aware/WifiAwareManager.java index d6e46fd52caf..03f5f401fc40 100644 --- a/wifi/java/android/net/wifi/aware/WifiAwareManager.java +++ b/wifi/java/android/net/wifi/aware/WifiAwareManager.java @@ -151,6 +151,27 @@ public class WifiAwareManager { */ public static final int WIFI_AWARE_DATA_PATH_ROLE_RESPONDER = 1; + /** @hide */ + @IntDef({ + WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN, + WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE}) + @Retention(RetentionPolicy.SOURCE) + public @interface DiscoveryLostReasonCode { + } + + /** + * Reason code provided in {@link DiscoverySessionCallback#onServiceLost(PeerHandle, int)} + * indicating that the service was lost for unknown reason. + */ + public static final int WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN = 0; + + /** + * Reason code provided in {@link DiscoverySessionCallback#onServiceLost(PeerHandle, int)} + * indicating that the service advertised by the peer is no longer visible. This may be because + * the peer is out of range or because the peer stopped advertising this service. + */ + public static final int WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE = 1; + private final Context mContext; private final IWifiAwareManager mService; @@ -695,7 +716,8 @@ public class WifiAwareManager { break; case CALLBACK_MATCH_EXPIRED: mOriginalCallback - .onServiceLost(new PeerHandle(msg.arg1)); + .onServiceLost(new PeerHandle(msg.arg1), + WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE); } } }; |