blob: 0b87c553bac9e2ccc414445ef9cf1f2168d229f9 [file] [log] [blame]
//
// Copyright (C) 2012 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#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