Chromium Code Reviews| Index: chrome/browser/chromeos/policy/device_status_collector.cc |
| diff --git a/chrome/browser/chromeos/policy/device_status_collector.cc b/chrome/browser/chromeos/policy/device_status_collector.cc |
| index d57319303d5a9686fe006802023ddd130fa5da19..9c43fc886570bf02f73ebe32a274243849dae953 100644 |
| --- a/chrome/browser/chromeos/policy/device_status_collector.cc |
| +++ b/chrome/browser/chromeos/policy/device_status_collector.cc |
| @@ -636,6 +636,22 @@ void DeviceStatusCollector::GetLocation( |
| } |
| } |
| +int DeviceStatusCollector::ConvertSignalStrength(int signal_strength) { |
| + // Shill attempts to convert attempts to convert from its internal dBm to a |
|
Thiemo Nagel
2015/04/16 15:16:33
Please remove duplicate "attempts to convert".
Andrew T Wilson (Slow)
2015/04/17 14:41:02
Done.
|
| + // percentage range (from 1-100) by subtracting 120 from the raw dBm value, |
|
Thiemo Nagel
2015/04/16 15:16:33
s/1-100/0-100/
s/substracting 120 from/adding 120
Andrew T Wilson (Slow)
2015/04/17 14:41:02
Done.
|
| + // and then clamping the result to the range 1-100. |
|
Thiemo Nagel
2015/04/16 15:16:33
s/1-100/0-100/
I'd suggest to include some kind o
Andrew T Wilson (Slow)
2015/04/17 14:41:02
Done.
|
| + // |
| + // To convert back to dBm, we subtract 120 from the percentage value to yield |
| + // a clamped dBm value in the range of -119 to -20dBm. |
| + // |
| + // TODO(atwilson): Tunnel the raw dBm signal strength from Shill instead of |
| + // doing the conversion here so we can report non-clamped values |
| + // (crbug.com/463334). |
| + DCHECK_GT(signal_strength, 0); |
| + DCHECK_LE(signal_strength, 100); |
| + return signal_strength - 120; |
| +} |
| + |
| void DeviceStatusCollector::GetNetworkInterfaces( |
| em::DeviceStatusReportRequest* request) { |
| // Maps shill device type strings to proto enum constants. |
| @@ -728,7 +744,12 @@ void DeviceStatusCollector::GetNetworkInterfaces( |
| // Copy fields from NetworkState into the status report. |
| em::NetworkState* proto_state = request->add_network_state(); |
| proto_state->set_connection_state(connection_state_enum); |
| - proto_state->set_signal_strength(state->signal_strength()); |
| + // If shill has provided a signal strength, convert it to dBm and store it |
|
Thiemo Nagel
2015/04/16 15:16:33
As far as I can see, this specific conversion shou
Andrew T Wilson (Slow)
2015/04/17 14:41:02
Only report this now for wifi networks.
|
| + // in the status report. |
| + if (state->signal_strength()) { |
| + proto_state->set_signal_strength( |
| + ConvertSignalStrength(state->signal_strength())); |
| + } |
| if (!state->device_path().empty()) |
| proto_state->set_device_path(state->device_path()); |