blob: c819251831c3a559c52a5b07903c57a004e33c3c [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;
67 mHal1_5->getDataCallList(serial);
68 return ok();
69}
70
71ScopedAStatus RadioData::getSlicingConfig(int32_t serial) {
72 LOG_CALL << serial;
73 if (mHal1_6) {
74 mHal1_6->getSlicingConfig(serial);
75 } else {
Tomasz Wasilczyk60638572021-12-13 17:13:48 -080076 respond()->getSlicingConfigResponse(notSupported(serial), {});
Tomasz Wasilczyk07161692021-11-02 12:14:52 -070077 }
78 return ok();
79}
80
81ScopedAStatus RadioData::releasePduSessionId(int32_t serial, int32_t id) {
82 LOG_CALL << serial;
83 if (mHal1_6) {
84 mHal1_6->releasePduSessionId(serial, id);
85 } else {
Tomasz Wasilczyk60638572021-12-13 17:13:48 -080086 respond()->releasePduSessionIdResponse(notSupported(serial));
Tomasz Wasilczyk07161692021-11-02 12:14:52 -070087 }
88 return ok();
89}
90
91ScopedAStatus RadioData::responseAcknowledgement() {
92 LOG_CALL;
93 mHal1_5->responseAcknowledgement();
94 return ok();
95}
96
97ScopedAStatus RadioData::setDataAllowed(int32_t serial, bool allow) {
98 LOG_CALL << serial;
99 mHal1_5->setDataAllowed(serial, allow);
100 return ok();
101}
102
103ScopedAStatus RadioData::setDataProfile(int32_t serial,
104 const std::vector<aidl::DataProfileInfo>& profiles) {
105 LOG_CALL << serial;
106 mHal1_5->setDataProfile_1_5(serial, toHidl(profiles));
107 return ok();
108}
109
110ScopedAStatus RadioData::setDataThrottling(int32_t serial, aidl::DataThrottlingAction dta,
111 int64_t completionDurationMs) {
112 LOG_CALL << serial;
113 if (mHal1_6) {
114 mHal1_6->setDataThrottling(serial, V1_6::DataThrottlingAction(dta), completionDurationMs);
115 } else {
Tomasz Wasilczyk60638572021-12-13 17:13:48 -0800116 respond()->setDataThrottlingResponse(notSupported(serial));
Tomasz Wasilczyk07161692021-11-02 12:14:52 -0700117 }
118 return ok();
119}
120
121ScopedAStatus RadioData::setInitialAttachApn(int32_t serial, const aidl::DataProfileInfo& info) {
122 LOG_CALL << serial;
123 mHal1_5->setInitialAttachApn_1_5(serial, toHidl(info));
124 return ok();
125}
126
127ScopedAStatus RadioData::setResponseFunctions(
128 const std::shared_ptr<aidl::IRadioDataResponse>& dataResponse,
129 const std::shared_ptr<aidl::IRadioDataIndication>& dataIndication) {
130 LOG_CALL << dataResponse << ' ' << dataIndication;
131
132 CHECK(dataResponse);
133 CHECK(dataIndication);
134
135 mRadioResponse->setResponseFunction(dataResponse);
136 mRadioIndication->setResponseFunction(dataIndication);
137
138 return ok();
139}
140
141ScopedAStatus RadioData::setupDataCall( //
142 int32_t serial, aidlCommon::AccessNetwork accessNetwork,
143 const aidl::DataProfileInfo& dataProfileInfo, bool roamingAllowed,
144 aidl::DataRequestReason reason, const std::vector<aidl::LinkAddress>& addresses,
145 const std::vector<std::string>& dnses, int32_t pduSessId,
Sarah Chine98dd0e2021-12-09 00:33:37 -0800146 const std::optional<aidl::SliceInfo>& sliceInfo, bool matchAllRuleAllowed) {
Tomasz Wasilczyk07161692021-11-02 12:14:52 -0700147 if (mHal1_6) {
148 mHal1_6->setupDataCall_1_6( //
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 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 {
156 mHal1_5->setupDataCall_1_5( //
157 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