blob: eb9bcf7197a5a2cc1c62ea8295246976f42601c7 [file] [log] [blame]
Tomasz Wasilczyk610ca0e2023-12-11 13:23:17 -08001/*
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/modem/BnRadioModemResponse.h>
21#undef __assert2
22#undef __noreturn__
23#include <cassert>
24
25#include <libminradio/modem/RadioModemResponseTracker.h>
26
27#include <libminradio/debug.h>
28
29#define RADIO_MODULE "ModemResponse"
30
31namespace android::hardware::radio::minimal {
32
33using namespace ::android::hardware::radio::minimal::binder_printing;
34using ::aidl::android::hardware::radio::RadioResponseInfo;
35using ::ndk::ScopedAStatus;
36namespace aidl = ::aidl::android::hardware::radio::modem;
37
38RadioModemResponseTracker::RadioModemResponseTracker(
39 std::shared_ptr<aidl::IRadioModem> req,
40 const std::shared_ptr<aidl::IRadioModemResponse>& resp)
41 : ResponseTracker(req, resp) {}
42
43ResponseTrackerResult<aidl::ImeiInfo> RadioModemResponseTracker::getImei() {
44 auto serial = newSerial();
45 if (auto status = request()->getImei(serial); !status.isOk()) return status;
46 return getResult<aidl::ImeiInfo>(serial);
47}
48
49ScopedAStatus RadioModemResponseTracker::getImeiResponse(
50 const RadioResponseInfo& info, const std::optional<aidl::ImeiInfo>& respData) {
51 LOG_CALL_RESPONSE << respData;
52 if (isTracked(info.serial)) return handle(info, respData.value_or(aidl::ImeiInfo{}));
53 return IRadioModemResponseDelegator::getImeiResponse(info, respData);
54}
55
56} // namespace android::hardware::radio::minimal