diff options
Diffstat (limited to 'wifi/java')
-rw-r--r-- | wifi/java/android/net/wifi/SoftApCapability.java | 8 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/SoftApConfiguration.java | 38 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiEnterpriseConfig.java | 22 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiInfo.java | 12 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiManager.java | 7 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiNetworkSuggestion.java | 36 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/nl80211/WifiNl80211Manager.java | 10 |
7 files changed, 95 insertions, 38 deletions
diff --git a/wifi/java/android/net/wifi/SoftApCapability.java b/wifi/java/android/net/wifi/SoftApCapability.java index 18b26db1b020..dcb57ecc933f 100644 --- a/wifi/java/android/net/wifi/SoftApCapability.java +++ b/wifi/java/android/net/wifi/SoftApCapability.java @@ -102,7 +102,9 @@ public final class SoftApCapability implements Parcelable { /** * Returns true when all of the queried features are supported, otherwise false. * - * @param features One or combination of the features from {@link @HotspotFeatures} + * @param features One or combination of the following features: + * {@link #SOFTAP_FEATURE_ACS_OFFLOAD}, {@link #SOFTAP_FEATURE_CLIENT_FORCE_DISCONNECT} or + * {@link #SOFTAP_FEATURE_WPA3_SAE}. */ public boolean areFeaturesSupported(@HotspotFeatures long features) { return (mSupportedFeatures & features) == features; @@ -122,7 +124,9 @@ public final class SoftApCapability implements Parcelable { * Constructor with combination of the feature. * Zero to no supported feature. * - * @param features One or combination of the features from {@link @HotspotFeatures}. + * @param features One or combination of the following features: + * {@link #SOFTAP_FEATURE_ACS_OFFLOAD}, {@link #SOFTAP_FEATURE_CLIENT_FORCE_DISCONNECT} or + * {@link #SOFTAP_FEATURE_WPA3_SAE}. * @hide */ public SoftApCapability(@HotspotFeatures long features) { diff --git a/wifi/java/android/net/wifi/SoftApConfiguration.java b/wifi/java/android/net/wifi/SoftApConfiguration.java index 457e0db9dc54..2bcd4f4241a6 100644 --- a/wifi/java/android/net/wifi/SoftApConfiguration.java +++ b/wifi/java/android/net/wifi/SoftApConfiguration.java @@ -165,7 +165,8 @@ public final class SoftApConfiguration implements Parcelable { /** * The operating band of the AP. - * One of the band types from {@link @BandType}. + * One or combination of the following band type: + * {@link #BAND_2GHZ}, {@link #BAND_5GHZ}, {@link #BAND_6GHZ}. */ private final @BandType int mBand; @@ -181,7 +182,11 @@ public final class SoftApConfiguration implements Parcelable { /** * The operating security type of the AP. - * One of the security types from {@link @SecurityType} + * One of the following security types: + * {@link #SECURITY_TYPE_OPEN}, + * {@link #SECURITY_TYPE_WPA2_PSK}, + * {@link #SECURITY_TYPE_WPA3_SAE_TRANSITION}, + * {@link #SECURITY_TYPE_WPA3_SAE} */ private final @SecurityType int mSecurityType; @@ -393,8 +398,12 @@ public final class SoftApConfiguration implements Parcelable { } /** - * Returns {@link BandType} set to be the band for the AP. - * {@link Builder#setBand(@BandType int)}. + * Returns band type set to be the band for the AP. + * + * One or combination of the following band type: + * {@link #BAND_2GHZ}, {@link #BAND_5GHZ}, {@link #BAND_6GHZ}. + * + * {@link Builder#setBand(int)}. * * @hide */ @@ -679,15 +688,19 @@ public final class SoftApConfiguration implements Parcelable { /** * Specifies that this AP should use specific security type with the given ASCII passphrase. * - * @param securityType one of the security types from {@link @SecurityType}. - * @param passphrase The passphrase to use for sepcific {@link @SecurityType} configuration - * or null with {@link @SecurityType#SECURITY_TYPE_OPEN}. + * @param securityType One of the following security types: + * {@link #SECURITY_TYPE_OPEN}, + * {@link #SECURITY_TYPE_WPA2_PSK}, + * {@link #SECURITY_TYPE_WPA3_SAE_TRANSITION}, + * {@link #SECURITY_TYPE_WPA3_SAE}. + * @param passphrase The passphrase to use for sepcific {@code securityType} configuration + * or null with {@link #SECURITY_TYPE_OPEN}. * * @return Builder for chaining. * @throws IllegalArgumentException when the passphrase length is invalid and - * {@code securityType} is not {@link @SecurityType#SECURITY_TYPE_OPEN} + * {@code securityType} is not {@link #SECURITY_TYPE_OPEN} * or non-null passphrase and {@code securityType} is - * {@link @SecurityType#SECURITY_TYPE_OPEN}. + * {@link #SECURITY_TYPE_OPEN}. */ @NonNull public Builder setPassphrase(@Nullable String passphrase, @SecurityType int securityType) { @@ -735,9 +748,10 @@ public final class SoftApConfiguration implements Parcelable { /** * Specifies the band for the AP. * <p> - * <li>If not set, defaults to BAND_2GHZ {@link @BandType}.</li> + * <li>If not set, defaults to {@link #BAND_2GHZ}.</li> * - * @param band One or combination of the band types from {@link @BandType}. + * @param band One or combination of the following band type: + * {@link #BAND_2GHZ}, {@link #BAND_5GHZ}, {@link #BAND_6GHZ}. * @return Builder for chaining. */ @NonNull @@ -758,7 +772,7 @@ public final class SoftApConfiguration implements Parcelable { * <p> * The default for the channel is a the special value 0 to have the framework * auto-select a valid channel from the band configured with - * {@link #setBand(@BandType int)}. + * {@link #setBand(int)}. * * The channel auto selection will offload to driver when * {@link SoftApCapability#areFeaturesSupported( diff --git a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java index 1aa20ef661ad..abd573f4bea9 100644 --- a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java +++ b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java @@ -1409,4 +1409,26 @@ public class WifiEnterpriseConfig implements Parcelable { public String getWapiCertSuite() { return getFieldValue(WAPI_CERT_SUITE_KEY); } + + /** + * Method determines whether the Enterprise configuration is insecure. An insecure + * configuration is one where EAP method requires a CA certification, i.e. PEAP, TLS, or + * TTLS, and any of the following conditions are met: + * - Both certificate and CA path are not configured. + * - Both alternative subject match and domain suffix match are not set. + * + * Note: this method does not exhaustively check security of the configuration - i.e. a return + * value of {@code false} is not a guarantee that the configuration is secure. + * @hide + */ + public boolean isInsecure() { + if (mEapMethod != Eap.PEAP && mEapMethod != Eap.TLS && mEapMethod != Eap.TTLS) { + return false; + } + if (!mIsAppInstalledCaCert && TextUtils.isEmpty(getCaPath())) { + return true; + } + return TextUtils.isEmpty(getAltSubjectMatch()) && TextUtils.isEmpty( + getDomainSuffixMatch()); + } } diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java index 70c5e72e4e0c..53883674e058 100644 --- a/wifi/java/android/net/wifi/WifiInfo.java +++ b/wifi/java/android/net/wifi/WifiInfo.java @@ -22,12 +22,13 @@ import android.annotation.Nullable; import android.annotation.SystemApi; import android.compat.annotation.UnsupportedAppUsage; import android.net.NetworkInfo.DetailedState; -import android.net.shared.Inet4AddressUtils; import android.os.Build; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; +import com.android.net.module.util.Inet4AddressUtils; + import java.net.Inet4Address; import java.net.InetAddress; import java.net.UnknownHostException; @@ -632,7 +633,6 @@ public class WifiInfo implements Parcelable { /** * @hide - * TODO: makes real freq boundaries */ public boolean is24GHz() { return ScanResult.is24GHz(mFrequency); @@ -640,7 +640,6 @@ public class WifiInfo implements Parcelable { /** * @hide - * TODO: makes real freq boundaries */ @UnsupportedAppUsage public boolean is5GHz() { @@ -648,6 +647,13 @@ public class WifiInfo implements Parcelable { } /** + * @hide + */ + public boolean is6GHz() { + return ScanResult.is6GHz(mFrequency); + } + + /** * Record the MAC address of the WLAN interface * @param macAddress the MAC address in {@code XX:XX:XX:XX:XX:XX} form * @hide diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 5f46cb3fa642..1b0497a0ecd5 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -1894,9 +1894,10 @@ public class WifiManager { * for a detailed explanation of the parameters. * When the device decides to connect to one of the provided network suggestions, platform sends * a directed broadcast {@link #ACTION_WIFI_NETWORK_SUGGESTION_POST_CONNECTION} to the app if - * the network was created with {@link WifiNetworkSuggestion.Builder - * #setIsAppInteractionRequired()} flag set and the app holds - * {@link android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION} permission. + * the network was created with + * {@link WifiNetworkSuggestion.Builder#setIsAppInteractionRequired(boolean)} flag set and the + * app holds {@link android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION} + * permission. *<p> * NOTE: * <li> These networks are just a suggestion to the platform. The platform will ultimately diff --git a/wifi/java/android/net/wifi/WifiNetworkSuggestion.java b/wifi/java/android/net/wifi/WifiNetworkSuggestion.java index cedf9b0b872d..4d3a2c02c686 100644 --- a/wifi/java/android/net/wifi/WifiNetworkSuggestion.java +++ b/wifi/java/android/net/wifi/WifiNetworkSuggestion.java @@ -100,7 +100,7 @@ public final class WifiNetworkSuggestion implements Parcelable { /** * Whether this network is metered or not. */ - private boolean mIsMetered; + private int mMeteredOverride; /** * Priority of this network among other network suggestions provided by the app. * The lower the number, the higher the priority (i.e value of 0 = highest priority). @@ -156,7 +156,7 @@ public final class WifiNetworkSuggestion implements Parcelable { mIsHiddenSSID = false; mIsAppInteractionRequired = false; mIsUserInteractionRequired = false; - mIsMetered = false; + mMeteredOverride = WifiConfiguration.METERED_OVERRIDE_NONE; mIsSharedWithUser = true; mIsSharedWithUserSet = false; mIsInitialAutojoinEnabled = true; @@ -257,28 +257,38 @@ public final class WifiNetworkSuggestion implements Parcelable { /** * Set the associated enterprise configuration for this network. Needed for authenticating - * to WPA2-EAP networks. See {@link WifiEnterpriseConfig} for description. + * to WPA2 enterprise networks. See {@link WifiEnterpriseConfig} for description. * * @param enterpriseConfig Instance of {@link WifiEnterpriseConfig}. * @return Instance of {@link Builder} to enable chaining of the builder method. + * @throws IllegalArgumentException if configuration CA certificate or + * AltSubjectMatch/DomainSuffixMatch is not set. */ public @NonNull Builder setWpa2EnterpriseConfig( @NonNull WifiEnterpriseConfig enterpriseConfig) { checkNotNull(enterpriseConfig); + if (enterpriseConfig.isInsecure()) { + throw new IllegalArgumentException("Enterprise configuration is insecure"); + } mWpa2EnterpriseConfig = new WifiEnterpriseConfig(enterpriseConfig); return this; } /** * Set the associated enterprise configuration for this network. Needed for authenticating - * to WPA3-SuiteB networks. See {@link WifiEnterpriseConfig} for description. + * to WPA3 enterprise networks. See {@link WifiEnterpriseConfig} for description. * * @param enterpriseConfig Instance of {@link WifiEnterpriseConfig}. * @return Instance of {@link Builder} to enable chaining of the builder method. + * @throws IllegalArgumentException if configuration CA certificate or + * AltSubjectMatch/DomainSuffixMatch is not set. */ public @NonNull Builder setWpa3EnterpriseConfig( @NonNull WifiEnterpriseConfig enterpriseConfig) { checkNotNull(enterpriseConfig); + if (enterpriseConfig.isInsecure()) { + throw new IllegalArgumentException("Enterprise configuration is insecure"); + } mWpa3EnterpriseConfig = new WifiEnterpriseConfig(enterpriseConfig); return this; } @@ -421,14 +431,18 @@ public final class WifiNetworkSuggestion implements Parcelable { /** * Specifies whether this network is metered. * <p> - * <li>If not set, defaults to false (i.e not metered).</li> + * <li>If not set, defaults to detect automatically.</li> * * @param isMetered {@code true} to indicate that the network is metered, {@code false} - * otherwise. + * for not metered. * @return Instance of {@link Builder} to enable chaining of the builder method. */ public @NonNull Builder setIsMetered(boolean isMetered) { - mIsMetered = isMetered; + if (isMetered) { + mMeteredOverride = WifiConfiguration.METERED_OVERRIDE_METERED; + } else { + mMeteredOverride = WifiConfiguration.METERED_OVERRIDE_NOT_METERED; + } return this; } @@ -541,9 +555,7 @@ public final class WifiNetworkSuggestion implements Parcelable { wifiConfiguration.hiddenSSID = mIsHiddenSSID; wifiConfiguration.priority = mPriority; - wifiConfiguration.meteredOverride = - mIsMetered ? WifiConfiguration.METERED_OVERRIDE_METERED - : WifiConfiguration.METERED_OVERRIDE_NOT_METERED; + wifiConfiguration.meteredOverride = mMeteredOverride; wifiConfiguration.carrierId = mCarrierId; wifiConfiguration.trusted = !mIsNetworkUntrusted; return wifiConfiguration; @@ -572,9 +584,7 @@ public final class WifiNetworkSuggestion implements Parcelable { wifiConfiguration.FQDN = mPasspointConfiguration.getHomeSp().getFqdn(); wifiConfiguration.setPasspointUniqueId(mPasspointConfiguration.getUniqueId()); wifiConfiguration.priority = mPriority; - wifiConfiguration.meteredOverride = - mIsMetered ? WifiConfiguration.METERED_OVERRIDE_METERED - : WifiConfiguration.METERED_OVERRIDE_NONE; + wifiConfiguration.meteredOverride = mMeteredOverride; wifiConfiguration.trusted = !mIsNetworkUntrusted; mPasspointConfiguration.setCarrierId(mCarrierId); mPasspointConfiguration.setMeteredOverride(wifiConfiguration.meteredOverride); diff --git a/wifi/java/android/net/wifi/nl80211/WifiNl80211Manager.java b/wifi/java/android/net/wifi/nl80211/WifiNl80211Manager.java index 3215246a9c1f..4116234c4c8d 100644 --- a/wifi/java/android/net/wifi/nl80211/WifiNl80211Manager.java +++ b/wifi/java/android/net/wifi/nl80211/WifiNl80211Manager.java @@ -1039,11 +1039,11 @@ public class WifiNl80211Manager { * The result depends on the on the country code that has been set. * * @param band as specified by one of the WifiScanner.WIFI_BAND_* constants. - * The following bands are supported {@link @WifiScanner.WifiBandBasic}: - * WifiScanner.WIFI_BAND_24_GHZ - * WifiScanner.WIFI_BAND_5_GHZ - * WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY - * WifiScanner.WIFI_BAND_6_GHZ + * The following bands are supported: + * {@link WifiScanner#WIFI_BAND_24_GHZ}, + * {@link WifiScanner#WIFI_BAND_5_GHZ}, + * {@link WifiScanner#WIFI_BAND_5_GHZ_DFS_ONLY}, + * {@link WifiScanner#WIFI_BAND_6_GHZ} * @return frequencies vector of valid frequencies (MHz), or an empty array for error. * @throws IllegalArgumentException if band is not recognized. */ |