• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #ifndef ACE_MOKC_INTERFACES_INNER_API_SECURITY_COMPONENT_KIT_H
16 #define ACE_MOKC_INTERFACES_INNER_API_SECURITY_COMPONENT_KIT_H
17 
18 #include <string>
19 #include "iremote_object.h"
20 #include "i_sec_comp_probe.h"
21 #include "sec_comp_base_mock.h"
22 
23 namespace OHOS {
24 namespace Security {
25 namespace SecurityComponent {
26 struct ExtraInfo {
27     uint32_t dataSize;
28     uint8_t* data;
29 };
30 
31 enum class ClickEventType : int32_t {
32     UNKNOWN_EVENT_TYPE,
33     POINT_EVENT_TYPE,
34     KEY_EVENT_TYPE,
35     ACCESSIBILITY_EVENT_TYPE
36 };
37 
38 struct SecCompPointEvent {
39     double touchX;
40     double touchY;
41     uint64_t timestamp;
42 };
43 
44 struct SecCompKeyEvent {
45     uint64_t timestamp;
46     int32_t keyCode;
47 };
48 
49 struct SecCompAccessibilityEvent {
50     uint64_t timestamp;
51     int32_t componentId;
52 };
53 
54 struct SecCompClickEvent {
55     ClickEventType type;
56     union {
57         SecCompPointEvent point;
58         SecCompKeyEvent key;
59         SecCompAccessibilityEvent accessibility;
60     };
61     ExtraInfo extraInfo;
62 };
63 
64 struct SecCompInfo {
65     int32_t scId;
66     std::string componentInfo;
67     SecCompClickEvent clickInfo;
68 };
69 
70 using OnFirstUseDialogCloseFunc = std::function<void(int32_t)>;
71 
72 class SecCompUiRegister {
73 public:
SecCompUiRegister(std::vector<uintptr_t> & callerList,ISecCompProbe * probe)74     SecCompUiRegister(std::vector<uintptr_t>& callerList, ISecCompProbe* probe) {};
75     virtual ~SecCompUiRegister() = default;
76     static ISecCompProbe* callbackProbe;
77 };
78 
79 class SecCompKit {
80 public:
RegisterSecurityComponent(SecCompType type,std::string & componentInfo,int32_t & scId)81     static int32_t RegisterSecurityComponent(SecCompType type, std::string& componentInfo, int32_t& scId)
82     {
83         scId = 1;
84         return 0;
85     };
86 
UpdateSecurityComponent(int32_t scId,std::string & componentInfo)87     static int32_t UpdateSecurityComponent(int32_t scId, std::string& componentInfo)
88     {
89         return 0;
90     };
91 
UnregisterSecurityComponent(int32_t scId)92     static int32_t UnregisterSecurityComponent(int32_t scId)
93     {
94         return 0;
95     };
96 
PreRegisterSecCompProcess()97     static int32_t PreRegisterSecCompProcess()
98     {
99         return 0;
100     };
101 
ReportSecurityComponentClickEvent(SecCompInfo & secCompInfo,sptr<IRemoteObject> callerToken,OnFirstUseDialogCloseFunc && func,std::string & message)102     static int32_t ReportSecurityComponentClickEvent(SecCompInfo& secCompInfo,
103         sptr<IRemoteObject> callerToken, OnFirstUseDialogCloseFunc&& func, std::string& message)
104     {
105         return 0;
106     };
107 
IsServiceExist()108     static bool IsServiceExist()
109     {
110         return false;
111     };
112 
LoadService()113     static bool LoadService()
114     {
115         return true;
116     };
117 
IsSystemAppCalling()118     static bool IsSystemAppCalling()
119     {
120         return false;
121     };
122 
HasCustomPermissionForSecComp()123     static bool HasCustomPermissionForSecComp()
124     {
125         return true;
126     };
127 };
128 }  // namespace SecurityComponent
129 }  // namespace Security
130 }  // namespace OHOS
131 #endif  // ACE_MOKC_INTERFACES_INNER_API_SECURITY_COMPONENT_KIT_H
132