summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorJong Wook Kim <jongwook@google.com>2018-03-16 16:19:34 -0700
committermukesh agrawal <quiche@google.com>2018-03-30 14:07:48 -0700
commit1c7f0d2c83318cdd1c127a083362e91765c0d941 (patch)
tree60bdda8edc06bd6e98766289b01a4b6ffa955339 /service
parent9adae7cd853e952b4528d6faa874556772ba3b4d (diff)
Move setMacAddress from wifiCond to vendor HAL
To dynamically set MAC address, use Vendor HAL instead of wificond to give vendors flexibility of implementing their own versions of setMacAddress. Bug: 74347653 Test: Unittest Test: Manual Test Change-Id: I5dbcf3dfd7190e0cd9b36b1b66e8aaf3fe5f5435
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiNative.java2
-rw-r--r--service/java/com/android/server/wifi/WifiVendorHal.java40
2 files changed, 41 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index 5d838b0fd..18992926c 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -1236,7 +1236,7 @@ public class WifiNative {
*/
public boolean setMacAddress(String interfaceName, MacAddress mac) {
// TODO(b/72459123): Suppress interface down/up events from this call
- return mWificondControl.setMacAddress(interfaceName, mac);
+ return mWifiVendorHal.setMacAddress(interfaceName, mac);
}
/********************************************************
diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java
index f90c49a05..36060fa55 100644
--- a/service/java/com/android/server/wifi/WifiVendorHal.java
+++ b/service/java/com/android/server/wifi/WifiVendorHal.java
@@ -54,6 +54,7 @@ import android.hardware.wifi.V1_0.WifiDebugTxPacketFateReport;
import android.hardware.wifi.V1_0.WifiInformationElement;
import android.hardware.wifi.V1_0.WifiStatus;
import android.hardware.wifi.V1_0.WifiStatusCode;
+import android.net.MacAddress;
import android.net.apf.ApfCapabilities;
import android.net.wifi.RttManager;
import android.net.wifi.RttManager.ResponderConfig;
@@ -1654,6 +1655,30 @@ public class WifiVendorHal {
}
/**
+ * Set Mac address on the given interface
+ *
+ * @param ifaceName Name of the interface
+ * @param mac MAC address to change into
+ * @return true for success
+ */
+ public boolean setMacAddress(@NonNull String ifaceName, @NonNull MacAddress mac) {
+ byte[] macByteArray = mac.toByteArray();
+ synchronized (sLock) {
+ try {
+ android.hardware.wifi.V1_2.IWifiStaIface ifaceV12 =
+ getWifiStaIfaceForV1_2Mockable(ifaceName);
+ if (ifaceV12 == null) return boolResult(false);
+ WifiStatus status = ifaceV12.setMacAddress(macByteArray);
+ if (!ok(status)) return false;
+ return true;
+ } catch (RemoteException e) {
+ handleRemoteException(e);
+ return false;
+ }
+ }
+ }
+
+ /**
* Get the APF (Android Packet Filter) capabilities of the device
*
* @param ifaceName Name of the interface.
@@ -2544,6 +2569,21 @@ public class WifiVendorHal {
return android.hardware.wifi.V1_2.IWifiChip.castFrom(mIWifiChip);
}
+ /**
+ * Method to mock out the V1_2 IWifiStaIface retrieval in unit tests.
+ *
+ * @param ifaceName Name of the interface
+ * @return 1.2 IWifiStaIface object if the device is running the 1.2 wifi hal service, null
+ * otherwise.
+ */
+ protected android.hardware.wifi.V1_2.IWifiStaIface getWifiStaIfaceForV1_2Mockable(
+ @NonNull String ifaceName) {
+ IWifiStaIface iface = getStaIface(ifaceName);
+ if (iface == null) return null;
+ return android.hardware.wifi.V1_2.IWifiStaIface.castFrom(iface);
+ }
+
+
private int frameworkToHalTxPowerScenario(int scenario) {
switch (scenario) {
case WifiNative.TX_POWER_SCENARIO_VOICE_CALL: