• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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_CONTEXT_H
17 #define IAM_CONTEXT_H
18 
19 #include <cstdint>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "nocopyable.h"
25 
26 #include "schedule_node.h"
27 
28 namespace OHOS {
29 namespace UserIam {
30 namespace UserAuth {
31 enum ContextState {
32     STATE_INIT,
33     STATE_RUNNING,
34     STATE_END,
35 };
36 
37 enum ContextType {
38     CONTEXT_SIMPLE_AUTH,
39     CONTEXT_ENROLL,
40     CONTEXT_IDENTIFY,
41     WIDGET_AUTH_CONTEXT,
42 };
43 
44 class Context {
45 public:
46     using ContextStopCallback = std::function<void()>;
47     virtual ~Context() = default;
48     virtual bool Start() = 0;
49     virtual bool Stop() = 0;
50     virtual uint64_t GetContextId() const = 0;
51     virtual ContextType GetContextType() const = 0;
52     virtual std::shared_ptr<ScheduleNode> GetScheduleNode(uint64_t scheduleId) const = 0;
53     virtual uint32_t GetTokenId() const = 0;
54     virtual int32_t GetLatestError() const = 0;
55 
56 protected:
57     virtual void SetLatestError(int32_t error) = 0;
58 };
59 } // namespace UserAuth
60 } // namespace UserIam
61 } // namespace OHOS
62 #endif // IAM_CONTEXT_H