1 /*
2 * Copyright (C) 2021 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 "structs.h"
18
19 #include "commonStructs.h"
20
21 #include "collections.h"
22
23 #include <android-base/logging.h>
24
25 namespace android::hardware::radio::compat {
26
27 using ::aidl::android::hardware::radio::AccessNetwork;
28 using ::aidl::android::hardware::radio::RadioTechnology;
29 namespace aidl = ::aidl::android::hardware::radio::modem;
30
toHidl(const aidl::NvWriteItem & item)31 V1_0::NvWriteItem toHidl(const aidl::NvWriteItem& item) {
32 return {
33 .itemId = static_cast<V1_0::NvItem>(item.itemId),
34 .value = item.value,
35 };
36 }
37
toAidl(const V1_0::RadioCapability & capa)38 aidl::RadioCapability toAidl(const V1_0::RadioCapability& capa) {
39 return {
40 .session = capa.session,
41 .phase = static_cast<int32_t>(capa.phase),
42 .raf = static_cast<int32_t>(capa.raf),
43 .logicalModemUuid = capa.logicalModemUuid,
44 .status = static_cast<int32_t>(capa.status),
45 };
46 }
47
toHidl(const aidl::RadioCapability & capa)48 V1_0::RadioCapability toHidl(const aidl::RadioCapability& capa) {
49 return {
50 .session = capa.session,
51 .phase = static_cast<V1_0::RadioCapabilityPhase>(capa.phase),
52 .raf = toHidlBitfield<V1_0::RadioAccessFamily>(capa.raf),
53 .logicalModemUuid = capa.logicalModemUuid,
54 .status = static_cast<V1_0::RadioCapabilityStatus>(capa.status),
55 };
56 }
57
toAidl(const V1_0::HardwareConfig & config)58 aidl::HardwareConfig toAidl(const V1_0::HardwareConfig& config) {
59 return {
60 .type = static_cast<int32_t>(config.type),
61 .uuid = config.uuid,
62 .state = static_cast<int32_t>(config.state),
63 .modem = toAidl(config.modem),
64 .sim = toAidl(config.sim),
65 };
66 }
67
toAidl(const V1_0::HardwareConfigModem & modem)68 aidl::HardwareConfigModem toAidl(const V1_0::HardwareConfigModem& modem) {
69 return {
70 .rilModel = modem.rilModel,
71 .rat = RadioTechnology(modem.rat),
72 .maxVoiceCalls = modem.maxVoice,
73 .maxDataCalls = modem.maxData,
74 .maxStandby = modem.maxStandby,
75 };
76 }
77
toAidl(const V1_0::HardwareConfigSim & sim)78 aidl::HardwareConfigSim toAidl(const V1_0::HardwareConfigSim& sim) {
79 return {
80 .modemUuid = sim.modemUuid,
81 };
82 }
83
toAidl(const V1_0::ActivityStatsInfo & info)84 aidl::ActivityStatsInfo toAidl(const V1_0::ActivityStatsInfo& info) {
85 const aidl::ActivityStatsTechSpecificInfo techSpecificInfo = {
86 .rat = AccessNetwork(AccessNetwork::UNKNOWN),
87 .frequencyRange = static_cast<int32_t>(
88 aidl::ActivityStatsTechSpecificInfo::FREQUENCY_RANGE_UNKNOWN),
89 .txmModetimeMs = toAidl(info.txmModetimeMs),
90 .rxModeTimeMs = static_cast<int32_t>(info.rxModeTimeMs),
91 };
92
93 return {
94 .sleepModeTimeMs = static_cast<int32_t>(info.sleepModeTimeMs),
95 .idleModeTimeMs = static_cast<int32_t>(info.idleModeTimeMs),
96 .techSpecificInfo = {techSpecificInfo},
97 };
98 }
99
100 } // namespace android::hardware::radio::compat
101