1 /*
2  * Copyright (c) 2021-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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_PATTERN_LOCK_PATTERN_LOCK_CONTROLLER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_PATTERN_LOCK_PATTERN_LOCK_CONTROLLER_H
18 #include "base/memory/ace_type.h"
19 namespace OHOS::Ace::V2 {
20 enum class PatternLockChallengeResult {
21     CORRECT = 1,
22     WRONG = 2,
23 };
24 using ErrorImpl = std::function<void(bool)>;
25 using ResetImpl = std::function<void()>;
26 using SetChallengeResultImpl = std::function<void(PatternLockChallengeResult)>;
27 
28 class PatternLockController : public virtual AceType {
29     DECLARE_ACE_TYPE(PatternLockController, AceType);
30 
31 public:
Reset()32     void Reset()
33     {
34         if (resetImpl_) {
35             resetImpl_();
36         }
37     }
SetResetImpl(const ResetImpl & resetImpl)38     void SetResetImpl(const ResetImpl& resetImpl)
39     {
40         resetImpl_ = resetImpl;
41     }
SetChallengeResult(PatternLockChallengeResult challengeResult)42     void SetChallengeResult(PatternLockChallengeResult challengeResult)
43     {
44         if (setChallengeResultImpl_) {
45             setChallengeResultImpl_(challengeResult);
46         }
47     }
SetChallengeResultImpl(const SetChallengeResultImpl & setChallengeResultImpl)48     void SetChallengeResultImpl(const SetChallengeResultImpl& setChallengeResultImpl)
49     {
50         setChallengeResultImpl_ = setChallengeResultImpl;
51     }
52 
53 private:
54     V2::ResetImpl resetImpl_;
55     V2::SetChallengeResultImpl setChallengeResultImpl_;
56 };
57 } // namespace OHOS::Ace::V2
58 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_PATTERN_LOCK_PATTERN_LOCK_CONTROLLER_H
59