From 7e22846566a7526782a8c19d5d7cf8257f6d55ed Mon Sep 17 00:00:00 2001 From: Les Lee Date: Mon, 10 Mar 2025 17:59:53 +0000 Subject: WiFi: Force 11be to false when 11ax is false. The 11be hotspot requires 11ax due to a dependency. When 11ax is false, but 11be is configured, it can cause a hostapd error (e.g., b/378048737). To prevent this, especially when OEMs might retain invalid SoftApConfigurations in Settings, we should implement the following protection: Protection for Android 16 and later. Automatically force 11be to false when 11ax is false. Trigger an error for invalid configurations, preventing changes in the Settings (this applies only when callers bypass the SDK API, such as through reflection). Flag: EXEMPT minor fix Bug: 401184848 Test: atest -c FrameworksWifiTests Test: atest -c FrameworksWifiApiTests Change-Id: I5b4ebc2a3dd82c02bb0f742815e3b13f40444c4c --- .../java/android/net/wifi/SoftApConfiguration.java | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'framework/java') diff --git a/framework/java/android/net/wifi/SoftApConfiguration.java b/framework/java/android/net/wifi/SoftApConfiguration.java index 92efcf72cb..086c816b71 100644 --- a/framework/java/android/net/wifi/SoftApConfiguration.java +++ b/framework/java/android/net/wifi/SoftApConfiguration.java @@ -1426,6 +1426,45 @@ public final class SoftApConfiguration implements Parcelable { mIsClientIsolationEnabled = other.mIsClientIsolationEnabled; } + /** + * Builds the {@link SoftApConfiguration} without any check. + * + * @return A new {@link SoftApConfiguration}, as configured by previous method calls. + * + * @hide + */ + @VisibleForTesting + @NonNull + public SoftApConfiguration buildWithoutCheck() { + return new SoftApConfiguration( + mWifiSsid, + mBssid, + mPassphrase, + mHiddenSsid, + mChannels, + mSecurityType, + mMaxNumberOfClients, + mAutoShutdownEnabled, + mShutdownTimeoutMillis, + mClientControlByUser, + mBlockedClientList, + mAllowedClientList, + mMacRandomizationSetting, + mBridgedModeOpportunisticShutdownEnabled, + mIeee80211axEnabled, + mIeee80211beEnabled, + mIsUserConfiguration, + mBridgedModeOpportunisticShutdownTimeoutMillis, + mVendorElements, + mPersistentRandomizedMacAddress, + mAllowedAcsChannels2g, + mAllowedAcsChannels5g, + mAllowedAcsChannels6g, + mMaxChannelBandwidth, + mVendorData, + mIsClientIsolationEnabled); + } + /** * Builds the {@link SoftApConfiguration}. * @@ -1451,6 +1490,11 @@ public final class SoftApConfiguration implements Parcelable { REMOVE_ZERO_FOR_TIMEOUT_SETTING) && mShutdownTimeoutMillis == DEFAULT_TIMEOUT) { mShutdownTimeoutMillis = 0; // Use 0 for legacy app. } + + if (SdkLevel.isAtLeastB() && !mIeee80211axEnabled) { + // Force 11BE to false since 11ax has dependency with 11AX. + mIeee80211beEnabled = false; + } return new SoftApConfiguration( mWifiSsid, mBssid, -- cgit v1.2.3-59-g8ed1b