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 | |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 34 | std::shared_ptr<aidl::IRadioDataResponse> RadioData::respond() { |
Tomasz Wasilczyk | 963a56f | 2021-12-16 12:19:09 -0800 | [diff] [blame] | 35 | return mCallbackManager->response().dataCb(); |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 36 | } |
| 37 | |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 38 | ScopedAStatus RadioData::allocatePduSessionId(int32_t serial) { |
| 39 | LOG_CALL << serial; |
| 40 | if (mHal1_6) { |
| 41 | mHal1_6->allocatePduSessionId(serial); |
| 42 | } else { |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 43 | respond()->allocatePduSessionIdResponse(notSupported(serial), 0); |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 44 | } |
| 45 | return ok(); |
| 46 | } |
| 47 | |
| 48 | ScopedAStatus RadioData::cancelHandover(int32_t serial, int32_t callId) { |
| 49 | LOG_CALL << serial; |
| 50 | if (mHal1_6) { |
| 51 | mHal1_6->cancelHandover(serial, callId); |
| 52 | } else { |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 53 | respond()->cancelHandoverResponse(notSupported(serial)); |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 54 | } |
| 55 | return ok(); |
| 56 | } |
| 57 | |
| 58 | ScopedAStatus RadioData::deactivateDataCall(int32_t serial, int32_t cid, |
| 59 | aidl::DataRequestReason reason) { |
| 60 | LOG_CALL << serial; |
| 61 | mHal1_5->deactivateDataCall_1_2(serial, cid, V1_2::DataRequestReason(reason)); |
| 62 | return ok(); |
| 63 | } |
| 64 | |
| 65 | ScopedAStatus RadioData::getDataCallList(int32_t serial) { |
| 66 | LOG_CALL << serial; |
Tomasz Wasilczyk | 571542b | 2021-12-15 16:15:45 -0800 | [diff] [blame] | 67 | if (mHal1_6) { |
| 68 | mHal1_6->getDataCallList_1_6(serial); |
| 69 | } else { |
| 70 | mHal1_5->getDataCallList(serial); |
| 71 | } |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 72 | return ok(); |
| 73 | } |
| 74 | |
| 75 | ScopedAStatus RadioData::getSlicingConfig(int32_t serial) { |
| 76 | LOG_CALL << serial; |
| 77 | if (mHal1_6) { |
| 78 | mHal1_6->getSlicingConfig(serial); |
| 79 | } else { |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 80 | respond()->getSlicingConfigResponse(notSupported(serial), {}); |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 81 | } |
| 82 | return ok(); |
| 83 | } |
| 84 | |
| 85 | ScopedAStatus RadioData::releasePduSessionId(int32_t serial, int32_t id) { |
| 86 | LOG_CALL << serial; |
| 87 | if (mHal1_6) { |
| 88 | mHal1_6->releasePduSessionId(serial, id); |
| 89 | } else { |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 90 | respond()->releasePduSessionIdResponse(notSupported(serial)); |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 91 | } |
| 92 | return ok(); |
| 93 | } |
| 94 | |
| 95 | ScopedAStatus RadioData::responseAcknowledgement() { |
| 96 | LOG_CALL; |
| 97 | mHal1_5->responseAcknowledgement(); |
| 98 | return ok(); |
| 99 | } |
| 100 | |
| 101 | ScopedAStatus RadioData::setDataAllowed(int32_t serial, bool allow) { |
| 102 | LOG_CALL << serial; |
| 103 | mHal1_5->setDataAllowed(serial, allow); |
| 104 | return ok(); |
| 105 | } |
| 106 | |
| 107 | ScopedAStatus RadioData::setDataProfile(int32_t serial, |
| 108 | const std::vector<aidl::DataProfileInfo>& profiles) { |
| 109 | LOG_CALL << serial; |
| 110 | mHal1_5->setDataProfile_1_5(serial, toHidl(profiles)); |
| 111 | return ok(); |
| 112 | } |
| 113 | |
| 114 | ScopedAStatus RadioData::setDataThrottling(int32_t serial, aidl::DataThrottlingAction dta, |
| 115 | int64_t completionDurationMs) { |
| 116 | LOG_CALL << serial; |
| 117 | if (mHal1_6) { |
| 118 | mHal1_6->setDataThrottling(serial, V1_6::DataThrottlingAction(dta), completionDurationMs); |
| 119 | } else { |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 120 | respond()->setDataThrottlingResponse(notSupported(serial)); |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 121 | } |
| 122 | return ok(); |
| 123 | } |
| 124 | |
Sarah Chin | 4ae4e17 | 2022-01-25 14:24:43 -0800 | [diff] [blame^] | 125 | ScopedAStatus RadioData::setInitialAttachApn(int32_t serial, |
| 126 | const std::optional<aidl::DataProfileInfo>& info) { |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 127 | LOG_CALL << serial; |
Sarah Chin | 4ae4e17 | 2022-01-25 14:24:43 -0800 | [diff] [blame^] | 128 | mHal1_5->setInitialAttachApn_1_5(serial, toHidl(info.value())); |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 129 | return ok(); |
| 130 | } |
| 131 | |
| 132 | ScopedAStatus RadioData::setResponseFunctions( |
Tomasz Wasilczyk | 963a56f | 2021-12-16 12:19:09 -0800 | [diff] [blame] | 133 | const std::shared_ptr<aidl::IRadioDataResponse>& response, |
| 134 | const std::shared_ptr<aidl::IRadioDataIndication>& indication) { |
| 135 | LOG_CALL << response << ' ' << indication; |
| 136 | mCallbackManager->setResponseFunctions(response, indication); |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 137 | return ok(); |
| 138 | } |
| 139 | |
Sarah Chin | 4ae4e17 | 2022-01-25 14:24:43 -0800 | [diff] [blame^] | 140 | ScopedAStatus RadioData::setupDataCall(int32_t serial, aidlCommon::AccessNetwork accessNetwork, |
| 141 | const aidl::DataProfileInfo& dataProfileInfo, |
| 142 | bool roamingAllowed, aidl::DataRequestReason reason, |
| 143 | const std::vector<aidl::LinkAddress>& addresses, |
| 144 | const std::vector<std::string>& dnses, int32_t pduSessId, |
| 145 | const std::optional<aidl::SliceInfo>& sliceInfo, |
| 146 | bool matchAllRuleAllowed) { |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 147 | if (mHal1_6) { |
Sarah Chin | 4ae4e17 | 2022-01-25 14:24:43 -0800 | [diff] [blame^] | 148 | mHal1_6->setupDataCall_1_6( |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 149 | serial, V1_5::AccessNetwork(accessNetwork), toHidl(dataProfileInfo), roamingAllowed, |
| 150 | V1_2::DataRequestReason(reason), toHidl(addresses), toHidl(dnses), pduSessId, |
| 151 | toHidl<V1_6::OptionalSliceInfo>(sliceInfo), |
Sarah Chin | e98dd0e | 2021-12-09 00:33:37 -0800 | [diff] [blame] | 152 | toHidl<V1_6::OptionalTrafficDescriptor>(dataProfileInfo.trafficDescriptor), |
| 153 | matchAllRuleAllowed); |
| 154 | mContext->addDataProfile(dataProfileInfo); |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 155 | } else { |
Sarah Chin | 4ae4e17 | 2022-01-25 14:24:43 -0800 | [diff] [blame^] | 156 | mHal1_5->setupDataCall_1_5( |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 157 | serial, V1_5::AccessNetwork(accessNetwork), toHidl(dataProfileInfo), roamingAllowed, |
| 158 | V1_2::DataRequestReason(reason), toHidl(addresses), toHidl(dnses)); |
| 159 | } |
| 160 | return ok(); |
| 161 | } |
| 162 | |
| 163 | ScopedAStatus RadioData::startHandover(int32_t serial, int32_t callId) { |
| 164 | LOG_CALL << serial; |
| 165 | if (mHal1_6) { |
| 166 | mHal1_6->startHandover(serial, callId); |
| 167 | } else { |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 168 | respond()->startHandoverResponse(notSupported(serial)); |
Tomasz Wasilczyk | 0716169 | 2021-11-02 12:14:52 -0700 | [diff] [blame] | 169 | } |
| 170 | return ok(); |
| 171 | } |
| 172 | |
| 173 | ScopedAStatus RadioData::startKeepalive(int32_t serial, const aidl::KeepaliveRequest& keepalive) { |
| 174 | LOG_CALL << serial; |
| 175 | mHal1_5->startKeepalive(serial, toHidl(keepalive)); |
| 176 | return ok(); |
| 177 | } |
| 178 | |
| 179 | ScopedAStatus RadioData::stopKeepalive(int32_t serial, int32_t sessionHandle) { |
| 180 | LOG_CALL << serial; |
| 181 | mHal1_5->stopKeepalive(serial, sessionHandle); |
| 182 | return ok(); |
| 183 | } |
| 184 | |
| 185 | } // namespace android::hardware::radio::compat |