• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 // see assert2_no_op in ResponseTracker.cpp
18 #define __assert2 assert2_no_op
19 #define __noreturn__ const
20 #include <aidl/android/hardware/radio/network/BnRadioNetworkResponse.h>
21 #undef __assert2
22 #undef __noreturn__
23 #include <cassert>
24 
25 #include <libminradio/network/RadioNetworkResponseTracker.h>
26 
27 #include <libminradio/debug.h>
28 
29 #define RADIO_MODULE "NetworkResponse"
30 
31 namespace android::hardware::radio::minimal {
32 
33 using namespace ::android::hardware::radio::minimal::binder_printing;
34 using ::aidl::android::hardware::radio::RadioResponseInfo;
35 using ::ndk::ScopedAStatus;
36 namespace aidl = ::aidl::android::hardware::radio::network;
37 
RadioNetworkResponseTracker(std::shared_ptr<aidl::IRadioNetwork> req,const std::shared_ptr<aidl::IRadioNetworkResponse> & resp)38 RadioNetworkResponseTracker::RadioNetworkResponseTracker(
39         std::shared_ptr<aidl::IRadioNetwork> req,
40         const std::shared_ptr<aidl::IRadioNetworkResponse>& resp)
41     : ResponseTracker(req, resp) {}
42 
43 ResponseTrackerResult<aidl::RegStateResult>
getDataRegistrationState()44 RadioNetworkResponseTracker::getDataRegistrationState() {
45     auto serial = newSerial();
46     if (auto status = request()->getDataRegistrationState(serial); !status.isOk()) return status;
47     return getResult<aidl::RegStateResult>(serial);
48 }
49 
getDataRegistrationStateResponse(const RadioResponseInfo & info,const aidl::RegStateResult & respData)50 ScopedAStatus RadioNetworkResponseTracker::getDataRegistrationStateResponse(
51         const RadioResponseInfo& info, const aidl::RegStateResult& respData) {
52     LOG_CALL_RESPONSE << respData;
53     if (isTracked(info.serial)) return handle(info, respData);
54     return IRadioNetworkResponseDelegator::getDataRegistrationStateResponse(info, respData);
55 }
56 
getSignalStrength()57 ResponseTrackerResult<aidl::SignalStrength> RadioNetworkResponseTracker::getSignalStrength() {
58     auto serial = newSerial();
59     if (auto status = request()->getSignalStrength(serial); !status.isOk()) return status;
60     return getResult<aidl::SignalStrength>(serial);
61 }
62 
getSignalStrengthResponse(const RadioResponseInfo & info,const aidl::SignalStrength & respData)63 ScopedAStatus RadioNetworkResponseTracker::getSignalStrengthResponse(
64         const RadioResponseInfo& info, const aidl::SignalStrength& respData) {
65     LOG_CALL_RESPONSE << respData;
66     if (isTracked(info.serial)) return handle(info, respData);
67     return IRadioNetworkResponseDelegator::getSignalStrengthResponse(info, respData);
68 }
69 
70 }  // namespace android::hardware::radio::minimal
71