blob: 67d76d6378ddb7542b1450fff5f8090adbadc4c9 [file] [log] [blame]
Arman Uguray72fab6a2013-01-10 19:32:42 -08001// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
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_universal_cdma.h"
6
7#include <chromeos/dbus/service_constants.h>
8#include <base/stringprintf.h>
9#include <base/string_number_conversions.h>
10#include <base/string_util.h>
11
12#include "shill/cellular_operator_info.h"
13#include "shill/dbus_properties_proxy_interface.h"
Arman Uguray0a3e2792013-01-17 16:31:50 -080014#include "shill/error.h"
Arman Uguray72fab6a2013-01-10 19:32:42 -080015#include "shill/logging.h"
Arman Uguray0a3e2792013-01-17 16:31:50 -080016#include "shill/pending_activation_store.h"
Arman Uguray72fab6a2013-01-10 19:32:42 -080017#include "shill/proxy_factory.h"
18
19#ifdef MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN
20#error "Do not include mm-modem.h"
21#endif
22
23using base::UintToString;
24
25using std::string;
26using std::vector;
27
28namespace shill {
29
30namespace {
31
Arman Ugurayc9673062013-05-13 21:21:53 -070032const char kPhoneNumber[] = "#777";
33const char kPropertyConnectNumber[] = "number";
34
Arman Uguray72fab6a2013-01-10 19:32:42 -080035string FormattedSID(const string &sid) {
36 return "[SID=" + sid + "]";
37}
38
39} // namespace
40
41// static
42unsigned int
43CellularCapabilityUniversalCDMA::friendly_service_name_id_cdma_ = 0;
44
45CellularCapabilityUniversalCDMA::CellularCapabilityUniversalCDMA(
46 Cellular *cellular,
47 ProxyFactory *proxy_factory,
48 ModemInfo *modem_info)
49 : CellularCapabilityUniversal(cellular,
50 proxy_factory,
51 modem_info),
Arman Uguray0a3e2792013-01-17 16:31:50 -080052 weak_cdma_ptr_factory_(this),
53 activation_state_(MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED),
Arman Uguray72fab6a2013-01-10 19:32:42 -080054 cdma_1x_registration_state_(MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN),
55 cdma_evdo_registration_state_(MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN),
56 nid_(0),
57 sid_(0) {
58 SLOG(Cellular, 2) << "Cellular capability constructed: Universal CDMA";
Arman Uguray0a3e2792013-01-17 16:31:50 -080059 // TODO(armansito): Update PRL for activation over cellular.
Arman Uguray72fab6a2013-01-10 19:32:42 -080060 // See crbug.com/197330.
61}
62
63void CellularCapabilityUniversalCDMA::InitProxies() {
64 SLOG(Cellular, 2) << __func__;
65 modem_cdma_proxy_.reset(
66 proxy_factory()->CreateMM1ModemModemCdmaProxy(cellular()->dbus_path(),
67 cellular()->dbus_owner()));
Arman Uguray0a3e2792013-01-17 16:31:50 -080068 modem_cdma_proxy_->set_activation_state_callback(
69 Bind(&CellularCapabilityUniversalCDMA::OnActivationStateChangedSignal,
70 weak_cdma_ptr_factory_.GetWeakPtr()));
Arman Uguray72fab6a2013-01-10 19:32:42 -080071 CellularCapabilityUniversal::InitProxies();
72}
73
74void CellularCapabilityUniversalCDMA::ReleaseProxies() {
75 SLOG(Cellular, 2) << __func__;
76 modem_cdma_proxy_.reset();
77 CellularCapabilityUniversal::ReleaseProxies();
78}
79
80void CellularCapabilityUniversalCDMA::Activate(
81 const string &carrier,
82 Error *error,
83 const ResultCallback &callback) {
Arman Uguray0a3e2792013-01-17 16:31:50 -080084 // Currently activation over the cellular network is not supported using
85 // ModemManager-next. Service activation is currently carried through over
86 // non-cellular networks and only the final step of the OTA activation
87 // procedure ("automatic activation") is performed by this class.
Arman Uguray72fab6a2013-01-10 19:32:42 -080088 OnUnsupportedOperation(__func__, error);
89}
90
91void CellularCapabilityUniversalCDMA::CompleteActivation(Error *error) {
Arman Uguray0a3e2792013-01-17 16:31:50 -080092 SLOG(Cellular, 2) << __func__;
93 if (cellular()->state() < Cellular::kStateEnabled) {
94 Error::PopulateAndLog(error, Error::kInvalidArguments,
95 "Unable to activate in state " +
96 Cellular::GetStateString(cellular()->state()));
97 return;
98 }
99 ActivateAutomatic();
Arman Uguray72fab6a2013-01-10 19:32:42 -0800100}
101
Arman Uguray0a3e2792013-01-17 16:31:50 -0800102void CellularCapabilityUniversalCDMA::ActivateAutomatic() {
103 if (activation_code_.empty()) {
104 SLOG(Cellular, 2) << "OTA activation cannot be run in the presence of no "
105 << "activation code.";
106 return;
107 }
108 PendingActivationStore::State state =
109 modem_info()->pending_activation_store()->GetActivationState(
110 PendingActivationStore::kIdentifierMEID, meid());
111 if (state == PendingActivationStore::kStatePending) {
112 SLOG(Cellular, 2) << "There's already a pending activation. Ignoring.";
113 return;
114 }
115 if (state == PendingActivationStore::kStateActivated) {
116 SLOG(Cellular, 2) << "A call to OTA activation has already completed "
117 << "successfully. Ignoring.";
118 return;
119 }
120
121 // Mark as pending activation, so that shill can recover if anything fails
122 // during OTA activation.
123 modem_info()->pending_activation_store()->SetActivationState(
124 PendingActivationStore::kIdentifierMEID,
125 meid(),
126 PendingActivationStore::kStatePending);
127
128 // Initiate OTA activation.
129 ResultCallback activation_callback =
130 Bind(&CellularCapabilityUniversalCDMA::OnActivateReply,
131 weak_cdma_ptr_factory_.GetWeakPtr(),
132 ResultCallback());
133 // TODO(armansito): Read the activation code from CellularOperatorInfo
134 Error error;
135 modem_cdma_proxy_->Activate(
136 activation_code_, &error, activation_callback, kTimeoutActivate);
137}
138
139void CellularCapabilityUniversalCDMA::UpdatePendingActivationState() {
Arman Uguray72fab6a2013-01-10 19:32:42 -0800140 SLOG(Cellular, 2) << __func__;
Arman Uguray0a3e2792013-01-17 16:31:50 -0800141 if (IsActivated()) {
142 SLOG(Cellular, 3) << "CDMA service activated. Clear store.";
143 modem_info()->pending_activation_store()->RemoveEntry(
144 PendingActivationStore::kIdentifierMEID, meid());
145 return;
146 }
147 PendingActivationStore::State state =
148 modem_info()->pending_activation_store()->GetActivationState(
149 PendingActivationStore::kIdentifierMEID, meid());
150 if (IsActivating() && state != PendingActivationStore::kStateFailureRetry) {
151 SLOG(Cellular, 3) << "OTA activation in progress. Nothing to do.";
152 return;
153 }
154 switch (state) {
155 case PendingActivationStore::kStateFailureRetry:
156 SLOG(Cellular, 3) << "OTA activation failed. Scheduling a retry.";
157 cellular()->dispatcher()->PostTask(
158 Bind(&CellularCapabilityUniversalCDMA::ActivateAutomatic,
159 weak_cdma_ptr_factory_.GetWeakPtr()));
160 break;
161 case PendingActivationStore::kStateActivated:
162 SLOG(Cellular, 3) << "OTA Activation has completed successfully. "
163 << "Waiting for activation state update to finalize.";
164 break;
165 default:
166 break;
167 }
168}
169
170bool CellularCapabilityUniversalCDMA::IsServiceActivationRequired() const {
171 // If there is no online payment portal information, it's safer to assume
172 // the service does not require activation.
173 if (!modem_info()->cellular_operator_info())
174 return false;
175
176 const CellularService::OLP *olp =
177 modem_info()->cellular_operator_info()->GetOLPBySID(UintToString(sid_));
178 if (!olp)
179 return false;
180
181 // We could also use the MDN to determine whether or not the service is
182 // activated, however, the CDMA ActivatonState property is a more absolute
183 // and fine-grained indicator of activation status.
184 return (activation_state_ == MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED);
185}
186
187bool CellularCapabilityUniversalCDMA::IsActivated() const {
188 return (activation_state_ == MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATED);
Arman Uguray72fab6a2013-01-10 19:32:42 -0800189}
190
191void CellularCapabilityUniversalCDMA::OnServiceCreated() {
192 SLOG(Cellular, 2) << __func__;
193 // TODO (armansito): Set storage identifier here based on the superclass
194 // implementation.
Arman Uguray0a3e2792013-01-17 16:31:50 -0800195 UpdateServiceActivationStateProperty();
Arman Uguray72fab6a2013-01-10 19:32:42 -0800196 UpdateServingOperator();
Arman Uguray0a3e2792013-01-17 16:31:50 -0800197 HandleNewActivationStatus(MM_CDMA_ACTIVATION_ERROR_NONE);
198 UpdatePendingActivationState();
Arman Uguray72fab6a2013-01-10 19:32:42 -0800199 UpdateOLP();
200}
201
Arman Uguray0a3e2792013-01-17 16:31:50 -0800202void CellularCapabilityUniversalCDMA::UpdateServiceActivationStateProperty() {
203 bool activation_required = IsServiceActivationRequired();
204 cellular()->service()->SetActivateOverNonCellularNetwork(activation_required);
205 string activation_state;
206 if (IsActivating())
207 activation_state = flimflam::kActivationStateActivating;
208 else if (activation_required)
209 activation_state = flimflam::kActivationStateNotActivated;
210 else
211 activation_state = flimflam::kActivationStateActivated;
212 cellular()->service()->SetActivationState(activation_state);
213}
214
Arman Uguray72fab6a2013-01-10 19:32:42 -0800215void CellularCapabilityUniversalCDMA::UpdateOLP() {
216 SLOG(Cellular,2) << __func__;
217 if (!modem_info()->cellular_operator_info())
218 return;
219
220 const CellularService::OLP *result =
221 modem_info()->cellular_operator_info()->GetOLPBySID(
222 UintToString(sid_));
223 if (!result)
224 return;
225
226 CellularService::OLP olp;
227 olp.CopyFrom(*result);
228 string post_data = olp.GetPostData();
229 ReplaceSubstringsAfterOffset(&post_data, 0, "${esn}", esn());
230 ReplaceSubstringsAfterOffset(&post_data, 0, "${mdn}", mdn());
231 ReplaceSubstringsAfterOffset(&post_data, 0, "${meid}", meid());
232 olp.SetPostData(post_data);
Arman Uguray0a3e2792013-01-17 16:31:50 -0800233 if (cellular()->service().get())
234 cellular()->service()->SetOLP(olp);
Arman Uguray72fab6a2013-01-10 19:32:42 -0800235}
236
237void CellularCapabilityUniversalCDMA::GetProperties() {
238 SLOG(Cellular, 2) << __func__;
239 CellularCapabilityUniversal::GetProperties();
240
241 scoped_ptr<DBusPropertiesProxyInterface> properties_proxy(
242 proxy_factory()->CreateDBusPropertiesProxy(cellular()->dbus_path(),
243 cellular()->dbus_owner()));
244 DBusPropertiesMap properties(
245 properties_proxy->GetAll(MM_DBUS_INTERFACE_MODEM_MODEMCDMA));
246 OnModemCDMAPropertiesChanged(properties, vector<string>());
247}
248
249string CellularCapabilityUniversalCDMA::CreateFriendlyServiceName() {
250 SLOG(Cellular, 2) << __func__ << ": " << GetRoamingStateString();
251
252 if (provider_.GetCode().empty()) {
253 UpdateOperatorInfo();
254 }
255
256 string name = provider_.GetName();
257 if (!name.empty()) {
258 // TODO(armansito): We may need to show the provider name in a
259 // specific way if roaming.
260 return name;
261 }
262
263 string code = provider_.GetCode();
264 if (!code.empty()) {
265 return "cellular_sid_" + code;
266 }
267
268 return base::StringPrintf("CDMANetwork%u", friendly_service_name_id_cdma_++);
269}
270
271void CellularCapabilityUniversalCDMA::UpdateOperatorInfo() {
272 SLOG(Cellular, 2) << __func__;
273
274 if (sid_ == 0 || !modem_info()->cellular_operator_info()) {
275 SLOG(Cellular, 2) << "No provider is currently available.";
276 provider_.SetCode("");
277 return;
278 }
279
280 string sid = UintToString(sid_);
281 const CellularOperatorInfo::CellularOperator *provider =
282 modem_info()->cellular_operator_info()->GetCellularOperatorBySID(sid);
283 if (!provider) {
284 SLOG(Cellular, 2) << "CDMA provider with "
285 << FormattedSID(sid)
286 << " not found.";
287 return;
288 }
289
290 if (!provider->name_list().empty()) {
291 provider_.SetName(provider->name_list()[0].name);
292 }
293 provider_.SetCode(sid);
294 provider_.SetCountry(provider->country());
295
Arman Uguray0a3e2792013-01-17 16:31:50 -0800296 activation_code_ = provider->activation_code();
297
Arman Uguray72fab6a2013-01-10 19:32:42 -0800298 // TODO(armansito): The CDMA interface only returns information about the
299 // current serving carrier, so for now both the home provider and the
300 // serving operator will be the same in case of roaming. We should figure
301 // out if there is a way to (and whether or not it is necessary to)
302 // determine if we're roaming.
303 cellular()->set_home_provider(provider_);
304
305 UpdateServingOperator();
306}
307
308void CellularCapabilityUniversalCDMA::UpdateServingOperator() {
309 SLOG(Cellular, 2) << __func__;
310 if (cellular()->service().get()) {
311 cellular()->service()->SetServingOperator(cellular()->home_provider());
312 }
313}
314
Arman Uguray0a3e2792013-01-17 16:31:50 -0800315void CellularCapabilityUniversalCDMA::OnActivationStateChangedSignal(
316 uint32 activation_state,
317 uint32 activation_error,
318 const DBusPropertiesMap &status_changes) {
319 SLOG(Cellular, 2) << __func__;
320
321 activation_state_ =
322 static_cast<MMModemCdmaActivationState>(activation_state);
323
324 string value;
325 if (DBusProperties::GetString(status_changes, "mdn", &value))
326 set_mdn(value);
327 if (DBusProperties::GetString(status_changes, "min", &value))
328 set_min(value);
329
330 SLOG(Cellular, 2) << "Activation state: "
331 << GetActivationStateString(activation_state_);
332
333 HandleNewActivationStatus(activation_error);
334 UpdatePendingActivationState();
335}
336
337void CellularCapabilityUniversalCDMA::OnActivateReply(
338 const ResultCallback &callback,
339 const Error &error) {
340 SLOG(Cellular, 2) << __func__;
341 if (error.IsSuccess()) {
342 LOG(INFO) << "Activation completed successfully.";
343 modem_info()->pending_activation_store()->SetActivationState(
344 PendingActivationStore::kIdentifierMEID,
345 meid(),
346 PendingActivationStore::kStateActivated);
347 } else {
348 LOG(ERROR) << "Activation failed with error: " << error;
349 modem_info()->pending_activation_store()->SetActivationState(
350 PendingActivationStore::kIdentifierMEID,
351 meid(),
352 PendingActivationStore::kStateFailureRetry);
353 }
354 UpdatePendingActivationState();
355 callback.Run(error);
356}
357
358void CellularCapabilityUniversalCDMA::HandleNewActivationStatus(uint32 error) {
359 SLOG(Cellular, 2) << __func__ << "(" << error << ")";
360 if (!cellular()->service().get()) {
361 LOG(ERROR) << "In " << __func__ << "(): service is null.";
362 return;
363 }
364 SLOG(Cellular, 2) << "Activation State: " << activation_state_;
365 cellular()->service()->SetActivationState(
366 GetActivationStateString(activation_state_));
367 cellular()->service()->set_error(GetActivationErrorString(error));
368 UpdateOLP();
369}
370
371// static
372string CellularCapabilityUniversalCDMA::GetActivationStateString(
373 uint32 state) {
374 switch (state) {
375 case MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATED:
376 return flimflam::kActivationStateActivated;
377 case MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATING:
378 return flimflam::kActivationStateActivating;
379 case MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED:
380 return flimflam::kActivationStateNotActivated;
381 case MM_MODEM_CDMA_ACTIVATION_STATE_PARTIALLY_ACTIVATED:
382 return flimflam::kActivationStatePartiallyActivated;
383 default:
384 return flimflam::kActivationStateUnknown;
385 }
386}
387
388// static
389string CellularCapabilityUniversalCDMA::GetActivationErrorString(
390 uint32 error) {
391 switch (error) {
392 case MM_CDMA_ACTIVATION_ERROR_WRONG_RADIO_INTERFACE:
393 return flimflam::kErrorNeedEvdo;
394 case MM_CDMA_ACTIVATION_ERROR_ROAMING:
395 return flimflam::kErrorNeedHomeNetwork;
396 case MM_CDMA_ACTIVATION_ERROR_COULD_NOT_CONNECT:
397 case MM_CDMA_ACTIVATION_ERROR_SECURITY_AUTHENTICATION_FAILED:
398 case MM_CDMA_ACTIVATION_ERROR_PROVISIONING_FAILED:
399 return flimflam::kErrorOtaspFailed;
400 case MM_CDMA_ACTIVATION_ERROR_NONE:
401 return "";
402 case MM_CDMA_ACTIVATION_ERROR_NO_SIGNAL:
403 default:
404 return flimflam::kErrorActivationFailed;
405 }
406}
407
Arman Uguray72fab6a2013-01-10 19:32:42 -0800408void CellularCapabilityUniversalCDMA::Register(const ResultCallback &callback) {
409 // TODO(armansito): Remove once 3GPP is implemented in its own class.
410}
411
412void CellularCapabilityUniversalCDMA::RegisterOnNetwork(
413 const string &network_id,
414 Error *error,
415 const ResultCallback &callback) {
416 // TODO(armansito): Remove once 3GPP is implemented in its own class.
417}
418
Arman Uguray0a3e2792013-01-17 16:31:50 -0800419bool CellularCapabilityUniversalCDMA::IsActivating() const {
420 PendingActivationStore::State state =
421 modem_info()->pending_activation_store()->GetActivationState(
422 PendingActivationStore::kIdentifierMEID, meid());
423 return (state == PendingActivationStore::kStatePending) ||
424 (state == PendingActivationStore::kStateFailureRetry) ||
425 (activation_state_ == MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATING);
426}
427
Arman Uguray72fab6a2013-01-10 19:32:42 -0800428bool CellularCapabilityUniversalCDMA::IsRegistered() {
429 return (cdma_1x_registration_state_ ==
430 MM_MODEM_CDMA_REGISTRATION_STATE_HOME ||
431 cdma_1x_registration_state_ ==
432 MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING ||
433 cdma_evdo_registration_state_ ==
434 MM_MODEM_CDMA_REGISTRATION_STATE_HOME ||
435 cdma_evdo_registration_state_ ==
436 MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING);
437}
438
439void CellularCapabilityUniversalCDMA::SetUnregistered(bool /*searching*/) {
440 cdma_1x_registration_state_ = MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN;
441 cdma_evdo_registration_state_ = MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN;
442}
443
Arman Ugurayc9673062013-05-13 21:21:53 -0700444void CellularCapabilityUniversalCDMA::SetupConnectProperties(
445 DBusPropertiesMap *properties) {
446 (*properties)[kPropertyConnectNumber].writer().append_string(
447 kPhoneNumber);
448}
449
Arman Uguray72fab6a2013-01-10 19:32:42 -0800450void CellularCapabilityUniversalCDMA::RequirePIN(
451 const string &pin, bool require,
452 Error *error, const ResultCallback &callback) {
453 // TODO(armansito): Remove once 3GPP is implemented in its own class.
454}
455
456void CellularCapabilityUniversalCDMA::EnterPIN(
457 const string &pin,
458 Error *error,
459 const ResultCallback &callback) {
460 // TODO(armansito): Remove once 3GPP is implemented in its own class.
461}
462
463void CellularCapabilityUniversalCDMA::UnblockPIN(
464 const string &unblock_code,
465 const string &pin,
466 Error *error,
467 const ResultCallback &callback) {
468 // TODO(armansito): Remove once 3GPP is implemented in its own class.
469}
470
471void CellularCapabilityUniversalCDMA::ChangePIN(
472 const string &old_pin, const string &new_pin,
473 Error *error, const ResultCallback &callback) {
474 // TODO(armansito): Remove once 3GPP is implemented in its own class.
475}
476
477void CellularCapabilityUniversalCDMA::Scan(Error *error,
478 const ResultCallback &callback) {
479 // TODO(armansito): Remove once 3GPP is implemented in its own class.
480}
481
482void CellularCapabilityUniversalCDMA::OnSimPathChanged(
483 const string &sim_path) {
484 // TODO(armansito): Remove once 3GPP is implemented in its own class.
485}
486
487string CellularCapabilityUniversalCDMA::GetRoamingStateString() const {
488 uint32 state = cdma_evdo_registration_state_;
489 if (state == MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) {
490 state = cdma_1x_registration_state_;
491 }
492 switch (state) {
493 case MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN:
494 case MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED:
495 break;
496 case MM_MODEM_CDMA_REGISTRATION_STATE_HOME:
497 return flimflam::kRoamingStateHome;
498 case MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING:
499 return flimflam::kRoamingStateRoaming;
500 default:
501 NOTREACHED();
502 }
503 return flimflam::kRoamingStateUnknown;
504}
505
506void CellularCapabilityUniversalCDMA::OnDBusPropertiesChanged(
507 const string &interface,
508 const DBusPropertiesMap &changed_properties,
509 const vector<string> &invalidated_properties) {
510 SLOG(Cellular, 2) << __func__ << "(" << interface << ")";
511 if (interface == MM_DBUS_INTERFACE_MODEM_MODEMCDMA) {
512 OnModemCDMAPropertiesChanged(changed_properties, invalidated_properties);
513 } else {
514 CellularCapabilityUniversal::OnDBusPropertiesChanged(
515 interface, changed_properties, invalidated_properties);
516 }
517}
518
519void CellularCapabilityUniversalCDMA::OnModemCDMAPropertiesChanged(
520 const DBusPropertiesMap &properties,
521 const std::vector<std::string> &/*invalidated_properties*/) {
522 SLOG(Cellular, 2) << __func__;
523 string str_value;
524 if (DBusProperties::GetString(properties,
525 MM_MODEM_MODEMCDMA_PROPERTY_MEID,
526 &str_value))
527 set_meid(str_value);
528 if (DBusProperties::GetString(properties,
529 MM_MODEM_MODEMCDMA_PROPERTY_ESN,
530 &str_value))
531 set_esn(str_value);
532
533 uint32_t sid = sid_;
534 uint32_t nid = nid_;
535 MMModemCdmaRegistrationState state_1x = cdma_1x_registration_state_;
536 MMModemCdmaRegistrationState state_evdo = cdma_evdo_registration_state_;
537 bool registration_changed = false;
538 uint32_t uint_value;
539 if (DBusProperties::GetUint32(
540 properties,
541 MM_MODEM_MODEMCDMA_PROPERTY_CDMA1XREGISTRATIONSTATE,
542 &uint_value)) {
543 state_1x = static_cast<MMModemCdmaRegistrationState>(uint_value);
544 registration_changed = true;
545 }
546 if (DBusProperties::GetUint32(
547 properties,
548 MM_MODEM_MODEMCDMA_PROPERTY_EVDOREGISTRATIONSTATE,
549 &uint_value)) {
550 state_evdo = static_cast<MMModemCdmaRegistrationState>(uint_value);
551 registration_changed = true;
552 }
553 if (DBusProperties::GetUint32(
554 properties,
555 MM_MODEM_MODEMCDMA_PROPERTY_SID,
556 &uint_value)) {
557 sid = uint_value;
558 registration_changed = true;
559 }
560 if (DBusProperties::GetUint32(
561 properties,
562 MM_MODEM_MODEMCDMA_PROPERTY_NID,
563 &uint_value)) {
564 nid = uint_value;
565 registration_changed = true;
566 }
Arman Uguray0a3e2792013-01-17 16:31:50 -0800567 if (DBusProperties::GetUint32(
568 properties,
569 MM_MODEM_MODEMCDMA_PROPERTY_ACTIVATIONSTATE,
570 &uint_value)) {
571 activation_state_ = static_cast<MMModemCdmaActivationState>(uint_value);
572 HandleNewActivationStatus(MM_CDMA_ACTIVATION_ERROR_NONE);
573 }
Arman Uguray72fab6a2013-01-10 19:32:42 -0800574 if (registration_changed)
575 OnCDMARegistrationChanged(state_1x, state_evdo, sid, nid);
576}
577
578void CellularCapabilityUniversalCDMA::OnCDMARegistrationChanged(
579 MMModemCdmaRegistrationState state_1x,
580 MMModemCdmaRegistrationState state_evdo,
581 uint32_t sid, uint32_t nid) {
582 SLOG(Cellular, 2) << __func__
583 << ": state_1x=" << state_1x
584 << ", state_evdo=" << state_evdo;
585 cdma_1x_registration_state_ = state_1x;
586 cdma_evdo_registration_state_ = state_evdo;
587 sid_ = sid;
588 nid_ = nid;
589 UpdateOperatorInfo();
590 cellular()->HandleNewRegistrationState();
591}
592
593} // namespace shill