summaryrefslogtreecommitdiff
path: root/framework/java
diff options
context:
space:
mode:
author Oscar Shu <xshu@google.com> 2025-02-07 00:35:14 +0000
committer Oscar Shu <xshu@google.com> 2025-02-07 20:37:17 +0000
commit0befec7e14fe5c9fdce05c5ccff98bf247a1b0fb (patch)
treeb75dc23996702604f5b639655cd2f0ba65c5b627 /framework/java
parentd2e6d4ad0ef559166200f27f2b3326212653ec65 (diff)
Allow WifiNetworkSpecifier to hint preference to secondary
When setPreferSecondarySta is true, the wifi framework will try to use secondary STA for this connection when possible. Flag: EXEMPT bugfix Bug: 391440945 Test: atest android.net.wifi Test: atest com.android.server.wifi Change-Id: I3d68c52b66b6ccf389e3e005abfdd026a723827a
Diffstat (limited to 'framework/java')
-rw-r--r--framework/java/android/net/wifi/WifiNetworkSpecifier.java44
1 files changed, 38 insertions, 6 deletions
diff --git a/framework/java/android/net/wifi/WifiNetworkSpecifier.java b/framework/java/android/net/wifi/WifiNetworkSpecifier.java
index 199969d9c7..e00e7e6b7b 100644
--- a/framework/java/android/net/wifi/WifiNetworkSpecifier.java
+++ b/framework/java/android/net/wifi/WifiNetworkSpecifier.java
@@ -192,6 +192,8 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
private int[] mChannels;
+ private boolean mPreferSecondarySta;
+
public Builder() {
mSsidPatternMatcher = null;
mBssidPatternMatcher = null;
@@ -480,6 +482,19 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
return this;
}
+ /**
+ * Hint the Wifi service to prefer using secondary STA for this connection.
+ *
+ * @param value - true to prefer this connection to be started on a secondary STA.
+ * false to let the wifi framework decide
+ * @return Instance of {@link Builder} to enable chaining of the builder method.
+ * @hide
+ */
+ @NonNull public Builder setPreferSecondarySta(boolean value) {
+ mPreferSecondarySta = value;
+ return this;
+ }
+
private void setSecurityParamsInWifiConfiguration(
@NonNull WifiConfiguration configuration) {
if (!TextUtils.isEmpty(mWpa2PskPassphrase)) { // WPA-PSK network.
@@ -684,7 +699,8 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
mBssidPatternMatcher,
mBand,
buildWifiConfiguration(),
- mChannels);
+ mChannels,
+ mPreferSecondarySta);
}
}
@@ -707,6 +723,7 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
@WifiBand private final int mBand;
private final int[] mChannelFreqs;
+ private boolean mPreferSecondarySta;
/**
* Security credentials for the network.
@@ -729,7 +746,8 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
@NonNull Pair<MacAddress, MacAddress> bssidPatternMatcher,
@WifiBand int band,
@NonNull WifiConfiguration wifiConfiguration,
- @NonNull int[] channelFreqs) {
+ @NonNull int[] channelFreqs,
+ boolean preferSecondarySta) {
checkNotNull(ssidPatternMatcher);
checkNotNull(bssidPatternMatcher);
checkNotNull(wifiConfiguration);
@@ -739,6 +757,7 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
this.mBand = band;
this.wifiConfiguration = wifiConfiguration;
this.mChannelFreqs = channelFreqs;
+ this.mPreferSecondarySta = preferSecondarySta;
}
/**
@@ -756,6 +775,14 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
return mChannelFreqs.clone();
}
+ /**
+ * @see Builder#setPreferSecondarySta(boolean)
+ * @hide
+ */
+ public boolean isPreferSecondarySta() {
+ return mPreferSecondarySta;
+ }
+
public static final @NonNull Creator<WifiNetworkSpecifier> CREATOR =
new Creator<WifiNetworkSpecifier>() {
@Override
@@ -767,9 +794,10 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
Pair.create(baseAddress, mask);
int band = in.readInt();
WifiConfiguration wifiConfiguration = in.readParcelable(null);
- int[] mChannels = in.createIntArray();
+ int[] channels = in.createIntArray();
+ boolean preferSecondarySta = in.readBoolean();
return new WifiNetworkSpecifier(ssidPatternMatcher, bssidPatternMatcher, band,
- wifiConfiguration, mChannels);
+ wifiConfiguration, channels, preferSecondarySta);
}
@Override
@@ -791,13 +819,15 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
dest.writeInt(mBand);
dest.writeParcelable(wifiConfiguration, flags);
dest.writeIntArray(mChannelFreqs);
+ dest.writeBoolean(mPreferSecondarySta);
}
@Override
public int hashCode() {
return Objects.hash(
ssidPatternMatcher.getPath(), ssidPatternMatcher.getType(), bssidPatternMatcher,
- mBand, wifiConfiguration.allowedKeyManagement, Arrays.hashCode(mChannelFreqs));
+ mBand, wifiConfiguration.allowedKeyManagement, Arrays.hashCode(mChannelFreqs),
+ mPreferSecondarySta);
}
@Override
@@ -818,7 +848,8 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
&& this.mBand == lhs.mBand
&& Objects.equals(this.wifiConfiguration.allowedKeyManagement,
lhs.wifiConfiguration.allowedKeyManagement)
- && Arrays.equals(mChannelFreqs, lhs.mChannelFreqs);
+ && Arrays.equals(mChannelFreqs, lhs.mChannelFreqs)
+ && mPreferSecondarySta == lhs.mPreferSecondarySta;
}
@Override
@@ -831,6 +862,7 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
.append(", BSSID=").append(wifiConfiguration.BSSID)
.append(", channels=").append(Arrays.toString(mChannelFreqs))
.append(", band=").append(mBand)
+ .append(", preferSecondarySta=").append(mPreferSecondarySta)
.append("]")
.toString();
}