blob: 6f32cdf02e19deb29890a6660d0040a07b2811d4 [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::RadioTechnology;
29namespace aidl = ::aidl::android::hardware::radio::modem;
30
31V1_0::NvWriteItem toHidl(const aidl::NvWriteItem& item) {
32 return {
Tomasz Wasilczykb542add2022-08-08 19:04:26 +000033 .itemId = static_cast<V1_0::NvItem>(item.itemId),
Tomasz Wasilczykdcbae482021-11-08 16:10:28 -080034 .value = item.value,
35 };
36}
37
38aidl::RadioCapability toAidl(const V1_0::RadioCapability& capa) {
39 return {
40 .session = capa.session,
41 .phase = static_cast<int32_t>(capa.phase),
Sarah Chinc9d3b7b2021-12-23 16:41:58 -080042 .raf = static_cast<int32_t>(capa.raf),
Tomasz Wasilczykdcbae482021-11-08 16:10:28 -080043 .logicalModemUuid = capa.logicalModemUuid,
44 .status = static_cast<int32_t>(capa.status),
45 };
46}
47
48V1_0::RadioCapability toHidl(const aidl::RadioCapability& capa) {
49 return {
50 .session = capa.session,
Tomasz Wasilczykb542add2022-08-08 19:04:26 +000051 .phase = static_cast<V1_0::RadioCapabilityPhase>(capa.phase),
Tomasz Wasilczykdcbae482021-11-08 16:10:28 -080052 .raf = toHidlBitfield<V1_0::RadioAccessFamily>(capa.raf),
53 .logicalModemUuid = capa.logicalModemUuid,
Tomasz Wasilczykb542add2022-08-08 19:04:26 +000054 .status = static_cast<V1_0::RadioCapabilityStatus>(capa.status),
Tomasz Wasilczykdcbae482021-11-08 16:10:28 -080055 };
56}
57
58aidl::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
68aidl::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
78aidl::HardwareConfigSim toAidl(const V1_0::HardwareConfigSim& sim) {
79 return {
80 .modemUuid = sim.modemUuid,
81 };
82}
83
84aidl::ActivityStatsInfo toAidl(const V1_0::ActivityStatsInfo& info) {
Gary Jian2ea92412021-11-19 14:54:49 +080085 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
Tomasz Wasilczykdcbae482021-11-08 16:10:28 -080093 return {
94 .sleepModeTimeMs = static_cast<int32_t>(info.sleepModeTimeMs),
95 .idleModeTimeMs = static_cast<int32_t>(info.idleModeTimeMs),
Gary Jian2ea92412021-11-19 14:54:49 +080096 .techSpecificInfo = {techSpecificInfo},
Tomasz Wasilczykdcbae482021-11-08 16:10:28 -080097 };
98}
99
100} // namespace android::hardware::radio::compat