diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-05-07 16:49:25 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-05-07 16:49:25 +0000 |
commit | 83b45d8dee3d3557e5aa6299a9c618d082b3a9d2 (patch) | |
tree | 8700ee7087934294e3597ddd0fbb0b7eec67627f /tests | |
parent | 0234ca3935341d612f6fbfed2cc53a743fee3bcd (diff) | |
parent | 5d540c3dbe22ebd666e5f712a28327d3c7f34a49 (diff) |
Merge changes from topic "radio_mode_change" into pi-dev
* changes:
WifiMetrics: Add metrics for radio mode change
WifiNative: Handle radio mode change callbacks
WifiVendorHal: Add callbacks for radio mode change detection
Diffstat (limited to 'tests')
3 files changed, 329 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index 91f58c451..9b9bce33d 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -286,6 +286,10 @@ public class WifiMetricsTest { private static final int NUM_WPS_OTHER_CONNECTION_FAILURE = 16; private static final int NUM_WPS_SUPPLICANT_FAILURE = 12; private static final int NUM_WPS_CANCELLATION = 11; + private static final int NUM_RADIO_MODE_CHANGE_TO_MCC = 4; + private static final int NUM_RADIO_MODE_CHANGE_TO_SCC = 13; + private static final int NUM_RADIO_MODE_CHANGE_TO_SBS = 19; + private static final int NUM_RADIO_MODE_CHANGE_TO_DBS = 34; private static final long NUM_WATCHDOG_SUCCESS_DURATION_MS = 65; /** Number of notifications per "Connect to Network" notification type. */ @@ -588,6 +592,18 @@ public class WifiMetricsTest { for (int i = 0; i < NUM_PASSPOINT_PROVIDER_UNINSTALL_SUCCESS; i++) { mWifiMetrics.incrementNumPasspointProviderUninstallSuccess(); } + for (int i = 0; i < NUM_RADIO_MODE_CHANGE_TO_MCC; i++) { + mWifiMetrics.incrementNumRadioModeChangeToMcc(); + } + for (int i = 0; i < NUM_RADIO_MODE_CHANGE_TO_SCC; i++) { + mWifiMetrics.incrementNumRadioModeChangeToScc(); + } + for (int i = 0; i < NUM_RADIO_MODE_CHANGE_TO_SBS; i++) { + mWifiMetrics.incrementNumRadioModeChangeToSbs(); + } + for (int i = 0; i < NUM_RADIO_MODE_CHANGE_TO_DBS; i++) { + mWifiMetrics.incrementNumRadioModeChangeToDbs(); + } // increment pno scan metrics for (int i = 0; i < NUM_PNO_SCAN_ATTEMPTS; i++) { @@ -882,6 +898,10 @@ public class WifiMetricsTest { mDecodedProto.numPasspointProviderUninstallSuccess); assertEquals(NUM_PASSPOINT_PROVIDERS_SUCCESSFULLY_CONNECTED, mDecodedProto.numPasspointProvidersSuccessfullyConnected); + assertEquals(NUM_RADIO_MODE_CHANGE_TO_MCC, mDecodedProto.numRadioModeChangeToMcc); + assertEquals(NUM_RADIO_MODE_CHANGE_TO_SCC, mDecodedProto.numRadioModeChangeToScc); + assertEquals(NUM_RADIO_MODE_CHANGE_TO_SBS, mDecodedProto.numRadioModeChangeToSbs); + assertEquals(NUM_RADIO_MODE_CHANGE_TO_DBS, mDecodedProto.numRadioModeChangeToDbs); PnoScanMetrics pno_metrics = mDecodedProto.pnoScanMetrics; assertNotNull(pno_metrics); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java index 13147ea4d..12ef6eccc 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java @@ -25,6 +25,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.inOrder; @@ -39,6 +40,7 @@ import android.net.InterfaceConfiguration; import android.net.wifi.IApInterface; import android.net.wifi.IClientInterface; import android.net.wifi.WifiConfiguration; +import android.net.wifi.WifiScanner; import android.os.INetworkManagementService; import android.os.RemoteException; import android.support.test.filters.SmallTest; @@ -84,6 +86,9 @@ public class WifiNativeInterfaceManagementTest { ArgumentCaptor.forClass(VendorHalDeathEventHandler.class); private ArgumentCaptor<WificondDeathEventHandler> mWificondDeathHandlerCaptor = ArgumentCaptor.forClass(WificondDeathEventHandler.class); + private ArgumentCaptor<WifiNative.VendorHalRadioModeChangeEventHandler> + mWifiVendorHalRadioModeChangeHandlerCaptor = + ArgumentCaptor.forClass(WifiNative.VendorHalRadioModeChangeEventHandler.class); private ArgumentCaptor<SupplicantDeathEventHandler> mSupplicantDeathHandlerCaptor = ArgumentCaptor.forClass(SupplicantDeathEventHandler.class); private ArgumentCaptor<WifiNative.HostapdDeathEventHandler> mHostapdDeathHandlerCaptor = @@ -107,6 +112,8 @@ public class WifiNativeInterfaceManagementTest { // mocks for negative or multi-interface tests. when(mWifiVendorHal.initialize(mWifiVendorHalDeathHandlerCaptor.capture())) .thenReturn(true); + doNothing().when(mWifiVendorHal).registerRadioModeChangeHandler( + mWifiVendorHalRadioModeChangeHandlerCaptor.capture()); when(mWifiVendorHal.isVendorHalSupported()).thenReturn(true); when(mWifiVendorHal.startVendorHal()).thenReturn(true); when(mWifiVendorHal.createStaIface(anyBoolean(), any())).thenReturn(IFACE_NAME_0); @@ -160,6 +167,7 @@ public class WifiNativeInterfaceManagementTest { mInOrder.verify(mWifiVendorHal).initialize(any()); mInOrder.verify(mWificondControl).initialize(any()); + mInOrder.verify(mWifiVendorHal).registerRadioModeChangeHandler(any()); } @After @@ -1140,6 +1148,27 @@ public class WifiNativeInterfaceManagementTest { mInOrder.verify(mNwManagementService).disableIpv6(IFACE_NAME_0); } + /** + * Verifies the handling of radio mode change callbacks. + */ + @Test + public void testRadioModeChangeCallback() { + WifiNative.VendorHalRadioModeChangeEventHandler handler = + mWifiVendorHalRadioModeChangeHandlerCaptor.getValue(); + + handler.onMcc(WifiScanner.WIFI_BAND_5_GHZ); + mInOrder.verify(mWifiMetrics).incrementNumRadioModeChangeToMcc(); + + handler.onScc(WifiScanner.WIFI_BAND_24_GHZ); + mInOrder.verify(mWifiMetrics).incrementNumRadioModeChangeToScc(); + + handler.onSbs(WifiScanner.WIFI_BAND_24_GHZ); + mInOrder.verify(mWifiMetrics).incrementNumRadioModeChangeToSbs(); + + handler.onDbs(); + mInOrder.verify(mWifiMetrics).incrementNumRadioModeChangeToDbs(); + } + private void executeAndValidateSetupClientInterface( boolean existingStaIface, boolean existingApIface, String ifaceName, @Mock WifiNative.InterfaceCallback callback, diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java index 9d20235ad..dcef6e9d4 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java @@ -38,6 +38,7 @@ import static org.mockito.Mockito.reset; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; import android.app.test.MockAnswerUtil.AnswerWithArguments; @@ -75,6 +76,8 @@ 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.hardware.wifi.V1_2.IWifiChipEventCallback.IfaceInfo; +import android.hardware.wifi.V1_2.IWifiChipEventCallback.RadioModeInfo; import android.net.KeepalivePacketData; import android.net.MacAddress; import android.net.apf.ApfCapabilities; @@ -115,6 +118,7 @@ import java.util.Set; public class WifiVendorHalTest { private static final String TEST_IFACE_NAME = "wlan0"; + private static final String TEST_IFACE_NAME_1 = "wlan1"; private static final MacAddress TEST_MAC_ADDRESS = MacAddress.fromString("ee:33:a2:94:10:92"); WifiVendorHal mWifiVendorHal; @@ -146,6 +150,8 @@ public class WifiVendorHalTest { private android.hardware.wifi.V1_2.IWifiChipEventCallback mIWifiChipEventCallbackV12; @Mock private WifiNative.VendorHalDeathEventHandler mVendorHalDeathHandler; + @Mock + private WifiNative.VendorHalRadioModeChangeEventHandler mVendorHalRadioModeChangeHandler; /** * Spy used to return the V1_1 IWifiChip mock object to simulate the 1.1 HAL running on the @@ -2182,6 +2188,280 @@ public class WifiVendorHalTest { assertFalse(mWifiVendorHal.setMacAddress(TEST_IFACE_NAME, TEST_MAC_ADDRESS)); } + /** + * Verifies radio mode change callback to indicate DBS mode. + */ + @Test + public void testRadioModeChangeCallbackToDbsMode() throws Exception { + startHalInStaModeAndRegisterRadioModeChangeCallback(); + + RadioModeInfo radioModeInfo0 = new RadioModeInfo(); + radioModeInfo0.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + RadioModeInfo radioModeInfo1 = new RadioModeInfo(); + radioModeInfo1.bandInfo = WifiScanner.WIFI_BAND_24_GHZ; + + IfaceInfo ifaceInfo0 = new IfaceInfo(); + ifaceInfo0.name = TEST_IFACE_NAME; + ifaceInfo0.channel = 34; + IfaceInfo ifaceInfo1 = new IfaceInfo(); + ifaceInfo1.name = TEST_IFACE_NAME_1; + ifaceInfo1.channel = 1; + + radioModeInfo0.ifaceInfos.add(ifaceInfo0); + radioModeInfo1.ifaceInfos.add(ifaceInfo1); + + ArrayList<RadioModeInfo> radioModeInfos = new ArrayList<>(); + radioModeInfos.add(radioModeInfo0); + radioModeInfos.add(radioModeInfo1); + + mIWifiChipEventCallbackV12.onRadioModeChange(radioModeInfos); + verify(mVendorHalRadioModeChangeHandler).onDbs(); + + verifyNoMoreInteractions(mVendorHalRadioModeChangeHandler); + } + + /** + * Verifies radio mode change callback to indicate SBS mode. + */ + @Test + public void testRadioModeChangeCallbackToSbsMode() throws Exception { + startHalInStaModeAndRegisterRadioModeChangeCallback(); + + RadioModeInfo radioModeInfo0 = new RadioModeInfo(); + radioModeInfo0.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + RadioModeInfo radioModeInfo1 = new RadioModeInfo(); + radioModeInfo1.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + + IfaceInfo ifaceInfo0 = new IfaceInfo(); + ifaceInfo0.name = TEST_IFACE_NAME; + ifaceInfo0.channel = 34; + IfaceInfo ifaceInfo1 = new IfaceInfo(); + ifaceInfo1.name = TEST_IFACE_NAME_1; + ifaceInfo1.channel = 36; + + radioModeInfo0.ifaceInfos.add(ifaceInfo0); + radioModeInfo1.ifaceInfos.add(ifaceInfo1); + + ArrayList<RadioModeInfo> radioModeInfos = new ArrayList<>(); + radioModeInfos.add(radioModeInfo0); + radioModeInfos.add(radioModeInfo1); + + mIWifiChipEventCallbackV12.onRadioModeChange(radioModeInfos); + verify(mVendorHalRadioModeChangeHandler).onSbs(WifiScanner.WIFI_BAND_5_GHZ); + + verifyNoMoreInteractions(mVendorHalRadioModeChangeHandler); + } + + /** + * Verifies radio mode change callback to indicate SCC mode. + */ + @Test + public void testRadioModeChangeCallbackToSccMode() throws Exception { + startHalInStaModeAndRegisterRadioModeChangeCallback(); + + RadioModeInfo radioModeInfo0 = new RadioModeInfo(); + radioModeInfo0.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + RadioModeInfo radioModeInfo1 = new RadioModeInfo(); + radioModeInfo1.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + + IfaceInfo ifaceInfo0 = new IfaceInfo(); + ifaceInfo0.name = TEST_IFACE_NAME; + ifaceInfo0.channel = 34; + IfaceInfo ifaceInfo1 = new IfaceInfo(); + ifaceInfo1.name = TEST_IFACE_NAME_1; + ifaceInfo1.channel = 34; + + radioModeInfo0.ifaceInfos.add(ifaceInfo0); + radioModeInfo0.ifaceInfos.add(ifaceInfo1); + radioModeInfo1.ifaceInfos.add(ifaceInfo0); + radioModeInfo1.ifaceInfos.add(ifaceInfo1); + + ArrayList<RadioModeInfo> radioModeInfos = new ArrayList<>(); + radioModeInfos.add(radioModeInfo0); + radioModeInfos.add(radioModeInfo1); + + mIWifiChipEventCallbackV12.onRadioModeChange(radioModeInfos); + verify(mVendorHalRadioModeChangeHandler).onScc(WifiScanner.WIFI_BAND_5_GHZ); + + verifyNoMoreInteractions(mVendorHalRadioModeChangeHandler); + } + + /** + * Verifies radio mode change callback to indicate MCC mode. + */ + @Test + public void testRadioModeChangeCallbackToMccMode() throws Exception { + startHalInStaModeAndRegisterRadioModeChangeCallback(); + + RadioModeInfo radioModeInfo0 = new RadioModeInfo(); + radioModeInfo0.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + RadioModeInfo radioModeInfo1 = new RadioModeInfo(); + radioModeInfo1.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + + IfaceInfo ifaceInfo0 = new IfaceInfo(); + ifaceInfo0.name = TEST_IFACE_NAME; + ifaceInfo0.channel = 34; + IfaceInfo ifaceInfo1 = new IfaceInfo(); + ifaceInfo1.name = TEST_IFACE_NAME_1; + ifaceInfo1.channel = 36; + + radioModeInfo0.ifaceInfos.add(ifaceInfo0); + radioModeInfo0.ifaceInfos.add(ifaceInfo1); + radioModeInfo1.ifaceInfos.add(ifaceInfo0); + radioModeInfo1.ifaceInfos.add(ifaceInfo1); + + ArrayList<RadioModeInfo> radioModeInfos = new ArrayList<>(); + radioModeInfos.add(radioModeInfo0); + radioModeInfos.add(radioModeInfo1); + + mIWifiChipEventCallbackV12.onRadioModeChange(radioModeInfos); + verify(mVendorHalRadioModeChangeHandler).onMcc(WifiScanner.WIFI_BAND_5_GHZ); + + verifyNoMoreInteractions(mVendorHalRadioModeChangeHandler); + } + + /** + * Verifies radio mode change callback error cases. + */ + @Test + public void testRadioModeChangeCallbackErrorTimeSharingWithDifferentIfacesOnBothRadios() + throws Exception { + startHalInStaModeAndRegisterRadioModeChangeCallback(); + + RadioModeInfo radioModeInfo0 = new RadioModeInfo(); + radioModeInfo0.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + RadioModeInfo radioModeInfo1 = new RadioModeInfo(); + radioModeInfo1.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + + IfaceInfo ifaceInfo0 = new IfaceInfo(); + ifaceInfo0.name = TEST_IFACE_NAME; + ifaceInfo0.channel = 34; + IfaceInfo ifaceInfo1 = new IfaceInfo(); + ifaceInfo1.name = TEST_IFACE_NAME_1; + ifaceInfo1.channel = 34; + + radioModeInfo0.ifaceInfos.add(ifaceInfo0); + radioModeInfo0.ifaceInfos.add(ifaceInfo0); + radioModeInfo1.ifaceInfos.add(ifaceInfo1); + radioModeInfo1.ifaceInfos.add(ifaceInfo1); + + ArrayList<RadioModeInfo> radioModeInfos = new ArrayList<>(); + radioModeInfos.add(radioModeInfo0); + radioModeInfos.add(radioModeInfo1); + + mIWifiChipEventCallbackV12.onRadioModeChange(radioModeInfos); + // Ignored.... + + verifyNoMoreInteractions(mVendorHalRadioModeChangeHandler); + } + + /** + * Verifies radio mode change callback error cases. + */ + @Test + public void testRadioModeChangeCallbackErrorTimeSharingWithDifferentNumberOfIfacesOnBothRadios() + throws Exception { + startHalInStaModeAndRegisterRadioModeChangeCallback(); + + RadioModeInfo radioModeInfo0 = new RadioModeInfo(); + radioModeInfo0.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + RadioModeInfo radioModeInfo1 = new RadioModeInfo(); + radioModeInfo1.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + + IfaceInfo ifaceInfo0 = new IfaceInfo(); + ifaceInfo0.name = TEST_IFACE_NAME; + ifaceInfo0.channel = 34; + IfaceInfo ifaceInfo1 = new IfaceInfo(); + ifaceInfo1.name = TEST_IFACE_NAME_1; + ifaceInfo1.channel = 34; + + radioModeInfo0.ifaceInfos.add(ifaceInfo0); + radioModeInfo1.ifaceInfos.add(ifaceInfo1); + radioModeInfo1.ifaceInfos.add(ifaceInfo1); + + ArrayList<RadioModeInfo> radioModeInfos = new ArrayList<>(); + radioModeInfos.add(radioModeInfo0); + radioModeInfos.add(radioModeInfo1); + + mIWifiChipEventCallbackV12.onRadioModeChange(radioModeInfos); + // Ignored.... + + verifyNoMoreInteractions(mVendorHalRadioModeChangeHandler); + } + + /** + * Verifies radio mode change callback error cases. + */ + @Test + public void testRadioModeChangeCallbackErrorSimultaneousWithSameIfaceOnBothRadios() + throws Exception { + startHalInStaModeAndRegisterRadioModeChangeCallback(); + + RadioModeInfo radioModeInfo0 = new RadioModeInfo(); + radioModeInfo0.bandInfo = WifiScanner.WIFI_BAND_24_GHZ; + RadioModeInfo radioModeInfo1 = new RadioModeInfo(); + radioModeInfo1.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + + IfaceInfo ifaceInfo0 = new IfaceInfo(); + ifaceInfo0.name = TEST_IFACE_NAME; + ifaceInfo0.channel = 34; + + radioModeInfo0.ifaceInfos.add(ifaceInfo0); + radioModeInfo1.ifaceInfos.add(ifaceInfo0); + + ArrayList<RadioModeInfo> radioModeInfos = new ArrayList<>(); + radioModeInfos.add(radioModeInfo0); + radioModeInfos.add(radioModeInfo1); + + mIWifiChipEventCallbackV12.onRadioModeChange(radioModeInfos); + // Ignored.... + + verifyNoMoreInteractions(mVendorHalRadioModeChangeHandler); + } + + /** + * Verifies radio mode change callback error cases. + */ + @Test + public void testRadioModeChangeCallbackErrorTimeSharingWithDifferentBandsOnBothRadios() + throws Exception { + startHalInStaModeAndRegisterRadioModeChangeCallback(); + + RadioModeInfo radioModeInfo0 = new RadioModeInfo(); + radioModeInfo0.bandInfo = WifiScanner.WIFI_BAND_24_GHZ; + RadioModeInfo radioModeInfo1 = new RadioModeInfo(); + radioModeInfo1.bandInfo = WifiScanner.WIFI_BAND_5_GHZ; + + IfaceInfo ifaceInfo0 = new IfaceInfo(); + ifaceInfo0.name = TEST_IFACE_NAME; + ifaceInfo0.channel = 34; + IfaceInfo ifaceInfo1 = new IfaceInfo(); + ifaceInfo1.name = TEST_IFACE_NAME_1; + ifaceInfo1.channel = 36; + + radioModeInfo0.ifaceInfos.add(ifaceInfo0); + radioModeInfo0.ifaceInfos.add(ifaceInfo1); + radioModeInfo1.ifaceInfos.add(ifaceInfo0); + radioModeInfo1.ifaceInfos.add(ifaceInfo1); + + ArrayList<RadioModeInfo> radioModeInfos = new ArrayList<>(); + radioModeInfos.add(radioModeInfo0); + radioModeInfos.add(radioModeInfo1); + + mIWifiChipEventCallbackV12.onRadioModeChange(radioModeInfos); + // Ignored.... + + verifyNoMoreInteractions(mVendorHalRadioModeChangeHandler); + } + + private void startHalInStaModeAndRegisterRadioModeChangeCallback() { + // Expose the 1.2 IWifiChip. + mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper()); + mWifiVendorHal.registerRadioModeChangeHandler(mVendorHalRadioModeChangeHandler); + assertTrue(mWifiVendorHal.startVendorHalSta()); + assertNotNull(mIWifiChipEventCallbackV12); + } + private void testAlertCallbackUsingProvidedCallback(IWifiChipEventCallback chipCallback) throws Exception { when(mIWifiChip.enableDebugErrorAlerts(anyBoolean())).thenReturn(mWifiStatusSuccess); |