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 31using base::Closure; 32using std::string; 33 34namespace shill { 35 36namespace Logging { 37static auto kModuleLogScope = ScopeLogger::kCellular; 38static string ObjectID(CellularCapability* c) { 39 return c->cellular()->GetRpcIdentifier(); 40} 41} 42 43const char CellularCapability::kModemPropertyIMSI[] = "imsi"; 44const char CellularCapability::kModemPropertyState[] = "State"; 45// All timeout values are in milliseconds 46const int CellularCapability::kTimeoutActivate = 300000; 47const int CellularCapability::kTimeoutConnect = 45000; 48const int CellularCapability::kTimeoutDefault = 5000; 49const int CellularCapability::kTimeoutDisconnect = 45000; 50const int CellularCapability::kTimeoutEnable = 45000; 51const int CellularCapability::kTimeoutRegister = 90000; 52const int CellularCapability::kTimeoutReset = 90000; 53const int CellularCapability::kTimeoutScan = 120000; 54 55CellularCapability::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 62CellularCapability::~CellularCapability() {} 63 64void 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 71void CellularCapability::DisconnectCleanup() {} 72 73void CellularCapability::Activate(const string& carrier, 74 Error* error, 75 const ResultCallback& callback) { 76 OnUnsupportedOperation(__func__, error); 77} 78 79void CellularCapability::CompleteActivation(Error* error) { 80 OnUnsupportedOperation(__func__, error); 81} 82 83bool CellularCapability::IsServiceActivationRequired() const { 84 return false; 85} 86 87void CellularCapability::RegisterOnNetwork( 88 const string& /*network_id*/, 89 Error* error, 90 const ResultCallback& /*callback*/) { 91 OnUnsupportedOperation(__func__, error); 92} 93 94void CellularCapability::RequirePIN(const std::string& /*pin*/, 95 bool /*require*/, 96 Error* error, 97 const ResultCallback& /*callback*/) { 98 OnUnsupportedOperation(__func__, error); 99} 100 101void CellularCapability::EnterPIN(const string& /*pin*/, 102 Error* error, 103 const ResultCallback& /*callback*/) { 104 OnUnsupportedOperation(__func__, error); 105} 106 107void CellularCapability::UnblockPIN(const string& /*unblock_code*/, 108 const string& /*pin*/, 109 Error* error, 110 const ResultCallback& /*callback*/) { 111 OnUnsupportedOperation(__func__, error); 112} 113 114void CellularCapability::ChangePIN(const string& /*old_pin*/, 115 const string& /*new_pin*/, 116 Error* error, 117 const ResultCallback& /*callback*/) { 118 OnUnsupportedOperation(__func__, error); 119} 120 121void CellularCapability::Scan(Error* error, 122 const ResultStringmapsCallback& callback) { 123 OnUnsupportedOperation(__func__, error); 124} 125 126void CellularCapability::Reset(Error* error, 127 const ResultCallback& /*callback*/) { 128 OnUnsupportedOperation(__func__, error); 129} 130 131void CellularCapability::SetCarrier(const std::string& /*carrier*/, 132 Error* error, 133 const ResultCallback& /*callback*/) { 134 OnUnsupportedOperation(__func__, error); 135} 136 137CellularBearer* CellularCapability::GetActiveBearer() const { 138 return nullptr; 139} 140 141bool CellularCapability::IsActivating() const { 142 return false; 143} 144 145bool CellularCapability::ShouldDetectOutOfCredit() const { 146 return false; 147} 148 149void CellularCapability::OnOperatorChanged() { 150 SLOG(this, 3) << __func__; 151 if (cellular()->service()) { 152 UpdateServiceOLP(); 153 } 154} 155 156void CellularCapability::UpdateServiceOLP() { 157 SLOG(this, 3) << __func__; 158} 159 160} // namespace shill 161