• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "collections.h"
20 
21 #include <android-base/logging.h>
22 
23 namespace android::hardware::radio::compat {
24 
25 namespace aidl = ::aidl::android::hardware::radio::config;
26 
toHidl(const aidl::SlotPortMapping & slotPortMapping)27 uint32_t toHidl(const aidl::SlotPortMapping& slotPortMapping) {
28     if (slotPortMapping.portId != 0) {
29         LOG(ERROR) << "Port ID " << slotPortMapping.portId << " != 0 not supported by HIDL HAL";
30     }
31     return slotPortMapping.physicalSlotId;
32 }
33 
toAidl(const config::V1_0::SimSlotStatus & sst)34 aidl::SimSlotStatus toAidl(const config::V1_0::SimSlotStatus& sst) {
35     return toAidl({sst, ""});
36 }
37 
toAidl(const config::V1_2::SimSlotStatus & sst)38 aidl::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 
toAidl(const config::V1_1::ModemInfo & info)53 uint8_t toAidl(const config::V1_1::ModemInfo& info) {
54     return info.modemId;
55 }
56 
toAidl(const config::V1_1::PhoneCapability & phoneCapability)57 aidl::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
67