diff options
author | lesl <lesl@google.com> | 2020-07-09 01:08:16 +0800 |
---|---|---|
committer | lesl <lesl@google.com> | 2020-07-10 08:49:32 +0800 |
commit | 857b2f8fddb9b30f353b0543939df1bd12f9f641 (patch) | |
tree | 1b3da17a9f9d8c95ce8622ec56c87c5c81da6adc /service | |
parent | d55cade0f9240ba70fd0fc6ed5e7458375740646 (diff) |
wifi: bypass randomized Mac set failure when hal not support
There are two use cases on SAP setMacaddress.
1. Mac randomization
a. HAl not support - get pass
b. Hal support - report error - generic error (Behavior changed in this
commit)
2. Customized bssid - it should get failure since it is unsupported.
a. Hal support - generic error
b. Hal not support - unsupported configuration error indication.
Bug: 160550985
Bug: 160550184
Test: atest FrameworksWifiTest
Test: R-GSI + Q-vendor : Hotspot works normally.
Merged-In: I530f41cd072ad0061e65fea9daf47c6b28113a77
Change-Id: I530f41cd072ad0061e65fea9daf47c6b28113a77
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/SoftApManager.java | 14 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiNative.java | 9 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiVendorHal.java | 22 |
3 files changed, 41 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java index ffbb388cc..9ef52e796 100644 --- a/service/java/com/android/server/wifi/SoftApManager.java +++ b/service/java/com/android/server/wifi/SoftApManager.java @@ -348,10 +348,16 @@ public class SoftApManager implements ActiveModeManager { return SUCCESS; } - // We're configuring a random/custom MAC address. In this case, driver support is mandatory. - if (!mWifiNative.setMacAddress(mApInterfaceName, mac)) { - Log.e(TAG, "failed to set explicitly requested MAC address"); - return ERROR_GENERIC; + + if (mWifiNative.isSetMacAddressSupported(mApInterfaceName)) { + if (!mWifiNative.setMacAddress(mApInterfaceName, mac)) { + Log.e(TAG, "failed to set explicitly requested MAC address"); + return ERROR_GENERIC; + } + } else if (!mIsRandomizeBssid) { + // If hardware does not support MAC address setter, + // only report the error for non randomization. + return ERROR_UNSUPPORTED_CONFIGURATION; } return SUCCESS; } diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 39d0fcc84..cf362d6a8 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -1788,6 +1788,15 @@ public class WifiNative { } /** + * Returns true if Hal version supports setMacAddress, otherwise false. + * + * @param interfaceName Name of the interface + */ + public boolean isSetMacAddressSupported(@NonNull String interfaceName) { + return mWifiVendorHal.isSetMacAddressSupported(interfaceName); + } + + /** * Get the factory MAC address of the given interface * @param interfaceName Name of the interface. * @return factory MAC address, or null on a failed call or if feature is unavailable. diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java index ed6ac7fdd..fd90c35df 100644 --- a/service/java/com/android/server/wifi/WifiVendorHal.java +++ b/service/java/com/android/server/wifi/WifiVendorHal.java @@ -1332,6 +1332,28 @@ public class WifiVendorHal { } /** + * Returns true if Hal version supports setMacAddress, otherwise false. + * + * @param ifaceName Name of the interface + */ + public boolean isSetMacAddressSupported(@NonNull String ifaceName) { + synchronized (sLock) { + android.hardware.wifi.V1_2.IWifiStaIface sta12 = + getWifiStaIfaceForV1_2Mockable(ifaceName); + if (sta12 != null) { + return true; + } + + android.hardware.wifi.V1_4.IWifiApIface ap14 = + getWifiApIfaceForV1_4Mockable(ifaceName); + if (ap14 != null) { + return true; + } + } + return false; + } + + /** * Get factory MAC address of the given interface * * @param ifaceName Name of the interface |