diff options
Diffstat (limited to 'chromeos/network')
-rw-r--r-- | chromeos/network/device_state.cc | 45 | ||||
-rw-r--r-- | chromeos/network/device_state.h | 2 | ||||
-rw-r--r-- | chromeos/network/network_device_handler_unittest.cc | 20 |
3 files changed, 26 insertions, 41 deletions
diff --git a/chromeos/network/device_state.cc b/chromeos/network/device_state.cc index a59d4cd..d736e16 100644 --- a/chromeos/network/device_state.cc +++ b/chromeos/network/device_state.cc @@ -20,7 +20,6 @@ DeviceState::DeviceState(const std::string& path) support_network_scan_(false), scanning_(false), sim_retries_left_(0), - sim_lock_enabled_(false), sim_present_(true), eap_authentication_completed_(false) { } @@ -53,7 +52,7 @@ bool DeviceState::PropertyChanged(const std::string& key, } else if (key == shill::kCarrierProperty) { return GetStringValue(key, value, &carrier_); } else if (key == shill::kFoundNetworksProperty) { - const base::ListValue* list = NULL; + const base::ListValue* list = nullptr; if (!value.GetAsList(&list)) return false; CellularScanResults parsed_results; @@ -62,35 +61,25 @@ bool DeviceState::PropertyChanged(const std::string& key, scan_results_.swap(parsed_results); return true; } else if (key == shill::kSIMLockStatusProperty) { - const base::DictionaryValue* dict = NULL; + const base::DictionaryValue* dict = nullptr; if (!value.GetAsDictionary(&dict)) return false; - // Return true if at least one of the property values changed. - bool property_changed = false; - const base::Value* out_value = NULL; - if (!dict->GetWithoutPathExpansion(shill::kSIMLockRetriesLeftProperty, - &out_value)) - return false; - if (GetUInt32Value(shill::kSIMLockRetriesLeftProperty, - *out_value, &sim_retries_left_)) - property_changed = true; - - if (!dict->GetWithoutPathExpansion(shill::kSIMLockTypeProperty, - &out_value)) - return false; - if (GetStringValue(shill::kSIMLockTypeProperty, - *out_value, &sim_lock_type_)) - property_changed = true; + // Set default values for SIM properties. + sim_lock_type_.erase(); + sim_retries_left_ = 0; - if (!dict->GetWithoutPathExpansion(shill::kSIMLockEnabledProperty, - &out_value)) - return false; - if (GetBooleanValue(shill::kSIMLockEnabledProperty, - *out_value, &sim_lock_enabled_)) - property_changed = true; - - return property_changed; + const base::Value* out_value = nullptr; + if (dict->GetWithoutPathExpansion(shill::kSIMLockTypeProperty, + &out_value)) { + GetStringValue(shill::kSIMLockTypeProperty, *out_value, &sim_lock_type_); + } + if (dict->GetWithoutPathExpansion(shill::kSIMLockRetriesLeftProperty, + &out_value)) { + GetUInt32Value(shill::kSIMLockRetriesLeftProperty, *out_value, + &sim_retries_left_); + } + return true; } else if (key == shill::kMeidProperty) { return GetStringValue(key, value, &meid_); } else if (key == shill::kImeiProperty) { @@ -126,7 +115,7 @@ bool DeviceState::InitialPropertiesReceived( void DeviceState::IPConfigPropertiesChanged( const std::string& ip_config_path, const base::DictionaryValue& properties) { - base::DictionaryValue* ip_config = NULL; + base::DictionaryValue* ip_config = nullptr; if (ip_configs_.GetDictionaryWithoutPathExpansion( ip_config_path, &ip_config)) { NET_LOG_EVENT("IPConfig Updated: " + ip_config_path, path()); diff --git a/chromeos/network/device_state.h b/chromeos/network/device_state.h index b09d63e..6542ff7 100644 --- a/chromeos/network/device_state.h +++ b/chromeos/network/device_state.h @@ -42,7 +42,6 @@ class CHROMEOS_EXPORT DeviceState : public ManagedState { const std::string& carrier() const { return carrier_; } const std::string& sim_lock_type() const { return sim_lock_type_; } uint32 sim_retries_left() const { return sim_retries_left_; } - bool sim_lock_enabled() const { return sim_lock_enabled_; } const std::string& meid() const { return meid_; } const std::string& imei() const { return imei_; } const std::string& iccid() const { return iccid_; } @@ -78,7 +77,6 @@ class CHROMEOS_EXPORT DeviceState : public ManagedState { std::string carrier_; std::string sim_lock_type_; uint32 sim_retries_left_; - bool sim_lock_enabled_; bool sim_present_; std::string meid_; std::string imei_; diff --git a/chromeos/network/network_device_handler_unittest.cc b/chromeos/network/network_device_handler_unittest.cc index 1da3397..38e078b 100644 --- a/chromeos/network/network_device_handler_unittest.cc +++ b/chromeos/network/network_device_handler_unittest.cc @@ -374,26 +374,24 @@ TEST_F(NetworkDeviceHandlerTest, UnblockPin) { } TEST_F(NetworkDeviceHandlerTest, ChangePin) { - const char kOldPin[] = "4321"; const char kNewPin[] = "1234"; + const char kIncorrectPin[] = "9999"; + + fake_device_client_->SetSimLocked(kDefaultCellularDevicePath, true); // Test that the success callback gets called. - network_device_handler_->ChangePin(kDefaultCellularDevicePath, - kOldPin, - kNewPin, - success_callback_, - error_callback_); + network_device_handler_->ChangePin( + kDefaultCellularDevicePath, FakeShillDeviceClient::kDefaultSimPin, + kNewPin, success_callback_, error_callback_); message_loop_.RunUntilIdle(); EXPECT_EQ(kResultSuccess, result_); // Test that the shill error propagates to the error callback. - network_device_handler_->ChangePin(kUnknownCellularDevicePath, - kOldPin, - kNewPin, - success_callback_, + network_device_handler_->ChangePin(kDefaultCellularDevicePath, kIncorrectPin, + kNewPin, success_callback_, error_callback_); message_loop_.RunUntilIdle(); - EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); + EXPECT_EQ(NetworkDeviceHandler::kErrorIncorrectPin, result_); } } // namespace chromeos |