blob: 7b9c7ec2aa19247745fca30a55f25d5e47acc542 [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());
Arman Ugurayf2b4a342013-05-23 18:26:52 -0700133
Arman Uguray0a3e2792013-01-17 16:31:50 -0800134 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();
Arman Ugurayf2b4a342013-05-23 18:26:52 -0700355
356 // CellularCapabilityUniversalCDMA::ActivateAutomatic passes a dummy
357 // ResultCallback when it calls Activate on the proxy object, in which case
358 // |callback.is_null()| will return true.
359 if (!callback.is_null())
360 callback.Run(error);
Arman Uguray0a3e2792013-01-17 16:31:50 -0800361}
362
363void CellularCapabilityUniversalCDMA::HandleNewActivationStatus(uint32 error) {
364 SLOG(Cellular, 2) << __func__ << "(" << error << ")";
365 if (!cellular()->service().get()) {
366 LOG(ERROR) << "In " << __func__ << "(): service is null.";
367 return;
368 }
369 SLOG(Cellular, 2) << "Activation State: " << activation_state_;
370 cellular()->service()->SetActivationState(
371 GetActivationStateString(activation_state_));
372 cellular()->service()->set_error(GetActivationErrorString(error));
373 UpdateOLP();
374}
375
376// static
377string CellularCapabilityUniversalCDMA::GetActivationStateString(
378 uint32 state) {
379 switch (state) {
380 case MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATED:
381 return flimflam::kActivationStateActivated;
382 case MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATING:
383 return flimflam::kActivationStateActivating;
384 case MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED:
385 return flimflam::kActivationStateNotActivated;
386 case MM_MODEM_CDMA_ACTIVATION_STATE_PARTIALLY_ACTIVATED:
387 return flimflam::kActivationStatePartiallyActivated;
388 default:
389 return flimflam::kActivationStateUnknown;
390 }
391}
392
393// static
394string CellularCapabilityUniversalCDMA::GetActivationErrorString(
395 uint32 error) {
396 switch (error) {
397 case MM_CDMA_ACTIVATION_ERROR_WRONG_RADIO_INTERFACE:
398 return flimflam::kErrorNeedEvdo;
399 case MM_CDMA_ACTIVATION_ERROR_ROAMING:
400 return flimflam::kErrorNeedHomeNetwork;
401 case MM_CDMA_ACTIVATION_ERROR_COULD_NOT_CONNECT:
402 case MM_CDMA_ACTIVATION_ERROR_SECURITY_AUTHENTICATION_FAILED:
403 case MM_CDMA_ACTIVATION_ERROR_PROVISIONING_FAILED:
404 return flimflam::kErrorOtaspFailed;
405 case MM_CDMA_ACTIVATION_ERROR_NONE:
406 return "";
407 case MM_CDMA_ACTIVATION_ERROR_NO_SIGNAL:
408 default:
409 return flimflam::kErrorActivationFailed;
410 }
411}
412
Arman Uguray72fab6a2013-01-10 19:32:42 -0800413void CellularCapabilityUniversalCDMA::Register(const ResultCallback &callback) {
414 // TODO(armansito): Remove once 3GPP is implemented in its own class.
415}
416
417void CellularCapabilityUniversalCDMA::RegisterOnNetwork(
418 const string &network_id,
419 Error *error,
420 const ResultCallback &callback) {
421 // TODO(armansito): Remove once 3GPP is implemented in its own class.
422}
423
Arman Uguray0a3e2792013-01-17 16:31:50 -0800424bool CellularCapabilityUniversalCDMA::IsActivating() const {
425 PendingActivationStore::State state =
426 modem_info()->pending_activation_store()->GetActivationState(
427 PendingActivationStore::kIdentifierMEID, meid());
428 return (state == PendingActivationStore::kStatePending) ||
429 (state == PendingActivationStore::kStateFailureRetry) ||
430 (activation_state_ == MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATING);
431}
432
Arman Uguray72fab6a2013-01-10 19:32:42 -0800433bool CellularCapabilityUniversalCDMA::IsRegistered() {
434 return (cdma_1x_registration_state_ ==
435 MM_MODEM_CDMA_REGISTRATION_STATE_HOME ||
436 cdma_1x_registration_state_ ==
437 MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING ||
438 cdma_evdo_registration_state_ ==
439 MM_MODEM_CDMA_REGISTRATION_STATE_HOME ||
440 cdma_evdo_registration_state_ ==
441 MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING);
442}
443
444void CellularCapabilityUniversalCDMA::SetUnregistered(bool /*searching*/) {
445 cdma_1x_registration_state_ = MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN;
446 cdma_evdo_registration_state_ = MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN;
447}
448
Arman Ugurayc9673062013-05-13 21:21:53 -0700449void CellularCapabilityUniversalCDMA::SetupConnectProperties(
450 DBusPropertiesMap *properties) {
451 (*properties)[kPropertyConnectNumber].writer().append_string(
452 kPhoneNumber);
453}
454
Arman Uguray72fab6a2013-01-10 19:32:42 -0800455void CellularCapabilityUniversalCDMA::RequirePIN(
456 const string &pin, bool require,
457 Error *error, const ResultCallback &callback) {
458 // TODO(armansito): Remove once 3GPP is implemented in its own class.
459}
460
461void CellularCapabilityUniversalCDMA::EnterPIN(
462 const string &pin,
463 Error *error,
464 const ResultCallback &callback) {
465 // TODO(armansito): Remove once 3GPP is implemented in its own class.
466}
467
468void CellularCapabilityUniversalCDMA::UnblockPIN(
469 const string &unblock_code,
470 const string &pin,
471 Error *error,
472 const ResultCallback &callback) {
473 // TODO(armansito): Remove once 3GPP is implemented in its own class.
474}
475
476void CellularCapabilityUniversalCDMA::ChangePIN(
477 const string &old_pin, const string &new_pin,
478 Error *error, const ResultCallback &callback) {
479 // TODO(armansito): Remove once 3GPP is implemented in its own class.
480}
481
482void CellularCapabilityUniversalCDMA::Scan(Error *error,
483 const ResultCallback &callback) {
484 // TODO(armansito): Remove once 3GPP is implemented in its own class.
485}
486
487void CellularCapabilityUniversalCDMA::OnSimPathChanged(
488 const string &sim_path) {
489 // TODO(armansito): Remove once 3GPP is implemented in its own class.
490}
491
492string CellularCapabilityUniversalCDMA::GetRoamingStateString() const {
493 uint32 state = cdma_evdo_registration_state_;
494 if (state == MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) {
495 state = cdma_1x_registration_state_;
496 }
497 switch (state) {
498 case MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN:
499 case MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED:
500 break;
501 case MM_MODEM_CDMA_REGISTRATION_STATE_HOME:
502 return flimflam::kRoamingStateHome;
503 case MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING:
504 return flimflam::kRoamingStateRoaming;
505 default:
506 NOTREACHED();
507 }
508 return flimflam::kRoamingStateUnknown;
509}
510
511void CellularCapabilityUniversalCDMA::OnDBusPropertiesChanged(
512 const string &interface,
513 const DBusPropertiesMap &changed_properties,
514 const vector<string> &invalidated_properties) {
515 SLOG(Cellular, 2) << __func__ << "(" << interface << ")";
516 if (interface == MM_DBUS_INTERFACE_MODEM_MODEMCDMA) {
517 OnModemCDMAPropertiesChanged(changed_properties, invalidated_properties);
518 } else {
519 CellularCapabilityUniversal::OnDBusPropertiesChanged(
520 interface, changed_properties, invalidated_properties);
521 }
522}
523
524void CellularCapabilityUniversalCDMA::OnModemCDMAPropertiesChanged(
525 const DBusPropertiesMap &properties,
526 const std::vector<std::string> &/*invalidated_properties*/) {
527 SLOG(Cellular, 2) << __func__;
528 string str_value;
529 if (DBusProperties::GetString(properties,
530 MM_MODEM_MODEMCDMA_PROPERTY_MEID,
531 &str_value))
532 set_meid(str_value);
533 if (DBusProperties::GetString(properties,
534 MM_MODEM_MODEMCDMA_PROPERTY_ESN,
535 &str_value))
536 set_esn(str_value);
537
538 uint32_t sid = sid_;
539 uint32_t nid = nid_;
540 MMModemCdmaRegistrationState state_1x = cdma_1x_registration_state_;
541 MMModemCdmaRegistrationState state_evdo = cdma_evdo_registration_state_;
542 bool registration_changed = false;
543 uint32_t uint_value;
544 if (DBusProperties::GetUint32(
545 properties,
546 MM_MODEM_MODEMCDMA_PROPERTY_CDMA1XREGISTRATIONSTATE,
547 &uint_value)) {
548 state_1x = static_cast<MMModemCdmaRegistrationState>(uint_value);
549 registration_changed = true;
550 }
551 if (DBusProperties::GetUint32(
552 properties,
553 MM_MODEM_MODEMCDMA_PROPERTY_EVDOREGISTRATIONSTATE,
554 &uint_value)) {
555 state_evdo = static_cast<MMModemCdmaRegistrationState>(uint_value);
556 registration_changed = true;
557 }
558 if (DBusProperties::GetUint32(
559 properties,
560 MM_MODEM_MODEMCDMA_PROPERTY_SID,
561 &uint_value)) {
562 sid = uint_value;
563 registration_changed = true;
564 }
565 if (DBusProperties::GetUint32(
566 properties,
567 MM_MODEM_MODEMCDMA_PROPERTY_NID,
568 &uint_value)) {
569 nid = uint_value;
570 registration_changed = true;
571 }
Arman Uguray0a3e2792013-01-17 16:31:50 -0800572 if (DBusProperties::GetUint32(
573 properties,
574 MM_MODEM_MODEMCDMA_PROPERTY_ACTIVATIONSTATE,
575 &uint_value)) {
576 activation_state_ = static_cast<MMModemCdmaActivationState>(uint_value);
577 HandleNewActivationStatus(MM_CDMA_ACTIVATION_ERROR_NONE);
578 }
Arman Uguray72fab6a2013-01-10 19:32:42 -0800579 if (registration_changed)
580 OnCDMARegistrationChanged(state_1x, state_evdo, sid, nid);
581}
582
583void CellularCapabilityUniversalCDMA::OnCDMARegistrationChanged(
584 MMModemCdmaRegistrationState state_1x,
585 MMModemCdmaRegistrationState state_evdo,
586 uint32_t sid, uint32_t nid) {
587 SLOG(Cellular, 2) << __func__
588 << ": state_1x=" << state_1x
589 << ", state_evdo=" << state_evdo;
590 cdma_1x_registration_state_ = state_1x;
591 cdma_evdo_registration_state_ = state_evdo;
592 sid_ = sid;
593 nid_ = nid;
594 UpdateOperatorInfo();
595 cellular()->HandleNewRegistrationState();
596}
597
598} // namespace shill