blob: fd68654725d47c677b8aab64bd1e0d371ccf4886 [file] [log] [blame]
// Copyright 2018 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "shill/cellular/modem_info.h"
#include <memory>
#include <utility>
#include <chromeos/dbus/service_constants.h>
#include "shill/cellular/modem_manager.h"
#include "shill/logging.h"
#include "shill/manager.h"
#include "shill/pending_activation_store.h"
using std::string;
namespace shill {
ModemInfo::ModemInfo(ControlInterface* control_interface,
EventDispatcher* dispatcher,
Metrics* metrics,
Manager* manager)
: control_interface_(control_interface),
dispatcher_(dispatcher),
metrics_(metrics),
manager_(manager) {}
ModemInfo::~ModemInfo() {
Stop();
}
void ModemInfo::Start() {
pending_activation_store_.reset(new PendingActivationStore());
pending_activation_store_->InitStorage(manager_->storage_path());
RegisterModemManager(std::make_unique<ModemManagerClassic>(
cromo::kCromoServiceName, cromo::kCromoServicePath, this));
RegisterModemManager(
std::make_unique<ModemManager1>(modemmanager::kModemManager1ServiceName,
modemmanager::kModemManager1ServicePath,
this));
}
void ModemInfo::Stop() {
pending_activation_store_.reset();
modem_managers_.clear();
}
void ModemInfo::OnDeviceInfoAvailable(const string& link_name) {
for (const auto& manager : modem_managers_) {
manager->OnDeviceInfoAvailable(link_name);
}
}
void ModemInfo::set_pending_activation_store(
PendingActivationStore* pending_activation_store) {
pending_activation_store_.reset(pending_activation_store);
}
void ModemInfo::RegisterModemManager(std::unique_ptr<ModemManager> manager) {
modem_managers_.push_back(std::move(manager));
modem_managers_.back()->Start();
}
} // namespace shill