diff options
author | stevenjb <stevenjb@chromium.org> | 2015-07-31 14:35:47 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-31 21:36:22 +0000 |
commit | 35dcf626841a5dfe68c68eae2967d7e246b775c4 (patch) | |
tree | 5a168caafdb5c6a40d733cc900ff68d864800d08 /chromeos/network | |
parent | 87092eedf1099e94edc6ec0e0247b3eed3fc3aee (diff) | |
download | chromium_src-35dcf626841a5dfe68c68eae2967d7e246b775c4.zip chromium_src-35dcf626841a5dfe68c68eae2967d7e246b775c4.tar.gz chromium_src-35dcf626841a5dfe68c68eae2967d7e246b775c4.tar.bz2 |
Implement networkingPrivate.unlockCellularSim and setCelluarSimState
This adds Cellular SIM functionality to the networkingPrivate API.
It also adds some functionality to the fake implementation to
better support testing.
BUG=277890
Review URL: https://codereview.chromium.org/1265513004
Cr-Commit-Position: refs/heads/master@{#341415}
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 |