blob: 9ba56231e234e464bbfa5562ebe5e400a6905728 [file] [log] [blame]
Tomasz Wasilczykbff3b5b2021-10-18 16:53:40 -07001/*
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 "collections.h"
20
21#include <android-base/logging.h>
22
23namespace android::hardware::radio::compat {
24
25namespace aidl = ::aidl::android::hardware::radio::config;
26
27hidl_vec<uint32_t> toHidl(const std::vector<aidl::SlotPortMapping>& slotMap) {
28 hidl_vec<uint32_t> out(slotMap.size());
29 for (const auto& el : slotMap) {
30 CHECK_GE(el.portId, 0);
31 CHECK_LT(static_cast<size_t>(el.portId), out.size());
32 out[el.portId] = el.physicalSlotId;
33 }
34 return out;
35}
36
37aidl::SimSlotStatus toAidl(const config::V1_0::SimSlotStatus& sst) {
38 return toAidl({sst, ""});
39}
40
41aidl::SimSlotStatus toAidl(const config::V1_2::SimSlotStatus& sst) {
42 const aidl::SimPortInfo portInfo = {
43 .iccId = sst.base.iccid,
44 .logicalSlotId = static_cast<int32_t>(sst.base.logicalSlotId),
45 .portActive = sst.base.slotState == config::V1_0::SlotState::ACTIVE,
46 };
47
48 return {
49 .cardState = static_cast<int32_t>(sst.base.cardState),
50 .atr = sst.base.atr,
51 .eid = sst.eid,
52 .portInfo = {portInfo},
53 };
54}
55
56uint8_t toAidl(const config::V1_1::ModemInfo& info) {
57 return info.modemId;
58}
59
60aidl::PhoneCapability toAidl(const config::V1_1::PhoneCapability& phoneCapability) {
61 return {
62 .maxActiveData = static_cast<int8_t>(phoneCapability.maxActiveData),
63 .maxActiveInternetData = static_cast<int8_t>(phoneCapability.maxActiveInternetData),
64 .isInternetLingeringSupported = phoneCapability.isInternetLingeringSupported,
65 .logicalModemIds = toAidl(phoneCapability.logicalModemList),
66 };
67}
68
69} // namespace android::hardware::radio::compat