1 /* 2 * Copyright (C) 2020 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 "host/commands/modem_simulator/device_config.h" 18 #include "host/libs/config/cuttlefish_config.h" 19 20 // this file provide cuttlefish hooks 21 namespace cuttlefish { 22 namespace modem { 23 host_id()24int DeviceConfig::host_id() { 25 if (!cuttlefish::CuttlefishConfig::Get()) { 26 return 1000; 27 } 28 auto config = cuttlefish::CuttlefishConfig::Get(); 29 auto instance = config->ForDefaultInstance(); 30 return instance.modem_simulator_host_id(); 31 } 32 PerInstancePath(const char * file_name)33std::string DeviceConfig::PerInstancePath(const char* file_name) { 34 if (!cuttlefish::CuttlefishConfig::Get()) { 35 return ""; 36 } 37 auto config = cuttlefish::CuttlefishConfig::Get(); 38 auto instance = config->ForDefaultInstance(); 39 return instance.PerInstancePath(file_name); 40 } 41 DefaultHostArtifactsPath(const std::string & file)42std::string DeviceConfig::DefaultHostArtifactsPath(const std::string& file) { 43 return cuttlefish::DefaultHostArtifactsPath(file); 44 } 45 ril_address_and_prefix()46std::string DeviceConfig::ril_address_and_prefix() { 47 auto config = cuttlefish::CuttlefishConfig::Get(); 48 auto instance = config->ForDefaultInstance(); 49 return instance.ril_ipaddr() + "/" + std::to_string(instance.ril_prefixlen()); 50 }; 51 ril_gateway()52std::string DeviceConfig::ril_gateway() { 53 auto config = cuttlefish::CuttlefishConfig::Get(); 54 auto instance = config->ForDefaultInstance(); 55 return instance.ril_gateway(); 56 } 57 ril_dns()58std::string DeviceConfig::ril_dns() { 59 auto config = cuttlefish::CuttlefishConfig::Get(); 60 auto instance = config->ForDefaultInstance(); 61 return instance.ril_dns(); 62 } 63 open_ifstream_crossplat(const char * filename)64std::ifstream DeviceConfig::open_ifstream_crossplat(const char* filename) { 65 return std::ifstream(filename); 66 } 67 open_ofstream_crossplat(const char * filename,std::ios_base::openmode mode)68std::ofstream DeviceConfig::open_ofstream_crossplat(const char* filename, std::ios_base::openmode mode) { 69 return std::ofstream(filename, mode); 70 } 71 72 } // namespace modem 73 } // namespace cuttlefish 74