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/stringprintf.h" | 8 #include "base/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" |
11 | 11 |
12 namespace chromeos { | 12 namespace chromeos { |
13 | 13 |
14 DeviceState::DeviceState(const std::string& path) | 14 DeviceState::DeviceState(const std::string& path) |
15 : ManagedState(MANAGED_TYPE_DEVICE, path), | 15 : ManagedState(MANAGED_TYPE_DEVICE, path), |
16 provider_requires_roaming_(false), | 16 provider_requires_roaming_(false), |
17 support_network_scan_(false), | 17 support_network_scan_(false), |
18 scanning_(false) { | 18 scanning_(false), |
| 19 sim_present_(true) { |
19 } | 20 } |
20 | 21 |
21 DeviceState::~DeviceState() { | 22 DeviceState::~DeviceState() { |
22 } | 23 } |
23 | 24 |
24 bool DeviceState::PropertyChanged(const std::string& key, | 25 bool DeviceState::PropertyChanged(const std::string& key, |
25 const base::Value& value) { | 26 const base::Value& value) { |
26 if (ManagedStatePropertyChanged(key, value)) | 27 if (ManagedStatePropertyChanged(key, value)) |
27 return true; | 28 return true; |
28 if (key == flimflam::kAddressProperty) { | 29 if (key == flimflam::kAddressProperty) { |
(...skipping 20 matching lines...) Expand all Loading... |
49 "%s (%s)", | 50 "%s (%s)", |
50 home_provider_name.c_str(), | 51 home_provider_name.c_str(), |
51 home_provider_country.c_str()); | 52 home_provider_country.c_str()); |
52 } else { | 53 } else { |
53 dict->GetStringWithoutPathExpansion(flimflam::kOperatorCodeKey, | 54 dict->GetStringWithoutPathExpansion(flimflam::kOperatorCodeKey, |
54 &home_provider_id_); | 55 &home_provider_id_); |
55 LOG(WARNING) << "Carrier ID not defined, using code instead: " | 56 LOG(WARNING) << "Carrier ID not defined, using code instead: " |
56 << home_provider_id_; | 57 << home_provider_id_; |
57 } | 58 } |
58 return true; | 59 return true; |
| 60 } else if (key == flimflam::kTechnologyFamilyProperty) { |
| 61 return GetStringValue(key, value, &technology_family_); |
| 62 } else if (key == flimflam::kSIMLockStatusProperty) { |
| 63 const DictionaryValue* dict = NULL; |
| 64 if (!value.GetAsDictionary(&dict)) |
| 65 return false; |
| 66 if (!dict->GetStringWithoutPathExpansion(flimflam::kSIMLockTypeProperty, |
| 67 &sim_lock_type_)) |
| 68 return false; |
| 69 // Ignore other SIMLockStatus properties. |
| 70 return true; |
| 71 } else if (key == shill::kSIMPresentProperty) { |
| 72 return GetBooleanValue(key, value, &sim_present_); |
59 } | 73 } |
60 return false; | 74 return false; |
61 } | 75 } |
62 | 76 |
| 77 bool DeviceState::IsSimAbsent() const { |
| 78 return technology_family_ == flimflam::kTechnologyFamilyGsm && !sim_present_; |
| 79 } |
| 80 |
63 } // namespace chromeos | 81 } // namespace chromeos |
OLD | NEW |