blob: 1a77169ab1b0aeb615ce10aafbf0c3526fea7c55 [file] [log] [blame]
Pomai Ahlo25fb3aa2022-12-12 13:58:55 -08001/*
2 * Copyright (C) 2022 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/Sap.h>
18
19#include "commonStructs.h"
20#include "debug.h"
21#include "structs.h"
22
23#include "collections.h"
24
25#define RADIO_MODULE "Sap"
26
27namespace android::hardware::radio::compat {
28
29using ::ndk::ScopedAStatus;
30namespace aidl = ::aidl::android::hardware::radio::sap;
31constexpr auto ok = &ScopedAStatus::ok;
32
33Sap::Sap(sp<V1_0::ISap> hidlHal) : mHal(hidlHal), mSapCallback(sp<SapCallback>::make()) {}
34
35ScopedAStatus Sap::apduReq(int32_t serial, aidl::SapApduType type,
36 const std::vector<uint8_t>& command) {
37 LOG_CALL << serial;
38 mHal->apduReq(serial, toHidl(type), toHidl(command));
39 return ok();
40}
41
42ScopedAStatus Sap::connectReq(int32_t serial, int32_t maxMsgSize) {
43 LOG_CALL << serial;
44 mHal->connectReq(serial, maxMsgSize);
45 return ok();
46}
47
48ScopedAStatus Sap::disconnectReq(int32_t serial) {
49 LOG_CALL << serial;
50 mHal->disconnectReq(serial);
51 return ok();
52}
53
54ScopedAStatus Sap::powerReq(int32_t serial, bool state) {
55 LOG_CALL << serial;
56 mHal->powerReq(serial, state);
57 return ok();
58}
59
60ScopedAStatus Sap::resetSimReq(int32_t serial) {
61 LOG_CALL << serial;
62 mHal->resetSimReq(serial);
63 return ok();
64}
65
66ScopedAStatus Sap::setCallback(
67 const std::shared_ptr<::aidl::android::hardware::radio::sap::ISapCallback>& sapCallback) {
68 LOG_CALL << sapCallback;
69
70 CHECK(sapCallback);
71
72 mSapCallback->setResponseFunction(sapCallback);
73 mHal->setCallback(mSapCallback).assertOk();
74 return ok();
75}
76ScopedAStatus Sap::setTransferProtocolReq(int32_t serial,
77 aidl::SapTransferProtocol transferProtocol) {
78 LOG_CALL << serial;
79 mHal->setTransferProtocolReq(serial, toHidl(transferProtocol));
80 return ok();
81}
82
83ScopedAStatus Sap::transferAtrReq(int32_t serial) {
84 LOG_CALL << serial;
85 mHal->transferAtrReq(serial);
86 return ok();
87}
88ScopedAStatus Sap::transferCardReaderStatusReq(int32_t serial) {
89 LOG_CALL << serial;
90 mHal->transferCardReaderStatusReq(serial);
91 return ok();
92}
93
94} // namespace android::hardware::radio::compat