blob: 53d575347bde871523d0897c16c6994140eee0f4 [file] [log] [blame]
Tomasz Wasilczykdcbae482021-11-08 16:10:28 -08001/*
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
25namespace android::hardware::radio::compat {
26
Gary Jian2ea92412021-11-19 14:54:49 +080027using ::aidl::android::hardware::radio::AccessNetwork;
Tomasz Wasilczykdcbae482021-11-08 16:10:28 -080028using ::aidl::android::hardware::radio::RadioAccessFamily;
29using ::aidl::android::hardware::radio::RadioTechnology;
30namespace aidl = ::aidl::android::hardware::radio::modem;
31
32V1_0::NvWriteItem toHidl(const aidl::NvWriteItem& item) {
33 return {
34 .itemId = V1_0::NvItem{item.itemId},
35 .value = item.value,
36 };
37}
38
39aidl::RadioCapability toAidl(const V1_0::RadioCapability& capa) {
40 return {
41 .session = capa.session,
42 .phase = static_cast<int32_t>(capa.phase),
43 .raf = RadioAccessFamily(capa.raf),
44 .logicalModemUuid = capa.logicalModemUuid,
45 .status = static_cast<int32_t>(capa.status),
46 };
47}
48
49V1_0::RadioCapability toHidl(const aidl::RadioCapability& capa) {
50 return {
51 .session = capa.session,
52 .phase = V1_0::RadioCapabilityPhase{capa.phase},
53 .raf = toHidlBitfield<V1_0::RadioAccessFamily>(capa.raf),
54 .logicalModemUuid = capa.logicalModemUuid,
55 .status = V1_0::RadioCapabilityStatus{capa.status},
56 };
57}
58
59aidl::HardwareConfig toAidl(const V1_0::HardwareConfig& config) {
60 return {
61 .type = static_cast<int32_t>(config.type),
62 .uuid = config.uuid,
63 .state = static_cast<int32_t>(config.state),
64 .modem = toAidl(config.modem),
65 .sim = toAidl(config.sim),
66 };
67}
68
69aidl::HardwareConfigModem toAidl(const V1_0::HardwareConfigModem& modem) {
70 return {
71 .rilModel = modem.rilModel,
72 .rat = RadioTechnology(modem.rat),
73 .maxVoiceCalls = modem.maxVoice,
74 .maxDataCalls = modem.maxData,
75 .maxStandby = modem.maxStandby,
76 };
77}
78
79aidl::HardwareConfigSim toAidl(const V1_0::HardwareConfigSim& sim) {
80 return {
81 .modemUuid = sim.modemUuid,
82 };
83}
84
85aidl::ActivityStatsInfo toAidl(const V1_0::ActivityStatsInfo& info) {
Gary Jian2ea92412021-11-19 14:54:49 +080086 const aidl::ActivityStatsTechSpecificInfo techSpecificInfo = {
87 .rat = AccessNetwork(AccessNetwork::UNKNOWN),
88 .frequencyRange = static_cast<int32_t>(
89 aidl::ActivityStatsTechSpecificInfo::FREQUENCY_RANGE_UNKNOWN),
90 .txmModetimeMs = toAidl(info.txmModetimeMs),
91 .rxModeTimeMs = static_cast<int32_t>(info.rxModeTimeMs),
92 };
93
Tomasz Wasilczykdcbae482021-11-08 16:10:28 -080094 return {
95 .sleepModeTimeMs = static_cast<int32_t>(info.sleepModeTimeMs),
96 .idleModeTimeMs = static_cast<int32_t>(info.idleModeTimeMs),
Gary Jian2ea92412021-11-19 14:54:49 +080097 .techSpecificInfo = {techSpecificInfo},
Tomasz Wasilczykdcbae482021-11-08 16:10:28 -080098 };
99}
100
101} // namespace android::hardware::radio::compat