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 /service | |
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 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiMetrics.java | 44 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiNative.java | 76 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiVendorHal.java | 97 |
3 files changed, 213 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..93dec11eb 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -1513,6 +1513,42 @@ public class WifiMetrics { } /** + * Increment number of times we detected a radio mode change to MCC. + */ + public void incrementNumRadioModeChangeToMcc() { + synchronized (mLock) { + mWifiLogProto.numRadioModeChangeToMcc++; + } + } + + /** + * Increment number of times we detected a radio mode change to SCC. + */ + public void incrementNumRadioModeChangeToScc() { + synchronized (mLock) { + mWifiLogProto.numRadioModeChangeToScc++; + } + } + + /** + * Increment number of times we detected a radio mode change to SBS. + */ + public void incrementNumRadioModeChangeToSbs() { + synchronized (mLock) { + mWifiLogProto.numRadioModeChangeToSbs++; + } + } + + /** + * Increment number of times we detected a radio mode change to DBS. + */ + public void incrementNumRadioModeChangeToDbs() { + synchronized (mLock) { + mWifiLogProto.numRadioModeChangeToDbs++; + } + } + + /** * 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 @@ -1950,6 +1986,14 @@ public class WifiMetrics { + mWifiLogProto.numPasspointProviderUninstallSuccess); pw.println("mWifiLogProto.numPasspointProvidersSuccessfullyConnected=" + mWifiLogProto.numPasspointProvidersSuccessfullyConnected); + pw.println("mWifiLogProto.numRadioModeChangeToMcc=" + + mWifiLogProto.numRadioModeChangeToMcc); + pw.println("mWifiLogProto.numRadioModeChangeToScc=" + + mWifiLogProto.numRadioModeChangeToScc); + pw.println("mWifiLogProto.numRadioModeChangeToSbs=" + + mWifiLogProto.numRadioModeChangeToSbs); + pw.println("mWifiLogProto.numRadioModeChangeToDbs=" + + mWifiLogProto.numRadioModeChangeToDbs); pw.println("mTotalSsidsInScanHistogram:" + mTotalSsidsInScanHistogram.toString()); pw.println("mTotalBssidsInScanHistogram:" diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 8a76c4d3b..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; } } @@ -1881,6 +1918,45 @@ public class WifiNative { } /** + * Callback to notify when vendor HAL detects that a change in radio mode. + */ + public interface VendorHalRadioModeChangeEventHandler { + /** + * Invoked when the vendor HAL detects a change to MCC mode. + * MCC (Multi channel concurrency) = Multiple interfaces are active on the same band, + * different channels, same radios. + * + * @param band Band on which MCC is detected (specified by one of the + * WifiScanner.WIFI_BAND_* constants) + */ + void onMcc(int band); + /** + * Invoked when the vendor HAL detects a change to SCC mode. + * SCC (Single channel concurrency) = Multiple interfaces are active on the same band, same + * channels, same radios. + * + * @param band Band on which SCC is detected (specified by one of the + * WifiScanner.WIFI_BAND_* constants) + */ + void onScc(int band); + /** + * Invoked when the vendor HAL detects a change to SBS mode. + * SBS (Single Band Simultaneous) = Multiple interfaces are active on the same band, + * different channels, different radios. + * + * @param band Band on which SBS is detected (specified by one of the + * WifiScanner.WIFI_BAND_* constants) + */ + void onSbs(int band); + /** + * Invoked when the vendor HAL detects a change to DBS mode. + * DBS (Dual Band Simultaneous) = Multiple interfaces are active on the different bands, + * different channels, different radios. + */ + void onDbs(); + } + + /** * Tests whether the HAL is running or not */ public boolean isHalStarted() { diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java index 16a279833..08d03d7de 100644 --- a/service/java/com/android/server/wifi/WifiVendorHal.java +++ b/service/java/com/android/server/wifi/WifiVendorHal.java @@ -85,7 +85,9 @@ import libcore.util.NonNull; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Set; +import java.util.stream.Collectors; /** * Vendor HAL via HIDL @@ -302,6 +304,20 @@ public class WifiVendorHal { } } + private WifiNative.VendorHalRadioModeChangeEventHandler mRadioModeChangeEventHandler; + + /** + * Register to listen for radio mode change events from the HAL. + * + * @param handler Handler to notify when the vendor HAL detects a radio mode change. + */ + public void registerRadioModeChangeHandler( + WifiNative.VendorHalRadioModeChangeEventHandler handler) { + synchronized (sLock) { + mRadioModeChangeEventHandler = handler; + } + } + /** * Returns whether the vendor HAL is supported on this device or not. */ @@ -2920,12 +2936,85 @@ public class WifiVendorHal { mIWifiChipEventCallback.onDebugErrorAlert(errorCode, debugData); } + private boolean areSameIfaceNames(List<IfaceInfo> ifaceList1, List<IfaceInfo> ifaceList2) { + List<String> ifaceNamesList1 = ifaceList1 + .stream() + .map(i -> i.name) + .collect(Collectors.toList()); + List<String> ifaceNamesList2 = ifaceList2 + .stream() + .map(i -> i.name) + .collect(Collectors.toList()); + return ifaceNamesList1.containsAll(ifaceNamesList2); + } + + private boolean areSameIfaces(List<IfaceInfo> ifaceList1, List<IfaceInfo> ifaceList2) { + return ifaceList1.containsAll(ifaceList2); + } + @Override - public void onRadioModeChange( - ArrayList<android.hardware.wifi.V1_2.IWifiChipEventCallback.RadioModeInfo> - radioModeInfoList) { - // Need to handle this callback. + public void onRadioModeChange(ArrayList<RadioModeInfo> radioModeInfoList) { mVerboseLog.d("onRadioModeChange " + radioModeInfoList); + WifiNative.VendorHalRadioModeChangeEventHandler handler; + synchronized (sLock) { + if (mRadioModeChangeEventHandler == null || radioModeInfoList == null) return; + handler = mRadioModeChangeEventHandler; + } + // Should only contain 1 or 2 radio infos. + if (radioModeInfoList.size() == 0 || radioModeInfoList.size() > 2) { + mLog.e("Unexpected number of radio info in list " + radioModeInfoList.size()); + return; + } + // Not concurrency scenario, uninteresting... + if (radioModeInfoList.size() == 1) return; + + RadioModeInfo radioModeInfo0 = radioModeInfoList.get(0); + RadioModeInfo radioModeInfo1 = radioModeInfoList.get(1); + // Number of ifaces on each radio should be equal. + if (radioModeInfo0.ifaceInfos.size() != radioModeInfo1.ifaceInfos.size()) { + mLog.e("Unexpected number of iface info in list " + + radioModeInfo0.ifaceInfos.size() + ", " + + radioModeInfo1.ifaceInfos.size()); + return; + } + int numIfacesOnEachRadio = radioModeInfo0.ifaceInfos.size(); + // Only 1 or 2 ifaces should be present on each radio. + if (numIfacesOnEachRadio == 0 || numIfacesOnEachRadio > 2) { + mLog.e("Unexpected number of iface info in list " + numIfacesOnEachRadio); + return; + } + // 2 ifaces simultaneous on 2 radios. + if (numIfacesOnEachRadio == 1) { + // Iface on radio0 should be different from the iface on radio1 for DBS & SBS. + if (areSameIfaceNames(radioModeInfo0.ifaceInfos, radioModeInfo1.ifaceInfos)) { + mLog.e("Unexpected for both radio infos to have same iface"); + return; + } + if (radioModeInfo0.bandInfo != radioModeInfo1.bandInfo) { + handler.onDbs(); + } else { + handler.onSbs(radioModeInfo0.bandInfo); + } + // 2 ifaces time sharing on 2 radios. + } else { + // Ifaces on radio0 & radio1 should be the same for MCC & SCC. + if (!areSameIfaces(radioModeInfo0.ifaceInfos, radioModeInfo1.ifaceInfos)) { + mLog.e("Unexpected for both radio infos to have different ifaces"); + return; + } + // Both radio0 & radio1 should now be in the same band (could be 5G or 2G). + if (radioModeInfo0.bandInfo != radioModeInfo1.bandInfo) { + mLog.e("Unexpected for both radio infos to have different band"); + return; + } + IfaceInfo ifaceInfo0 = radioModeInfo0.ifaceInfos.get(0); + IfaceInfo ifaceInfo1 = radioModeInfo0.ifaceInfos.get(1); + if (ifaceInfo0.channel != ifaceInfo1.channel) { + handler.onMcc(radioModeInfo0.bandInfo); + } else { + handler.onScc(radioModeInfo0.bandInfo); + } + } } } |