diff options
4 files changed, 98 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index 5bb23b060..469c12ead 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -1513,6 +1513,38 @@ public class WifiMetrics { } /** + * Increment number of times we detected a radio mode change to MCC. + */ + public void incrementNumRadioModeChangeToMcc() { + synchronized (mLock) { + } + } + + /** + * Increment number of times we detected a radio mode change to SCC. + */ + public void incrementNumRadioModeChangeToScc() { + synchronized (mLock) { + } + } + + /** + * Increment number of times we detected a radio mode change to SBS. + */ + public void incrementNumRadioModeChangeToSbs() { + synchronized (mLock) { + } + } + + /** + * Increment number of times we detected a radio mode change to DBS. + */ + public void incrementNumRadioModeChangeToDbs() { + synchronized (mLock) { + } + } + + /** * Increment N-Way network selection decision histograms: * Counts the size of various sets of scanDetails within a scan, and increment the occurrence * of that size for the associated histogram. There are ten histograms generated for each diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 0be2b199d..0f785873b 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -614,6 +614,41 @@ public class WifiNative { } } + /** + * Radio mode change handler for the Vendor HAL daemon. + */ + private class VendorHalRadioModeChangeHandlerInternal + implements VendorHalRadioModeChangeEventHandler { + @Override + public void onMcc(int band) { + synchronized (mLock) { + Log.i(TAG, "Device is in MCC mode now"); + mWifiMetrics.incrementNumRadioModeChangeToMcc(); + } + } + @Override + public void onScc(int band) { + synchronized (mLock) { + Log.i(TAG, "Device is in SCC mode now"); + mWifiMetrics.incrementNumRadioModeChangeToScc(); + } + } + @Override + public void onSbs(int band) { + synchronized (mLock) { + Log.i(TAG, "Device is in SBS mode now"); + mWifiMetrics.incrementNumRadioModeChangeToSbs(); + } + } + @Override + public void onDbs() { + synchronized (mLock) { + Log.i(TAG, "Device is in DBS mode now"); + mWifiMetrics.incrementNumRadioModeChangeToDbs(); + } + } + } + // For devices that don't support the vendor HAL, we will not support any concurrency. // So simulate the HalDeviceManager behavior by triggering the destroy listener for // any active interface. @@ -720,6 +755,8 @@ public class WifiNative { Log.e(TAG, "Failed to initialize wificond"); return false; } + mWifiVendorHal.registerRadioModeChangeHandler( + new VendorHalRadioModeChangeHandlerInternal()); return true; } } diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java index 8dd4509f6..08d03d7de 100644 --- a/service/java/com/android/server/wifi/WifiVendorHal.java +++ b/service/java/com/android/server/wifi/WifiVendorHal.java @@ -2991,10 +2991,8 @@ public class WifiVendorHal { return; } if (radioModeInfo0.bandInfo != radioModeInfo1.bandInfo) { - mLog.i("Device is in DBS mode now"); handler.onDbs(); } else { - mLog.i("Device is in SBS mode now"); handler.onSbs(radioModeInfo0.bandInfo); } // 2 ifaces time sharing on 2 radios. @@ -3012,10 +3010,8 @@ public class WifiVendorHal { IfaceInfo ifaceInfo0 = radioModeInfo0.ifaceInfos.get(0); IfaceInfo ifaceInfo1 = radioModeInfo0.ifaceInfos.get(1); if (ifaceInfo0.channel != ifaceInfo1.channel) { - mLog.i("Device is in MCC mode now"); handler.onMcc(radioModeInfo0.bandInfo); } else { - mLog.i("Device is in SCC mode now"); handler.onScc(radioModeInfo0.bandInfo); } } 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, |