• 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 IAM_WIDGET_SCHEDULE_NODE_H
17 #define IAM_WIDGET_SCHEDULE_NODE_H
18 
19 #include <cstdint>
20 #include <memory>
21 #include <optional>
22 
23 #include "finite_state_machine.h"
24 #include "iam_common_defines.h"
25 #include "resource_node.h"
26 #include "widget_schedule_node_callback.h"
27 #include "thread_handler.h"
28 #include "user_auth_common_defines.h"
29 
30 namespace OHOS {
31 namespace UserIam {
32 namespace UserAuth {
33 class Context;
34 class WidgetScheduleNode {
35 public:
36     enum State : uint32_t {
37         S_WIDGET_INIT = 0,
38         S_WIDGET_WAITING = 1,
39         S_WIDGET_AUTH_RUNNING = 2,
40         S_WIDGET_AUTH_FINISHED = 3,
41         S_WIDGET_RELOAD_WAITING = 4,
42         S_WIDGET_RELEASED = 5,
43     };
44 
45     enum Event : uint32_t {
46         E_START_WIDGET = 0,
47         E_START_AUTH = 1,
48         E_UPDATE_AUTH = 2,
49         E_CANCEL_AUTH = 3,
50         E_COMPLETE_AUTH = 4,
51         E_NAVI_PIN_AUTH = 5,
52         E_WIDGET_PARA_INVALID = 6,
53         E_WIDGET_RELOAD = 7,
54         E_STOP_AUTH = 8,
55         E_WIDGET_RELEASE = 9,
56     };
57 
58     virtual ~WidgetScheduleNode() = default;
59     virtual bool StartSchedule() = 0;
60     virtual bool StopSchedule() = 0;
61     virtual bool StartAuthList(const std::vector<AuthType> &authTypeList, bool endAfterFirstFail,
62         AuthIntent authIntent) = 0;
63     virtual bool StopAuthList(const std::vector<AuthType> &authTypeList) = 0;
64     virtual bool SuccessAuth(AuthType authType) = 0;
65     virtual bool FailAuth(AuthType authType) = 0;
66     virtual bool NaviPinAuth() = 0;
67     virtual bool WidgetParaInvalid() = 0;
68     virtual bool WidgetReload(uint32_t orientation, uint32_t needRotate, uint32_t alreadyLoad,
69         AuthType &rotateAuthType) = 0;
70     virtual void SetCallback(std::shared_ptr<WidgetScheduleNodeCallback> callback) = 0;
71     virtual void SendAuthTipInfo(const std::vector<AuthType> &authTypeList, int32_t tipCode) = 0;
72     virtual bool ClearSchedule() = 0;
73 };
74 } // namespace UserAuth
75 } // namespace UserIam
76 } // namespace OHOS
77 #endif // IAM_WIDGET_SCHEDULE_NODE_H
78