/* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include #include #include #include "vts_test_util.h" using namespace ::android::hardware::radio::V1_0; using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; using ::android::sp; #define TIMEOUT_PERIOD 40 #define SAP_SERVICE_NAME "slot1" class SapHidlTest; /* Callback class for sap response */ class SapCallback : public ISapCallback { private: SapHidlTest& parent; public: SapResultCode sapResultCode; int32_t sapResponseToken; SapCallback(SapHidlTest& parent); virtual ~SapCallback() = default; Return connectResponse(int32_t token, SapConnectRsp sapConnectRsp, int32_t maxMsgSize); Return disconnectResponse(int32_t token); Return disconnectIndication(int32_t token, SapDisconnectType disconnectType); Return apduResponse(int32_t token, SapResultCode resultCode, const ::android::hardware::hidl_vec& apduRsp); Return transferAtrResponse(int32_t token, SapResultCode resultCode, const ::android::hardware::hidl_vec& atr); Return powerResponse(int32_t token, SapResultCode resultCode); Return resetSimResponse(int32_t token, SapResultCode resultCode); Return statusIndication(int32_t token, SapStatus status); Return transferCardReaderStatusResponse(int32_t token, SapResultCode resultCode, int32_t cardReaderStatus); Return errorResponse(int32_t token); Return transferProtocolResponse(int32_t token, SapResultCode resultCode); }; // Test environment for Sap HIDL HAL. class SapHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { public: // get the test environment singleton static SapHidlEnvironment* Instance() { static SapHidlEnvironment* instance = new SapHidlEnvironment; return instance; } virtual void registerTestServices() override { registerTestService(); } private: SapHidlEnvironment() {} }; // The main test class for Sap HIDL. class SapHidlTest : public ::testing::VtsHalHidlTargetTestBase { private: std::mutex mtx; std::condition_variable cv; int count; public: virtual void SetUp() override; virtual void TearDown() override; /* Used as a mechanism to inform the test about data/event callback */ void notify(int receivedToken); /* Test code calls this function to wait for response */ std::cv_status wait(); /* Sap service */ sp sap; /* Sap Callback object */ sp sapCb; /* Token for sap request */ int32_t token; };