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 "common/libs/device_config/device_config.h"
18 #include "host/commands/modem_simulator/device_config.h"
19 #include "host/libs/config/cuttlefish_config.h"
20 
21 // this file provide cuttlefish hooks
22 namespace cuttlefish {
23 namespace modem {
24 
host_port()25 int DeviceConfig::host_port() {
26   if (!cuttlefish::CuttlefishConfig::Get()) {
27       return 6500;
28   }
29   auto config = cuttlefish::CuttlefishConfig::Get();
30   auto instance = config->ForDefaultInstance();
31   auto host_port = instance.host_port();
32   return host_port;
33 }
34 
PerInstancePath(const char * file_name)35 std::string DeviceConfig::PerInstancePath(const char* file_name) {
36   if (!cuttlefish::CuttlefishConfig::Get()) {
37       return "";
38   }
39   auto config = cuttlefish::CuttlefishConfig::Get();
40   auto instance = config->ForDefaultInstance();
41   return instance.PerInstancePath(file_name);
42 }
43 
DefaultHostArtifactsPath(const std::string & file)44 std::string DeviceConfig::DefaultHostArtifactsPath(const std::string& file) {
45   return cuttlefish::DefaultHostArtifactsPath(file);
46 }
47 
ril_address_and_prefix()48 const char* DeviceConfig::ril_address_and_prefix() {
49   if (!cuttlefish::DeviceConfig::Get()) {
50       return "10.0.2.15/24";
51   }
52   return cuttlefish::DeviceConfig::Get()->ril_address_and_prefix();
53 };
54 
ril_gateway()55 const char* DeviceConfig::ril_gateway() {
56   if (!cuttlefish::DeviceConfig::Get()) {
57       return "10.0.2.2";
58   }
59   return cuttlefish::DeviceConfig::Get()->ril_gateway();
60 }
ril_dns()61 const char* DeviceConfig::ril_dns() {
62   if (!cuttlefish::DeviceConfig::Get()) {
63       return "8.8.8.8";
64   }
65   return cuttlefish::DeviceConfig::Get()->ril_dns();
66 }
67 
68 }  // namespace modem
69 }  // namespace cuttlefish
70