2 * Copyright (C) 2017 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <android-base/logging.h>
19 #include <VtsHalHidlTargetTestBase.h>
21 #include <condition_variable>
24 #include <android/hardware/radio/1.0/ISap.h>
25 #include <android/hardware/radio/1.0/ISapCallback.h>
26 #include <android/hardware/radio/1.0/types.h>
28 #include "vts_test_util.h"
30 using namespace ::android::hardware::radio::V1_0;
32 using ::android::hardware::hidl_string;
33 using ::android::hardware::hidl_vec;
34 using ::android::hardware::Return;
35 using ::android::hardware::Void;
38 #define TIMEOUT_PERIOD 40
39 #define SAP_SERVICE_NAME "slot1"
43 /* Callback class for sap response */
44 class SapCallback : public ISapCallback {
49 SapResultCode sapResultCode;
50 int32_t sapResponseToken;
52 SapCallback(SapHidlTest& parent);
54 virtual ~SapCallback() = default;
56 Return<void> connectResponse(int32_t token, SapConnectRsp sapConnectRsp, int32_t maxMsgSize);
58 Return<void> disconnectResponse(int32_t token);
60 Return<void> disconnectIndication(int32_t token, SapDisconnectType disconnectType);
62 Return<void> apduResponse(int32_t token, SapResultCode resultCode,
63 const ::android::hardware::hidl_vec<uint8_t>& apduRsp);
65 Return<void> transferAtrResponse(int32_t token, SapResultCode resultCode,
66 const ::android::hardware::hidl_vec<uint8_t>& atr);
68 Return<void> powerResponse(int32_t token, SapResultCode resultCode);
70 Return<void> resetSimResponse(int32_t token, SapResultCode resultCode);
72 Return<void> statusIndication(int32_t token, SapStatus status);
74 Return<void> transferCardReaderStatusResponse(int32_t token, SapResultCode resultCode,
75 int32_t cardReaderStatus);
77 Return<void> errorResponse(int32_t token);
79 Return<void> transferProtocolResponse(int32_t token, SapResultCode resultCode);
82 // The main test class for Sap HIDL.
83 class SapHidlTest : public ::testing::VtsHalHidlTargetTestBase {
86 std::condition_variable cv;
90 virtual void SetUp() override;
92 virtual void TearDown() override;
94 /* Used as a mechanism to inform the test about data/event callback */
97 /* Test code calls this function to wait for response */
98 std::cv_status wait();
103 /* Sap Callback object */
104 sp<SapCallback> sapCb;
107 // A class for test environment setup
108 class SapHidlEnvironment : public ::testing::Environment {
110 virtual void SetUp() {}
111 virtual void TearDown() {}