Tomasz Wasilczyk | dcbae48 | 2021-11-08 16:10:28 -0800 | [diff] [blame] | 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 "commonStructs.h" |
| 20 | |
| 21 | #include "collections.h" |
| 22 | |
| 23 | #include <android-base/logging.h> |
| 24 | |
| 25 | namespace android::hardware::radio::compat { |
| 26 | |
| 27 | using ::aidl::android::hardware::radio::RadioAccessFamily; |
| 28 | using ::aidl::android::hardware::radio::RadioTechnology; |
| 29 | namespace aidl = ::aidl::android::hardware::radio::modem; |
| 30 | |
| 31 | V1_0::NvWriteItem toHidl(const aidl::NvWriteItem& item) { |
| 32 | return { |
| 33 | .itemId = V1_0::NvItem{item.itemId}, |
| 34 | .value = item.value, |
| 35 | }; |
| 36 | } |
| 37 | |
| 38 | aidl::RadioCapability toAidl(const V1_0::RadioCapability& capa) { |
| 39 | return { |
| 40 | .session = capa.session, |
| 41 | .phase = static_cast<int32_t>(capa.phase), |
| 42 | .raf = RadioAccessFamily(capa.raf), |
| 43 | .logicalModemUuid = capa.logicalModemUuid, |
| 44 | .status = static_cast<int32_t>(capa.status), |
| 45 | }; |
| 46 | } |
| 47 | |
| 48 | V1_0::RadioCapability toHidl(const aidl::RadioCapability& capa) { |
| 49 | return { |
| 50 | .session = capa.session, |
| 51 | .phase = V1_0::RadioCapabilityPhase{capa.phase}, |
| 52 | .raf = toHidlBitfield<V1_0::RadioAccessFamily>(capa.raf), |
| 53 | .logicalModemUuid = capa.logicalModemUuid, |
| 54 | .status = V1_0::RadioCapabilityStatus{capa.status}, |
| 55 | }; |
| 56 | } |
| 57 | |
| 58 | aidl::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 | |
| 68 | aidl::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 | |
| 78 | aidl::HardwareConfigSim toAidl(const V1_0::HardwareConfigSim& sim) { |
| 79 | return { |
| 80 | .modemUuid = sim.modemUuid, |
| 81 | }; |
| 82 | } |
| 83 | |
| 84 | aidl::ActivityStatsInfo toAidl(const V1_0::ActivityStatsInfo& info) { |
| 85 | return { |
| 86 | .sleepModeTimeMs = static_cast<int32_t>(info.sleepModeTimeMs), |
| 87 | .idleModeTimeMs = static_cast<int32_t>(info.idleModeTimeMs), |
| 88 | .txmModetimeMs = toAidl(info.txmModetimeMs), |
| 89 | .rxModeTimeMs = static_cast<int32_t>(info.rxModeTimeMs), |
| 90 | }; |
| 91 | } |
| 92 | |
| 93 | } // namespace android::hardware::radio::compat |