Commit b68ee71b authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Network Config WebUI: Support cellular initializing and scanning

Bug: 816864
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ia0c8b5c098bfb649175f1f87e5895f85dad98cb0
Reviewed-on: https://chromium-review.googlesource.com/947043
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541457}
parent 78754aa2
...@@ -126,6 +126,8 @@ Polymer({ ...@@ -126,6 +126,8 @@ Polymer({
loadTimeData.getString('networkListItemConnectingTo'), loadTimeData.getString('networkListItemConnectingTo'),
networkListItemInitializing: networkListItemInitializing:
loadTimeData.getString('networkListItemInitializing'), loadTimeData.getString('networkListItemInitializing'),
networkListItemScanning:
loadTimeData.getString('networkListItemScanning'),
networkListItemNotConnected: networkListItemNotConnected:
loadTimeData.getString('networkListItemNotConnected'), loadTimeData.getString('networkListItemNotConnected'),
networkListItemNoNetwork: networkListItemNoNetwork:
......
...@@ -25,6 +25,7 @@ var NetworkUI = (function() { ...@@ -25,6 +25,7 @@ var NetworkUI = (function() {
loadTimeData.getString('networkListItemConnectingTo'), loadTimeData.getString('networkListItemConnectingTo'),
networkListItemInitializing: networkListItemInitializing:
loadTimeData.getString('networkListItemInitializing'), loadTimeData.getString('networkListItemInitializing'),
networkListItemScanning: loadTimeData.getString('networkListItemScanning'),
networkListItemNotConnected: networkListItemNotConnected:
loadTimeData.getString('networkListItemNotConnected'), loadTimeData.getString('networkListItemNotConnected'),
networkListItemNoNetwork: networkListItemNoNetwork:
......
...@@ -68,10 +68,9 @@ Polymer({ ...@@ -68,10 +68,9 @@ Polymer({
* @private * @private
*/ */
getNetworkStateText_: function(activeNetworkState, deviceState) { getNetworkStateText_: function(activeNetworkState, deviceState) {
const state = activeNetworkState.ConnectionState; const stateText = this.getConnectionStateText_(activeNetworkState);
const name = CrOnc.getNetworkName(activeNetworkState); if (stateText)
if (state) return stateText;
return this.getConnectionStateText_(state, name);
// No network state, use device state. // No network state, use device state.
if (deviceState) { if (deviceState) {
// Type specific scanning or initialization states. // Type specific scanning or initialization states.
...@@ -98,12 +97,15 @@ Polymer({ ...@@ -98,12 +97,15 @@ Polymer({
}, },
/** /**
* @param {CrOnc.ConnectionState} state * @param {!CrOnc.NetworkStateProperties} networkState
* @param {string} name
* @return {string} * @return {string}
* @private * @private
*/ */
getConnectionStateText_: function(state, name) { getConnectionStateText_: function(networkState) {
const state = networkState.ConnectionState;
if (!state)
return '';
const name = CrOnc.getNetworkName(networkState);
switch (state) { switch (state) {
case CrOnc.ConnectionState.CONNECTED: case CrOnc.ConnectionState.CONNECTED:
return name; return name;
...@@ -112,6 +114,10 @@ Polymer({ ...@@ -112,6 +114,10 @@ Polymer({
return CrOncStrings.networkListItemConnectingTo.replace('$1', name); return CrOncStrings.networkListItemConnectingTo.replace('$1', name);
return CrOncStrings.networkListItemConnecting; return CrOncStrings.networkListItemConnecting;
case CrOnc.ConnectionState.NOT_CONNECTED: case CrOnc.ConnectionState.NOT_CONNECTED:
if (networkState.Type == CrOnc.Type.CELLULAR && networkState.Cellular &&
networkState.Cellular.Scanning) {
return this.i18n('internetMobileSearching');
}
return CrOncStrings.networkListItemNotConnected; return CrOncStrings.networkListItemNotConnected;
} }
assertNotReached(); assertNotReached();
......
...@@ -120,6 +120,8 @@ Polymer({ ...@@ -120,6 +120,8 @@ Polymer({
loadTimeData.getString('networkListItemConnectingTo'), loadTimeData.getString('networkListItemConnectingTo'),
networkListItemInitializing: networkListItemInitializing:
loadTimeData.getString('networkListItemInitializing'), loadTimeData.getString('networkListItemInitializing'),
networkListItemScanning:
loadTimeData.getString('networkListItemScanning'),
networkListItemNotConnected: networkListItemNotConnected:
loadTimeData.getString('networkListItemNotConnected'), loadTimeData.getString('networkListItemNotConnected'),
networkListItemNoNetwork: networkListItemNoNetwork:
......
...@@ -32,6 +32,7 @@ struct { ...@@ -32,6 +32,7 @@ struct {
{"networkListItemConnecting", IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING}, {"networkListItemConnecting", IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING},
{"networkListItemConnectingTo", IDS_NETWORK_LIST_CONNECTING_TO}, {"networkListItemConnectingTo", IDS_NETWORK_LIST_CONNECTING_TO},
{"networkListItemInitializing", IDS_NETWORK_LIST_INITIALIZING}, {"networkListItemInitializing", IDS_NETWORK_LIST_INITIALIZING},
{"networkListItemScanning", IDS_SETTINGS_INTERNET_MOBILE_SEARCH},
{"networkListItemNotConnected", IDS_NETWORK_LIST_NOT_CONNECTED}, {"networkListItemNotConnected", IDS_NETWORK_LIST_NOT_CONNECTED},
{"networkListItemNoNetwork", IDS_NETWORK_LIST_NO_NETWORK}, {"networkListItemNoNetwork", IDS_NETWORK_LIST_NO_NETWORK},
{"vpnNameTemplate", IDS_NETWORK_LIST_THIRD_PARTY_VPN_NAME_TEMPLATE}, {"vpnNameTemplate", IDS_NETWORK_LIST_THIRD_PARTY_VPN_NAME_TEMPLATE},
......
...@@ -44,7 +44,12 @@ chrome.test.runTests([ ...@@ -44,7 +44,12 @@ chrome.test.runTests([
ModelID:"test_model_id", ModelID:"test_model_id",
NetworkTechnology: 'GSM', NetworkTechnology: 'GSM',
RoamingState: 'Home', RoamingState: 'Home',
SIMLockStatus: {LockEnabled: true, LockType: '', RetriesLeft: 3} SIMLockStatus: {
LockEnabled: true,
LockType: '',
RetriesLeft: 3,
},
Scanning: false,
}, },
ConnectionState: 'NotConnected', ConnectionState: 'NotConnected',
GUID: 'stub_cellular1_guid', GUID: 'stub_cellular1_guid',
......
...@@ -592,7 +592,8 @@ var availableTests = [ ...@@ -592,7 +592,8 @@ var availableTests = [
ModelID:"test_model_id", ModelID:"test_model_id",
NetworkTechnology: 'GSM', NetworkTechnology: 'GSM',
RoamingState: 'Home', RoamingState: 'Home',
SIMLockStatus: {LockEnabled: true, LockType: '', RetriesLeft: 3} SIMLockStatus: {LockEnabled: true, LockType: '', RetriesLeft: 3},
Scanning: false,
}, },
ConnectionState: ConnectionStateType.NOT_CONNECTED, ConnectionState: ConnectionStateType.NOT_CONNECTED,
GUID: kCellularGuid, GUID: kCellularGuid,
...@@ -624,6 +625,7 @@ var availableTests = [ ...@@ -624,6 +625,7 @@ var availableTests = [
MIN: "test_min", MIN: "test_min",
ModelID:"test_model_id", ModelID:"test_model_id",
SIMLockStatus: {LockEnabled: true, LockType: '', RetriesLeft: 3}, SIMLockStatus: {LockEnabled: true, LockType: '', RetriesLeft: 3},
Scanning: false,
SignalStrength: 0, SignalStrength: 0,
}, },
Connectable: false, Connectable: false,
......
...@@ -165,18 +165,19 @@ std::unique_ptr<base::DictionaryValue> TranslateNetworkStateToONC( ...@@ -165,18 +165,19 @@ std::unique_ptr<base::DictionaryValue> TranslateNetworkStateToONC(
// Get any Device properties required to translate state. // Get any Device properties required to translate state.
if (NetworkTypePattern::Cellular().MatchesType(network->type())) { if (NetworkTypePattern::Cellular().MatchesType(network->type())) {
// We need to set Device[Cellular.ProviderRequiresRoaming] so that
// Cellular[RoamingState] can be set correctly for badging network icons.
const DeviceState* device = const DeviceState* device =
NetworkHandler::Get()->network_state_handler()->GetDeviceState( NetworkHandler::Get()->network_state_handler()->GetDeviceState(
network->device_path()); network->device_path());
if (device) { if (device) {
std::unique_ptr<base::DictionaryValue> device_dict( base::DictionaryValue device_dict;
new base::DictionaryValue); // We need to set Device.Cellular.ProviderRequiresRoaming so that
device_dict->SetKey(shill::kProviderRequiresRoamingProperty, // Cellular.RoamingState can be set correctly for badging network icons.
base::Value(device->provider_requires_roaming())); device_dict.SetKey(shill::kProviderRequiresRoamingProperty,
shill_dictionary->SetWithoutPathExpansion(shill::kDeviceProperty, base::Value(device->provider_requires_roaming()));
std::move(device_dict)); // Scanning is also used in the UI when displaying a list of networks.
device_dict.SetKey(shill::kScanningProperty,
base::Value(device->scanning()));
shill_dictionary->SetKey(shill::kDeviceProperty, std::move(device_dict));
} }
} }
......
...@@ -436,6 +436,7 @@ void ShillToONCTranslator::TranslateCellularWithState() { ...@@ -436,6 +436,7 @@ void ShillToONCTranslator::TranslateCellularWithState() {
const base::DictionaryValue* device_dictionary = NULL; const base::DictionaryValue* device_dictionary = NULL;
bool requires_roaming = false; bool requires_roaming = false;
bool scanning = false;
shill_dictionary_->GetDictionaryWithoutPathExpansion(shill::kDeviceProperty, shill_dictionary_->GetDictionaryWithoutPathExpansion(shill::kDeviceProperty,
&device_dictionary); &device_dictionary);
if (device_dictionary) { if (device_dictionary) {
...@@ -448,9 +449,11 @@ void ShillToONCTranslator::TranslateCellularWithState() { ...@@ -448,9 +449,11 @@ void ShillToONCTranslator::TranslateCellularWithState() {
nested_translator.CreateTranslatedONCObject(); nested_translator.CreateTranslatedONCObject();
onc_object_->MergeDictionary(nested_object.get()); onc_object_->MergeDictionary(nested_object.get());
/// Get the requires_roaming from the Device dictionary. /// Get requires_roaming and scanning from the Device dictionary.
device_dictionary->GetBooleanWithoutPathExpansion( device_dictionary->GetBooleanWithoutPathExpansion(
shill::kProviderRequiresRoamingProperty, &requires_roaming); shill::kProviderRequiresRoamingProperty, &requires_roaming);
device_dictionary->GetBooleanWithoutPathExpansion(shill::kScanningProperty,
&scanning);
} }
if (requires_roaming) { if (requires_roaming) {
onc_object_->SetKey(::onc::cellular::kRoamingState, onc_object_->SetKey(::onc::cellular::kRoamingState,
...@@ -459,6 +462,7 @@ void ShillToONCTranslator::TranslateCellularWithState() { ...@@ -459,6 +462,7 @@ void ShillToONCTranslator::TranslateCellularWithState() {
TranslateWithTableAndSet(shill::kRoamingStateProperty, kRoamingStateTable, TranslateWithTableAndSet(shill::kRoamingStateProperty, kRoamingStateTable,
::onc::cellular::kRoamingState); ::onc::cellular::kRoamingState);
} }
onc_object_->SetKey(::onc::cellular::kScanning, base::Value(scanning));
} }
void ShillToONCTranslator::TranslateCellularDevice() { void ShillToONCTranslator::TranslateCellularDevice() {
......
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
"SIMLockStatus": { "SIMLockStatus": {
"LockType": "sim-pin", "LockType": "sim-pin",
"LockEnabled": true "LockEnabled": true
} },
"Scanning": false
}, },
"Source":"Device" "Source":"Device"
} }
...@@ -1093,6 +1093,7 @@ TEST_F(NetworkingPrivateApiTest, GetCellularProperties) { ...@@ -1093,6 +1093,7 @@ TEST_F(NetworkingPrivateApiTest, GetCellularProperties) {
.Set("ModelID", "test_model_id") .Set("ModelID", "test_model_id")
.Set("NetworkTechnology", "GSM") .Set("NetworkTechnology", "GSM")
.Set("RoamingState", "Home") .Set("RoamingState", "Home")
.SetBoolean("Scanning", false)
.Build()) .Build())
.Set("ConnectionState", "Connected") .Set("ConnectionState", "Connected")
.Set("GUID", "cellular_guid") .Set("GUID", "cellular_guid")
...@@ -1146,6 +1147,7 @@ TEST_F(NetworkingPrivateApiTest, GetCellularPropertiesFromWebUi) { ...@@ -1146,6 +1147,7 @@ TEST_F(NetworkingPrivateApiTest, GetCellularPropertiesFromWebUi) {
.Set("MIN", "test_min") .Set("MIN", "test_min")
.Set("NetworkTechnology", "GSM") .Set("NetworkTechnology", "GSM")
.Set("RoamingState", "Home") .Set("RoamingState", "Home")
.SetBoolean("Scanning", false)
.Set("APNList", ListBuilder() .Set("APNList", ListBuilder()
.Append(expected_apn->CreateDeepCopy()) .Append(expected_apn->CreateDeepCopy())
.Build()) .Build())
......
...@@ -580,6 +580,7 @@ namespace networkingPrivate { ...@@ -580,6 +580,7 @@ namespace networkingPrivate {
ActivationStateType? ActivationState; ActivationStateType? ActivationState;
DOMString? NetworkTechnology; DOMString? NetworkTechnology;
DOMString? RoamingState; DOMString? RoamingState;
boolean? Scanning;
boolean? SIMPresent; boolean? SIMPresent;
long? SignalStrength; long? SignalStrength;
}; };
......
...@@ -748,6 +748,7 @@ chrome.networkingPrivate.ManagedCellularProperties; ...@@ -748,6 +748,7 @@ chrome.networkingPrivate.ManagedCellularProperties;
* ActivationState: (!chrome.networkingPrivate.ActivationStateType|undefined), * ActivationState: (!chrome.networkingPrivate.ActivationStateType|undefined),
* NetworkTechnology: (string|undefined), * NetworkTechnology: (string|undefined),
* RoamingState: (string|undefined), * RoamingState: (string|undefined),
* Scanning: (boolean|undefined),
* SIMPresent: (boolean|undefined), * SIMPresent: (boolean|undefined),
* SignalStrength: (number|undefined) * SignalStrength: (number|undefined)
* }} * }}
......
...@@ -103,9 +103,7 @@ Polymer({ ...@@ -103,9 +103,7 @@ Polymer({
* @private * @private
*/ */
isStateTextVisible_: function() { isStateTextVisible_: function() {
return !!this.networkState && return !!this.networkState && !!this.getNetworkStateText_();
(this.networkState.ConnectionState !=
CrOnc.ConnectionState.NOT_CONNECTED);
}, },
/** /**
...@@ -114,16 +112,20 @@ Polymer({ ...@@ -114,16 +112,20 @@ Polymer({
* @private * @private
*/ */
getNetworkStateText_: function() { getNetworkStateText_: function() {
if (!this.isStateTextVisible_()) if (!this.networkState)
return ''; return '';
var state = this.networkState.ConnectionState; var connectionState = this.networkState.ConnectionState;
// For Cellular, an empty ConnectionState indicates that the device is if (this.networkState.Type == CrOnc.Type.CELLULAR) {
// still initializing. // For Cellular, an empty ConnectionState indicates that the device is
if (!state && this.networkState.Type == CrOnc.Type.CELLULAR) // still initializing.
return CrOncStrings.networkListItemInitializing; if (!connectionState)
if (state == CrOnc.ConnectionState.CONNECTED) return CrOncStrings.networkListItemInitializing;
if (this.networkState.Cellular && this.networkState.Cellular.Scanning)
return CrOncStrings.networkListItemScanning;
}
if (connectionState == CrOnc.ConnectionState.CONNECTED)
return CrOncStrings.networkListItemConnected; return CrOncStrings.networkListItemConnected;
if (state == CrOnc.ConnectionState.CONNECTING) if (connectionState == CrOnc.ConnectionState.CONNECTING)
return CrOncStrings.networkListItemConnecting; return CrOncStrings.networkListItemConnecting;
return ''; return '';
}, },
......
...@@ -149,6 +149,8 @@ Polymer({ ...@@ -149,6 +149,8 @@ Polymer({
this.cellularDeviceState_ = deviceStates.find(function(device) { this.cellularDeviceState_ = deviceStates.find(function(device) {
return device.Type == CrOnc.Type.CELLULAR; return device.Type == CrOnc.Type.CELLULAR;
}); });
if (this.cellularDeviceState_)
this.ensureCellularNetwork_(networkStates);
this.networkStateList_ = networkStates; this.networkStateList_ = networkStates;
var defaultNetwork; var defaultNetwork;
if (networkStates.length > 0) { if (networkStates.length > 0) {
...@@ -176,6 +178,30 @@ Polymer({ ...@@ -176,6 +178,30 @@ Polymer({
this.fire('default-network-changed', defaultNetwork); this.fire('default-network-changed', defaultNetwork);
}, },
/**
* Modifies |networkStates| to include a cellular network if none exists.
* @param {!Array<!CrOnc.NetworkStateProperties>} networkStates
* @private
*/
ensureCellularNetwork_: function(networkStates) {
if (networkStates.find(function(network) {
return network.Type == CrOnc.Type.CELLULAR;
})) {
return;
}
// Add a Cellular network after the Ethernet network if it exists.
var idx = networkStates.length > 0 &&
networkStates[0].Type == CrOnc.Type.ETHERNET ?
1 :
0;
var cellular = {
GUID: '',
Type: CrOnc.Type.CELLULAR,
Cellular: {Scanning: this.cellularDeviceState_.Scanning}
};
networkStates.splice(idx, 0, cellular);
},
/** /**
* Event triggered when a cr-network-list-item is selected. * Event triggered when a cr-network-list-item is selected.
* @param {!{target: HTMLElement, detail: !CrOnc.NetworkStateProperties}} e * @param {!{target: HTMLElement, detail: !CrOnc.NetworkStateProperties}} e
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
* networkListItemConnecting: string, * networkListItemConnecting: string,
* networkListItemConnectingTo: string, * networkListItemConnectingTo: string,
* networkListItemInitializing: string, * networkListItemInitializing: string,
* networkListItemScanning: string,
* networkListItemNotConnected: string, * networkListItemNotConnected: string,
* networkListItemNoNetwork: string, * networkListItemNoNetwork: string,
* vpnNameTemplate: string, * vpnNameTemplate: string,
......
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