blob: 91529c9af3a131326a009a7f56be0287d61e0ccc [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() {
35 return mRadioResponse->dataCb();
36}
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
125ScopedAStatus RadioData::setInitialAttachApn(int32_t serial, const aidl::DataProfileInfo& info) {
126 LOG_CALL << serial;
127 mHal1_5->setInitialAttachApn_1_5(serial, toHidl(info));
128 return ok();
129}
130
131ScopedAStatus RadioData::setResponseFunctions(
132 const std::shared_ptr<aidl::IRadioDataResponse>& dataResponse,
133 const std::shared_ptr<aidl::IRadioDataIndication>& dataIndication) {
134 LOG_CALL << dataResponse << ' ' << dataIndication;
135
136 CHECK(dataResponse);
137 CHECK(dataIndication);
138
139 mRadioResponse->setResponseFunction(dataResponse);
140 mRadioIndication->setResponseFunction(dataIndication);
141
142 return ok();
143}
144
145ScopedAStatus RadioData::setupDataCall( //
146 int32_t serial, aidlCommon::AccessNetwork accessNetwork,
147 const aidl::DataProfileInfo& dataProfileInfo, bool roamingAllowed,
148 aidl::DataRequestReason reason, const std::vector<aidl::LinkAddress>& addresses,
149 const std::vector<std::string>& dnses, int32_t pduSessId,
Sarah Chine98dd0e2021-12-09 00:33:37 -0800150 const std::optional<aidl::SliceInfo>& sliceInfo, bool matchAllRuleAllowed) {
Tomasz Wasilczyk07161692021-11-02 12:14:52 -0700151 if (mHal1_6) {
152 mHal1_6->setupDataCall_1_6( //
153 serial, V1_5::AccessNetwork(accessNetwork), toHidl(dataProfileInfo), roamingAllowed,
154 V1_2::DataRequestReason(reason), toHidl(addresses), toHidl(dnses), pduSessId,
155 toHidl<V1_6::OptionalSliceInfo>(sliceInfo),
Sarah Chine98dd0e2021-12-09 00:33:37 -0800156 toHidl<V1_6::OptionalTrafficDescriptor>(dataProfileInfo.trafficDescriptor),
157 matchAllRuleAllowed);
158 mContext->addDataProfile(dataProfileInfo);
Tomasz Wasilczyk07161692021-11-02 12:14:52 -0700159 } else {
160 mHal1_5->setupDataCall_1_5( //
161 serial, V1_5::AccessNetwork(accessNetwork), toHidl(dataProfileInfo), roamingAllowed,
162 V1_2::DataRequestReason(reason), toHidl(addresses), toHidl(dnses));
163 }
164 return ok();
165}
166
167ScopedAStatus RadioData::startHandover(int32_t serial, int32_t callId) {
168 LOG_CALL << serial;
169 if (mHal1_6) {
170 mHal1_6->startHandover(serial, callId);
171 } else {
Tomasz Wasilczyk60638572021-12-13 17:13:48 -0800172 respond()->startHandoverResponse(notSupported(serial));
Tomasz Wasilczyk07161692021-11-02 12:14:52 -0700173 }
174 return ok();
175}
176
177ScopedAStatus RadioData::startKeepalive(int32_t serial, const aidl::KeepaliveRequest& keepalive) {
178 LOG_CALL << serial;
179 mHal1_5->startKeepalive(serial, toHidl(keepalive));
180 return ok();
181}
182
183ScopedAStatus RadioData::stopKeepalive(int32_t serial, int32_t sessionHandle) {
184 LOG_CALL << serial;
185 mHal1_5->stopKeepalive(serial, sessionHandle);
186 return ok();
187}
188
189} // namespace android::hardware::radio::compat