blob: 71c9d386712f838d14ee9a54d9b053586f17aa9c [file] [log] [blame]
Eric Shienbrood5de44ab2011-12-05 10:46:27 -05001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkovdaf43862011-10-27 11:37:28 +02002// 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 Shienbrood9a245532012-03-07 14:20:39 -05007#include <base/bind.h>
Eric Shienbrood5de44ab2011-12-05 10:46:27 -05008#include <chromeos/dbus/service_constants.h>
9
Darin Petkovdaf43862011-10-27 11:37:28 +020010#include "shill/cellular.h"
Darin Petkovb05315f2011-11-07 10:14:25 +010011#include "shill/error.h"
Christopher Wileyb691efd2012-08-09 13:51:51 -070012#include "shill/logging.h"
Darin Petkov9c1dcef2012-02-07 15:58:26 +010013#include "shill/property_accessor.h"
Darin Petkovb05315f2011-11-07 10:14:25 +010014
Eric Shienbrood3e20a232012-02-16 11:35:56 -050015using base::Closure;
Darin Petkovb05315f2011-11-07 10:14:25 +010016using std::string;
Darin Petkovdaf43862011-10-27 11:37:28 +020017
18namespace shill {
19
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040020const char CellularCapability::kModemPropertyIMSI[] = "imsi";
21const char CellularCapability::kModemPropertyState[] = "State";
Eric Shienbrood9a245532012-03-07 14:20:39 -050022// All timeout values are in milliseconds
Arman Uguray0a3e2792013-01-17 16:31:50 -080023const int CellularCapability::kTimeoutActivate = 300000;
Eric Shienbrood9a245532012-03-07 14:20:39 -050024const int CellularCapability::kTimeoutConnect = 45000;
25const int CellularCapability::kTimeoutDefault = 5000;
Thieu Le049adb52012-11-12 17:14:51 -080026const int CellularCapability::kTimeoutDisconnect = 45000;
Thieu Leae41caf2012-11-28 11:25:50 -080027const int CellularCapability::kTimeoutEnable = 45000;
Eric Shienbrood9a245532012-03-07 14:20:39 -050028const int CellularCapability::kTimeoutRegister = 90000;
Ben Chan5d0d32c2013-01-08 02:05:29 -080029const int CellularCapability::kTimeoutReset = 90000;
Eric Shienbrood9a245532012-03-07 14:20:39 -050030const int CellularCapability::kTimeoutScan = 120000;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050031
32CellularCapability::CellularCapability(Cellular *cellular,
Thieu Lece4483e2013-01-23 15:12:03 -080033 ProxyFactory *proxy_factory,
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070034 ModemInfo *modem_info)
Jason Glasgow82f9ab32012-04-04 14:27:19 -040035 : cellular_(cellular),
Thieu Lece4483e2013-01-23 15:12:03 -080036 proxy_factory_(proxy_factory),
Prathmesh Prabhu49ffffd2014-01-09 18:28:55 -080037 modem_info_(modem_info) {}
Darin Petkovdaf43862011-10-27 11:37:28 +020038
39CellularCapability::~CellularCapability() {}
40
Ben Chanf98f00e2014-02-05 14:48:43 -080041void CellularCapability::OnUnsupportedOperation(const char *operation,
42 Error *error) {
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050043 string message("The ");
44 message.append(operation).append(" operation is not supported.");
Eric Shienbrood9a245532012-03-07 14:20:39 -050045 Error::PopulateAndLog(error, Error::kNotSupported, message);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050046}
47
Ben Chanf98f00e2014-02-05 14:48:43 -080048void CellularCapability::DisconnectCleanup() {}
49
50void CellularCapability::Activate(const string &carrier,
51 Error *error,
52 const ResultCallback &callback) {
53 OnUnsupportedOperation(__func__, error);
54}
55
Arman Ugurayc7b15602013-02-16 00:56:18 -080056void CellularCapability::CompleteActivation(Error *error) {
57 OnUnsupportedOperation(__func__, error);
58}
59
Ben Chan15786032012-11-04 21:28:02 -080060bool CellularCapability::IsServiceActivationRequired() const {
61 return false;
62}
63
Darin Petkov184c54e2011-11-15 12:44:39 +010064void CellularCapability::RegisterOnNetwork(
Eric Shienbrood9a245532012-03-07 14:20:39 -050065 const string &/*network_id*/,
Ben Chanf98f00e2014-02-05 14:48:43 -080066 Error *error,
67 const ResultCallback &/*callback*/) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050068 OnUnsupportedOperation(__func__, error);
Darin Petkov184c54e2011-11-15 12:44:39 +010069}
70
Eric Shienbrood9a245532012-03-07 14:20:39 -050071void CellularCapability::RequirePIN(const std::string &/*pin*/,
72 bool /*require*/,
73 Error *error,
74 const ResultCallback &/*callback*/) {
75 OnUnsupportedOperation(__func__, error);
Darin Petkovb05315f2011-11-07 10:14:25 +010076}
77
Darin Petkove5bc2cb2011-12-07 14:47:32 +010078void CellularCapability::EnterPIN(const string &/*pin*/,
Eric Shienbrood9a245532012-03-07 14:20:39 -050079 Error *error,
80 const ResultCallback &/*callback*/) {
81 OnUnsupportedOperation(__func__, error);
Darin Petkovb05315f2011-11-07 10:14:25 +010082}
83
84void CellularCapability::UnblockPIN(const string &/*unblock_code*/,
85 const string &/*pin*/,
Eric Shienbrood9a245532012-03-07 14:20:39 -050086 Error *error,
87 const ResultCallback &/*callback*/) {
88 OnUnsupportedOperation(__func__, error);
Darin Petkovb05315f2011-11-07 10:14:25 +010089}
90
91void CellularCapability::ChangePIN(const string &/*old_pin*/,
92 const string &/*new_pin*/,
Eric Shienbrood9a245532012-03-07 14:20:39 -050093 Error *error,
94 const ResultCallback &/*callback*/) {
95 OnUnsupportedOperation(__func__, error);
Darin Petkovb05315f2011-11-07 10:14:25 +010096}
97
Eric Shienbrood9a245532012-03-07 14:20:39 -050098void CellularCapability::Scan(Error *error,
Prathmesh Prabhu49ffffd2014-01-09 18:28:55 -080099 const ResultStringmapsCallback &callback) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500100 OnUnsupportedOperation(__func__, error);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500101}
102
Ben Chan5d0d32c2013-01-08 02:05:29 -0800103void CellularCapability::Reset(Error *error,
104 const ResultCallback &/*callback*/) {
105 OnUnsupportedOperation(__func__, error);
106}
107
Darin Petkovc37a9c42012-09-06 15:28:22 +0200108void CellularCapability::SetCarrier(const std::string &/*carrier*/,
109 Error *error,
110 const ResultCallback &/*callback*/) {
111 OnUnsupportedOperation(__func__, error);
112}
113
Ben Chan539ab022014-02-03 16:34:57 -0800114CellularBearer *CellularCapability::GetActiveBearer() const {
115 return NULL;
116}
117
Christopher Wiley1582bdd2012-11-15 11:31:14 -0800118bool CellularCapability::IsActivating() const {
119 return false;
120}
121
Arman Ugurayf84a4242013-04-09 20:01:07 -0700122bool CellularCapability::ShouldDetectOutOfCredit() const {
Arman Ugurayd42d8ec2013-04-08 19:28:21 -0700123 return false;
124}
125
Prathmesh Prabhu92df6192014-04-29 18:08:08 -0700126void CellularCapability::OnOperatorChanged() {
127 SLOG(Cellular, 3) << __func__;
128 if (cellular()->service()) {
129 UpdateServiceOLP();
130 }
131}
132
133void CellularCapability::UpdateServiceOLP() {
134 SLOG(Cellular, 3) << __func__;
135}
136
Darin Petkovdaf43862011-10-27 11:37:28 +0200137} // namespace shill