Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -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 <libradiocompat/RadioData.h> |
| 18 | |
| 19 | #include "commonStructs.h" |
| 20 | #include "debug.h" |
| 21 | #include "structs.h" |
| 22 | |
| 23 | #include "collections.h" |
| 24 | |
| 25 | #define RADIO_MODULE "Data" |
| 26 | |
| 27 | namespace android::hardware::radio::compat { |
| 28 | |
| 29 | using ::ndk::ScopedAStatus; |
| 30 | namespace aidl = ::aidl::android::hardware::radio::data; |
| 31 | namespace aidlCommon = ::aidl::android::hardware::radio; |
| 32 | constexpr auto ok = &ScopedAStatus::ok; |
| 33 | |
| 34 | ScopedAStatus RadioData::allocatePduSessionId(int32_t serial) { |
| 35 | LOG_CALL << serial; |
| 36 | if (mHal1_6) { |
| 37 | mHal1_6->allocatePduSessionId(serial); |
| 38 | } else { |
| 39 | respond().allocatePduSessionIdResponse(notSupported(serial), 0); |
| 40 | } |
| 41 | return ok(); |
| 42 | } |
| 43 | |
| 44 | ScopedAStatus RadioData::cancelHandover(int32_t serial, int32_t callId) { |
| 45 | LOG_CALL << serial; |
| 46 | if (mHal1_6) { |
| 47 | mHal1_6->cancelHandover(serial, callId); |
| 48 | } else { |
| 49 | respond().cancelHandoverResponse(notSupported(serial)); |
| 50 | } |
| 51 | return ok(); |
| 52 | } |
| 53 | |
| 54 | ScopedAStatus RadioData::deactivateDataCall(int32_t serial, int32_t cid, |
| 55 | aidl::DataRequestReason reason) { |
| 56 | LOG_CALL << serial; |
| 57 | mHal1_5->deactivateDataCall_1_2(serial, cid, V1_2::DataRequestReason(reason)); |
| 58 | return ok(); |
| 59 | } |
| 60 | |
| 61 | ScopedAStatus RadioData::getDataCallList(int32_t serial) { |
| 62 | LOG_CALL << serial; |
| 63 | mHal1_5->getDataCallList(serial); |
| 64 | return ok(); |
| 65 | } |
| 66 | |
| 67 | ScopedAStatus RadioData::getSlicingConfig(int32_t serial) { |
| 68 | LOG_CALL << serial; |
| 69 | if (mHal1_6) { |
| 70 | mHal1_6->getSlicingConfig(serial); |
| 71 | } else { |
| 72 | respond().getSlicingConfigResponse(notSupported(serial), {}); |
| 73 | } |
| 74 | return ok(); |
| 75 | } |
| 76 | |
| 77 | ScopedAStatus RadioData::releasePduSessionId(int32_t serial, int32_t id) { |
| 78 | LOG_CALL << serial; |
| 79 | if (mHal1_6) { |
| 80 | mHal1_6->releasePduSessionId(serial, id); |
| 81 | } else { |
| 82 | respond().releasePduSessionIdResponse(notSupported(serial)); |
| 83 | } |
| 84 | return ok(); |
| 85 | } |
| 86 | |
| 87 | ScopedAStatus RadioData::responseAcknowledgement() { |
| 88 | LOG_CALL; |
| 89 | mHal1_5->responseAcknowledgement(); |
| 90 | return ok(); |
| 91 | } |
| 92 | |
| 93 | ScopedAStatus RadioData::setDataAllowed(int32_t serial, bool allow) { |
| 94 | LOG_CALL << serial; |
| 95 | mHal1_5->setDataAllowed(serial, allow); |
| 96 | return ok(); |
| 97 | } |
| 98 | |
| 99 | ScopedAStatus RadioData::setDataProfile(int32_t serial, |
| 100 | const std::vector<aidl::DataProfileInfo>& profiles) { |
| 101 | LOG_CALL << serial; |
| 102 | mHal1_5->setDataProfile_1_5(serial, toHidl(profiles)); |
| 103 | return ok(); |
| 104 | } |
| 105 | |
| 106 | ScopedAStatus RadioData::setDataThrottling(int32_t serial, aidl::DataThrottlingAction dta, |
| 107 | int64_t completionDurationMs) { |
| 108 | LOG_CALL << serial; |
| 109 | if (mHal1_6) { |
| 110 | mHal1_6->setDataThrottling(serial, V1_6::DataThrottlingAction(dta), completionDurationMs); |
| 111 | } else { |
| 112 | respond().setDataThrottlingResponse(notSupported(serial)); |
| 113 | } |
| 114 | return ok(); |
| 115 | } |
| 116 | |
| 117 | ScopedAStatus RadioData::setInitialAttachApn(int32_t serial, const aidl::DataProfileInfo& info) { |
| 118 | LOG_CALL << serial; |
| 119 | mHal1_5->setInitialAttachApn_1_5(serial, toHidl(info)); |
| 120 | return ok(); |
| 121 | } |
| 122 | |
| 123 | ScopedAStatus RadioData::setResponseFunctions( |
| 124 | const std::shared_ptr<aidl::IRadioDataResponse>& dataResponse, |
| 125 | const std::shared_ptr<aidl::IRadioDataIndication>& dataIndication) { |
| 126 | LOG_CALL << dataResponse << ' ' << dataIndication; |
| 127 | |
| 128 | CHECK(dataResponse); |
| 129 | CHECK(dataIndication); |
| 130 | |
| 131 | mRadioResponse->setResponseFunction(dataResponse); |
| 132 | mRadioIndication->setResponseFunction(dataIndication); |
| 133 | |
| 134 | return ok(); |
| 135 | } |
| 136 | |
| 137 | ScopedAStatus RadioData::setupDataCall( // |
| 138 | int32_t serial, aidlCommon::AccessNetwork accessNetwork, |
| 139 | const aidl::DataProfileInfo& dataProfileInfo, bool roamingAllowed, |
| 140 | aidl::DataRequestReason reason, const std::vector<aidl::LinkAddress>& addresses, |
| 141 | const std::vector<std::string>& dnses, int32_t pduSessId, |
| 142 | const std::optional<aidl::SliceInfo>& sliceInfo, |
| 143 | const std::optional<aidl::TrafficDescriptor>& trDesc, bool matchAllRuleAllowed) { |
| 144 | if (mHal1_6) { |
| 145 | mHal1_6->setupDataCall_1_6( // |
| 146 | serial, V1_5::AccessNetwork(accessNetwork), toHidl(dataProfileInfo), roamingAllowed, |
| 147 | V1_2::DataRequestReason(reason), toHidl(addresses), toHidl(dnses), pduSessId, |
| 148 | toHidl<V1_6::OptionalSliceInfo>(sliceInfo), |
| 149 | toHidl<V1_6::OptionalTrafficDescriptor>(trDesc), matchAllRuleAllowed); |
| 150 | } else { |
| 151 | mHal1_5->setupDataCall_1_5( // |
| 152 | serial, V1_5::AccessNetwork(accessNetwork), toHidl(dataProfileInfo), roamingAllowed, |
| 153 | V1_2::DataRequestReason(reason), toHidl(addresses), toHidl(dnses)); |
| 154 | } |
| 155 | return ok(); |
| 156 | } |
| 157 | |
| 158 | ScopedAStatus RadioData::startHandover(int32_t serial, int32_t callId) { |
| 159 | LOG_CALL << serial; |
| 160 | if (mHal1_6) { |
| 161 | mHal1_6->startHandover(serial, callId); |
| 162 | } else { |
| 163 | respond().startHandoverResponse(notSupported(serial)); |
| 164 | } |
| 165 | return ok(); |
| 166 | } |
| 167 | |
| 168 | ScopedAStatus RadioData::startKeepalive(int32_t serial, const aidl::KeepaliveRequest& keepalive) { |
| 169 | LOG_CALL << serial; |
| 170 | mHal1_5->startKeepalive(serial, toHidl(keepalive)); |
| 171 | return ok(); |
| 172 | } |
| 173 | |
| 174 | ScopedAStatus RadioData::stopKeepalive(int32_t serial, int32_t sessionHandle) { |
| 175 | LOG_CALL << serial; |
| 176 | mHal1_5->stopKeepalive(serial, sessionHandle); |
| 177 | return ok(); |
| 178 | } |
| 179 | |
| 180 | } // namespace android::hardware::radio::compat |