Add field trial for surfacing cellular types in AndroidNetworkMonitor
This field trial will be used to rollout the cellular types added in https://webrtc-review.googlesource.com/c/src/+/174500 in a controlled fashion. Bug: webrtc:11473 Change-Id: I371d13d6935f6e0273a023657ce1b11b32bef346 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174831 Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Commit-Queue: Jonas Oreland <jonaso@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31224}
This commit is contained in:

committed by
Commit Bot

parent
cd1ba9411b
commit
8c7384c307
@ -76,7 +76,9 @@ static NetworkType GetNetworkTypeFromJava(
|
|||||||
return NetworkType::NETWORK_UNKNOWN;
|
return NetworkType::NETWORK_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static rtc::AdapterType AdapterTypeFromNetworkType(NetworkType network_type) {
|
static rtc::AdapterType AdapterTypeFromNetworkType(
|
||||||
|
NetworkType network_type,
|
||||||
|
bool surface_cellular_types) {
|
||||||
switch (network_type) {
|
switch (network_type) {
|
||||||
case NETWORK_UNKNOWN:
|
case NETWORK_UNKNOWN:
|
||||||
return rtc::ADAPTER_TYPE_UNKNOWN;
|
return rtc::ADAPTER_TYPE_UNKNOWN;
|
||||||
@ -85,9 +87,17 @@ static rtc::AdapterType AdapterTypeFromNetworkType(NetworkType network_type) {
|
|||||||
case NETWORK_WIFI:
|
case NETWORK_WIFI:
|
||||||
return rtc::ADAPTER_TYPE_WIFI;
|
return rtc::ADAPTER_TYPE_WIFI;
|
||||||
case NETWORK_5G:
|
case NETWORK_5G:
|
||||||
|
return surface_cellular_types ? rtc::ADAPTER_TYPE_CELLULAR_5G
|
||||||
|
: rtc::ADAPTER_TYPE_CELLULAR;
|
||||||
case NETWORK_4G:
|
case NETWORK_4G:
|
||||||
|
return surface_cellular_types ? rtc::ADAPTER_TYPE_CELLULAR_4G
|
||||||
|
: rtc::ADAPTER_TYPE_CELLULAR;
|
||||||
case NETWORK_3G:
|
case NETWORK_3G:
|
||||||
|
return surface_cellular_types ? rtc::ADAPTER_TYPE_CELLULAR_3G
|
||||||
|
: rtc::ADAPTER_TYPE_CELLULAR;
|
||||||
case NETWORK_2G:
|
case NETWORK_2G:
|
||||||
|
return surface_cellular_types ? rtc::ADAPTER_TYPE_CELLULAR_2G
|
||||||
|
: rtc::ADAPTER_TYPE_CELLULAR;
|
||||||
case NETWORK_UNKNOWN_CELLULAR:
|
case NETWORK_UNKNOWN_CELLULAR:
|
||||||
return rtc::ADAPTER_TYPE_CELLULAR;
|
return rtc::ADAPTER_TYPE_CELLULAR;
|
||||||
case NETWORK_VPN:
|
case NETWORK_VPN:
|
||||||
@ -196,6 +206,8 @@ void AndroidNetworkMonitor::Start() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
started_ = true;
|
started_ = true;
|
||||||
|
surface_cellular_types_ =
|
||||||
|
webrtc::field_trial::IsEnabled("WebRTC-SurfaceCellularTypes");
|
||||||
find_network_handle_without_ipv6_temporary_part_ =
|
find_network_handle_without_ipv6_temporary_part_ =
|
||||||
webrtc::field_trial::IsEnabled(
|
webrtc::field_trial::IsEnabled(
|
||||||
"WebRTC-FindNetworkHandleWithoutIpv6TemporaryPart");
|
"WebRTC-FindNetworkHandleWithoutIpv6TemporaryPart");
|
||||||
@ -347,10 +359,11 @@ void AndroidNetworkMonitor::OnNetworkConnected_w(
|
|||||||
const NetworkInformation& network_info) {
|
const NetworkInformation& network_info) {
|
||||||
RTC_LOG(LS_INFO) << "Network connected: " << network_info.ToString();
|
RTC_LOG(LS_INFO) << "Network connected: " << network_info.ToString();
|
||||||
adapter_type_by_name_[network_info.interface_name] =
|
adapter_type_by_name_[network_info.interface_name] =
|
||||||
AdapterTypeFromNetworkType(network_info.type);
|
AdapterTypeFromNetworkType(network_info.type, surface_cellular_types_);
|
||||||
if (network_info.type == NETWORK_VPN) {
|
if (network_info.type == NETWORK_VPN) {
|
||||||
vpn_underlying_adapter_type_by_name_[network_info.interface_name] =
|
vpn_underlying_adapter_type_by_name_[network_info.interface_name] =
|
||||||
AdapterTypeFromNetworkType(network_info.underlying_type_for_vpn);
|
AdapterTypeFromNetworkType(network_info.underlying_type_for_vpn,
|
||||||
|
surface_cellular_types_);
|
||||||
}
|
}
|
||||||
network_info_by_handle_[network_info.handle] = network_info;
|
network_info_by_handle_[network_info.handle] = network_info;
|
||||||
for (const rtc::IPAddress& address : network_info.ip_addresses) {
|
for (const rtc::IPAddress& address : network_info.ip_addresses) {
|
||||||
|
@ -114,6 +114,7 @@ class AndroidNetworkMonitor : public rtc::NetworkMonitorBase,
|
|||||||
std::map<rtc::IPAddress, NetworkHandle> network_handle_by_address_;
|
std::map<rtc::IPAddress, NetworkHandle> network_handle_by_address_;
|
||||||
std::map<NetworkHandle, NetworkInformation> network_info_by_handle_;
|
std::map<NetworkHandle, NetworkInformation> network_info_by_handle_;
|
||||||
bool find_network_handle_without_ipv6_temporary_part_;
|
bool find_network_handle_without_ipv6_temporary_part_;
|
||||||
|
bool surface_cellular_types_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AndroidNetworkMonitorFactory : public rtc::NetworkMonitorFactory {
|
class AndroidNetworkMonitorFactory : public rtc::NetworkMonitorFactory {
|
||||||
|
Reference in New Issue
Block a user