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

Commit fd4b0456 authored by Oscar Shu's avatar Oscar Shu Committed by Automerger Merge Worker
Browse files

Merge "New startScan API for 6Ghz RNR support" into sc-dev am: ba8e4506

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13419725

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I42e8dd85e1dbcf9d436e994df50e93da4286e6dc
parents 4893d528 ba8e4506
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -7758,11 +7758,13 @@ package android.net.wifi.nl80211 {
    method public boolean setupInterfaceForSoftApMode(@NonNull String);
    method @Nullable public android.net.wifi.nl80211.WifiNl80211Manager.SignalPollResult signalPoll(@NonNull String);
    method public boolean startPnoScan(@NonNull String, @NonNull android.net.wifi.nl80211.PnoSettings, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.nl80211.WifiNl80211Manager.PnoScanRequestCallback);
    method public boolean startScan(@NonNull String, int, @Nullable java.util.Set<java.lang.Integer>, @Nullable java.util.List<byte[]>);
    method @Deprecated public boolean startScan(@NonNull String, int, @Nullable java.util.Set<java.lang.Integer>, @Nullable java.util.List<byte[]>);
    method public boolean startScan(@NonNull String, int, @Nullable java.util.Set<java.lang.Integer>, @Nullable java.util.List<byte[]>, @Nullable android.os.Bundle);
    method public boolean stopPnoScan(@NonNull String);
    method public boolean tearDownClientInterface(@NonNull String);
    method public boolean tearDownInterfaces();
    method public boolean tearDownSoftApInterface(@NonNull String);
    field public static final String SCANNING_PARAM_ENABLE_6GHZ_RNR = "android.net.wifi.nl80211.SCANNING_PARAM_ENABLE_6GHZ_RNR";
    field public static final int SCAN_TYPE_PNO_SCAN = 1; // 0x1
    field public static final int SCAN_TYPE_SINGLE_SCAN = 0; // 0x0
    field public static final int SEND_MGMT_FRAME_ERROR_ALREADY_STARTED = 5; // 0x5
+5 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ public class SingleScanSettings implements Parcelable {
    private static final String TAG = "SingleScanSettings";

    public int scanType;
    public boolean enable6GhzRnr;
    public ArrayList<ChannelSettings> channelSettings;
    public ArrayList<HiddenNetwork> hiddenNetworks;

@@ -50,6 +51,7 @@ public class SingleScanSettings implements Parcelable {
            return false;
        }
        return scanType == settings.scanType
                && enable6GhzRnr == settings.enable6GhzRnr
                && channelSettings.equals(settings.channelSettings)
                && hiddenNetworks.equals(settings.hiddenNetworks);
    }
@@ -57,7 +59,7 @@ public class SingleScanSettings implements Parcelable {
    /** override hash code */
    @Override
    public int hashCode() {
        return Objects.hash(scanType, channelSettings, hiddenNetworks);
        return Objects.hash(scanType, channelSettings, hiddenNetworks, enable6GhzRnr);
    }


@@ -83,6 +85,7 @@ public class SingleScanSettings implements Parcelable {
            Log.wtf(TAG, "Invalid scan type " + scanType);
        }
        out.writeInt(scanType);
        out.writeBoolean(enable6GhzRnr);
        out.writeTypedList(channelSettings);
        out.writeTypedList(hiddenNetworks);
    }
@@ -100,6 +103,7 @@ public class SingleScanSettings implements Parcelable {
            if (!isValidScanType(result.scanType)) {
                Log.wtf(TAG, "Invalid scan type " + result.scanType);
            }
            result.enable6GhzRnr = in.readBoolean();
            result.channelSettings = new ArrayList<ChannelSettings>();
            in.readTypedList(result.channelSettings, ChannelSettings.CREATOR);
            result.hiddenNetworks = new ArrayList<HiddenNetwork>();
+20 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.net.wifi.SoftApInfo;
import android.net.wifi.WifiAnnotations;
import android.net.wifi.WifiScanner;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
@@ -90,6 +91,10 @@ public class WifiNl80211Manager {
     */
    public static final int SCAN_TYPE_PNO_SCAN = 1;

    // Extra scanning parameter used to enable 6Ghz RNR (Reduced Neighbour Support).
    public static final String SCANNING_PARAM_ENABLE_6GHZ_RNR =
            "android.net.wifi.nl80211.SCANNING_PARAM_ENABLE_6GHZ_RNR";

    private AlarmManager mAlarmManager;
    private Handler mEventHandler;

@@ -910,6 +915,15 @@ public class WifiNl80211Manager {
        }
    }

    /**
     * @deprecated replaced by {@link #startScan(String, int, Set, List, Bundle)}
     **/
    @Deprecated
    public boolean startScan(@NonNull String ifaceName, @WifiAnnotations.ScanType int scanType,
            @Nullable Set<Integer> freqs, @Nullable List<byte[]> hiddenNetworkSSIDs) {
        return startScan(ifaceName, scanType, freqs, hiddenNetworkSSIDs, null);
    }

    /**
     * Start a scan using the specified parameters. A scan is an asynchronous operation. The
     * result of the operation is returned in the {@link ScanEventCallback} registered when
@@ -929,11 +943,13 @@ public class WifiNl80211Manager {
     * @param freqs list of frequencies to scan for, if null scan all supported channels.
     * @param hiddenNetworkSSIDs List of hidden networks to be scanned for, a null indicates that
     *                           no hidden frequencies will be scanned for.
     * @param extraScanningParams bundle of extra scanning parameters.
     * @return Returns true on success, false on failure (e.g. when called before the interface
     * has been set up).
     */
    public boolean startScan(@NonNull String ifaceName, @WifiAnnotations.ScanType int scanType,
            @Nullable Set<Integer> freqs, @Nullable List<byte[]> hiddenNetworkSSIDs) {
            @Nullable Set<Integer> freqs, @Nullable List<byte[]> hiddenNetworkSSIDs,
            @Nullable Bundle extraScanningParams) {
        IWifiScannerImpl scannerImpl = getScannerImpl(ifaceName);
        if (scannerImpl == null) {
            Log.e(TAG, "No valid wificond scanner interface handler for iface=" + ifaceName);
@@ -948,6 +964,9 @@ public class WifiNl80211Manager {
        }
        settings.channelSettings  = new ArrayList<>();
        settings.hiddenNetworks  = new ArrayList<>();
        if (extraScanningParams != null) {
            settings.enable6GhzRnr = extraScanningParams.getBoolean(SCANNING_PARAM_ENABLE_6GHZ_RNR);
        }

        if (freqs != null) {
            for (Integer freq : freqs) {
+1 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class SingleScanSettingsTest {
                new ArrayList<>(Arrays.asList(mChannelSettings1, mChannelSettings2));
        scanSettings.hiddenNetworks =
                new ArrayList<>(Arrays.asList(mHiddenNetwork1, mHiddenNetwork2));
        scanSettings.enable6GhzRnr = true;

        Parcel parcel = Parcel.obtain();
        scanSettings.writeToParcel(parcel, 0);
+55 −4
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.net.wifi.SoftApInfo;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiScanner;
import android.net.wifi.util.HexEncoding;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
@@ -506,7 +507,51 @@ public class WifiNl80211ManagerTest {
                SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST));
        verify(mWifiScannerImpl).scan(argThat(new ScanMatcher(
                IWifiScannerImpl.SCAN_TYPE_LOW_POWER,
                SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST)));
                SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST, false)));
    }

    /**
     * Verify the new startScan() API can convert input parameters to SingleScanSettings correctly.
     */
    @Test
    public void testScanWithBundle() throws Exception {
        when(mWifiScannerImpl.scan(any(SingleScanSettings.class))).thenReturn(true);
        Bundle bundle = new Bundle();
        bundle.putBoolean(WifiNl80211Manager.SCANNING_PARAM_ENABLE_6GHZ_RNR, true);
        assertTrue(mWificondControl.startScan(
                TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_LOW_POWER,
                SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST, bundle));
        verify(mWifiScannerImpl).scan(argThat(new ScanMatcher(
                IWifiScannerImpl.SCAN_TYPE_LOW_POWER,
                SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST, true)));
    }

    /**
     * Verify default values in SingleScanSettings when the input Bundle to startScan is null.
     */
    @Test
    public void testScanWithNullBundle() throws Exception {
        when(mWifiScannerImpl.scan(any(SingleScanSettings.class))).thenReturn(true);
        assertTrue(mWificondControl.startScan(
                TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_LOW_POWER,
                SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST, null));
        verify(mWifiScannerImpl).scan(argThat(new ScanMatcher(
                IWifiScannerImpl.SCAN_TYPE_LOW_POWER,
                SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST, false)));
    }

    /**
     * Verify default values in SingleScanSettings when the input Bundle to startScan is empty.
     */
    @Test
    public void testScanWithEmptyBundle() throws Exception {
        when(mWifiScannerImpl.scan(any(SingleScanSettings.class))).thenReturn(true);
        assertTrue(mWificondControl.startScan(
                TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_LOW_POWER,
                SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST, new Bundle()));
        verify(mWifiScannerImpl).scan(argThat(new ScanMatcher(
                IWifiScannerImpl.SCAN_TYPE_LOW_POWER,
                SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST, false)));
    }

    /**
@@ -527,7 +572,7 @@ public class WifiNl80211ManagerTest {
        // But the argument passed down should have the duplicate removed.
        verify(mWifiScannerImpl).scan(argThat(new ScanMatcher(
                IWifiScannerImpl.SCAN_TYPE_LOW_POWER,
                SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST)));
                SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST, false)));
    }

    /**
@@ -539,7 +584,7 @@ public class WifiNl80211ManagerTest {
        assertTrue(mWificondControl.startScan(
                TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_HIGH_ACCURACY, null, null));
        verify(mWifiScannerImpl).scan(argThat(new ScanMatcher(
                IWifiScannerImpl.SCAN_TYPE_HIGH_ACCURACY, null, null)));
                IWifiScannerImpl.SCAN_TYPE_HIGH_ACCURACY, null, null, false)));
    }

    /**
@@ -1068,11 +1113,14 @@ public class WifiNl80211ManagerTest {
        int mExpectedScanType;
        private final Set<Integer> mExpectedFreqs;
        private final List<byte[]> mExpectedSsids;
        private final boolean mExpectedEnable6GhzRnr;

        ScanMatcher(int expectedScanType, Set<Integer> expectedFreqs, List<byte[]> expectedSsids) {
        ScanMatcher(int expectedScanType, Set<Integer> expectedFreqs, List<byte[]> expectedSsids,
                boolean expectedEnable6GhzRnr) {
            this.mExpectedScanType = expectedScanType;
            this.mExpectedFreqs = expectedFreqs;
            this.mExpectedSsids = expectedSsids;
            this.mExpectedEnable6GhzRnr = expectedEnable6GhzRnr;
        }

        @Override
@@ -1080,6 +1128,9 @@ public class WifiNl80211ManagerTest {
            if (settings.scanType != mExpectedScanType) {
                return false;
            }
            if (settings.enable6GhzRnr != mExpectedEnable6GhzRnr) {
                return false;
            }
            ArrayList<ChannelSettings> channelSettings = settings.channelSettings;
            ArrayList<HiddenNetwork> hiddenNetworks = settings.hiddenNetworks;
            if (mExpectedFreqs != null) {