Revert "Reset all maps in AndroidNetworkMonitor Start()/Stop()"

This reverts commit 02293096f9689fee3d32defa77dca227cc1eee90.

Reason for revert: mysterious crashes in android_network_monitor.cc

Original change's description:
> Reset all maps in AndroidNetworkMonitor Start()/Stop()
>
> This cl/ fixes another race condition with the recent additions
> to NetworkMonitorAutoDetect (getAllNetworksFromCache).
>
> The getAllNetworksFromCache-feature uses the by the Android team
> preferred way of enumerating networks, i.e to register network listeners.
>
> Th recent fix to add IsAdapterAvailable, https://webrtc-review.googlesource.com/c/src/+/257400
> contained a bug in that the adapter_type_by_name_ map was not
> reset either on disconnect or Start/Stop.
>
> This cl/ addresses that including unit test.
> It also de-obfuscates NetworkMonitor so that it always
> calls NotifyOfActiveNetworkList on startMonitoring even
> if list.size() == 0. This should not matter but makes
> code easier to understand.
>
> Bug: webrtc:13741
> Change-Id: I438b877eebf769a8b2e7292b697ef1c0a349b24f
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258721
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#36530}

Bug: webrtc:13741
Change-Id: I36fbf63f658d3e8048e13959cbebfbd14df12b14
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264146
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37016}
This commit is contained in:
Jonas Oreland
2022-05-27 13:54:34 +02:00
committed by WebRTC LUCI CQ
parent 94ad387f77
commit 8cd7b0a7ba
4 changed files with 6 additions and 99 deletions

View File

@ -138,11 +138,10 @@ public class NetworkMonitor {
startMonitoring(
applicationContext != null ? applicationContext : ContextUtils.getApplicationContext(),
fieldTrialsString);
// The native observers expect a network list update after they call startMonitoring.
synchronized (nativeNetworkObservers) {
nativeNetworkObservers.add(nativeObserver);
}
// The native observer expects a network list update after startMonitoring.
updateObserverActiveNetworkList(nativeObserver);
// currentConnectionType was updated in startMonitoring().
// Need to notify the native observers here.
@ -272,7 +271,7 @@ public class NetworkMonitor {
networkInfoList =
(networkChangeDetector == null) ? null : networkChangeDetector.getActiveNetworkList();
}
if (networkInfoList == null) {
if (networkInfoList == null || networkInfoList.size() == 0) {
return;
}