diff options
author | Roshan Pius <rpius@google.com> | 2017-03-22 15:16:19 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2017-03-28 10:10:26 -0700 |
commit | f2e03411f137f55940a8f3592e96a272585bd7dd (patch) | |
tree | 3c8a8ba799b9e8db1ed7cd1592e1cd0bee0560e2 /service | |
parent | 45a984619e338090981499e4823e0177649e3c28 (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
Merged-In: I90c65f97b0025e6d1416170c18038d4e2064d76f
Diffstat (limited to 'service')
4 files changed, 84 insertions, 44 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 9cd2c3842..5e448ad07 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; } |