1 /* 2 * Copyright (C) 2025 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 #pragma once 18 #include <memory> 19 #include <mutex> 20 #include <unordered_map> 21 #include <unordered_set> 22 23 #include <aidl/android/hardware/radio/data/BnRadioData.h> 24 #include "AtChannel.h" 25 #include "IdAllocator.h" 26 27 namespace aidl { 28 namespace android { 29 namespace hardware { 30 namespace radio { 31 namespace implementation { 32 using ::ndk::ScopedAStatus; 33 34 struct RadioData : public data::BnRadioData { 35 RadioData(std::shared_ptr<AtChannel> atChannel); 36 37 ScopedAStatus getSlicingConfig(int32_t serial) override; 38 39 ScopedAStatus setDataAllowed(int32_t serial, bool allow) override; 40 ScopedAStatus setDataProfile( 41 int32_t serial, 42 const std::vector<data::DataProfileInfo>& profiles) 43 override; 44 ScopedAStatus setDataThrottling( 45 int32_t serial, 46 data::DataThrottlingAction dataThrottlingAction, 47 int64_t completionDurationMillis) override; 48 ScopedAStatus setInitialAttachApn( 49 int32_t serial, 50 const std::optional<data::DataProfileInfo>& dpInfo) 51 override; 52 53 ScopedAStatus allocatePduSessionId(int32_t serial) override; 54 ScopedAStatus releasePduSessionId(int32_t serial, int32_t id) override; 55 56 ScopedAStatus setupDataCall( 57 int32_t serial, AccessNetwork accessNetwork, 58 const data::DataProfileInfo& dataProfileInfo, 59 bool roamingAllowed, data::DataRequestReason reason, 60 const std::vector<data::LinkAddress>& addresses, 61 const std::vector<std::string>& dnses, int32_t pduSessionId, 62 const std::optional<data::SliceInfo>& sliceInfo, 63 bool matchAllRuleAllowed) override; 64 ScopedAStatus deactivateDataCall( 65 int32_t serial, int32_t cid, 66 data::DataRequestReason reason) override; 67 ScopedAStatus getDataCallList(int32_t serial) override; 68 69 ScopedAStatus startHandover(int32_t serial, int32_t callId) override; 70 ScopedAStatus cancelHandover(int32_t serial, int32_t callId) override; 71 72 ScopedAStatus startKeepalive( 73 int32_t serial, 74 const data::KeepaliveRequest& keepalive) override; 75 ScopedAStatus stopKeepalive(int32_t serial, int32_t sessionHandle) override; 76 77 void atResponseSink(const AtResponsePtr& response); handleUnsolicitedRadioData78 template <class IGNORE> void handleUnsolicited(const IGNORE&) {} 79 80 ScopedAStatus responseAcknowledgement() override; 81 ScopedAStatus setResponseFunctions( 82 const std::shared_ptr<data::IRadioDataResponse>& radioDataResponse, 83 const std::shared_ptr<data::IRadioDataIndication>& radioDataIndication) override; 84 85 private: 86 int32_t allocateId(); 87 void releaseId(int32_t cid); 88 89 std::vector<data::SetupDataCallResult> getDataCalls() const; 90 91 const std::shared_ptr<AtChannel> mAtChannel; 92 AtChannel::Conversation mAtConversation; 93 std::shared_ptr<data::IRadioDataResponse> mRadioDataResponse; 94 std::shared_ptr<data::IRadioDataIndication> mRadioDataIndication; 95 std::unordered_map<int32_t, data::SetupDataCallResult> mDataCalls; 96 std::unordered_set<int32_t> mKeepAliveSessions; 97 IdAllocator mIdAllocator; 98 mutable std::mutex mMtx; 99 }; 100 101 } // namespace implementation 102 } // namespace radio 103 } // namespace hardware 104 } // namespace android 105 } // namespace aidl 106