blob: 39ad944c512e58750687f884faa1a96f3b9c5f26 [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
Tomasz Wasilczyke807d372022-01-05 13:15:39 -080027uint32_t toHidl(const aidl::SlotPortMapping& slotPortMapping) {
28 if (slotPortMapping.portId != 0) {
29 LOG(ERROR) << "Port ID " << slotPortMapping.portId << " != 0 not supported by HIDL HAL";
Tomasz Wasilczykbff3b5b2021-10-18 16:53:40 -070030 }
Tomasz Wasilczyke807d372022-01-05 13:15:39 -080031 return slotPortMapping.physicalSlotId;
Tomasz Wasilczykbff3b5b2021-10-18 16:53:40 -070032}
33
34aidl::SimSlotStatus toAidl(const config::V1_0::SimSlotStatus& sst) {
35 return toAidl({sst, ""});
36}
37
38aidl::SimSlotStatus toAidl(const config::V1_2::SimSlotStatus& sst) {
39 const aidl::SimPortInfo portInfo = {
40 .iccId = sst.base.iccid,
41 .logicalSlotId = static_cast<int32_t>(sst.base.logicalSlotId),
42 .portActive = sst.base.slotState == config::V1_0::SlotState::ACTIVE,
43 };
44
45 return {
46 .cardState = static_cast<int32_t>(sst.base.cardState),
47 .atr = sst.base.atr,
48 .eid = sst.eid,
49 .portInfo = {portInfo},
50 };
51}
52
53uint8_t toAidl(const config::V1_1::ModemInfo& info) {
54 return info.modemId;
55}
56
57aidl::PhoneCapability toAidl(const config::V1_1::PhoneCapability& phoneCapability) {
58 return {
59 .maxActiveData = static_cast<int8_t>(phoneCapability.maxActiveData),
60 .maxActiveInternetData = static_cast<int8_t>(phoneCapability.maxActiveInternetData),
61 .isInternetLingeringSupported = phoneCapability.isInternetLingeringSupported,
62 .logicalModemIds = toAidl(phoneCapability.logicalModemList),
63 };
64}
65
66} // namespace android::hardware::radio::compat