• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
respond()34 std::shared_ptr<aidl::IRadioDataResponse> RadioData::respond() {
35     return mCallbackManager->response().dataCb();
36 }
37 
allocatePduSessionId(int32_t serial)38 ScopedAStatus RadioData::allocatePduSessionId(int32_t serial) {
39     LOG_CALL << serial;
40     if (mHal1_6) {
41         mHal1_6->allocatePduSessionId(serial);
42     } else {
43         respond()->allocatePduSessionIdResponse(notSupported(serial), 0);
44     }
45     return ok();
46 }
47 
cancelHandover(int32_t serial,int32_t callId)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 {
53         respond()->cancelHandoverResponse(notSupported(serial));
54     }
55     return ok();
56 }
57 
deactivateDataCall(int32_t serial,int32_t cid,aidl::DataRequestReason reason)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 
getDataCallList(int32_t serial)65 ScopedAStatus RadioData::getDataCallList(int32_t serial) {
66     LOG_CALL << serial;
67     if (mHal1_6) {
68         mHal1_6->getDataCallList_1_6(serial);
69     } else {
70         mHal1_5->getDataCallList(serial);
71     }
72     return ok();
73 }
74 
getSlicingConfig(int32_t serial)75 ScopedAStatus RadioData::getSlicingConfig(int32_t serial) {
76     LOG_CALL << serial;
77     if (mHal1_6) {
78         mHal1_6->getSlicingConfig(serial);
79     } else {
80         respond()->getSlicingConfigResponse(notSupported(serial), {});
81     }
82     return ok();
83 }
84 
releasePduSessionId(int32_t serial,int32_t id)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 {
90         respond()->releasePduSessionIdResponse(notSupported(serial));
91     }
92     return ok();
93 }
94 
responseAcknowledgement()95 ScopedAStatus RadioData::responseAcknowledgement() {
96     LOG_CALL;
97     mHal1_5->responseAcknowledgement();
98     return ok();
99 }
100 
setDataAllowed(int32_t serial,bool allow)101 ScopedAStatus RadioData::setDataAllowed(int32_t serial, bool allow) {
102     LOG_CALL << serial;
103     mHal1_5->setDataAllowed(serial, allow);
104     return ok();
105 }
106 
setDataProfile(int32_t serial,const std::vector<aidl::DataProfileInfo> & profiles)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 
setDataThrottling(int32_t serial,aidl::DataThrottlingAction dta,int64_t completionDurationMs)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 {
120         respond()->setDataThrottlingResponse(notSupported(serial));
121     }
122     return ok();
123 }
124 
setInitialAttachApn(int32_t serial,const std::optional<aidl::DataProfileInfo> & info)125 ScopedAStatus RadioData::setInitialAttachApn(int32_t serial,
126                                              const std::optional<aidl::DataProfileInfo>& info) {
127     LOG_CALL << serial;
128     mHal1_5->setInitialAttachApn_1_5(serial, toHidl(info.value()));
129     return ok();
130 }
131 
setResponseFunctions(const std::shared_ptr<aidl::IRadioDataResponse> & response,const std::shared_ptr<aidl::IRadioDataIndication> & indication)132 ScopedAStatus RadioData::setResponseFunctions(
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);
137     return ok();
138 }
139 
setupDataCall(int32_t serial,aidlCommon::AccessNetwork accessNetwork,const aidl::DataProfileInfo & dataProfileInfo,bool roamingAllowed,aidl::DataRequestReason reason,const std::vector<aidl::LinkAddress> & addresses,const std::vector<std::string> & dnses,int32_t pduSessId,const std::optional<aidl::SliceInfo> & sliceInfo,bool matchAllRuleAllowed)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) {
147     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),
152                 toHidl<V1_6::OptionalTrafficDescriptor>(dataProfileInfo.trafficDescriptor),
153                 matchAllRuleAllowed);
154         mContext->addDataProfile(dataProfileInfo);
155     } 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 
startHandover(int32_t serial,int32_t callId)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 {
168         respond()->startHandoverResponse(notSupported(serial));
169     }
170     return ok();
171 }
172 
startKeepalive(int32_t serial,const aidl::KeepaliveRequest & keepalive)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 
stopKeepalive(int32_t serial,int32_t sessionHandle)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
186