1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ANTI_FRAUD_SERVICE_CLIENT_H 17 #define ANTI_FRAUD_SERVICE_CLIENT_H 18 19 #include "anti_fraud_service_client_type.h" 20 #include "anti_fraud_detect_res_listener.h" 21 #include "anti_fraud_detect_res_listener_type.h" 22 #include "anti_fraud_detect_res_listener_stub_impl.h" 23 #include "ianti_fraud_detect_res_listener.h" 24 #include <vector> 25 #include <memory> 26 #include <mutex> 27 28 #define TAS_API __attribute__ ((visibility ("default"))) 29 30 namespace OHOS::AntiFraudService { 31 32 class AntiFraudServiceClient { 33 public: 34 static AntiFraudServiceClient& GetInstance(); 35 36 /** 37 * @brief Invoking anti fraud service to perform voice anti fraud detection. 38 * 39 * This is an asynchronous interface, it returns the test result through the listener callback. 40 * 41 * @param listener The listener of voice anti-fraud detection result. 42 * @return The invoking result. 43 */ 44 ErrCode AntiFraudVoiceDetect(const std::shared_ptr<AntiFraudDetectResListener> &listener); 45 46 private: 47 AntiFraudServiceClient(); 48 ~AntiFraudServiceClient() = default; 49 50 void DispatchHandleAntiFraudDetectRes(const AntiFraudInnerResult &antiFraudInnerResult); 51 52 std::mutex listenerMutex_; 53 std::shared_ptr<AntiFraudDetectResListener> listener_; 54 55 OnDetectResCallbackFunc callbackFunc_; 56 sptr<IAntiFraudDetectResListener> remoteCallback_ = nullptr; 57 58 DISALLOW_COPY_AND_MOVE(AntiFraudServiceClient); 59 }; 60 } 61 #endif