1 /* 2 * Copyright (c) 2022 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 EXCECUTOR_H 17 #define EXCECUTOR_H 18 19 #include <cstdint> 20 #include <mutex> 21 #include <set> 22 #include <string> 23 24 #include "nocopyable.h" 25 26 #include "co_auth_client_callback.h" 27 #include "executor_mgr_wrapper.h" 28 #include "iasync_command.h" 29 #include "iam_executor_iauth_executor_hdi.h" 30 31 namespace OHOS { 32 namespace UserIam { 33 namespace UserAuth { 34 class Executor : public std::enable_shared_from_this<Executor>, public NoCopyable { 35 public: 36 Executor(std::shared_ptr<ExecutorMgrWrapper> executorMgrWrapper, std::shared_ptr<IAuthExecutorHdi> executorHdi, 37 uint16_t hdiId); 38 ~Executor() override = default; 39 40 void OnHdiConnect(); 41 void OnHdiDisconnect(); 42 void OnFrameworkReady(); 43 void AddCommand(std::shared_ptr<IAsyncCommand> command); 44 void RemoveCommand(std::shared_ptr<IAsyncCommand> command); 45 std::shared_ptr<IAuthExecutorHdi> GetExecutorHdi(); 46 const char *GetDescription(); 47 int32_t GetAuthType() const; 48 49 private: 50 void RegisterExecutorCallback(ExecutorInfo &executorInfo); 51 void RespondCallbackOnDisconnect(); 52 std::shared_ptr<ExecutorRegisterCallback> executorCallback_; 53 std::mutex mutex_; 54 std::set<std::shared_ptr<IAsyncCommand>> command2Respond_; 55 std::shared_ptr<ExecutorMgrWrapper> executorMgrWrapper_; 56 std::shared_ptr<IAuthExecutorHdi> executorHdi_; 57 std::string description_; 58 uint16_t hdiId_; 59 int32_t authType_; 60 }; 61 } // namespace UserAuth 62 } // namespace UserIam 63 } // namespace OHOS 64 65 #endif // EXCECUTOR_H