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

Commit 7d18334f authored by Roshan Pius's avatar Roshan Pius
Browse files

WifiManager: Add abort callback for network request

Add a callback to inform the UI that the active request has been
aborted.

Bug: 113878056
Test: ./frameworks/base/wifi/tests/runtests.sh
Change-Id: I85bc1aee37af66b57471a7abf67dec55b13f97b0
parent 9a8e1810
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ oneway interface INetworkRequestMatchCallback
{
   void onUserSelectionCallbackRegistration(in INetworkRequestUserSelectionCallback userSelectionCallback);

   void onAbort();

   void onMatch(in List<ScanResult> scanResults);

   void onUserSelectionConnectSuccess(in WifiConfiguration wificonfiguration);
+19 −0
Original line number Diff line number Diff line
@@ -1266,6 +1266,15 @@ public class WifiManager {
        void onUserSelectionCallbackRegistration(
                @NonNull NetworkRequestUserSelectionCallback userSelectionCallback);

        /**
         * Invoked when the active network request is aborted, either because
         * <li> The app released the request, OR</li>
         * <li> Request was overridden by a new request</li>
         * This signals the end of processing for the current request and should stop the UI
         * component. No subsequent calls from the UI component will be handled by the platform.
         */
        void onAbort();

        /**
         * Invoked when a network request initiated by an app matches some networks in scan results.
         * This may be invoked multiple times for a single network request as the platform finds new
@@ -1362,6 +1371,16 @@ public class WifiManager {
            });
        }

        @Override
        public void onAbort() {
            if (mVerboseLoggingEnabled) {
                Log.v(TAG, "NetworkRequestMatchCallbackProxy: onAbort");
            }
            mHandler.post(() -> {
                mCallback.onAbort();
            });
        }

        @Override
        public void onMatch(List<ScanResult> scanResults) {
            if (mVerboseLoggingEnabled) {
+5 −0
Original line number Diff line number Diff line
@@ -1202,6 +1202,11 @@ i * Verify that a call to cancel WPS immediately returns a failure.
                mock(INetworkRequestUserSelectionCallback.class);

        assertEquals(0, mLooper.dispatchAll());

        callbackCaptor.getValue().onAbort();
        assertEquals(1, mLooper.dispatchAll());
        verify(mNetworkRequestMatchCallback).onAbort();

        callbackCaptor.getValue().onMatch(new ArrayList<ScanResult>());
        assertEquals(1, mLooper.dispatchAll());
        verify(mNetworkRequestMatchCallback).onMatch(anyList());