• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 SA_COMMAND_MANGER
17 #define SA_COMMAND_MANGER
18 
19 #include <map>
20 #include <memory>
21 #include <set>
22 #include <shared_mutex>
23 #include <vector>
24 
25 #include "face_auth_hdi.h"
26 
27 #include "face_auth_executor_hdi.h"
28 #include "isa_command_processor.h"
29 
30 namespace OHOS {
31 namespace UserIam {
32 namespace FaceAuth {
33 namespace UserAuth = OHOS::UserIam::UserAuth;
34 class SaCommandManager {
35 public:
36     static SaCommandManager &GetInstance();
37 
38     void RegisterSaCommandProcessor(std::vector<SaCommandId> commandIds,
39         std::shared_ptr<ISaCommandProcessor> processor);
40     void UnregisterSaCommandProcessor(std::vector<SaCommandId> commandIds,
41         std::shared_ptr<ISaCommandProcessor> processor);
42 
43     UserAuth::ResultCode ProcessSaCommands(std::shared_ptr<FaceAuthExecutorHdi> executor,
44         const std::vector<SaCommand> &commands);
45     void OnHdiDisconnect(std::shared_ptr<FaceAuthExecutorHdi> executor);
46 
47 private:
48     SaCommandManager() = default;
49     ~SaCommandManager() = default;
50 
51     std::map<SaCommandId, std::set<std::shared_ptr<ISaCommandProcessor>>> commandId2Processors_;
52     std::set<std::shared_ptr<ISaCommandProcessor>> processors_;
53     std::shared_mutex mutex_;
54 };
55 } // namespace FaceAuth
56 } // namespace UserIam
57 } // namespace OHOS
58 
59 #endif // SA_COMMAND_MANGER