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

Commit 06a55ff1 authored by Les Lee's avatar Les Lee Committed by Android (Google) Code Review
Browse files

Merge "wifi: Add new API to notify wificond of CC have changed"

parents 1569dd7a 1a8877f5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8819,6 +8819,7 @@ package android.net.wifi.nl80211 {
    method @Nullable public android.net.wifi.nl80211.DeviceWiphyCapabilities getDeviceWiphyCapabilities(@NonNull String);
    method @NonNull public java.util.List<android.net.wifi.nl80211.NativeScanResult> getScanResults(@NonNull String, int);
    method @Nullable public android.net.wifi.nl80211.WifiNl80211Manager.TxPacketCounters getTxPacketCounters(@NonNull String);
    method public boolean notifyCountryCodeChanged();
    method @Nullable public static android.net.wifi.nl80211.WifiNl80211Manager.OemSecurityType parseOemSecurityTypeElement(int, int, @NonNull byte[]);
    method @Deprecated public boolean registerApCallback(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.nl80211.WifiNl80211Manager.SoftApCallback);
    method public boolean registerCountryCodeChangedListener(@NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.nl80211.WifiNl80211Manager.CountryCodeChangedListener);
+20 −0
Original line number Diff line number Diff line
@@ -1261,6 +1261,26 @@ public class WifiNl80211Manager {
        mWificondEventHandler.unregisterCountryCodeChangedListener(listener);
    }

    /**
     * Notifies the wificond daemon that the WiFi framework has successfully updated the Country
     * Code of the driver. The wificond daemon needs this notification if the device does not
     * support the NL80211_CMD_REG_CHANGED (otherwise it will find out on its own). The wificond
     * updates in internal state in response to this Country Code update.
     *
     * @return true on success, false otherwise.
     */
    public boolean notifyCountryCodeChanged() {
        try {
            if (mWificond != null) {
                mWificond.notifyCountryCodeChanged();
                return true;
            }
        } catch (RemoteException e1) {
            Log.e(TAG, "Failed to notify country code changed due to remote exception");
        }
        return false;
    }

    /**
     * Register the provided callback handler for SoftAp events. The interface must first be created
     * using {@link #setupInterfaceForSoftApMode(String)}. The callback registration is valid until
+20 −0
Original line number Diff line number Diff line
@@ -1137,6 +1137,26 @@ public class WifiNl80211ManagerTest {
        assertEquals(capaExpected, capaActual);
    }

    /**
     * Tests notifyCountryCodeChanged
     */
    @Test
    public void testNotifyCountryCodeChanged() throws Exception {
        doNothing().when(mWificond).notifyCountryCodeChanged();
        assertTrue(mWificondControl.notifyCountryCodeChanged());
        verify(mWificond).notifyCountryCodeChanged();
    }

    /**
     * Tests notifyCountryCodeChanged with RemoteException
     */
    @Test
    public void testNotifyCountryCodeChangedRemoteException() throws Exception {
        doThrow(new RemoteException()).when(mWificond).notifyCountryCodeChanged();
        assertFalse(mWificondControl.notifyCountryCodeChanged());
        verify(mWificond).notifyCountryCodeChanged();
    }

    // Create a ArgumentMatcher which captures a SingleScanSettings parameter and checks if it
    // matches the provided frequency set and ssid set.
    private class ScanMatcher implements ArgumentMatcher<SingleScanSettings> {