diff options
author | Les Lee <lesl@google.com> | 2020-07-14 14:29:14 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-07-14 14:29:14 +0000 |
commit | c794cd4c5fa839fbd7b0914a57da37f14ce39c2f (patch) | |
tree | 0f210b1766b4c405527f3e28338466265e282036 /service | |
parent | 000ad45722c73f345de77ff43973b2ed811b90e1 (diff) | |
parent | 857b2f8fddb9b30f353b0543939df1bd12f9f641 (diff) |
Merge "wifi: bypass randomized Mac set failure when hal not support" into rvc-dev
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 |