• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 COMMON_DUMMY_H
17 #define COMMON_DUMMY_H
18 
19 #include "resource_node_pool.h"
20 #include "iam_logger.h"
21 
22 #define LOG_LABEL OHOS::UserIam::Common::LABEL_USER_AUTH_SA
23 
24 namespace OHOS {
25 namespace UserIam {
26 namespace UserAuth {
27 class DummyResourceNode final : public ResourceNode {
28 public:
29     using ExecutorRegisterInfo = CoAuthInterface::ExecutorRegisterInfo;
GetExecutorIndex()30     uint64_t GetExecutorIndex() const
31     {
32         IAM_LOGI("start");
33         static uint64_t index = 0;
34         ++index;
35         return index;
36     }
37 
GetOwnerDeviceId()38     std::string GetOwnerDeviceId() const
39     {
40         IAM_LOGI("start");
41         return "";
42     }
43 
GetOwnerPid()44     uint32_t GetOwnerPid() const
45     {
46         IAM_LOGI("start");
47         return 0;
48     }
49 
GetAuthType()50     AuthType GetAuthType() const
51     {
52         IAM_LOGI("start");
53         return PIN;
54     }
55 
GetExecutorRole()56     ExecutorRole GetExecutorRole() const
57     {
58         IAM_LOGI("start");
59         return SCHEDULER;
60     }
61 
GetExecutorSensorHint()62     uint64_t GetExecutorSensorHint() const
63     {
64         IAM_LOGI("start");
65         return 0;
66     }
67 
GetExecutorMatcher()68     uint64_t GetExecutorMatcher() const
69     {
70         IAM_LOGI("start");
71         return 0;
72     }
73 
GetExecutorEsl()74     ExecutorSecureLevel GetExecutorEsl() const
75     {
76         IAM_LOGI("start");
77         return ESL0;
78     }
79 
GetExecutorPublicKey()80     std::vector<uint8_t> GetExecutorPublicKey() const
81     {
82         IAM_LOGI("start");
83         return {};
84     }
85 
BeginExecute(uint64_t scheduleId,const std::vector<uint8_t> & publicKey,const Attributes & command)86     int32_t BeginExecute(uint64_t scheduleId, const std::vector<uint8_t> &publicKey,
87         const Attributes &command)
88     {
89         IAM_LOGI("start");
90         static_cast<void>(scheduleId);
91         static_cast<void>(publicKey);
92         static_cast<void>(command);
93         return SUCCESS;
94     }
95 
EndExecute(uint64_t scheduleId,const Attributes & command)96     int32_t EndExecute(uint64_t scheduleId, const Attributes &command)
97     {
98         IAM_LOGI("start");
99         static_cast<void>(scheduleId);
100         static_cast<void>(command);
101         return SUCCESS;
102     }
103 
SetProperty(const Attributes & properties)104     int32_t SetProperty(const Attributes &properties)
105     {
106         IAM_LOGI("start");
107         static_cast<void>(properties);
108         return SUCCESS;
109     }
110 
GetProperty(const Attributes & condition,Attributes & values)111     int32_t GetProperty(const Attributes &condition, Attributes &values)
112     {
113         IAM_LOGI("start");
114         static_cast<void>(condition);
115         static_cast<void>(values);
116         return SUCCESS;
117     }
118 
Detach()119     void Detach()
120     {
121         IAM_LOGI("start");
122     }
123 };
124 
125 class DummyResourceNodePoolListener final : public ResourceNodePool::ResourceNodePoolListener {
126 public:
OnResourceNodePoolInsert(const std::shared_ptr<ResourceNode> & resource)127     void OnResourceNodePoolInsert(const std::shared_ptr<ResourceNode> &resource)
128     {
129         IAM_LOGI("start");
130         static_cast<void>(resource);
131     }
132 
OnResourceNodePoolDelete(const std::shared_ptr<ResourceNode> & resource)133     void OnResourceNodePoolDelete(const std::shared_ptr<ResourceNode> &resource)
134     {
135         IAM_LOGI("start");
136         static_cast<void>(resource);
137     }
138 
OnResourceNodePoolUpdate(const std::shared_ptr<ResourceNode> & resource)139     void OnResourceNodePoolUpdate(const std::shared_ptr<ResourceNode> &resource)
140     {
141         IAM_LOGI("start");
142         static_cast<void>(resource);
143     }
144 };
145 } // namespace UserAuth
146 } // namespace UserIam
147 } // namespace OHOS
148 #endif // COMMON_DUMMY_H
149