Commit fc11883f authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Unified: Support toggle of mobile data and tether.

Currently, network feature pod button may show Ethernet, mobile data &
tether in addition to WiFi. However, clicking on the button always
toggled WiFi enabled / disabled.

TEST=manual
BUG=856030

Change-Id: If39e3360a045e0b0ba64cb89c43999dd11151549
Reviewed-on: https://chromium-review.googlesource.com/1116510Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571388}
parent 50441c1a
......@@ -14,13 +14,36 @@
using chromeos::NetworkHandler;
using chromeos::NetworkTypePattern;
using chromeos::NetworkState;
namespace ash {
namespace {
void SetNetworkEnabled(bool enabled) {
// TODO(tetsui): Handle other types of networks.
const NetworkState* network =
NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType(
NetworkTypePattern::NonVirtual());
// For cellular and tether, users are only allowed to disable them from
// feature pod toggle.
if (!enabled && network && network->Matches(NetworkTypePattern::Cellular())) {
NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
NetworkTypePattern::Cellular(), false,
chromeos::network_handler::ErrorCallback());
return;
}
if (!enabled && network && network->Matches(NetworkTypePattern::Tether())) {
NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
NetworkTypePattern::Tether(), false,
chromeos::network_handler::ErrorCallback());
return;
}
if (network && !network->Matches(NetworkTypePattern::WiFi()))
return;
NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
NetworkTypePattern::WiFi(), enabled,
chromeos::network_handler::ErrorCallback());
......
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