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" |
Christopher Wiley | b691efd | 2012-08-09 13:51:51 -0700 | [diff] [blame] | 12 | #include "shill/logging.h" |
Darin Petkov | 9c1dcef | 2012-02-07 15:58:26 +0100 | [diff] [blame] | 13 | #include "shill/property_accessor.h" |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 14 | |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 15 | using base::Closure; |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 16 | using std::string; |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 17 | |
| 18 | namespace shill { |
| 19 | |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 20 | const char CellularCapability::kModemPropertyIMSI[] = "imsi"; |
| 21 | const char CellularCapability::kModemPropertyState[] = "State"; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 22 | // All timeout values are in milliseconds |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 23 | const int CellularCapability::kTimeoutActivate = 300000; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 24 | const int CellularCapability::kTimeoutConnect = 45000; |
| 25 | const int CellularCapability::kTimeoutDefault = 5000; |
Thieu Le | 049adb5 | 2012-11-12 17:14:51 -0800 | [diff] [blame] | 26 | const int CellularCapability::kTimeoutDisconnect = 45000; |
Thieu Le | ae41caf | 2012-11-28 11:25:50 -0800 | [diff] [blame] | 27 | const int CellularCapability::kTimeoutEnable = 45000; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 28 | const int CellularCapability::kTimeoutRegister = 90000; |
Ben Chan | 5d0d32c | 2013-01-08 02:05:29 -0800 | [diff] [blame] | 29 | const int CellularCapability::kTimeoutReset = 90000; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 30 | const int CellularCapability::kTimeoutScan = 120000; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 31 | |
| 32 | CellularCapability::CellularCapability(Cellular *cellular, |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 33 | ProxyFactory *proxy_factory, |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 34 | ModemInfo *modem_info) |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 35 | : cellular_(cellular), |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 36 | proxy_factory_(proxy_factory), |
Prathmesh Prabhu | 49ffffd | 2014-01-09 18:28:55 -0800 | [diff] [blame] | 37 | modem_info_(modem_info) {} |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 38 | |
| 39 | CellularCapability::~CellularCapability() {} |
| 40 | |
Ben Chan | f98f00e | 2014-02-05 14:48:43 -0800 | [diff] [blame] | 41 | void CellularCapability::OnUnsupportedOperation(const char *operation, |
| 42 | Error *error) { |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 43 | string message("The "); |
| 44 | message.append(operation).append(" operation is not supported."); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 45 | Error::PopulateAndLog(error, Error::kNotSupported, message); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 46 | } |
| 47 | |
Ben Chan | f98f00e | 2014-02-05 14:48:43 -0800 | [diff] [blame] | 48 | void CellularCapability::DisconnectCleanup() {} |
| 49 | |
| 50 | void CellularCapability::Activate(const string &carrier, |
| 51 | Error *error, |
| 52 | const ResultCallback &callback) { |
| 53 | OnUnsupportedOperation(__func__, error); |
| 54 | } |
| 55 | |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 56 | void CellularCapability::CompleteActivation(Error *error) { |
| 57 | OnUnsupportedOperation(__func__, error); |
| 58 | } |
| 59 | |
Ben Chan | 1578603 | 2012-11-04 21:28:02 -0800 | [diff] [blame] | 60 | bool CellularCapability::IsServiceActivationRequired() const { |
| 61 | return false; |
| 62 | } |
| 63 | |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 64 | void CellularCapability::RegisterOnNetwork( |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 65 | const string &/*network_id*/, |
Ben Chan | f98f00e | 2014-02-05 14:48:43 -0800 | [diff] [blame] | 66 | Error *error, |
| 67 | const ResultCallback &/*callback*/) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 68 | OnUnsupportedOperation(__func__, error); |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 69 | } |
| 70 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 71 | void CellularCapability::RequirePIN(const std::string &/*pin*/, |
| 72 | bool /*require*/, |
| 73 | Error *error, |
| 74 | const ResultCallback &/*callback*/) { |
| 75 | OnUnsupportedOperation(__func__, error); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 76 | } |
| 77 | |
Darin Petkov | e5bc2cb | 2011-12-07 14:47:32 +0100 | [diff] [blame] | 78 | void CellularCapability::EnterPIN(const string &/*pin*/, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 79 | Error *error, |
| 80 | const ResultCallback &/*callback*/) { |
| 81 | OnUnsupportedOperation(__func__, error); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | void CellularCapability::UnblockPIN(const string &/*unblock_code*/, |
| 85 | const string &/*pin*/, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 86 | Error *error, |
| 87 | const ResultCallback &/*callback*/) { |
| 88 | OnUnsupportedOperation(__func__, error); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | void CellularCapability::ChangePIN(const string &/*old_pin*/, |
| 92 | const string &/*new_pin*/, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 93 | Error *error, |
| 94 | const ResultCallback &/*callback*/) { |
| 95 | OnUnsupportedOperation(__func__, error); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 96 | } |
| 97 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 98 | void CellularCapability::Scan(Error *error, |
Prathmesh Prabhu | 49ffffd | 2014-01-09 18:28:55 -0800 | [diff] [blame] | 99 | const ResultStringmapsCallback &callback) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 100 | OnUnsupportedOperation(__func__, error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 101 | } |
| 102 | |
Ben Chan | 5d0d32c | 2013-01-08 02:05:29 -0800 | [diff] [blame] | 103 | void CellularCapability::Reset(Error *error, |
| 104 | const ResultCallback &/*callback*/) { |
| 105 | OnUnsupportedOperation(__func__, error); |
| 106 | } |
| 107 | |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 108 | void CellularCapability::SetCarrier(const std::string &/*carrier*/, |
| 109 | Error *error, |
| 110 | const ResultCallback &/*callback*/) { |
| 111 | OnUnsupportedOperation(__func__, error); |
| 112 | } |
| 113 | |
Ben Chan | 539ab02 | 2014-02-03 16:34:57 -0800 | [diff] [blame] | 114 | CellularBearer *CellularCapability::GetActiveBearer() const { |
| 115 | return NULL; |
| 116 | } |
| 117 | |
Christopher Wiley | 1582bdd | 2012-11-15 11:31:14 -0800 | [diff] [blame] | 118 | bool CellularCapability::IsActivating() const { |
| 119 | return false; |
| 120 | } |
| 121 | |
Arman Uguray | f84a424 | 2013-04-09 20:01:07 -0700 | [diff] [blame] | 122 | bool CellularCapability::ShouldDetectOutOfCredit() const { |
Arman Uguray | d42d8ec | 2013-04-08 19:28:21 -0700 | [diff] [blame] | 123 | return false; |
| 124 | } |
| 125 | |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 126 | void CellularCapability::OnOperatorChanged() { |
| 127 | SLOG(Cellular, 3) << __func__; |
| 128 | if (cellular()->service()) { |
| 129 | UpdateServiceOLP(); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | void CellularCapability::UpdateServiceOLP() { |
| 134 | SLOG(Cellular, 3) << __func__; |
| 135 | } |
| 136 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 137 | } // namespace shill |