diff options
author | Roshan Pius <rpius@google.com> | 2017-03-28 05:35:19 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-28 05:35:19 +0000 |
commit | 003d0201a3f9864da30fc82ce35577f0ce365022 (patch) | |
tree | 6750bebbca86bb86d4e8eeee021a3a5d13bf2e2d | |
parent | 666d0c35b9a3d31bcf3978b69159560068f964ed (diff) | |
parent | 96455476082f5680fd0f66eb5a87cd6f2fde1a70 (diff) |
Merge changes from topic 'unused_code'
am: 9645547608
Change-Id: Iad2e7bed5cd04ed335971f5f1b5cf6d036d3f24f
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); |