1 //
2 // Copyright (C) 2012 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #include "shill/cellular/cellular_capability.h"
18
19 #include <base/bind.h>
20 #if defined(__ANDROID__)
21 #include <dbus/service_constants.h>
22 #else
23 #include <chromeos/dbus/service_constants.h>
24 #endif // __ANDROID__
25
26 #include "shill/cellular/cellular.h"
27 #include "shill/error.h"
28 #include "shill/logging.h"
29 #include "shill/property_accessor.h"
30
31 using base::Closure;
32 using std::string;
33
34 namespace shill {
35
36 namespace Logging {
37 static auto kModuleLogScope = ScopeLogger::kCellular;
ObjectID(CellularCapability * c)38 static string ObjectID(CellularCapability* c) {
39 return c->cellular()->GetRpcIdentifier();
40 }
41 }
42
43 const char CellularCapability::kModemPropertyIMSI[] = "imsi";
44 const char CellularCapability::kModemPropertyState[] = "State";
45 // All timeout values are in milliseconds
46 const int CellularCapability::kTimeoutActivate = 300000;
47 const int CellularCapability::kTimeoutConnect = 45000;
48 const int CellularCapability::kTimeoutDefault = 5000;
49 const int CellularCapability::kTimeoutDisconnect = 45000;
50 const int CellularCapability::kTimeoutEnable = 45000;
51 const int CellularCapability::kTimeoutRegister = 90000;
52 const int CellularCapability::kTimeoutReset = 90000;
53 const int CellularCapability::kTimeoutScan = 120000;
54
CellularCapability(Cellular * cellular,ControlInterface * control_interface,ModemInfo * modem_info)55 CellularCapability::CellularCapability(Cellular* cellular,
56 ControlInterface* control_interface,
57 ModemInfo* modem_info)
58 : cellular_(cellular),
59 control_interface_(control_interface),
60 modem_info_(modem_info) {}
61
~CellularCapability()62 CellularCapability::~CellularCapability() {}
63
OnUnsupportedOperation(const char * operation,Error * error)64 void CellularCapability::OnUnsupportedOperation(const char* operation,
65 Error* error) {
66 string message("The ");
67 message.append(operation).append(" operation is not supported.");
68 Error::PopulateAndLog(FROM_HERE, error, Error::kNotSupported, message);
69 }
70
DisconnectCleanup()71 void CellularCapability::DisconnectCleanup() {}
72
Activate(const string & carrier,Error * error,const ResultCallback & callback)73 void CellularCapability::Activate(const string& carrier,
74 Error* error,
75 const ResultCallback& callback) {
76 OnUnsupportedOperation(__func__, error);
77 }
78
CompleteActivation(Error * error)79 void CellularCapability::CompleteActivation(Error* error) {
80 OnUnsupportedOperation(__func__, error);
81 }
82
IsServiceActivationRequired() const83 bool CellularCapability::IsServiceActivationRequired() const {
84 return false;
85 }
86
RegisterOnNetwork(const string &,Error * error,const ResultCallback &)87 void CellularCapability::RegisterOnNetwork(
88 const string& /*network_id*/,
89 Error* error,
90 const ResultCallback& /*callback*/) {
91 OnUnsupportedOperation(__func__, error);
92 }
93
RequirePIN(const std::string &,bool,Error * error,const ResultCallback &)94 void CellularCapability::RequirePIN(const std::string& /*pin*/,
95 bool /*require*/,
96 Error* error,
97 const ResultCallback& /*callback*/) {
98 OnUnsupportedOperation(__func__, error);
99 }
100
EnterPIN(const string &,Error * error,const ResultCallback &)101 void CellularCapability::EnterPIN(const string& /*pin*/,
102 Error* error,
103 const ResultCallback& /*callback*/) {
104 OnUnsupportedOperation(__func__, error);
105 }
106
UnblockPIN(const string &,const string &,Error * error,const ResultCallback &)107 void CellularCapability::UnblockPIN(const string& /*unblock_code*/,
108 const string& /*pin*/,
109 Error* error,
110 const ResultCallback& /*callback*/) {
111 OnUnsupportedOperation(__func__, error);
112 }
113
ChangePIN(const string &,const string &,Error * error,const ResultCallback &)114 void CellularCapability::ChangePIN(const string& /*old_pin*/,
115 const string& /*new_pin*/,
116 Error* error,
117 const ResultCallback& /*callback*/) {
118 OnUnsupportedOperation(__func__, error);
119 }
120
Scan(Error * error,const ResultStringmapsCallback & callback)121 void CellularCapability::Scan(Error* error,
122 const ResultStringmapsCallback& callback) {
123 OnUnsupportedOperation(__func__, error);
124 }
125
Reset(Error * error,const ResultCallback &)126 void CellularCapability::Reset(Error* error,
127 const ResultCallback& /*callback*/) {
128 OnUnsupportedOperation(__func__, error);
129 }
130
SetCarrier(const std::string &,Error * error,const ResultCallback &)131 void CellularCapability::SetCarrier(const std::string& /*carrier*/,
132 Error* error,
133 const ResultCallback& /*callback*/) {
134 OnUnsupportedOperation(__func__, error);
135 }
136
GetActiveBearer() const137 CellularBearer* CellularCapability::GetActiveBearer() const {
138 return nullptr;
139 }
140
IsActivating() const141 bool CellularCapability::IsActivating() const {
142 return false;
143 }
144
ShouldDetectOutOfCredit() const145 bool CellularCapability::ShouldDetectOutOfCredit() const {
146 return false;
147 }
148
OnOperatorChanged()149 void CellularCapability::OnOperatorChanged() {
150 SLOG(this, 3) << __func__;
151 if (cellular()->service()) {
152 UpdateServiceOLP();
153 }
154 }
155
UpdateServiceOLP()156 void CellularCapability::UpdateServiceOLP() {
157 SLOG(this, 3) << __func__;
158 }
159
160 } // namespace shill
161