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 }; 36 37 struct SecCompPointEvent { 38 double touchX; 39 double touchY; 40 uint64_t timestamp; 41 }; 42 43 struct SecCompKeyEvent { 44 uint64_t timestamp; 45 int32_t keyCode; 46 }; 47 48 struct SecCompClickEvent { 49 ClickEventType type; 50 union { 51 SecCompPointEvent point; 52 SecCompKeyEvent key; 53 }; 54 ExtraInfo extraInfo; 55 }; 56 57 struct SecCompInfo { 58 int32_t scId; 59 std::string componentInfo; 60 SecCompClickEvent clickInfo; 61 }; 62 63 using OnFirstUseDialogCloseFunc = std::function<void(int32_t)>; 64 65 class SecCompUiRegister { 66 public: SecCompUiRegister(std::vector<uintptr_t> & callerList,ISecCompProbe * probe)67 SecCompUiRegister(std::vector<uintptr_t>& callerList, ISecCompProbe* probe) {}; 68 virtual ~SecCompUiRegister() = default; 69 static ISecCompProbe* callbackProbe; 70 }; 71 72 class SecCompKit { 73 public: RegisterSecurityComponent(SecCompType type,std::string & componentInfo,int32_t & scId)74 static int32_t RegisterSecurityComponent(SecCompType type, std::string& componentInfo, int32_t& scId) 75 { 76 scId = 1; 77 return 0; 78 }; 79 UpdateSecurityComponent(int32_t scId,std::string & componentInfo)80 static int32_t UpdateSecurityComponent(int32_t scId, std::string& componentInfo) 81 { 82 return 0; 83 }; 84 UnregisterSecurityComponent(int32_t scId)85 static int32_t UnregisterSecurityComponent(int32_t scId) 86 { 87 return 0; 88 }; 89 PreRegisterSecCompProcess()90 static int32_t PreRegisterSecCompProcess() 91 { 92 return 0; 93 }; 94 ReportSecurityComponentClickEvent(SecCompInfo & secCompInfo,sptr<IRemoteObject> callerToken,OnFirstUseDialogCloseFunc && func,std::string & message)95 static int32_t ReportSecurityComponentClickEvent(SecCompInfo& secCompInfo, 96 sptr<IRemoteObject> callerToken, OnFirstUseDialogCloseFunc&& func, std::string& message) 97 { 98 return 0; 99 }; 100 IsServiceExist()101 static bool IsServiceExist() 102 { 103 return false; 104 }; 105 LoadService()106 static bool LoadService() 107 { 108 return true; 109 }; 110 IsSystemAppCalling()111 static bool IsSystemAppCalling() 112 { 113 return false; 114 }; 115 }; 116 } // namespace SecurityComponent 117 } // namespace Security 118 } // namespace OHOS 119 #endif // ACE_MOKC_INTERFACES_INNER_API_SECURITY_COMPONENT_KIT_H 120