diff options
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); } } }; |