1 /* 2 * Copyright (c) 2022-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 PIN_AUTH_EXECUTOR_CALLBACK_HDI 17 #define PIN_AUTH_EXECUTOR_CALLBACK_HDI 18 19 #include <cstdint> 20 #include <vector> 21 22 #include "nocopyable.h" 23 24 #include "iam_executor_iexecute_callback.h" 25 #include "pin_auth_hdi.h" 26 #include "pin_auth_manager.h" 27 #include "pin_auth_all_in_one_hdi.h" 28 #include "pin_auth_collector_hdi.h" 29 30 namespace OHOS { 31 namespace UserIam { 32 namespace PinAuth { 33 class PinAuthExecutorCallbackHdi : public IExecutorCallback, public NoCopyable { 34 public: 35 PinAuthExecutorCallbackHdi(std::shared_ptr<UserAuth::IExecuteCallback> frameworkCallback, 36 std::shared_ptr<PinAuthAllInOneHdi> pinAuthAllInOneHdi, const UserAuth::ExecutorParam ¶m, 37 GetDataMode mode); 38 PinAuthExecutorCallbackHdi(std::shared_ptr<UserAuth::IExecuteCallback> frameworkCallback, 39 std::shared_ptr<PinAuthCollectorHdi> pinAuthCollectorHdi, const UserAuth::ExecutorParam ¶m, 40 GetDataMode mode); 41 PinAuthExecutorCallbackHdi(std::shared_ptr<UserAuth::IExecuteCallback> frameworkCallback, 42 const UserAuth::ExecutorParam ¶m, GetDataMode mode); 43 ~PinAuthExecutorCallbackHdi() override = default; 44 int32_t OnResult(int32_t code, const std::vector<uint8_t> &extraInfo) override; 45 int32_t OnGetData(const std::vector<uint8_t>& algoParameter, uint64_t authSubType, uint32_t algoVersion, 46 const std::vector<uint8_t> &challenge, const std::string &complexityReg) override; 47 int32_t OnTip(int32_t tip, const std::vector<uint8_t> &extraInfo) override; 48 int32_t OnMessage(int32_t destRole, const std::vector<uint8_t> &msg) override; 49 50 private: 51 void DoVibrator(); 52 std::shared_ptr<UserAuth::IExecuteCallback> frameworkCallback_; 53 std::shared_ptr<PinAuthAllInOneHdi> pinAuthAllInOneHdi_; 54 std::shared_ptr<PinAuthCollectorHdi> pinAuthCollectorHdi_; 55 UserAuth::ResultCode ConvertResultCode(const int32_t in); 56 uint32_t tokenId_; 57 GetDataMode mode_; 58 uint64_t scheduleId_; 59 int32_t authIntent_; 60 int32_t userId_; 61 }; 62 } // PinAuth 63 } // UserIam 64 } // OHOS 65 66 #endif // PIN_AUTH_EXECUTOR_CALLBACK_HDI