| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/network/device_state.h" | 5 #include "chromeos/network/device_state.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "third_party/cros_system_api/dbus/service_constants.h" | 10 #include "third_party/cros_system_api/dbus/service_constants.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 return true; | 28 return true; |
| 29 if (key == flimflam::kAddressProperty) { | 29 if (key == flimflam::kAddressProperty) { |
| 30 return GetStringValue(key, value, &mac_address_); | 30 return GetStringValue(key, value, &mac_address_); |
| 31 } else if (key == flimflam::kScanningProperty) { | 31 } else if (key == flimflam::kScanningProperty) { |
| 32 return GetBooleanValue(key, value, &scanning_); | 32 return GetBooleanValue(key, value, &scanning_); |
| 33 } else if (key == flimflam::kSupportNetworkScanProperty) { | 33 } else if (key == flimflam::kSupportNetworkScanProperty) { |
| 34 return GetBooleanValue(key, value, &support_network_scan_); | 34 return GetBooleanValue(key, value, &support_network_scan_); |
| 35 } else if (key == shill::kProviderRequiresRoamingProperty) { | 35 } else if (key == shill::kProviderRequiresRoamingProperty) { |
| 36 return GetBooleanValue(key, value, &provider_requires_roaming_); | 36 return GetBooleanValue(key, value, &provider_requires_roaming_); |
| 37 } else if (key == flimflam::kHomeProviderProperty) { | 37 } else if (key == flimflam::kHomeProviderProperty) { |
| 38 const DictionaryValue* dict = NULL; | 38 const base::DictionaryValue* dict = NULL; |
| 39 if (!value.GetAsDictionary(&dict)) | 39 if (!value.GetAsDictionary(&dict)) |
| 40 return false; | 40 return false; |
| 41 std::string home_provider_country; | 41 std::string home_provider_country; |
| 42 std::string home_provider_name; | 42 std::string home_provider_name; |
| 43 dict->GetStringWithoutPathExpansion(flimflam::kOperatorCountryKey, | 43 dict->GetStringWithoutPathExpansion(flimflam::kOperatorCountryKey, |
| 44 &home_provider_country); | 44 &home_provider_country); |
| 45 dict->GetStringWithoutPathExpansion(flimflam::kOperatorNameKey, | 45 dict->GetStringWithoutPathExpansion(flimflam::kOperatorNameKey, |
| 46 &home_provider_name); | 46 &home_provider_name); |
| 47 // Set home_provider_id_ | 47 // Set home_provider_id_ |
| 48 if (!home_provider_name.empty() && !home_provider_country.empty()) { | 48 if (!home_provider_name.empty() && !home_provider_country.empty()) { |
| 49 home_provider_id_ = base::StringPrintf( | 49 home_provider_id_ = base::StringPrintf( |
| 50 "%s (%s)", | 50 "%s (%s)", |
| 51 home_provider_name.c_str(), | 51 home_provider_name.c_str(), |
| 52 home_provider_country.c_str()); | 52 home_provider_country.c_str()); |
| 53 } else { | 53 } else { |
| 54 dict->GetStringWithoutPathExpansion(flimflam::kOperatorCodeKey, | 54 dict->GetStringWithoutPathExpansion(flimflam::kOperatorCodeKey, |
| 55 &home_provider_id_); | 55 &home_provider_id_); |
| 56 LOG(WARNING) << "Carrier ID not defined, using code instead: " | 56 LOG(WARNING) << "Carrier ID not defined, using code instead: " |
| 57 << home_provider_id_; | 57 << home_provider_id_; |
| 58 } | 58 } |
| 59 return true; | 59 return true; |
| 60 } else if (key == flimflam::kTechnologyFamilyProperty) { | 60 } else if (key == flimflam::kTechnologyFamilyProperty) { |
| 61 return GetStringValue(key, value, &technology_family_); | 61 return GetStringValue(key, value, &technology_family_); |
| 62 } else if (key == flimflam::kSIMLockStatusProperty) { | 62 } else if (key == flimflam::kSIMLockStatusProperty) { |
| 63 const DictionaryValue* dict = NULL; | 63 const base::DictionaryValue* dict = NULL; |
| 64 if (!value.GetAsDictionary(&dict)) | 64 if (!value.GetAsDictionary(&dict)) |
| 65 return false; | 65 return false; |
| 66 if (!dict->GetStringWithoutPathExpansion(flimflam::kSIMLockTypeProperty, | 66 if (!dict->GetStringWithoutPathExpansion(flimflam::kSIMLockTypeProperty, |
| 67 &sim_lock_type_)) | 67 &sim_lock_type_)) |
| 68 return false; | 68 return false; |
| 69 // Ignore other SIMLockStatus properties. | 69 // Ignore other SIMLockStatus properties. |
| 70 return true; | 70 return true; |
| 71 } else if (key == shill::kSIMPresentProperty) { | 71 } else if (key == shill::kSIMPresentProperty) { |
| 72 return GetBooleanValue(key, value, &sim_present_); | 72 return GetBooleanValue(key, value, &sim_present_); |
| 73 } | 73 } |
| 74 return false; | 74 return false; |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool DeviceState::IsSimAbsent() const { | 77 bool DeviceState::IsSimAbsent() const { |
| 78 return technology_family_ == flimflam::kTechnologyFamilyGsm && !sim_present_; | 78 return technology_family_ == flimflam::kTechnologyFamilyGsm && !sim_present_; |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace chromeos | 81 } // namespace chromeos |
| OLD | NEW |