Tomasz Wasilczyk | 6301e8f | 2021-10-18 16:53:40 -0700 | [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 "commonStructs.h" |
| 18 | |
| 19 | namespace android::hardware::radio::compat { |
| 20 | |
| 21 | namespace aidl = ::aidl::android::hardware::radio; |
| 22 | |
Tomasz Wasilczyk | 6902a75 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 23 | aidl::RadioResponseInfo notSupported(int32_t serial) { |
Tomasz Wasilczyk | 6301e8f | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 24 | return { |
Tomasz Wasilczyk | 6902a75 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 25 | .type = aidl::RadioResponseType::SOLICITED, |
Tomasz Wasilczyk | 6301e8f | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 26 | .serial = serial, |
Tomasz Wasilczyk | 6902a75 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 27 | .error = aidl::RadioError::REQUEST_NOT_SUPPORTED, |
Tomasz Wasilczyk | 6301e8f | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 28 | }; |
| 29 | } |
| 30 | |
Tomasz Wasilczyk | fb10e00 | 2021-10-28 13:22:47 -0700 | [diff] [blame] | 31 | std::string toAidl(const hidl_string& str) { |
| 32 | return str; |
| 33 | } |
| 34 | |
| 35 | hidl_string toHidl(const std::string& str) { |
| 36 | return str; |
| 37 | } |
| 38 | |
| 39 | uint8_t toAidl(int8_t v) { |
| 40 | return v; |
| 41 | } |
| 42 | |
Tomasz Wasilczyk | d2e7459 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 43 | int8_t toAidl(uint8_t v) { |
| 44 | return v; |
| 45 | } |
| 46 | |
| 47 | int32_t toAidl(uint32_t v) { |
| 48 | return v; |
| 49 | } |
| 50 | |
Pomai Ahlo | 25fb3aa | 2022-12-12 13:58:55 -0800 | [diff] [blame] | 51 | uint8_t toHidl(int8_t v) { |
| 52 | return v; |
| 53 | } |
| 54 | |
Tomasz Wasilczyk | 6301e8f | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 55 | aidl::RadioIndicationType toAidl(V1_0::RadioIndicationType type) { |
| 56 | return aidl::RadioIndicationType(type); |
| 57 | } |
| 58 | |
| 59 | aidl::RadioResponseType toAidl(V1_0::RadioResponseType type) { |
| 60 | return aidl::RadioResponseType(type); |
| 61 | } |
| 62 | |
| 63 | aidl::RadioError toAidl(V1_0::RadioError err) { |
| 64 | return aidl::RadioError(err); |
| 65 | } |
| 66 | |
| 67 | aidl::RadioError toAidl(V1_6::RadioError err) { |
| 68 | return aidl::RadioError(err); |
| 69 | } |
| 70 | |
| 71 | aidl::RadioResponseInfo toAidl(const V1_0::RadioResponseInfo& info) { |
| 72 | return { |
| 73 | .type = toAidl(info.type), |
| 74 | .serial = info.serial, |
| 75 | .error = toAidl(info.error), |
| 76 | }; |
| 77 | } |
| 78 | |
| 79 | aidl::RadioResponseInfo toAidl(const V1_6::RadioResponseInfo& info) { |
| 80 | return { |
| 81 | .type = toAidl(info.type), |
| 82 | .serial = info.serial, |
| 83 | .error = toAidl(info.error), |
| 84 | }; |
| 85 | } |
| 86 | |
| 87 | } // namespace android::hardware::radio::compat |