Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "shill/cellular_capability.h" |
| 6 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 7 | #include <base/bind.h> |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 8 | #include <chromeos/dbus/service_constants.h> |
| 9 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 10 | #include "shill/cellular.h" |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 11 | #include "shill/error.h" |
Darin Petkov | 9c1dcef | 2012-02-07 15:58:26 +0100 | [diff] [blame] | 12 | #include "shill/property_accessor.h" |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 13 | #include "shill/proxy_factory.h" |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 14 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 15 | using base::Bind; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 16 | using base::Callback; |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 17 | using base::Closure; |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 18 | using std::string; |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 19 | |
| 20 | namespace shill { |
| 21 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 22 | const char CellularCapability::kConnectPropertyPhoneNumber[] = "number"; |
| 23 | const char CellularCapability::kPropertyIMSI[] = "imsi"; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 24 | // All timeout values are in milliseconds |
| 25 | const int CellularCapability::kTimeoutActivate = 120000; |
| 26 | const int CellularCapability::kTimeoutConnect = 45000; |
| 27 | const int CellularCapability::kTimeoutDefault = 5000; |
| 28 | const int CellularCapability::kTimeoutEnable = 15000; |
| 29 | const int CellularCapability::kTimeoutRegister = 90000; |
| 30 | const int CellularCapability::kTimeoutScan = 120000; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 31 | |
| 32 | CellularCapability::CellularCapability(Cellular *cellular, |
| 33 | ProxyFactory *proxy_factory) |
| 34 | : allow_roaming_(false), |
Darin Petkov | 0d06f7d | 2012-02-03 13:08:19 +0100 | [diff] [blame] | 35 | scanning_supported_(false), |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 36 | cellular_(cellular), |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 37 | proxy_factory_(proxy_factory), |
| 38 | weak_ptr_factory_(this) { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 39 | PropertyStore *store = cellular->mutable_store(); |
| 40 | store->RegisterConstString(flimflam::kCarrierProperty, &carrier_); |
Darin Petkov | 9c1dcef | 2012-02-07 15:58:26 +0100 | [diff] [blame] | 41 | HelpRegisterDerivedBool(flimflam::kCellularAllowRoamingProperty, |
| 42 | &CellularCapability::GetAllowRoaming, |
| 43 | &CellularCapability::SetAllowRoaming); |
Darin Petkov | 0d06f7d | 2012-02-03 13:08:19 +0100 | [diff] [blame] | 44 | store->RegisterConstBool(flimflam::kSupportNetworkScanProperty, |
| 45 | &scanning_supported_); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 46 | store->RegisterConstString(flimflam::kEsnProperty, &esn_); |
| 47 | store->RegisterConstString(flimflam::kFirmwareRevisionProperty, |
| 48 | &firmware_revision_); |
| 49 | store->RegisterConstString(flimflam::kHardwareRevisionProperty, |
| 50 | &hardware_revision_); |
| 51 | store->RegisterConstString(flimflam::kImeiProperty, &imei_); |
| 52 | store->RegisterConstString(flimflam::kImsiProperty, &imsi_); |
| 53 | store->RegisterConstString(flimflam::kManufacturerProperty, &manufacturer_); |
| 54 | store->RegisterConstString(flimflam::kMdnProperty, &mdn_); |
| 55 | store->RegisterConstString(flimflam::kMeidProperty, &meid_); |
| 56 | store->RegisterConstString(flimflam::kMinProperty, &min_); |
| 57 | store->RegisterConstString(flimflam::kModelIDProperty, &model_id_); |
| 58 | } |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 59 | |
| 60 | CellularCapability::~CellularCapability() {} |
| 61 | |
Darin Petkov | 9c1dcef | 2012-02-07 15:58:26 +0100 | [diff] [blame] | 62 | void CellularCapability::HelpRegisterDerivedBool( |
| 63 | const string &name, |
| 64 | bool(CellularCapability::*get)(Error *error), |
| 65 | void(CellularCapability::*set)(const bool &value, Error *error)) { |
| 66 | cellular()->mutable_store()->RegisterDerivedBool( |
| 67 | name, |
| 68 | BoolAccessor( |
| 69 | new CustomAccessor<CellularCapability, bool>(this, get, set))); |
| 70 | } |
| 71 | |
| 72 | void CellularCapability::SetAllowRoaming(const bool &value, Error */*error*/) { |
| 73 | VLOG(2) << __func__ << "(" << allow_roaming_ << "->" << value << ")"; |
| 74 | if (allow_roaming_ == value) { |
| 75 | return; |
| 76 | } |
| 77 | allow_roaming_ = value; |
| 78 | if (!value && GetRoamingStateString() == flimflam::kRoamingStateRoaming) { |
| 79 | Error error; |
| 80 | cellular()->Disconnect(&error); |
| 81 | } |
| 82 | cellular()->adaptor()->EmitBoolChanged( |
| 83 | flimflam::kCellularAllowRoamingProperty, value); |
| 84 | } |
| 85 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 86 | void CellularCapability::RunNextStep(CellularTaskList *tasks) { |
| 87 | CHECK(!tasks->empty()); |
| 88 | VLOG(2) << __func__ << ": " << tasks->size() << " remaining tasks"; |
| 89 | Closure task = (*tasks)[0]; |
| 90 | tasks->erase(tasks->begin()); |
| 91 | cellular()->dispatcher()->PostTask(task); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 92 | } |
| 93 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 94 | void CellularCapability::StepCompletedCallback( |
| 95 | const ResultCallback &callback, |
| 96 | CellularTaskList *tasks, |
| 97 | const Error &error) { |
| 98 | if (error.IsSuccess() && !tasks->empty()) { |
| 99 | RunNextStep(tasks); |
| 100 | return; |
| 101 | } |
| 102 | delete tasks; |
| 103 | callback.Run(error); |
| 104 | } |
| 105 | |
| 106 | void CellularCapability::InitProxies() { |
| 107 | VLOG(2) << __func__; |
| 108 | proxy_.reset(proxy_factory()->CreateModemProxy( |
| 109 | cellular()->dbus_path(), cellular()->dbus_owner())); |
| 110 | simple_proxy_.reset(proxy_factory()->CreateModemSimpleProxy( |
| 111 | cellular()->dbus_path(), cellular()->dbus_owner())); |
| 112 | proxy_->set_state_changed_callback( |
| 113 | Bind(&CellularCapability::OnModemStateChangedSignal, |
| 114 | weak_ptr_factory_.GetWeakPtr())); |
| 115 | } |
| 116 | |
| 117 | void CellularCapability::ReleaseProxies() { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 118 | VLOG(2) << __func__; |
| 119 | proxy_.reset(); |
| 120 | simple_proxy_.reset(); |
Darin Petkov | a3d3be5 | 2011-11-14 21:34:16 +0100 | [diff] [blame] | 121 | } |
| 122 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 123 | void CellularCapability::FinishEnable(const ResultCallback &callback) { |
| 124 | callback.Run(Error()); |
| 125 | GetRegistrationState(); |
| 126 | GetSignalQuality(); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 127 | } |
| 128 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 129 | void CellularCapability::FinishDisable(const ResultCallback &callback) { |
| 130 | ReleaseProxies(); |
| 131 | callback.Run(Error()); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | void CellularCapability::OnUnsupportedOperation( |
| 135 | const char *operation, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 136 | Error *error) { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 137 | string message("The "); |
| 138 | message.append(operation).append(" operation is not supported."); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 139 | Error::PopulateAndLog(error, Error::kNotSupported, message); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 140 | } |
| 141 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 142 | // always called from an async context |
| 143 | void CellularCapability::EnableModem(const ResultCallback &callback) { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 144 | VLOG(2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 145 | CHECK(!callback.is_null()); |
| 146 | Error error; |
| 147 | proxy_->Enable(true, &error, callback, kTimeoutEnable); |
| 148 | if (error.IsFailure()) |
| 149 | callback.Run(error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 150 | } |
| 151 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 152 | // always called from an async context |
| 153 | void CellularCapability::DisableModem(const ResultCallback &callback) { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 154 | VLOG(2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 155 | CHECK(!callback.is_null()); |
| 156 | Error error; |
| 157 | proxy_->Enable(false, &error, callback, kTimeoutDefault); |
| 158 | if (error.IsFailure()) |
| 159 | callback.Run(error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 160 | } |
| 161 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 162 | // always called from an async context |
| 163 | void CellularCapability::GetModemStatus(const ResultCallback &callback) { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 164 | VLOG(2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 165 | CHECK(!callback.is_null()); |
| 166 | DBusPropertyMapCallback cb = Bind(&CellularCapability::OnGetModemStatusReply, |
| 167 | weak_ptr_factory_.GetWeakPtr(), callback); |
| 168 | Error error; |
| 169 | simple_proxy_->GetModemStatus(&error, cb, kTimeoutDefault); |
| 170 | if (error.IsFailure()) |
| 171 | callback.Run(error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 172 | } |
| 173 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 174 | // always called from an async context |
| 175 | void CellularCapability::GetModemInfo(const ResultCallback &callback) { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 176 | VLOG(2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 177 | CHECK(!callback.is_null()); |
| 178 | ModemInfoCallback cb = Bind(&CellularCapability::OnGetModemInfoReply, |
| 179 | weak_ptr_factory_.GetWeakPtr(), callback); |
| 180 | Error error; |
| 181 | proxy_->GetModemInfo(&error, cb, kTimeoutDefault); |
| 182 | if (error.IsFailure()) |
| 183 | callback.Run(error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 184 | } |
| 185 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 186 | void CellularCapability::Connect(const DBusPropertiesMap &properties, |
| 187 | Error *error, |
| 188 | const ResultCallback &callback) { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 189 | VLOG(2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 190 | ResultCallback cb = Bind(&CellularCapability::OnConnectReply, |
| 191 | weak_ptr_factory_.GetWeakPtr(), |
| 192 | callback); |
| 193 | simple_proxy_->Connect(properties, error, cb, kTimeoutConnect); |
| 194 | } |
| 195 | |
| 196 | void CellularCapability::Disconnect(Error *error, |
| 197 | const ResultCallback &callback) { |
| 198 | VLOG(2) << __func__; |
| 199 | ResultCallback cb = Bind(&CellularCapability::OnDisconnectReply, |
| 200 | weak_ptr_factory_.GetWeakPtr(), |
| 201 | callback); |
| 202 | proxy_->Disconnect(error, cb, kTimeoutDefault); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | void CellularCapability::Activate(const string &/*carrier*/, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 206 | Error *error, |
| 207 | const ResultCallback &/*callback*/) { |
| 208 | OnUnsupportedOperation(__func__, error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 209 | } |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 210 | |
| 211 | void CellularCapability::RegisterOnNetwork( |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 212 | const string &/*network_id*/, |
| 213 | Error *error, const ResultCallback &/*callback*/) { |
| 214 | OnUnsupportedOperation(__func__, error); |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 215 | } |
| 216 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 217 | void CellularCapability::RequirePIN(const std::string &/*pin*/, |
| 218 | bool /*require*/, |
| 219 | Error *error, |
| 220 | const ResultCallback &/*callback*/) { |
| 221 | OnUnsupportedOperation(__func__, error); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 222 | } |
| 223 | |
Darin Petkov | e5bc2cb | 2011-12-07 14:47:32 +0100 | [diff] [blame] | 224 | void CellularCapability::EnterPIN(const string &/*pin*/, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 225 | Error *error, |
| 226 | const ResultCallback &/*callback*/) { |
| 227 | OnUnsupportedOperation(__func__, error); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | void CellularCapability::UnblockPIN(const string &/*unblock_code*/, |
| 231 | const string &/*pin*/, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 232 | Error *error, |
| 233 | const ResultCallback &/*callback*/) { |
| 234 | OnUnsupportedOperation(__func__, error); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | void CellularCapability::ChangePIN(const string &/*old_pin*/, |
| 238 | const string &/*new_pin*/, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 239 | Error *error, |
| 240 | const ResultCallback &/*callback*/) { |
| 241 | OnUnsupportedOperation(__func__, error); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 242 | } |
| 243 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 244 | void CellularCapability::Scan(Error *error, |
| 245 | const ResultCallback &callback) { |
| 246 | OnUnsupportedOperation(__func__, error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 247 | } |
| 248 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 249 | void CellularCapability::OnGetModemStatusReply( |
| 250 | const ResultCallback &callback, |
| 251 | const DBusPropertiesMap &props, |
| 252 | const Error &error) { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 253 | VLOG(2) << __func__ << " " << props.size() << " props. error " << error; |
| 254 | if (error.IsSuccess()) { |
| 255 | DBusProperties::GetString(props, "carrier", &carrier_); |
| 256 | DBusProperties::GetString(props, "meid", &meid_); |
| 257 | DBusProperties::GetString(props, "imei", &imei_); |
| 258 | DBusProperties::GetString(props, kPropertyIMSI, &imsi_); |
| 259 | DBusProperties::GetString(props, "esn", &esn_); |
| 260 | DBusProperties::GetString(props, "mdn", &mdn_); |
| 261 | DBusProperties::GetString(props, "min", &min_); |
| 262 | DBusProperties::GetString(props, "firmware_revision", &firmware_revision_); |
| 263 | |
| 264 | uint32 state; |
| 265 | if (DBusProperties::GetUint32(props, "state", &state)) |
| 266 | cellular()->set_modem_state(static_cast<Cellular::ModemState>(state)); |
| 267 | |
| 268 | UpdateStatus(props); |
| 269 | } |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 270 | callback.Run(error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 271 | } |
| 272 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 273 | void CellularCapability::OnGetModemInfoReply( |
| 274 | const ResultCallback &callback, |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 275 | const ModemHardwareInfo &info, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 276 | const Error &error) { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 277 | VLOG(2) << __func__ << "(" << error << ")"; |
| 278 | if (error.IsSuccess()) { |
| 279 | manufacturer_ = info._1; |
| 280 | model_id_ = info._2; |
| 281 | hardware_revision_ = info._3; |
| 282 | VLOG(2) << __func__ << ": " << info._1 << ", " << info._2 << ", " |
| 283 | << info._3; |
| 284 | } |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 285 | callback.Run(error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 286 | } |
| 287 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 288 | // TODO(ers): use the supplied callback when Connect is fully asynchronous |
| 289 | void CellularCapability::OnConnectReply(const ResultCallback &callback, |
| 290 | const Error &error) { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 291 | VLOG(2) << __func__ << "(" << error << ")"; |
| 292 | if (error.IsSuccess()) |
| 293 | cellular()->OnConnected(); |
| 294 | else |
| 295 | cellular()->OnConnectFailed(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 296 | if (!callback.is_null()) |
| 297 | callback.Run(error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 298 | } |
| 299 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 300 | // TODO(ers): use the supplied callback when Disonnect is fully asynchronous |
| 301 | void CellularCapability::OnDisconnectReply(const ResultCallback &callback, |
| 302 | const Error &error) { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 303 | VLOG(2) << __func__ << "(" << error << ")"; |
| 304 | if (error.IsSuccess()) |
| 305 | cellular()->OnDisconnected(); |
| 306 | else |
| 307 | cellular()->OnDisconnectFailed(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 308 | if (!callback.is_null()) |
| 309 | callback.Run(error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 310 | } |
| 311 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 312 | void CellularCapability::OnModemStateChangedSignal( |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 313 | uint32 old_state, uint32 new_state, uint32 reason) { |
| 314 | VLOG(2) << __func__ << "(" << old_state << ", " << new_state << ", " |
| 315 | << reason << ")"; |
| 316 | // TODO(petkov): Complete this (crosbug.com/19662) |
| 317 | #if 0 |
| 318 | modem_state_ = static_cast<ModemState>(new_state); |
| 319 | if (old_state == new_state) { |
| 320 | return; |
| 321 | } |
| 322 | switch (new_state) { |
| 323 | case kModemStateEnabled: |
| 324 | if (old_state == kModemStateDisabled || |
| 325 | old_state == kModemStateEnabling) { |
| 326 | Start(); |
| 327 | } |
| 328 | // TODO(petkov): Handle the case when the state is downgraded to Enabled. |
| 329 | break; |
| 330 | default: |
| 331 | break; |
| 332 | } |
| 333 | #endif |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 334 | } |
| 335 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 336 | } // namespace shill |