Commit 956b131c authored by Hugo Benichi's avatar Hugo Benichi Committed by Commit Bot

arc: net: remove ARC N legacy APIs

This patch removes net.mojom APIs and fields only used in ARC N:
 - NetworkConfiguration mac_address: the host mac_address of a network
 is now completely hidden in ARC P.
 - GetDefaultNetwork and DefaultNetworkChanged: ARC P is multinetwork
 aware and always need the full list of connected services.

BUG=b:149716479
BUG=b:145960788
TEST=Compiled, flashed eve, ran CtsNetTestCases.

Change-Id: I3368d620d44dd910aae7a12c84c207c3d5cb6cf3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2086362Reviewed-by: default avatarKazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Hugo Benichi <hugobenichi@google.com>
Cr-Commit-Position: refs/heads/master@{#748094}
parent c1aeee4e
...@@ -192,8 +192,8 @@ struct NetworkConfiguration { ...@@ -192,8 +192,8 @@ struct NetworkConfiguration {
// IP configuration for the network service inside ARC. // IP configuration for the network service inside ARC.
array<IPConfiguration>? ip_configs; array<IPConfiguration>? ip_configs;
// MAC address of the network interface inside the ARC. // Deprecated field unused from ARC P and later.
string? mac_address; string? deprecated_mac_address;
// The type of the underlying physical network. // The type of the underlying physical network.
NetworkType type; NetworkType type;
...@@ -336,7 +336,7 @@ struct AndroidVpnConfiguration { ...@@ -336,7 +336,7 @@ struct AndroidVpnConfiguration {
}; };
// Next Method ID: 14 // Next Method ID: 14
// ID 3 is missing as it belonged to a deprecated method. // IDs 3 and 9 are missing as they belonged to deprecated methods.
interface NetHost { interface NetHost {
// Sends a request to get enabled / disabled status of WiFi. // Sends a request to get enabled / disabled status of WiFi.
GetWifiEnabledState@1() => (bool is_enabled); GetWifiEnabledState@1() => (bool is_enabled);
...@@ -364,11 +364,6 @@ interface NetHost { ...@@ -364,11 +364,6 @@ interface NetHost {
// Disconnects from network |guid|. // Disconnects from network |guid|.
[MinVersion=4] StartDisconnect@8(string guid) => (NetworkResult status); [MinVersion=4] StartDisconnect@8(string guid) => (NetworkResult status);
// Retrieve details (IP, SSID, etc.) about the current network connection.
[MinVersion=5] GetDefaultNetwork@9() => (
NetworkConfiguration? logical_default,
NetworkConfiguration? physical_default);
// Sends a request to get the subset of network services existing on Chrome OS // Sends a request to get the subset of network services existing on Chrome OS
// that match the kind specified with GetNetworksRequestType. This call // that match the kind specified with GetNetworksRequestType. This call
// supports three usages: // supports three usages:
...@@ -401,6 +396,7 @@ interface NetHost { ...@@ -401,6 +396,7 @@ interface NetHost {
}; };
// Next Method ID: 8 // Next Method ID: 8
// ID 2 is missing as it belonged to deprecated method.
interface NetInstance { interface NetInstance {
// DEPRECATED: Please use Init@6 instead. // DEPRECATED: Please use Init@6 instead.
InitDeprecated@0(NetHost host_ptr); InitDeprecated@0(NetHost host_ptr);
...@@ -411,11 +407,6 @@ interface NetInstance { ...@@ -411,11 +407,6 @@ interface NetInstance {
// Notifies the instance of a WiFI AP scan being completed. // Notifies the instance of a WiFI AP scan being completed.
[MinVersion=1] ScanCompleted@1(); [MinVersion=1] ScanCompleted@1();
// Notifies the instance of a change in the host default network service.
[MinVersion=2] DefaultNetworkChanged@2(
NetworkConfiguration? logical_default,
NetworkConfiguration? physical_default);
// Notifies the instance of a change in the state of WiFi on the host. // Notifies the instance of a change in the state of WiFi on the host.
[MinVersion=3] WifiEnabledStateChanged@3(bool is_enabled); [MinVersion=3] WifiEnabledStateChanged@3(bool is_enabled);
......
...@@ -355,8 +355,6 @@ arc::mojom::NetworkConfigurationPtr TranslateONCConfiguration( ...@@ -355,8 +355,6 @@ arc::mojom::NetworkConfigurationPtr TranslateONCConfiguration(
mojo->guid = GetStringFromONCDictionary(dict, onc::network_config::kGUID, mojo->guid = GetStringFromONCDictionary(dict, onc::network_config::kGUID,
true /* required */); true /* required */);
mojo->mac_address = GetStringFromONCDictionary(
dict, onc::network_config::kMacAddress, false /* required */);
TranslateONCNetworkTypeDetails(dict, mojo.get()); TranslateONCNetworkTypeDetails(dict, mojo.get());
if (network_state) { if (network_state) {
...@@ -456,36 +454,6 @@ void StartDisconnectFailureCallback( ...@@ -456,36 +454,6 @@ void StartDisconnectFailureCallback(
std::move(callback).Run(arc::mojom::NetworkResult::FAILURE); std::move(callback).Run(arc::mojom::NetworkResult::FAILURE);
} }
void GetDefaultNetworkSuccessCallback(
base::OnceCallback<void(arc::mojom::NetworkConfigurationPtr,
arc::mojom::NetworkConfigurationPtr)> callback,
const std::string& service_path,
const base::DictionaryValue& dictionary) {
// TODO(cernekee): Figure out how to query Chrome for the default physical
// service if a VPN is connected, rather than just reporting the
// default logical service in both fields.
const chromeos::NetworkState* network_state =
GetStateHandler()->GetNetworkState(service_path);
std::move(callback).Run(
TranslateONCConfiguration(network_state, &dictionary),
TranslateONCConfiguration(network_state, &dictionary));
}
void GetDefaultNetworkFailureCallback(
base::OnceCallback<void(arc::mojom::NetworkConfigurationPtr,
arc::mojom::NetworkConfigurationPtr)> callback,
const std::string& error_name,
std::unique_ptr<base::DictionaryValue> error_data) {
LOG(ERROR) << "Failed to query default logical network: " << error_name;
std::move(callback).Run(nullptr, nullptr);
}
void DefaultNetworkFailureCallback(
const std::string& error_name,
std::unique_ptr<base::DictionaryValue> error_data) {
LOG(ERROR) << "Failed to query default logical network: " << error_name;
}
void ArcVpnSuccessCallback() { void ArcVpnSuccessCallback() {
DVLOG(1) << "ArcVpnSuccessCallback"; DVLOG(1) << "ArcVpnSuccessCallback";
} }
...@@ -799,80 +767,8 @@ void ArcNetHostImpl::ScanCompleted(const chromeos::DeviceState* /*unused*/) { ...@@ -799,80 +767,8 @@ void ArcNetHostImpl::ScanCompleted(const chromeos::DeviceState* /*unused*/) {
net_instance->ScanCompleted(); net_instance->ScanCompleted();
} }
const chromeos::NetworkState* ArcNetHostImpl::GetDefaultNetworkFromChrome() {
// If an Android VPN is connected, report the underlying physical
// connection only. Never tell Android about its own VPN.
// If a Chrome OS VPN is connected, report the Chrome OS VPN as the
// default connection.
if (arc_vpn_service_path_.empty()) {
return GetShillBackedNetwork(GetStateHandler()->DefaultNetwork());
}
return GetShillBackedNetwork(GetStateHandler()->ConnectedNetworkByType(
chromeos::NetworkTypePattern::NonVirtual()));
}
void ArcNetHostImpl::GetDefaultNetwork(GetDefaultNetworkCallback callback) {
const chromeos::NetworkState* default_network = GetDefaultNetworkFromChrome();
if (!default_network) {
VLOG(1) << "GetDefaultNetwork: no default network";
std::move(callback).Run(nullptr, nullptr);
return;
}
VLOG(1) << "GetDefaultNetwork: default network is "
<< default_network->path();
std::string user_id_hash = chromeos::LoginState::Get()->primary_user_hash();
// TODO(crbug.com/730593): Remove AdaptCallbackForRepeating() by updating
// the callee interface.
auto repeating_callback =
base::AdaptCallbackForRepeating(std::move(callback));
GetManagedConfigurationHandler()->GetProperties(
user_id_hash, default_network->path(),
base::Bind(&GetDefaultNetworkSuccessCallback, repeating_callback),
base::Bind(&GetDefaultNetworkFailureCallback, repeating_callback));
}
void ArcNetHostImpl::DefaultNetworkSuccessCallback(
const std::string& service_path,
const base::DictionaryValue& dictionary) {
auto* net_instance = ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->net(),
DefaultNetworkChanged);
if (!net_instance)
return;
const chromeos::NetworkState* network_state =
GetStateHandler()->GetNetworkState(service_path);
net_instance->DefaultNetworkChanged(
TranslateONCConfiguration(network_state, &dictionary),
TranslateONCConfiguration(network_state, &dictionary));
}
void ArcNetHostImpl::UpdateDefaultNetwork() {
const chromeos::NetworkState* default_network = GetDefaultNetworkFromChrome();
if (!default_network) {
VLOG(1) << "No default network";
auto* net_instance = ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->net(),
DefaultNetworkChanged);
if (net_instance)
net_instance->DefaultNetworkChanged(nullptr, nullptr);
return;
}
VLOG(1) << "New default network: " << default_network->path() << " ("
<< default_network->type() << ")";
std::string user_id_hash = chromeos::LoginState::Get()->primary_user_hash();
GetManagedConfigurationHandler()->GetProperties(
user_id_hash, default_network->path(),
base::Bind(&ArcNetHostImpl::DefaultNetworkSuccessCallback,
weak_factory_.GetWeakPtr()),
base::Bind(&DefaultNetworkFailureCallback));
}
void ArcNetHostImpl::DefaultNetworkChanged( void ArcNetHostImpl::DefaultNetworkChanged(
const chromeos::NetworkState* network) { const chromeos::NetworkState* network) {
UpdateDefaultNetwork();
UpdateActiveNetworks(); UpdateActiveNetworks();
} }
...@@ -1070,12 +966,6 @@ void ArcNetHostImpl::DisconnectRequested(const std::string& service_path) { ...@@ -1070,12 +966,6 @@ void ArcNetHostImpl::DisconnectRequested(const std::string& service_path) {
void ArcNetHostImpl::NetworkConnectionStateChanged( void ArcNetHostImpl::NetworkConnectionStateChanged(
const chromeos::NetworkState* network) { const chromeos::NetworkState* network) {
// DefaultNetworkChanged() won't be invoked if an ARC VPN is the default
// network and the underlying physical connection changed, so check for
// that condition here. This is invoked any time any service state
// changes.
UpdateDefaultNetwork();
const chromeos::NetworkState* shill_backed_network = const chromeos::NetworkState* shill_backed_network =
GetShillBackedNetwork(network); GetShillBackedNetwork(network);
if (!shill_backed_network) if (!shill_backed_network)
...@@ -1144,7 +1034,6 @@ void ArcNetHostImpl::NetworkListChanged() { ...@@ -1144,7 +1034,6 @@ void ArcNetHostImpl::NetworkListChanged() {
// During the transition when a new service comes online, it will // During the transition when a new service comes online, it will
// temporarily be ranked below "inferior" services. This callback // temporarily be ranked below "inferior" services. This callback
// informs us that shill's ordering has been updated. // informs us that shill's ordering has been updated.
UpdateDefaultNetwork();
UpdateActiveNetworks(); UpdateActiveNetworks();
} }
......
...@@ -96,7 +96,6 @@ class ArcNetHostImpl : public KeyedService, ...@@ -96,7 +96,6 @@ class ArcNetHostImpl : public KeyedService,
const std::vector<const chromeos::NetworkState*>& networks) override; const std::vector<const chromeos::NetworkState*>& networks) override;
void NetworkListChanged() override; void NetworkListChanged() override;
void DeviceListChanged() override; void DeviceListChanged() override;
void GetDefaultNetwork(GetDefaultNetworkCallback callback) override;
// Overriden from chromeos::NetworkConnectionObserver. // Overriden from chromeos::NetworkConnectionObserver.
void DisconnectRequested(const std::string& service_path) override; void DisconnectRequested(const std::string& service_path) override;
...@@ -107,7 +106,6 @@ class ArcNetHostImpl : public KeyedService, ...@@ -107,7 +106,6 @@ class ArcNetHostImpl : public KeyedService,
private: private:
const chromeos::NetworkState* GetDefaultNetworkFromChrome(); const chromeos::NetworkState* GetDefaultNetworkFromChrome();
void UpdateDefaultNetwork();
void UpdateActiveNetworks(); void UpdateActiveNetworks();
void DefaultNetworkSuccessCallback(const std::string& service_path, void DefaultNetworkSuccessCallback(const std::string& service_path,
const base::DictionaryValue& dictionary); const base::DictionaryValue& dictionary);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment