summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-03-22 15:16:19 -0700
committerRoshan Pius <rpius@google.com>2017-03-27 10:15:21 -0700
commitcb594dc8e61189be19c56ab03626df045ed90d1a (patch)
treef57a4a27929c4d48ea566a7c669bb4d18963c2c2
parent7adcbd6f7b0baef1e4186376b0b43789303856cf (diff)
WifiNative: Fixing some nits
Remove unnecesary static types defined in SupplicantStaIfaceHal and be consistent with all the other API's in WifiNative. The layer below (i.e WifiVendorHal, SupplicantStaIfaceHal, etc) should convert from WifiNative type to the corrsponding HIDL type. Also, WifiVendorHal can direcly accept a looper in it's constructor instead of passing it a Handler Thread. Bug: 36524196 Test: Manual test & unit tests Change-Id: I90c65f97b0025e6d1416170c18038d4e2064d76f
-rw-r--r--service/java/com/android/server/wifi/SupplicantStaIfaceHal.java89
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java3
-rw-r--r--service/java/com/android/server/wifi/WifiNative.java26
-rw-r--r--service/java/com/android/server/wifi/WifiVendorHal.java10
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java4
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java7
6 files changed, 90 insertions, 49 deletions
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
index 09ce833fb..681cf3a3e 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
@@ -1199,17 +1199,29 @@ public class SupplicantStaIfaceHal {
}
}
- public static final byte RX_FILTER_TYPE_V4_MULTICAST =
- ISupplicantStaIface.RxFilterType.V6_MULTICAST;
- public static final byte RX_FILTER_TYPE_V6_MULTICAST =
- ISupplicantStaIface.RxFilterType.V6_MULTICAST;
/**
* Add an RX filter.
*
- * @param type one of {@link #RX_FILTER_TYPE_V4_MULTICAST} or
- * {@link #RX_FILTER_TYPE_V6_MULTICAST} values.
+ * @param type one of {@link WifiNative#RX_FILTER_TYPE_V4_MULTICAST}
+ * {@link WifiNative#RX_FILTER_TYPE_V6_MULTICAST} values.
* @return true if request is sent successfully, false otherwise.
*/
+ public boolean addRxFilter(int type) {
+ byte halType;
+ switch (type) {
+ case WifiNative.RX_FILTER_TYPE_V4_MULTICAST:
+ halType = ISupplicantStaIface.RxFilterType.V4_MULTICAST;
+ break;
+ case WifiNative.RX_FILTER_TYPE_V6_MULTICAST:
+ halType = ISupplicantStaIface.RxFilterType.V6_MULTICAST;
+ break;
+ default:
+ Log.e(TAG, "Invalid Rx Filter type: " + type);
+ return false;
+ }
+ return addRxFilter(halType);
+ }
+
public boolean addRxFilter(byte type) {
synchronized (mLock) {
final String methodStr = "addRxFilter";
@@ -1227,10 +1239,26 @@ public class SupplicantStaIfaceHal {
/**
* Remove an RX filter.
*
- * @param type one of {@link #RX_FILTER_TYPE_V4_MULTICAST} or
- * {@link #RX_FILTER_TYPE_V6_MULTICAST} values.
+ * @param type one of {@link WifiNative#RX_FILTER_TYPE_V4_MULTICAST}
+ * {@link WifiNative#RX_FILTER_TYPE_V6_MULTICAST} values.
* @return true if request is sent successfully, false otherwise.
*/
+ public boolean removeRxFilter(int type) {
+ byte halType;
+ switch (type) {
+ case WifiNative.RX_FILTER_TYPE_V4_MULTICAST:
+ halType = ISupplicantStaIface.RxFilterType.V4_MULTICAST;
+ break;
+ case WifiNative.RX_FILTER_TYPE_V6_MULTICAST:
+ halType = ISupplicantStaIface.RxFilterType.V6_MULTICAST;
+ break;
+ default:
+ Log.e(TAG, "Invalid Rx Filter type: " + type);
+ return false;
+ }
+ return removeRxFilter(halType);
+ }
+
public boolean removeRxFilter(byte type) {
synchronized (mLock) {
final String methodStr = "removeRxFilter";
@@ -1245,17 +1273,34 @@ public class SupplicantStaIfaceHal {
}
}
- public static final byte BT_COEX_MODE_ENABLED = ISupplicantStaIface.BtCoexistenceMode.ENABLED;
- public static final byte BT_COEX_MODE_DISABLED = ISupplicantStaIface.BtCoexistenceMode.DISABLED;
- public static final byte BT_COEX_MODE_SENSE = ISupplicantStaIface.BtCoexistenceMode.SENSE;
/**
* Set Bt co existense mode.
*
- * @param mode one of the above {@link #BT_COEX_MODE_ENABLED}, {@link #BT_COEX_MODE_DISABLED}
- * or {@link #BT_COEX_MODE_SENSE} values.
+ * @param mode one of the above {@link WifiNative#BLUETOOTH_COEXISTENCE_MODE_DISABLED},
+ * {@link WifiNative#BLUETOOTH_COEXISTENCE_MODE_ENABLED} or
+ * {@link WifiNative#BLUETOOTH_COEXISTENCE_MODE_SENSE}.
* @return true if request is sent successfully, false otherwise.
*/
- public boolean setBtCoexistenceMode(byte mode) {
+ public boolean setBtCoexistenceMode(int mode) {
+ byte halMode;
+ switch (mode) {
+ case WifiNative.BLUETOOTH_COEXISTENCE_MODE_ENABLED:
+ halMode = ISupplicantStaIface.BtCoexistenceMode.ENABLED;
+ break;
+ case WifiNative.BLUETOOTH_COEXISTENCE_MODE_DISABLED:
+ halMode = ISupplicantStaIface.BtCoexistenceMode.DISABLED;
+ break;
+ case WifiNative.BLUETOOTH_COEXISTENCE_MODE_SENSE:
+ halMode = ISupplicantStaIface.BtCoexistenceMode.SENSE;
+ break;
+ default:
+ Log.e(TAG, "Invalid Bt Coex mode: " + mode);
+ return false;
+ }
+ return setBtCoexistenceMode(halMode);
+ }
+
+ private boolean setBtCoexistenceMode(byte mode) {
synchronized (mLock) {
final String methodStr = "setBtCoexistenceMode";
if (!checkSupplicantStaIfaceAndLogFailure(methodStr)) return false;
@@ -1507,19 +1552,17 @@ public class SupplicantStaIfaceHal {
}
}
- public static final int LOG_LEVEL_EXCESSIVE = ISupplicant.DebugLevel.EXCESSIVE;
- public static final int LOG_LEVEL_MSGDUMP = ISupplicant.DebugLevel.MSGDUMP;
- public static final int LOG_LEVEL_DEBUG = ISupplicant.DebugLevel.DEBUG;
- public static final int LOG_LEVEL_INFO = ISupplicant.DebugLevel.INFO;
- public static final int LOG_LEVEL_WARNING = ISupplicant.DebugLevel.WARNING;
- public static final int LOG_LEVEL_ERROR = ISupplicant.DebugLevel.ERROR;
/**
* Set the debug log level for wpa_supplicant
- * @param level One of the above {@link #LOG_LEVEL_EXCESSIVE} - {@link #LOG_LEVEL_ERROR} value.
+ *
+ * @param turnOnVerbose Whether to turn on verbose logging or not.
* @return true if request is sent successfully, false otherwise.
*/
- public boolean setLogLevel(int level) {
- return setDebugParams(level, false, false);
+ public boolean setLogLevel(boolean turnOnVerbose) {
+ int logLevel = turnOnVerbose
+ ? ISupplicant.DebugLevel.DEBUG
+ : ISupplicant.DebugLevel.INFO;
+ return setDebugParams(logLevel, false, false);
}
/** See ISupplicant.hal for documentation */
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index 6fee22c1a..1ecf88260 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -152,7 +152,8 @@ public class WifiInjector {
// Modules interacting with Native.
mWifiMonitor = new WifiMonitor(this);
mHalDeviceManager = new HalDeviceManager();
- mWifiVendorHal = new WifiVendorHal(mHalDeviceManager, mWifiStateMachineHandlerThread);
+ mWifiVendorHal =
+ new WifiVendorHal(mHalDeviceManager, mWifiStateMachineHandlerThread.getLooper());
mSupplicantStaIfaceHal = new SupplicantStaIfaceHal(mContext, mWifiMonitor);
mWificondControl = new WificondControl(this, mWifiMonitor);
mWifiNative = new WifiNative(SystemProperties.get("wifi.interface", "wlan0"),
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index 1cc923343..f6a7e7c39 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -272,10 +272,7 @@ public class WifiNative {
* @param turnOnVerbose Whether to turn on verbose logging or not.
*/
public void setSupplicantLogLevel(boolean turnOnVerbose) {
- int logLevel = turnOnVerbose
- ? SupplicantStaIfaceHal.LOG_LEVEL_DEBUG
- : SupplicantStaIfaceHal.LOG_LEVEL_INFO;
- mSupplicantStaIfaceHal.setLogLevel(logLevel);
+ mSupplicantStaIfaceHal.setLogLevel(turnOnVerbose);
}
/**
@@ -314,6 +311,8 @@ public class WifiNative {
return mSupplicantStaIfaceHal.getMacAddress();
}
+ public static final int RX_FILTER_TYPE_V4_MULTICAST = 0;
+ public static final int RX_FILTER_TYPE_V6_MULTICAST = 1;
/**
* Start filtering out Multicast V4 packets
* @return {@code true} if the operation succeeded, {@code false} otherwise
@@ -341,7 +340,7 @@ public class WifiNative {
public boolean startFilteringMulticastV4Packets() {
return mSupplicantStaIfaceHal.stopRxFilter()
&& mSupplicantStaIfaceHal.removeRxFilter(
- SupplicantStaIfaceHal.RX_FILTER_TYPE_V4_MULTICAST)
+ RX_FILTER_TYPE_V4_MULTICAST)
&& mSupplicantStaIfaceHal.startRxFilter();
}
@@ -352,7 +351,7 @@ public class WifiNative {
public boolean stopFilteringMulticastV4Packets() {
return mSupplicantStaIfaceHal.stopRxFilter()
&& mSupplicantStaIfaceHal.addRxFilter(
- SupplicantStaIfaceHal.RX_FILTER_TYPE_V4_MULTICAST)
+ RX_FILTER_TYPE_V4_MULTICAST)
&& mSupplicantStaIfaceHal.startRxFilter();
}
@@ -363,7 +362,7 @@ public class WifiNative {
public boolean startFilteringMulticastV6Packets() {
return mSupplicantStaIfaceHal.stopRxFilter()
&& mSupplicantStaIfaceHal.removeRxFilter(
- SupplicantStaIfaceHal.RX_FILTER_TYPE_V6_MULTICAST)
+ RX_FILTER_TYPE_V6_MULTICAST)
&& mSupplicantStaIfaceHal.startRxFilter();
}
@@ -374,16 +373,13 @@ public class WifiNative {
public boolean stopFilteringMulticastV6Packets() {
return mSupplicantStaIfaceHal.stopRxFilter()
&& mSupplicantStaIfaceHal.addRxFilter(
- SupplicantStaIfaceHal.RX_FILTER_TYPE_V6_MULTICAST)
+ RX_FILTER_TYPE_V6_MULTICAST)
&& mSupplicantStaIfaceHal.startRxFilter();
}
- public static final int BLUETOOTH_COEXISTENCE_MODE_ENABLED =
- SupplicantStaIfaceHal.BT_COEX_MODE_ENABLED;
- public static final int BLUETOOTH_COEXISTENCE_MODE_DISABLED =
- SupplicantStaIfaceHal.BT_COEX_MODE_DISABLED;
- public static final int BLUETOOTH_COEXISTENCE_MODE_SENSE =
- SupplicantStaIfaceHal.BT_COEX_MODE_SENSE;
+ public static final int BLUETOOTH_COEXISTENCE_MODE_ENABLED = 0;
+ public static final int BLUETOOTH_COEXISTENCE_MODE_DISABLED = 1;
+ public static final int BLUETOOTH_COEXISTENCE_MODE_SENSE = 2;
/**
* Sets the bluetooth coexistence mode.
*
@@ -393,7 +389,7 @@ public class WifiNative {
* @return Whether the mode was successfully set.
*/
public boolean setBluetoothCoexistenceMode(int mode) {
- return mSupplicantStaIfaceHal.setBtCoexistenceMode((byte) mode);
+ return mSupplicantStaIfaceHal.setBtCoexistenceMode(mode);
}
/**
diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java
index 8fb3bc3a0..8646b613b 100644
--- a/service/java/com/android/server/wifi/WifiVendorHal.java
+++ b/service/java/com/android/server/wifi/WifiVendorHal.java
@@ -65,6 +65,7 @@ import android.net.wifi.WifiScanner;
import android.net.wifi.WifiSsid;
import android.net.wifi.WifiWakeReasonAndCounts;
import android.os.HandlerThread;
+import android.os.Looper;
import android.os.RemoteException;
import android.util.MutableBoolean;
import android.util.MutableInt;
@@ -204,14 +205,14 @@ public class WifiVendorHal {
private IWifiRttController mIWifiRttController;
private final HalDeviceManager mHalDeviceManager;
private final HalDeviceManagerStatusListener mHalDeviceManagerStatusCallbacks;
- private final HandlerThread mWifiStateMachineHandlerThread;
+ private final Looper mLooper;
private final IWifiStaIfaceEventCallback mIWifiStaIfaceEventCallback;
private final IWifiChipEventCallback mIWifiChipEventCallback;
public WifiVendorHal(HalDeviceManager halDeviceManager,
- HandlerThread wifiStateMachineHandlerThread) {
+ Looper looper) {
mHalDeviceManager = halDeviceManager;
- mWifiStateMachineHandlerThread = wifiStateMachineHandlerThread;
+ mLooper = looper;
mHalDeviceManagerStatusCallbacks = new HalDeviceManagerStatusListener();
mIWifiStaIfaceEventCallback = new StaIfaceEventCallback();
mIWifiChipEventCallback = new ChipEventCallback();
@@ -237,8 +238,7 @@ public class WifiVendorHal {
public boolean initialize(WifiNative.VendorHalDeathEventHandler handler) {
synchronized (sLock) {
mHalDeviceManager.initialize();
- mHalDeviceManager.registerStatusListener(
- mHalDeviceManagerStatusCallbacks, mWifiStateMachineHandlerThread.getLooper());
+ mHalDeviceManager.registerStatusListener(mHalDeviceManagerStatusCallbacks, mLooper);
mDeathEventHandler = handler;
return true;
}
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
index 8a2ceaf08..f2cb90e63 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
@@ -1166,12 +1166,12 @@ public class SupplicantStaIfaceHalTest {
.thenReturn(mStatusSuccess);
// Fail before initialization is performed.
- assertFalse(mDut.setLogLevel(SupplicantStaIfaceHal.LOG_LEVEL_DEBUG));
+ assertFalse(mDut.setLogLevel(true));
executeAndValidateInitializationSequence();
// This should work.
- assertTrue(mDut.setLogLevel(SupplicantStaIfaceHal.LOG_LEVEL_DEBUG));
+ assertTrue(mDut.setLogLevel(true));
verify(mISupplicantMock)
.setDebugParams(eq(ISupplicant.DebugLevel.DEBUG), eq(false), eq(false));
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
index 15fc55f66..4e5594bcc 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
@@ -55,7 +55,7 @@ import android.net.wifi.WifiManager;
import android.net.wifi.WifiScanner;
import android.net.wifi.WifiSsid;
import android.net.wifi.WifiWakeReasonAndCounts;
-import android.os.HandlerThread;
+import android.os.test.TestLooper;
import android.os.RemoteException;
import android.util.Pair;
@@ -90,7 +90,7 @@ public class WifiVendorHalTest {
@Mock
private HalDeviceManager mHalDeviceManager;
@Mock
- private HandlerThread mWifiStateMachineHandlerThread;
+ private TestLooper mLooper;
@Mock
private WifiVendorHal.HalDeviceManagerStatusListener mHalDeviceManagerStatusCallbacks;
@Mock
@@ -120,6 +120,7 @@ public class WifiVendorHalTest {
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mWifiLog = new FakeWifiLog();
+ mLooper = new TestLooper();
mWifiStatusSuccess = new WifiStatus();
mWifiStatusSuccess.code = WifiStatusCode.SUCCESS;
mWifiStatusFailure = new WifiStatus();
@@ -171,7 +172,7 @@ public class WifiVendorHalTest {
}));
// Create the vendor HAL object under test.
- mWifiVendorHal = new WifiVendorHal(mHalDeviceManager, mWifiStateMachineHandlerThread);
+ mWifiVendorHal = new WifiVendorHal(mHalDeviceManager, mLooper.getLooper());
// Initialize the vendor HAL to capture the registered callback.
mWifiVendorHal.initialize(mVendorHalDeathHandler);