Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a3e3896 authored by Nate Jiang's avatar Nate Jiang
Browse files

[AWARE] API indicating when a Service is no longer visible

Add an API to indacate a discovered service is no longer visible

Bug: 73139535
Test: atest android.net.wifi
Change-Id: Id79107ede15547eaf3d7dbc7b0c67ec8f8a12c40
parent 462fc154
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -31737,6 +31737,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 onSessionConfigFailed();
    method public void onSessionConfigUpdated();
    method public void onSessionTerminated();
+1 −0
Original line number Diff line number Diff line
@@ -579,6 +579,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 onSessionConfigFailed();
    method public void onSessionConfigUpdated();
    method public void onSessionTerminated();
+12 −0
Original line number Diff line number Diff line
@@ -189,4 +189,16 @@ public class DiscoverySessionCallback {
    public void onMessageReceived(PeerHandle peerHandle, byte[] message) {
        /* empty */
    }

    /**
     * Called when the discovered peer is no longer visible. All further operations on this
     * discovery session will fail. If the peer is visible 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.
     */
    public void onServiceLost(@NonNull PeerHandle peerHandle) {
        /* empty */
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -35,4 +35,5 @@ oneway interface IWifiAwareDiscoverySessionCallback
    void onMessageSendSuccess(int messageId);
    void onMessageSendFail(int messageId, int reason);
    void onMessageReceived(int peerId, in byte[] message);
    void onMatchExpired(int peerId);
}
+13 −0
Original line number Diff line number Diff line
@@ -587,6 +587,7 @@ public class WifiAwareManager {
        private static final int CALLBACK_MESSAGE_SEND_FAIL = 6;
        private static final int CALLBACK_MESSAGE_RECEIVED = 7;
        private static final int CALLBACK_MATCH_WITH_DISTANCE = 8;
        private static final int CALLBACK_MATCH_EXPIRED = 9;

        private static final String MESSAGE_BUNDLE_KEY_MESSAGE = "message";
        private static final String MESSAGE_BUNDLE_KEY_MESSAGE2 = "message2";
@@ -676,6 +677,9 @@ public class WifiAwareManager {
                            mOriginalCallback.onMessageReceived(new PeerHandle(msg.arg1),
                                    (byte[]) msg.obj);
                            break;
                        case CALLBACK_MATCH_EXPIRED:
                            mOriginalCallback
                                    .onServiceLost(new PeerHandle(msg.arg1));
                    }
                }
            };
@@ -746,6 +750,15 @@ public class WifiAwareManager {
            onMatchCommon(CALLBACK_MATCH_WITH_DISTANCE, peerId, serviceSpecificInfo, matchFilter,
                    distanceMm);
        }
        @Override
        public void onMatchExpired(int peerId) {
            if (VDBG) {
                Log.v(TAG, "onMatchExpired: peerId=" + peerId);
            }
            Message msg = mHandler.obtainMessage(CALLBACK_MATCH_EXPIRED);
            msg.arg1 = peerId;
            mHandler.sendMessage(msg);
        }

        @Override
        public void onMessageSendSuccess(int messageId) {
Loading