blob: 51f554342086b89b5c41f2633c254047f11268ba [file] [log] [blame]
Tomasz Wasilczyk07161692021-11-02 12:14:52 -07001/*
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
27namespace android::hardware::radio::compat {
28
29using ::ndk::ScopedAStatus;
30namespace aidl = ::aidl::android::hardware::radio::data;
31namespace aidlCommon = ::aidl::android::hardware::radio;
32constexpr auto ok = &ScopedAStatus::ok;
33
Tomasz Wasilczyk60638572021-12-13 17:13:48 -080034std::shared_ptr<aidl::IRadioDataResponse> RadioData::respond() {
Tomasz Wasilczyk963a56f2021-12-16 12:19:09 -080035 return mCallbackManager->response().dataCb();
Tomasz Wasilczyk60638572021-12-13 17:13:48 -080036}
37
Tomasz Wasilczyk07161692021-11-02 12:14:52 -070038ScopedAStatus RadioData::allocatePduSessionId(int32_t serial) {
39 LOG_CALL << serial;
40 if (mHal1_6) {
41 mHal1_6->allocatePduSessionId(serial);
42 } else {
Tomasz Wasilczyk60638572021-12-13 17:13:48 -080043 respond()->allocatePduSessionIdResponse(notSupported(serial), 0);
Tomasz Wasilczyk07161692021-11-02 12:14:52 -070044 }
45 return ok();
46}
47
48ScopedAStatus 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 Wasilczyk60638572021-12-13 17:13:48 -080053 respond()->cancelHandoverResponse(notSupported(serial));
Tomasz Wasilczyk07161692021-11-02 12:14:52 -070054 }
55 return ok();
56}
57
58ScopedAStatus 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
65ScopedAStatus RadioData::getDataCallList(int32_t serial) {
66 LOG_CALL << serial;
Tomasz Wasilczyk571542b2021-12-15 16:15:45 -080067 if (mHal1_6) {
68 mHal1_6->getDataCallList_1_6(serial);
69 } else {
70 mHal1_5->getDataCallList(serial);
71 }
Tomasz Wasilczyk07161692021-11-02 12:14:52 -070072 return ok();
73}
74
75ScopedAStatus RadioData::getSlicingConfig(int32_t serial) {
76 LOG_CALL << serial;
77 if (mHal1_6) {
78 mHal1_6->getSlicingConfig(serial);
79 } else {
Tomasz Wasilczyk60638572021-12-13 17:13:48 -080080 respond()->getSlicingConfigResponse(notSupported(serial), {});
Tomasz Wasilczyk07161692021-11-02 12:14:52 -070081 }
82 return ok();
83}
84
85ScopedAStatus 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 Wasilczyk60638572021-12-13 17:13:48 -080090 respond()->releasePduSessionIdResponse(notSupported(serial));
Tomasz Wasilczyk07161692021-11-02 12:14:52 -070091 }
92 return ok();
93}
94
95ScopedAStatus RadioData::responseAcknowledgement() {
96 LOG_CALL;
97 mHal1_5->responseAcknowledgement();
98 return ok();
99}
100
101ScopedAStatus RadioData::setDataAllowed(int32_t serial, bool allow) {
102 LOG_CALL << serial;
103 mHal1_5->setDataAllowed(serial, allow);
104 return ok();
105}
106
107ScopedAStatus 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
114ScopedAStatus 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 Wasilczyk60638572021-12-13 17:13:48 -0800120 respond()->setDataThrottlingResponse(notSupported(serial));
Tomasz Wasilczyk07161692021-11-02 12:14:52 -0700121 }
122 return ok();
123}
124
Sarah Chin4ae4e172022-01-25 14:24:43 -0800125ScopedAStatus RadioData::setInitialAttachApn(int32_t serial,
126 const std::optional<aidl::DataProfileInfo>& info) {
Tomasz Wasilczyk07161692021-11-02 12:14:52 -0700127 LOG_CALL << serial;
Sarah Chin4ae4e172022-01-25 14:24:43 -0800128 mHal1_5->setInitialAttachApn_1_5(serial, toHidl(info.value()));
Tomasz Wasilczyk07161692021-11-02 12:14:52 -0700129 return ok();
130}
131
132ScopedAStatus RadioData::setResponseFunctions(
Tomasz Wasilczyk963a56f2021-12-16 12:19:09 -0800133 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 Wasilczyk07161692021-11-02 12:14:52 -0700137 return ok();
138}
139
Sarah Chin4ae4e172022-01-25 14:24:43 -0800140ScopedAStatus 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 Wasilczyk07161692021-11-02 12:14:52 -0700147 if (mHal1_6) {
Sarah Chin4ae4e172022-01-25 14:24:43 -0800148 mHal1_6->setupDataCall_1_6(
Tomasz Wasilczyk07161692021-11-02 12:14:52 -0700149 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 Chine98dd0e2021-12-09 00:33:37 -0800152 toHidl<V1_6::OptionalTrafficDescriptor>(dataProfileInfo.trafficDescriptor),
153 matchAllRuleAllowed);
154 mContext->addDataProfile(dataProfileInfo);
Tomasz Wasilczyk07161692021-11-02 12:14:52 -0700155 } else {
Sarah Chin4ae4e172022-01-25 14:24:43 -0800156 mHal1_5->setupDataCall_1_5(
Tomasz Wasilczyk07161692021-11-02 12:14:52 -0700157 serial, V1_5::AccessNetwork(accessNetwork), toHidl(dataProfileInfo), roamingAllowed,
158 V1_2::DataRequestReason(reason), toHidl(addresses), toHidl(dnses));
159 }
160 return ok();
161}
162
163ScopedAStatus 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 Wasilczyk60638572021-12-13 17:13:48 -0800168 respond()->startHandoverResponse(notSupported(serial));
Tomasz Wasilczyk07161692021-11-02 12:14:52 -0700169 }
170 return ok();
171}
172
173ScopedAStatus 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
179ScopedAStatus 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