diff options
| author | 2020-10-14 14:35:52 -0700 | |
|---|---|---|
| committer | 2020-10-16 18:11:53 +0000 | |
| commit | 57188e13c27926902e54ef38bb6427c14469001f (patch) | |
| tree | 3426da24a87fd6217c9e18b643d650a3986f88ed | |
| 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
| -rw-r--r-- | api/current.txt | 4 | ||||
| -rw-r--r-- | wifi/api/current.txt | 4 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/aware/DiscoverySessionCallback.java | 10 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/aware/WifiAwareManager.java | 24 | ||||
| -rw-r--r-- | wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java | 7 |
5 files changed, 41 insertions, 8 deletions
diff --git a/api/current.txt b/api/current.txt index d20bff2da8eb..2bbb98d09209 100644 --- a/api/current.txt +++ b/api/current.txt @@ -31863,7 +31863,7 @@ package android.net.wifi.aware { method public void onPublishStarted(@NonNull android.net.wifi.aware.PublishDiscoverySession); method public void onServiceDiscovered(android.net.wifi.aware.PeerHandle, byte[], java.util.List<byte[]>); method public void onServiceDiscoveredWithinRange(android.net.wifi.aware.PeerHandle, byte[], java.util.List<byte[]>, int); - method public void onServiceLost(@NonNull android.net.wifi.aware.PeerHandle); + method public void onServiceLost(@NonNull android.net.wifi.aware.PeerHandle, int); method public void onSessionConfigFailed(); method public void onSessionConfigUpdated(); method public void onSessionTerminated(); @@ -31943,6 +31943,8 @@ package android.net.wifi.aware { field public static final String ACTION_WIFI_AWARE_STATE_CHANGED = "android.net.wifi.aware.action.WIFI_AWARE_STATE_CHANGED"; field public static final int WIFI_AWARE_DATA_PATH_ROLE_INITIATOR = 0; // 0x0 field public static final int WIFI_AWARE_DATA_PATH_ROLE_RESPONDER = 1; // 0x1 + field public static final int WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE = 1; // 0x1 + field public static final int WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN = 0; // 0x0 } public final class WifiAwareNetworkInfo implements android.os.Parcelable android.net.TransportInfo { diff --git a/wifi/api/current.txt b/wifi/api/current.txt index f7061181b72b..d6e89223ba95 100644 --- a/wifi/api/current.txt +++ b/wifi/api/current.txt @@ -584,7 +584,7 @@ package android.net.wifi.aware { method public void onPublishStarted(@NonNull android.net.wifi.aware.PublishDiscoverySession); method public void onServiceDiscovered(android.net.wifi.aware.PeerHandle, byte[], java.util.List<byte[]>); method public void onServiceDiscoveredWithinRange(android.net.wifi.aware.PeerHandle, byte[], java.util.List<byte[]>, int); - method public void onServiceLost(@NonNull android.net.wifi.aware.PeerHandle); + method public void onServiceLost(@NonNull android.net.wifi.aware.PeerHandle, int); method public void onSessionConfigFailed(); method public void onSessionConfigUpdated(); method public void onSessionTerminated(); @@ -664,6 +664,8 @@ package android.net.wifi.aware { field public static final String ACTION_WIFI_AWARE_STATE_CHANGED = "android.net.wifi.aware.action.WIFI_AWARE_STATE_CHANGED"; field public static final int WIFI_AWARE_DATA_PATH_ROLE_INITIATOR = 0; // 0x0 field public static final int WIFI_AWARE_DATA_PATH_ROLE_RESPONDER = 1; // 0x1 + field public static final int WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE = 1; // 0x1 + field public static final int WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN = 0; // 0x0 } public final class WifiAwareNetworkInfo implements android.os.Parcelable android.net.TransportInfo { 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); } } }; diff --git a/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java b/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java index 5fe0cb42073d..d163fb0e6adf 100644 --- a/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java +++ b/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java @@ -16,6 +16,7 @@ package android.net.wifi.aware; +import static android.net.wifi.aware.WifiAwareManager.WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE; import static android.net.wifi.aware.WifiAwareNetworkSpecifier.NETWORK_SPECIFIER_TYPE_IB; import static org.hamcrest.core.IsEqual.equalTo; @@ -372,7 +373,8 @@ public class WifiAwareManagerTest { // (5) discovery session is no longer visible sessionProxyCallback.getValue().onMatchExpired(peerHandle.peerId); mMockLooper.dispatchAll(); - inOrder.verify(mockSessionCallback).onServiceLost(peerIdCaptor.capture()); + inOrder.verify(mockSessionCallback).onServiceLost(peerIdCaptor.capture(), + eq(WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE)); assertEquals(peerHandle.peerId, peerIdCaptor.getValue().peerId); // (6) terminate @@ -520,7 +522,8 @@ public class WifiAwareManagerTest { // (5) discovery session is no longer visible sessionProxyCallback.getValue().onMatchExpired(peerHandle.peerId); mMockLooper.dispatchAll(); - inOrder.verify(mockSessionCallback).onServiceLost(peerIdCaptor.capture()); + inOrder.verify(mockSessionCallback).onServiceLost(peerIdCaptor.capture(), + eq(WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE)); assertEquals(peerHandle.peerId, peerIdCaptor.getValue().peerId); // (6) terminate |