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

Commit 0234e4c4 authored by Jimmy Chen's avatar Jimmy Chen
Browse files

wifi: add interface name to ScanResult

Add interface name to ScanResult to allow connection on a secondary
interface.
In the initial support for multiple chips, a single
ClientModeImpl supports connection to multiple interfaces,
but only one at a time.
When a new connection is needed, the ClientModeImpl is
handed a WifiConfiguration with attached ScanResult to
describe the connection. The ClientModeImpl needs to
figure out on which interface to perform the connection.
Having interface name as part of ScanResult makes it very
easy to figure out the interface. It is also very easy to
add as the scanner implementation always have this information
at hand.
Without the interface name, there is not enough information
to figure out the exact interface (chip) to which the
connection belongs.

Bug: 147495504
Test: Manual - enable wifi and connect to an access point
Test: atest com.android.server.wifi
Test: atest FrameworksWifiApiTests
Change-Id: I9e2f102f27eab01dbc407ea9cbb0bd9d6819395a
parent 346cee22
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -80,6 +80,12 @@ public final class ScanResult implements Parcelable {
     */
    public String capabilities;

    /**
     * The interface name on which the scan result was received.
     * @hide
     */
    public String ifaceName;

    /**
     * @hide
     * No security protocol.
@@ -939,6 +945,7 @@ public final class ScanResult implements Parcelable {
            flags = source.flags;
            radioChainInfos = source.radioChainInfos;
            this.mWifiStandard = source.mWifiStandard;
            this.ifaceName = source.ifaceName;
        }
    }

@@ -977,6 +984,7 @@ public final class ScanResult implements Parcelable {
        sb.append(", 80211mcResponder: ");
        sb.append(((flags & FLAG_80211mc_RESPONDER) != 0) ? "is supported" : "is not supported");
        sb.append(", Radio Chain Infos: ").append(Arrays.toString(radioChainInfos));
        sb.append(", interface name: ").append(ifaceName);
        return sb.toString();
    }

@@ -1056,6 +1064,7 @@ public final class ScanResult implements Parcelable {
        } else {
            dest.writeInt(0);
        }
        dest.writeString((ifaceName != null) ? ifaceName.toString() : "");
    }

    /** Implement the Parcelable interface */
@@ -1134,6 +1143,7 @@ public final class ScanResult implements Parcelable {
                        sr.radioChainInfos[i].level = in.readInt();
                    }
                }
                sr.ifaceName = in.readString();
                return sr;
            }

+6 −2
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public class ScanResultTest {
    public static final long TEST_TSF = 04660l;
    public static final @WifiAnnotations.WifiStandard int TEST_WIFI_STANDARD =
            ScanResult.WIFI_STANDARD_11AC;
    public static final String TEST_IFACE_NAME = "test_ifname";

    /**
     * Frequency to channel map. This include some frequencies used outside the US.
@@ -219,7 +220,7 @@ public class ScanResultTest {
                + "passpoint: no, ChannelBandwidth: 0, centerFreq0: 0, centerFreq1: 0, "
                + "standard: 11ac, "
                + "80211mcResponder: is not supported, "
                + "Radio Chain Infos: null", scanResult.toString());
                + "Radio Chain Infos: null, interface name: test_ifname", scanResult.toString());
    }

    /**
@@ -242,7 +243,8 @@ public class ScanResultTest {
                + "standard: 11ac, "
                + "80211mcResponder: is not supported, "
                + "Radio Chain Infos: [RadioChainInfo: id=0, level=-45, "
                + "RadioChainInfo: id=1, level=-54]", scanResult.toString());
                + "RadioChainInfo: id=1, level=-54], interface name: test_ifname",
                scanResult.toString());
    }

    /**
@@ -283,6 +285,8 @@ public class ScanResultTest {
        result.frequency = TEST_FREQUENCY;
        result.timestamp = TEST_TSF;
        result.setWifiStandard(TEST_WIFI_STANDARD);
        result.ifaceName = TEST_IFACE_NAME;

        return result;
    }