blob: 925956ef79519eaefe01fe6b4d04602964bdf3cc [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() {
Ben Chan07193fd2013-07-12 22:10:55 -0700216 SLOG(Cellular, 2) << __func__;
217
218 const CellularOperatorInfo *cellular_operator_info =
219 modem_info()->cellular_operator_info();
220 if (!cellular_operator_info)
221 return;
222
223 string sid_string = UintToString(sid_);
224 const CellularOperatorInfo::CellularOperator *cellular_operator =
225 cellular_operator_info->GetCellularOperatorBySID(sid_string);
226 if (!cellular_operator)
Arman Uguray72fab6a2013-01-10 19:32:42 -0800227 return;
228
229 const CellularService::OLP *result =
Ben Chan07193fd2013-07-12 22:10:55 -0700230 cellular_operator_info->GetOLPBySID(sid_string);
Arman Uguray72fab6a2013-01-10 19:32:42 -0800231 if (!result)
232 return;
233
234 CellularService::OLP olp;
235 olp.CopyFrom(*result);
236 string post_data = olp.GetPostData();
237 ReplaceSubstringsAfterOffset(&post_data, 0, "${esn}", esn());
Ben Chan07193fd2013-07-12 22:10:55 -0700238 ReplaceSubstringsAfterOffset(&post_data, 0, "${mdn}",
239 GetMdnForOLP(*cellular_operator));
Arman Uguray72fab6a2013-01-10 19:32:42 -0800240 ReplaceSubstringsAfterOffset(&post_data, 0, "${meid}", meid());
241 olp.SetPostData(post_data);
Arman Uguray0a3e2792013-01-17 16:31:50 -0800242 if (cellular()->service().get())
243 cellular()->service()->SetOLP(olp);
Arman Uguray72fab6a2013-01-10 19:32:42 -0800244}
245
246void CellularCapabilityUniversalCDMA::GetProperties() {
247 SLOG(Cellular, 2) << __func__;
248 CellularCapabilityUniversal::GetProperties();
249
250 scoped_ptr<DBusPropertiesProxyInterface> properties_proxy(
251 proxy_factory()->CreateDBusPropertiesProxy(cellular()->dbus_path(),
252 cellular()->dbus_owner()));
253 DBusPropertiesMap properties(
254 properties_proxy->GetAll(MM_DBUS_INTERFACE_MODEM_MODEMCDMA));
255 OnModemCDMAPropertiesChanged(properties, vector<string>());
256}
257
258string CellularCapabilityUniversalCDMA::CreateFriendlyServiceName() {
259 SLOG(Cellular, 2) << __func__ << ": " << GetRoamingStateString();
260
261 if (provider_.GetCode().empty()) {
262 UpdateOperatorInfo();
263 }
264
265 string name = provider_.GetName();
266 if (!name.empty()) {
267 // TODO(armansito): We may need to show the provider name in a
268 // specific way if roaming.
269 return name;
270 }
271
272 string code = provider_.GetCode();
273 if (!code.empty()) {
274 return "cellular_sid_" + code;
275 }
276
277 return base::StringPrintf("CDMANetwork%u", friendly_service_name_id_cdma_++);
278}
279
280void CellularCapabilityUniversalCDMA::UpdateOperatorInfo() {
281 SLOG(Cellular, 2) << __func__;
282
283 if (sid_ == 0 || !modem_info()->cellular_operator_info()) {
284 SLOG(Cellular, 2) << "No provider is currently available.";
285 provider_.SetCode("");
286 return;
287 }
288
289 string sid = UintToString(sid_);
290 const CellularOperatorInfo::CellularOperator *provider =
291 modem_info()->cellular_operator_info()->GetCellularOperatorBySID(sid);
292 if (!provider) {
293 SLOG(Cellular, 2) << "CDMA provider with "
294 << FormattedSID(sid)
295 << " not found.";
296 return;
297 }
298
299 if (!provider->name_list().empty()) {
300 provider_.SetName(provider->name_list()[0].name);
301 }
302 provider_.SetCode(sid);
303 provider_.SetCountry(provider->country());
304
Arman Uguray0a3e2792013-01-17 16:31:50 -0800305 activation_code_ = provider->activation_code();
306
Arman Uguray72fab6a2013-01-10 19:32:42 -0800307 // TODO(armansito): The CDMA interface only returns information about the
308 // current serving carrier, so for now both the home provider and the
309 // serving operator will be the same in case of roaming. We should figure
310 // out if there is a way to (and whether or not it is necessary to)
311 // determine if we're roaming.
312 cellular()->set_home_provider(provider_);
313
314 UpdateServingOperator();
315}
316
317void CellularCapabilityUniversalCDMA::UpdateServingOperator() {
318 SLOG(Cellular, 2) << __func__;
319 if (cellular()->service().get()) {
320 cellular()->service()->SetServingOperator(cellular()->home_provider());
Arman Uguray2269bb62013-07-26 14:53:30 -0700321 cellular()->service()->SetFriendlyName(CreateFriendlyServiceName());
Arman Uguray72fab6a2013-01-10 19:32:42 -0800322 }
323}
324
Arman Uguray0a3e2792013-01-17 16:31:50 -0800325void CellularCapabilityUniversalCDMA::OnActivationStateChangedSignal(
326 uint32 activation_state,
327 uint32 activation_error,
328 const DBusPropertiesMap &status_changes) {
329 SLOG(Cellular, 2) << __func__;
330
331 activation_state_ =
332 static_cast<MMModemCdmaActivationState>(activation_state);
333
334 string value;
335 if (DBusProperties::GetString(status_changes, "mdn", &value))
336 set_mdn(value);
337 if (DBusProperties::GetString(status_changes, "min", &value))
338 set_min(value);
339
340 SLOG(Cellular, 2) << "Activation state: "
341 << GetActivationStateString(activation_state_);
342
343 HandleNewActivationStatus(activation_error);
344 UpdatePendingActivationState();
345}
346
347void CellularCapabilityUniversalCDMA::OnActivateReply(
348 const ResultCallback &callback,
349 const Error &error) {
350 SLOG(Cellular, 2) << __func__;
351 if (error.IsSuccess()) {
352 LOG(INFO) << "Activation completed successfully.";
353 modem_info()->pending_activation_store()->SetActivationState(
354 PendingActivationStore::kIdentifierMEID,
355 meid(),
356 PendingActivationStore::kStateActivated);
357 } else {
358 LOG(ERROR) << "Activation failed with error: " << error;
359 modem_info()->pending_activation_store()->SetActivationState(
360 PendingActivationStore::kIdentifierMEID,
361 meid(),
362 PendingActivationStore::kStateFailureRetry);
363 }
364 UpdatePendingActivationState();
Arman Ugurayf2b4a342013-05-23 18:26:52 -0700365
366 // CellularCapabilityUniversalCDMA::ActivateAutomatic passes a dummy
367 // ResultCallback when it calls Activate on the proxy object, in which case
368 // |callback.is_null()| will return true.
369 if (!callback.is_null())
370 callback.Run(error);
Arman Uguray0a3e2792013-01-17 16:31:50 -0800371}
372
373void CellularCapabilityUniversalCDMA::HandleNewActivationStatus(uint32 error) {
374 SLOG(Cellular, 2) << __func__ << "(" << error << ")";
375 if (!cellular()->service().get()) {
376 LOG(ERROR) << "In " << __func__ << "(): service is null.";
377 return;
378 }
379 SLOG(Cellular, 2) << "Activation State: " << activation_state_;
380 cellular()->service()->SetActivationState(
381 GetActivationStateString(activation_state_));
382 cellular()->service()->set_error(GetActivationErrorString(error));
383 UpdateOLP();
384}
385
386// static
387string CellularCapabilityUniversalCDMA::GetActivationStateString(
388 uint32 state) {
389 switch (state) {
390 case MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATED:
391 return flimflam::kActivationStateActivated;
392 case MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATING:
393 return flimflam::kActivationStateActivating;
394 case MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED:
395 return flimflam::kActivationStateNotActivated;
396 case MM_MODEM_CDMA_ACTIVATION_STATE_PARTIALLY_ACTIVATED:
397 return flimflam::kActivationStatePartiallyActivated;
398 default:
399 return flimflam::kActivationStateUnknown;
400 }
401}
402
403// static
404string CellularCapabilityUniversalCDMA::GetActivationErrorString(
405 uint32 error) {
406 switch (error) {
407 case MM_CDMA_ACTIVATION_ERROR_WRONG_RADIO_INTERFACE:
408 return flimflam::kErrorNeedEvdo;
409 case MM_CDMA_ACTIVATION_ERROR_ROAMING:
410 return flimflam::kErrorNeedHomeNetwork;
411 case MM_CDMA_ACTIVATION_ERROR_COULD_NOT_CONNECT:
412 case MM_CDMA_ACTIVATION_ERROR_SECURITY_AUTHENTICATION_FAILED:
413 case MM_CDMA_ACTIVATION_ERROR_PROVISIONING_FAILED:
414 return flimflam::kErrorOtaspFailed;
415 case MM_CDMA_ACTIVATION_ERROR_NONE:
416 return "";
417 case MM_CDMA_ACTIVATION_ERROR_NO_SIGNAL:
418 default:
419 return flimflam::kErrorActivationFailed;
420 }
421}
422
Arman Uguray72fab6a2013-01-10 19:32:42 -0800423void CellularCapabilityUniversalCDMA::Register(const ResultCallback &callback) {
424 // TODO(armansito): Remove once 3GPP is implemented in its own class.
425}
426
427void CellularCapabilityUniversalCDMA::RegisterOnNetwork(
428 const string &network_id,
429 Error *error,
430 const ResultCallback &callback) {
431 // TODO(armansito): Remove once 3GPP is implemented in its own class.
432}
433
Arman Uguray0a3e2792013-01-17 16:31:50 -0800434bool CellularCapabilityUniversalCDMA::IsActivating() const {
435 PendingActivationStore::State state =
436 modem_info()->pending_activation_store()->GetActivationState(
437 PendingActivationStore::kIdentifierMEID, meid());
438 return (state == PendingActivationStore::kStatePending) ||
439 (state == PendingActivationStore::kStateFailureRetry) ||
440 (activation_state_ == MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATING);
441}
442
Arman Uguray72fab6a2013-01-10 19:32:42 -0800443bool CellularCapabilityUniversalCDMA::IsRegistered() {
444 return (cdma_1x_registration_state_ ==
445 MM_MODEM_CDMA_REGISTRATION_STATE_HOME ||
446 cdma_1x_registration_state_ ==
447 MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING ||
448 cdma_evdo_registration_state_ ==
449 MM_MODEM_CDMA_REGISTRATION_STATE_HOME ||
450 cdma_evdo_registration_state_ ==
451 MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING);
452}
453
454void CellularCapabilityUniversalCDMA::SetUnregistered(bool /*searching*/) {
455 cdma_1x_registration_state_ = MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN;
456 cdma_evdo_registration_state_ = MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN;
457}
458
Arman Ugurayc9673062013-05-13 21:21:53 -0700459void CellularCapabilityUniversalCDMA::SetupConnectProperties(
460 DBusPropertiesMap *properties) {
461 (*properties)[kPropertyConnectNumber].writer().append_string(
462 kPhoneNumber);
463}
464
Arman Uguray72fab6a2013-01-10 19:32:42 -0800465void CellularCapabilityUniversalCDMA::RequirePIN(
466 const string &pin, bool require,
467 Error *error, const ResultCallback &callback) {
468 // TODO(armansito): Remove once 3GPP is implemented in its own class.
469}
470
471void CellularCapabilityUniversalCDMA::EnterPIN(
472 const string &pin,
473 Error *error,
474 const ResultCallback &callback) {
475 // TODO(armansito): Remove once 3GPP is implemented in its own class.
476}
477
478void CellularCapabilityUniversalCDMA::UnblockPIN(
479 const string &unblock_code,
480 const string &pin,
481 Error *error,
482 const ResultCallback &callback) {
483 // TODO(armansito): Remove once 3GPP is implemented in its own class.
484}
485
486void CellularCapabilityUniversalCDMA::ChangePIN(
487 const string &old_pin, const string &new_pin,
488 Error *error, const ResultCallback &callback) {
489 // TODO(armansito): Remove once 3GPP is implemented in its own class.
490}
491
492void CellularCapabilityUniversalCDMA::Scan(Error *error,
493 const ResultCallback &callback) {
494 // TODO(armansito): Remove once 3GPP is implemented in its own class.
495}
496
497void CellularCapabilityUniversalCDMA::OnSimPathChanged(
498 const string &sim_path) {
499 // TODO(armansito): Remove once 3GPP is implemented in its own class.
500}
501
502string CellularCapabilityUniversalCDMA::GetRoamingStateString() const {
503 uint32 state = cdma_evdo_registration_state_;
504 if (state == MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) {
505 state = cdma_1x_registration_state_;
506 }
507 switch (state) {
508 case MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN:
509 case MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED:
510 break;
511 case MM_MODEM_CDMA_REGISTRATION_STATE_HOME:
512 return flimflam::kRoamingStateHome;
513 case MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING:
514 return flimflam::kRoamingStateRoaming;
515 default:
516 NOTREACHED();
517 }
518 return flimflam::kRoamingStateUnknown;
519}
520
521void CellularCapabilityUniversalCDMA::OnDBusPropertiesChanged(
522 const string &interface,
523 const DBusPropertiesMap &changed_properties,
524 const vector<string> &invalidated_properties) {
525 SLOG(Cellular, 2) << __func__ << "(" << interface << ")";
526 if (interface == MM_DBUS_INTERFACE_MODEM_MODEMCDMA) {
527 OnModemCDMAPropertiesChanged(changed_properties, invalidated_properties);
528 } else {
529 CellularCapabilityUniversal::OnDBusPropertiesChanged(
530 interface, changed_properties, invalidated_properties);
531 }
532}
533
534void CellularCapabilityUniversalCDMA::OnModemCDMAPropertiesChanged(
535 const DBusPropertiesMap &properties,
536 const std::vector<std::string> &/*invalidated_properties*/) {
537 SLOG(Cellular, 2) << __func__;
538 string str_value;
539 if (DBusProperties::GetString(properties,
540 MM_MODEM_MODEMCDMA_PROPERTY_MEID,
541 &str_value))
542 set_meid(str_value);
543 if (DBusProperties::GetString(properties,
544 MM_MODEM_MODEMCDMA_PROPERTY_ESN,
545 &str_value))
546 set_esn(str_value);
547
548 uint32_t sid = sid_;
549 uint32_t nid = nid_;
550 MMModemCdmaRegistrationState state_1x = cdma_1x_registration_state_;
551 MMModemCdmaRegistrationState state_evdo = cdma_evdo_registration_state_;
552 bool registration_changed = false;
553 uint32_t uint_value;
554 if (DBusProperties::GetUint32(
555 properties,
556 MM_MODEM_MODEMCDMA_PROPERTY_CDMA1XREGISTRATIONSTATE,
557 &uint_value)) {
558 state_1x = static_cast<MMModemCdmaRegistrationState>(uint_value);
559 registration_changed = true;
560 }
561 if (DBusProperties::GetUint32(
562 properties,
563 MM_MODEM_MODEMCDMA_PROPERTY_EVDOREGISTRATIONSTATE,
564 &uint_value)) {
565 state_evdo = static_cast<MMModemCdmaRegistrationState>(uint_value);
566 registration_changed = true;
567 }
568 if (DBusProperties::GetUint32(
569 properties,
570 MM_MODEM_MODEMCDMA_PROPERTY_SID,
571 &uint_value)) {
572 sid = uint_value;
573 registration_changed = true;
574 }
575 if (DBusProperties::GetUint32(
576 properties,
577 MM_MODEM_MODEMCDMA_PROPERTY_NID,
578 &uint_value)) {
579 nid = uint_value;
580 registration_changed = true;
581 }
Arman Uguray0a3e2792013-01-17 16:31:50 -0800582 if (DBusProperties::GetUint32(
583 properties,
584 MM_MODEM_MODEMCDMA_PROPERTY_ACTIVATIONSTATE,
585 &uint_value)) {
586 activation_state_ = static_cast<MMModemCdmaActivationState>(uint_value);
587 HandleNewActivationStatus(MM_CDMA_ACTIVATION_ERROR_NONE);
588 }
Arman Uguray72fab6a2013-01-10 19:32:42 -0800589 if (registration_changed)
590 OnCDMARegistrationChanged(state_1x, state_evdo, sid, nid);
591}
592
593void CellularCapabilityUniversalCDMA::OnCDMARegistrationChanged(
594 MMModemCdmaRegistrationState state_1x,
595 MMModemCdmaRegistrationState state_evdo,
596 uint32_t sid, uint32_t nid) {
597 SLOG(Cellular, 2) << __func__
598 << ": state_1x=" << state_1x
599 << ", state_evdo=" << state_evdo;
600 cdma_1x_registration_state_ = state_1x;
601 cdma_evdo_registration_state_ = state_evdo;
602 sid_ = sid;
603 nid_ = nid;
604 UpdateOperatorInfo();
605 cellular()->HandleNewRegistrationState();
606}
607
608} // namespace shill