Commit ccdac52d authored by Steven Bennetts's avatar Steven Bennetts Committed by Chromium LUCI CQ

CrOS networking: Fix Custom APN crash

This also modernizes DeviceState.apn_list_ to use Value instead of
ListValue and removes the unused accessor.

Bug=b:176226595

Change-Id: Ida3f1eb4c12d2af39ab7cc183e40a2f66dd3acff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2640634
Auto-Submit: Steven Bennetts <stevenjb@chromium.org>
Commit-Queue: Azeem Arshad <azeemarshad@chromium.org>
Reviewed-by: default avatarAzeem Arshad <azeemarshad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845203}
parent 4c0a560c
......@@ -105,7 +105,7 @@ bool DeviceState::PropertyChanged(const std::string& key,
} else if (key == shill::kCellularApnListProperty) {
if (!value.is_list())
return false;
apn_list_ = base::ListValue(value.Clone().TakeList());
apn_list_ = value.Clone();
return true;
} else if (key == shill::kInhibitedProperty) {
return GetBooleanValue(key, value, &inhibited_);
......
......@@ -52,7 +52,6 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) DeviceState : public ManagedState {
const std::string& imei() const { return imei_; }
const std::string& iccid() const { return iccid_; }
const std::string& mdn() const { return mdn_; }
const base::ListValue& apn_list() const { return apn_list_; }
const CellularScanResults& scan_results() const { return scan_results_; }
bool inhibited() const { return inhibited_; }
......@@ -130,7 +129,7 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) DeviceState : public ManagedState {
base::DictionaryValue properties_;
// List of APNs.
base::ListValue apn_list_;
base::Value apn_list_;
// Dictionary of IPConfig properties, keyed by IpConfig path.
base::DictionaryValue ip_configs_;
......
......@@ -2386,10 +2386,14 @@ void CrosNetworkConfig::UpdateCustomAPNList(
if (!cellular_config.apn) {
return;
}
const DeviceState* device =
network_state_handler_->GetDeviceState(network->device_path());
DCHECK(device);
if (!device) {
// Unexpected, but see note in NetworkStateToMojo.
NET_LOG(DEBUG) << "Cellular device is not available for APN list: "
<< network->device_path();
return;
}
// Do not update custom APN list if APN is in device APN list.
if (device->HasAPN(cellular_config.apn->access_point_name)) {
return;
......
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