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#ifndef SHILL_CELLULAR_MODEM_INFO_H_ 18#define SHILL_CELLULAR_MODEM_INFO_H_ 19 20#include <memory> 21#include <string> 22 23#include <base/memory/scoped_vector.h> 24#include <gtest/gtest_prod.h> // for FRIEND_TEST 25 26namespace shill { 27 28class ControlInterface; 29class EventDispatcher; 30class Manager; 31class Metrics; 32class ModemManager; 33class PendingActivationStore; 34 35// Manages modem managers. 36class ModemInfo { 37 public: 38 ModemInfo(ControlInterface* control, 39 EventDispatcher* dispatcher, 40 Metrics* metrics, 41 Manager* manager); 42 virtual ~ModemInfo(); 43 44 virtual void Start(); 45 virtual void Stop(); 46 47 virtual void OnDeviceInfoAvailable(const std::string& link_name); 48 49 ControlInterface* control_interface() const { return control_interface_; } 50 EventDispatcher* dispatcher() const { return dispatcher_; } 51 Metrics* metrics() const { return metrics_; } 52 Manager* manager() const { return manager_; } 53 PendingActivationStore* pending_activation_store() const { 54 return pending_activation_store_.get(); 55 } 56 57 protected: 58 // Write accessors for unit-tests. 59 void set_control_interface(ControlInterface* control) { 60 control_interface_ = control; 61 } 62 void set_event_dispatcher(EventDispatcher* dispatcher) { 63 dispatcher_ = dispatcher; 64 } 65 void set_metrics(Metrics* metrics) { 66 metrics_ = metrics; 67 } 68 void set_manager(Manager* manager) { 69 manager_ = manager; 70 } 71 void set_pending_activation_store( 72 PendingActivationStore* pending_activation_store); 73 74 private: 75 friend class ModemInfoTest; 76 FRIEND_TEST(ModemInfoTest, RegisterModemManager); 77 FRIEND_TEST(ModemInfoTest, StartStop); 78 79 typedef ScopedVector<ModemManager> ModemManagers; 80 81 // Registers and starts |manager|. Takes ownership of |manager|. 82 void RegisterModemManager(ModemManager* manager); 83 ModemManagers modem_managers_; 84 85 ControlInterface* control_interface_; 86 EventDispatcher* dispatcher_; 87 Metrics* metrics_; 88 Manager* manager_; 89 90 // Post-payment activation state of the modem. 91 std::unique_ptr<PendingActivationStore> pending_activation_store_; 92 93 DISALLOW_COPY_AND_ASSIGN(ModemInfo); 94}; 95 96} // namespace shill 97 98#endif // SHILL_CELLULAR_MODEM_INFO_H_ 99