已合并
修复安全控件并发初始化与边界检查问题 #439
修复安全控件并发初始化与边界检查问题 #439
已合并
panyongchao创建于 27 天前
6 个文件变更+400-137
Mframeworks/BUILD.gn+9-0
@@ -12,9 +12,15 @@
12# limitations under the License.12# limitations under the License.
13 13 
14import("//build/ohos.gni")14import("//build/ohos.gni")
15+import("../security_component.gni")
15 16 
16sec_comp_root_dir = ".."17sec_comp_root_dir = ".."
17 18 
19+security_component_enhance_adapter_defines = []
20+if (!security_component_enhance_enable) {
21+ security_component_enhance_adapter_defines = [ "SECURITY_COMPONENT_ENHANCE_DISABLE" ]
22+}
23+ 
18config("security_component_framework_src_set_config") {24config("security_component_framework_src_set_config") {
19 include_dirs = [25 include_dirs = [
20 "common/include",26 "common/include",
@@ -90,6 +96,7 @@ ohos_source_set("security_component_enhance_adapter_src_set") {
90 96 
91 configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]97 configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]
92 public_configs = [ ":security_component_enhance_adapter_src_set_config" ]98 public_configs = [ ":security_component_enhance_adapter_src_set_config" ]
99+ defines = security_component_enhance_adapter_defines
93 100 
94 external_deps = [101 external_deps = [
95 "c_utils:utils",102 "c_utils:utils",
@@ -119,6 +126,7 @@ ohos_source_set("security_component_enhance_adapter_service_src_set") {
119 126 
120 configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]127 configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]
121 public_configs = [ ":security_component_enhance_adapter_src_set_config" ]128 public_configs = [ ":security_component_enhance_adapter_src_set_config" ]
129+ defines = security_component_enhance_adapter_defines
122 130 
123 external_deps = [131 external_deps = [
124 "bounds_checking_function:libsec_shared",132 "bounds_checking_function:libsec_shared",
@@ -189,6 +197,7 @@ ohos_source_set("security_component_no_cfi_enhance_adapter_src_set") {
189 197 
190 configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]198 configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]
191 public_configs = [ ":security_component_enhance_adapter_src_set_config" ]199 public_configs = [ ":security_component_enhance_adapter_src_set_config" ]
200+ defines = security_component_enhance_adapter_defines
192 201 
193 external_deps = [202 external_deps = [
194 "bounds_checking_function:libsec_shared",203 "bounds_checking_function:libsec_shared",
Mframeworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp+163-125
@@ -14,6 +14,7 @@
14 */14 */
15#include "sec_comp_enhance_adapter.h"15#include "sec_comp_enhance_adapter.h"
16 16 
17+#include <atomic>
17#include <dlfcn.h>18#include <dlfcn.h>
18#include <sys/types.h>19#include <sys/types.h>
19 20 
@@ -33,6 +34,82 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {
33static const std::string ENHANCE_INPUT_INTERFACE_LIB = "libsecurity_component_client_enhance.z.so";34static const std::string ENHANCE_INPUT_INTERFACE_LIB = "libsecurity_component_client_enhance.z.so";
34static const std::string ENHANCE_SRV_INTERFACE_LIB = "libsecurity_component_service_enhance.z.so";35static const std::string ENHANCE_SRV_INTERFACE_LIB = "libsecurity_component_service_enhance.z.so";
35static const std::string ENHANCE_CLIENT_INTERFACE_LIB = "libsecurity_component_client_enhance.z.so";36static const std::string ENHANCE_CLIENT_INTERFACE_LIB = "libsecurity_component_client_enhance.z.so";
37+#ifndef SECURITY_COMPONENT_ENHANCE_DISABLE
38+static constexpr uint32_t MAX_INIT_RETRY_TIMES = 3;
39+#endif
40+ 
41+std::atomic_bool g_inputHandlerReady = false;
42+std::atomic_bool g_srvHandlerReady = false;
43+std::atomic_bool g_clientHandlerReady = false;
44+uint32_t g_inputInitRetryTimes = 0;
45+uint32_t g_srvInitRetryTimes = 0;
46+uint32_t g_clientInitRetryTimes = 0;
47+ 
48+struct EnhanceHandlerContext {
49+ const std::string* libPath = nullptr;
50+ std::atomic_bool* handlerReady = nullptr;
51+ bool* isHandlerInit = nullptr;
52+ uint32_t* initRetryTimes = nullptr;
53+};
54+ 
55+bool GetEnhanceHandlerContext(EnhanceInterfaceType type, EnhanceHandlerContext& context)
56+{
57+ switch (type) {
58+ case SEC_COMP_ENHANCE_INPUT_INTERFACE:
59+ context = { &ENHANCE_INPUT_INTERFACE_LIB, &g_inputHandlerReady,
60+ &SecCompEnhanceAdapter::isEnhanceInputHandlerInit, &g_inputInitRetryTimes };
61+ return true;
62+ case SEC_COMP_ENHANCE_SRV_INTERFACE:
63+ context = { &ENHANCE_SRV_INTERFACE_LIB, &g_srvHandlerReady,
64+ &SecCompEnhanceAdapter::isEnhanceSrvHandlerInit, &g_srvInitRetryTimes };
65+ return true;
66+ case SEC_COMP_ENHANCE_CLIENT_INTERFACE:
67+ context = { &ENHANCE_CLIENT_INTERFACE_LIB, &g_clientHandlerReady,
68+ &SecCompEnhanceAdapter::isEnhanceClientHandlerInit, &g_clientInitRetryTimes };
69+ return true;
70+ default:
71+ return false;
72+ }
73+}
74+ 
75+void MarkEnhanceHandlerReady(const EnhanceHandlerContext& context)
76+{
77+ *context.isHandlerInit = true;
78+ context.handlerReady->store(true, std::memory_order_release);
79+}
80+ 
81+SecCompInputEnhanceInterface* GetInputHandler()
82+{
83+ if (!g_inputHandlerReady.load(std::memory_order_acquire)) {
84+ SecCompEnhanceAdapter::InitEnhanceHandler(SEC_COMP_ENHANCE_INPUT_INTERFACE);
85+ }
86+ if (!g_inputHandlerReady.load(std::memory_order_acquire)) {
87+ return nullptr;
88+ }
89+ return SecCompEnhanceAdapter::inputHandler;
90+}
91+ 
92+SecCompSrvEnhanceInterface* GetSrvHandler()
93+{
94+ if (!g_srvHandlerReady.load(std::memory_order_acquire)) {
95+ SecCompEnhanceAdapter::InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE);
96+ }
97+ if (!g_srvHandlerReady.load(std::memory_order_acquire)) {
98+ return nullptr;
99+ }
100+ return SecCompEnhanceAdapter::srvHandler;
101+}
102+ 
103+SecCompClientEnhanceInterface* GetClientHandler()
104+{
105+ if (!g_clientHandlerReady.load(std::memory_order_acquire)) {
106+ SecCompEnhanceAdapter::InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE);
107+ }
108+ if (!g_clientHandlerReady.load(std::memory_order_acquire)) {
109+ return nullptr;
110+ }
111+ return SecCompEnhanceAdapter::clientHandler;
112+}
36}113}
37 114 
38SecCompInputEnhanceInterface* SecCompEnhanceAdapter::inputHandler = nullptr;115SecCompInputEnhanceInterface* SecCompEnhanceAdapter::inputHandler = nullptr;
@@ -48,55 +125,58 @@ std::mutex SecCompEnhanceAdapter::initMtx;
48 125 
49void SecCompEnhanceAdapter::InitEnhanceHandler(EnhanceInterfaceType type)126void SecCompEnhanceAdapter::InitEnhanceHandler(EnhanceInterfaceType type)
50{127{
128+ EnhanceHandlerContext context;
129+ if (!GetEnhanceHandlerContext(type, context) || context.handlerReady->load(std::memory_order_acquire)) {
130+ return;
131+ }
132+ 
51 std::unique_lock<std::mutex> lck(initMtx);133 std::unique_lock<std::mutex> lck(initMtx);
52- std::string libPath = "";134+ if (context.handlerReady->load(std::memory_order_relaxed)) {
53- switch (type) {135+ return;
54- case SEC_COMP_ENHANCE_INPUT_INTERFACE:
55- libPath = ENHANCE_INPUT_INTERFACE_LIB;
56- isEnhanceInputHandlerInit = true;
57- break;
58- case SEC_COMP_ENHANCE_SRV_INTERFACE:
59- libPath = ENHANCE_SRV_INTERFACE_LIB;
60- isEnhanceSrvHandlerInit = true;
61- break;
62- case SEC_COMP_ENHANCE_CLIENT_INTERFACE:
63- libPath = ENHANCE_CLIENT_INTERFACE_LIB;
64- isEnhanceClientHandlerInit = true;
65- break;
66- default:
67- break;
68 }136 }
69 137 
70#ifdef SECURITY_COMPONENT_ENHANCE_DISABLE138#ifdef SECURITY_COMPONENT_ENHANCE_DISABLE
panyongchao
panyongchaopanyongchao6 天前

确认宏是不是生效的

likedislike
71- void* handler = nullptr;139+ MarkEnhanceHandlerReady(context);
140+ return;
72#else141#else
73- void* handler = dlopen(libPath.c_str(), RTLD_LAZY);142+ if (*context.initRetryTimes >= MAX_INIT_RETRY_TIMES) {
74-#endif143+ MarkEnhanceHandlerReady(context);
144+ return;
145+ }
146+ ++(*context.initRetryTimes);
147+ void* handler = dlopen(context.libPath->c_str(), RTLD_LAZY);
75 if (handler == nullptr) {148 if (handler == nullptr) {
76- SC_LOG_ERROR(LABEL, "init enhance lib %{public}s failed, error %{public}s", libPath.c_str(), dlerror());149+ SC_LOG_ERROR(LABEL, "init enhance lib %{public}s failed at attempt %{public}u, error %{public}s",
150+ context.libPath->c_str(), *context.initRetryTimes, dlerror());
151+ if (*context.initRetryTimes >= MAX_INIT_RETRY_TIMES) {
152+ MarkEnhanceHandlerReady(context);
153+ }
77 return;154 return;
78 }155 }
79 if (type == SEC_COMP_ENHANCE_CLIENT_INTERFACE) {156 if (type == SEC_COMP_ENHANCE_CLIENT_INTERFACE) {
80 EnhanceInterface getClientInstance = reinterpret_cast<EnhanceInterface>(dlsym(handler, "GetClientInstance"));157 EnhanceInterface getClientInstance = reinterpret_cast<EnhanceInterface>(dlsym(handler, "GetClientInstance"));
81 if (getClientInstance == nullptr) {158 if (getClientInstance == nullptr) {
82- SC_LOG_ERROR(LABEL, "GetClientInstance failed.");159+ SC_LOG_ERROR(LABEL, "GetClientInstance failed at attempt %{public}u.", *context.initRetryTimes);
160+ MarkEnhanceHandlerReady(context);
83 return;161 return;
84 }162 }
85 SecCompClientEnhanceInterface* instance = getClientInstance();163 SecCompClientEnhanceInterface* instance = getClientInstance();
86- if (instance != nullptr) {164+ if (instance == nullptr) {
87- SC_LOG_DEBUG(LABEL, "Dlopen client enhance successful.");165+ MarkEnhanceHandlerReady(context);
88- clientHandler = instance;166+ return;
89 }167 }
168+ SC_LOG_DEBUG(LABEL, "Dlopen client enhance successful.");
169+ clientHandler = instance;
90 }170 }
171+ MarkEnhanceHandlerReady(context);
172+#endif
panyongchao
panyongchaopanyongchao6 天前

搞个几次重试,确认一下蓝区dlopen 失败

likedislike
91}173}
92 174 
93int32_t SecCompEnhanceAdapter::SetEnhanceCfg(uint8_t* cfg, uint32_t cfgLen)175int32_t SecCompEnhanceAdapter::SetEnhanceCfg(uint8_t* cfg, uint32_t cfgLen)
94{176{
95- if (!isEnhanceInputHandlerInit) {177+ SecCompInputEnhanceInterface* handler = GetInputHandler();
96- InitEnhanceHandler(SEC_COMP_ENHANCE_INPUT_INTERFACE);178+ if (handler != nullptr) {
97- }179+ return handler->SetEnhanceCfg(cfg, cfgLen);
98- if (inputHandler != nullptr) {
99- return inputHandler->SetEnhanceCfg(cfg, cfgLen);
100 }180 }
101 return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE;181 return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE;
102}182}
@@ -104,60 +184,49 @@ int32_t SecCompEnhanceAdapter::SetEnhanceCfg(uint8_t* cfg, uint32_t cfgLen)
104int32_t SecCompEnhanceAdapter::GetPointerEventEnhanceData(void* data, uint32_t dataLen,184int32_t SecCompEnhanceAdapter::GetPointerEventEnhanceData(void* data, uint32_t dataLen,
105 uint8_t* enhanceData, uint32_t& enHancedataLen)185 uint8_t* enhanceData, uint32_t& enHancedataLen)
106{186{
107- if (!isEnhanceInputHandlerInit) {187+ SecCompInputEnhanceInterface* handler = GetInputHandler();
108- InitEnhanceHandler(SEC_COMP_ENHANCE_INPUT_INTERFACE);188+ if (handler != nullptr) {
109- }189+ return handler->GetPointerEventEnhanceData(data, dataLen, enhanceData, enHancedataLen);
110- if (inputHandler != nullptr) {
111- return inputHandler->GetPointerEventEnhanceData(data, dataLen, enhanceData, enHancedataLen);
112 }190 }
113 return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE;191 return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE;
114}192}
115 193 
116int32_t SecCompEnhanceAdapter::CheckAndUpdateExtraInfo(SecCompClickEvent& clickInfo)194int32_t SecCompEnhanceAdapter::CheckAndUpdateExtraInfo(SecCompClickEvent& clickInfo)
117{195{
118- if (!isEnhanceSrvHandlerInit) {196+ SecCompSrvEnhanceInterface* handler = GetSrvHandler();
119- InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE);197+ if (handler != nullptr) {
120- }
121- if (srvHandler != nullptr) {
122 if (clickInfo.extraInfo.dataSize == 0 || clickInfo.extraInfo.data == nullptr) {198 if (clickInfo.extraInfo.dataSize == 0 || clickInfo.extraInfo.data == nullptr) {
123 SC_LOG_ERROR(LABEL, "HMAC info is invalid");199 SC_LOG_ERROR(LABEL, "HMAC info is invalid");
124 return SC_SERVICE_ERROR_CLICK_EVENT_INVALID;200 return SC_SERVICE_ERROR_CLICK_EVENT_INVALID;
125 }201 }
126- return srvHandler->CheckAndUpdateExtraInfo(clickInfo);202+ return handler->CheckAndUpdateExtraInfo(clickInfo);
127 }203 }
128 return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE;204 return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE;
129}205}
130 206 
131void SecCompEnhanceAdapter::AddSecurityComponentProcess(int32_t pid)207void SecCompEnhanceAdapter::AddSecurityComponentProcess(int32_t pid)
132{208{
133- if (!isEnhanceSrvHandlerInit) {209+ SecCompSrvEnhanceInterface* handler = GetSrvHandler();
134- InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE);210+ if (handler != nullptr) {
135- }211+ handler->AddSecurityComponentProcess(pid);
136- if (srvHandler != nullptr) {
137- srvHandler->AddSecurityComponentProcess(pid);
138 }212 }
139}213}
140 214 
141bool SecCompEnhanceAdapter::IsBypassPermitted(const std::string& bundleName)215bool SecCompEnhanceAdapter::IsBypassPermitted(const std::string& bundleName)
142{216{
143- if (!isEnhanceSrvHandlerInit) {217+ SecCompSrvEnhanceInterface* handler = GetSrvHandler();
144- InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE);218+ if (handler != nullptr) {
145- }219+ return handler->IsBypassPermitted(bundleName);
146- if (srvHandler != nullptr) {
147- return srvHandler->IsBypassPermitted(bundleName);
148 }220 }
149 return false;221 return false;
150}222}
151 223 
152__attribute__((noinline)) bool SecCompEnhanceAdapter::EnhanceDataPreprocess(std::string& componentInfo)224__attribute__((noinline)) bool SecCompEnhanceAdapter::EnhanceDataPreprocess(std::string& componentInfo)
153{225{
154- if (!isEnhanceClientHandlerInit) {226+ SecCompClientEnhanceInterface* handler = GetClientHandler();
155- InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE);
156- }
157- 
158 uintptr_t enhanceCallerAddr = reinterpret_cast<uintptr_t>(__builtin_return_address(0));227 uintptr_t enhanceCallerAddr = reinterpret_cast<uintptr_t>(__builtin_return_address(0));
159- if (clientHandler != nullptr) {228+ if (handler != nullptr) {
160- return clientHandler->EnhanceDataPreprocess(enhanceCallerAddr, componentInfo);229+ return handler->EnhanceDataPreprocess(enhanceCallerAddr, componentInfo);
161 }230 }
162 return true;231 return true;
163}232}
@@ -165,13 +234,10 @@ __attribute__((noinline)) bool SecCompEnhanceAdapter::EnhanceDataPreprocess(std:
165__attribute__((noinline)) bool SecCompEnhanceAdapter::EnhanceDataPreprocess(234__attribute__((noinline)) bool SecCompEnhanceAdapter::EnhanceDataPreprocess(
166 int32_t scId, std::string& componentInfo)235 int32_t scId, std::string& componentInfo)
167{236{
168- if (!isEnhanceClientHandlerInit) {237+ SecCompClientEnhanceInterface* handler = GetClientHandler();
169- InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE);
170- }
171- 
172 uintptr_t enhanceCallerAddr = reinterpret_cast<uintptr_t>(__builtin_return_address(0));238 uintptr_t enhanceCallerAddr = reinterpret_cast<uintptr_t>(__builtin_return_address(0));
173- if (clientHandler != nullptr) {239+ if (handler != nullptr) {
174- return clientHandler->EnhanceDataPreprocess(enhanceCallerAddr, scId, componentInfo);240+ return handler->EnhanceDataPreprocess(enhanceCallerAddr, scId, componentInfo);
175 }241 }
176 return true;242 return true;
177}243}
@@ -220,13 +286,10 @@ static bool ReadMessageParcel(SecCompRawdata& tmpData, MessageParcel& data)
220__attribute__((noinline)) bool SecCompEnhanceAdapter::EnhanceClientSerialize(286__attribute__((noinline)) bool SecCompEnhanceAdapter::EnhanceClientSerialize(
221 MessageParcel& input, SecCompRawdata& output)287 MessageParcel& input, SecCompRawdata& output)
222{288{
223- if (!isEnhanceClientHandlerInit) {289+ SecCompClientEnhanceInterface* handler = GetClientHandler();
224- InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE);
225- }
226- 
227 uintptr_t enhanceCallerAddr = reinterpret_cast<uintptr_t>(__builtin_return_address(0));290 uintptr_t enhanceCallerAddr = reinterpret_cast<uintptr_t>(__builtin_return_address(0));
228- if (clientHandler != nullptr) {291+ if (handler != nullptr) {
229- return clientHandler->EnhanceClientSerialize(enhanceCallerAddr, input, output);292+ return handler->EnhanceClientSerialize(enhanceCallerAddr, input, output);
230 }293 }
231 294 
232 return WriteMessageParcel(input, output);295 return WriteMessageParcel(input, output);
@@ -235,13 +298,10 @@ __attribute__((noinline)) bool SecCompEnhanceAdapter::EnhanceClientSerialize(
235__attribute__((noinline)) bool SecCompEnhanceAdapter::EnhanceClientDeserialize(298__attribute__((noinline)) bool SecCompEnhanceAdapter::EnhanceClientDeserialize(
236 SecCompRawdata& input, MessageParcel& output)299 SecCompRawdata& input, MessageParcel& output)
237{300{
238- if (!isEnhanceClientHandlerInit) {301+ SecCompClientEnhanceInterface* handler = GetClientHandler();
239- InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE);
240- }
241- 
242 uintptr_t enhanceCallerAddr = reinterpret_cast<uintptr_t>(__builtin_return_address(0));302 uintptr_t enhanceCallerAddr = reinterpret_cast<uintptr_t>(__builtin_return_address(0));
243- if (clientHandler != nullptr) {303+ if (handler != nullptr) {
244- return clientHandler->EnhanceClientDeserialize(enhanceCallerAddr, input, output);304+ return handler->EnhanceClientDeserialize(enhanceCallerAddr, input, output);
245 }305 }
246 306 
247 return ReadMessageParcel(input, output);307 return ReadMessageParcel(input, output);
@@ -249,11 +309,9 @@ __attribute__((noinline)) bool SecCompEnhanceAdapter::EnhanceClientDeserialize(
249 309 
250bool SecCompEnhanceAdapter::EnhanceSrvSerialize(MessageParcel& input, SecCompRawdata& output)310bool SecCompEnhanceAdapter::EnhanceSrvSerialize(MessageParcel& input, SecCompRawdata& output)
251{311{
252- if (!isEnhanceSrvHandlerInit) {312+ SecCompSrvEnhanceInterface* handler = GetSrvHandler();
253- InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE);313+ if (handler != nullptr) {
254- }314+ return handler->EnhanceSrvSerialize(input, output);
255- if (srvHandler != nullptr) {
256- return srvHandler->EnhanceSrvSerialize(input, output);
257 }315 }
258 316 
259 return WriteMessageParcel(input, output);317 return WriteMessageParcel(input, output);
@@ -261,11 +319,9 @@ bool SecCompEnhanceAdapter::EnhanceSrvSerialize(MessageParcel& input, SecCompRaw
261 319 
262bool SecCompEnhanceAdapter::EnhanceSrvDeserialize(SecCompRawdata& input, MessageParcel& output)320bool SecCompEnhanceAdapter::EnhanceSrvDeserialize(SecCompRawdata& input, MessageParcel& output)
263{321{
264- if (!isEnhanceSrvHandlerInit) {322+ SecCompSrvEnhanceInterface* handler = GetSrvHandler();
265- InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE);323+ if (handler != nullptr) {
266- }324+ return handler->EnhanceSrvDeserialize(input, output);
267- if (srvHandler != nullptr) {
268- return srvHandler->EnhanceSrvDeserialize(input, output);
269 }325 }
270 326 
271 return ReadMessageParcel(input, output);327 return ReadMessageParcel(input, output);
@@ -273,88 +329,70 @@ bool SecCompEnhanceAdapter::EnhanceSrvDeserialize(SecCompRawdata& input, Message
273 329 
274__attribute__((noinline)) void SecCompEnhanceAdapter::RegisterScIdEnhance(int32_t scId)330__attribute__((noinline)) void SecCompEnhanceAdapter::RegisterScIdEnhance(int32_t scId)
275{331{
276- if (!isEnhanceClientHandlerInit) {332+ SecCompClientEnhanceInterface* handler = GetClientHandler();
277- InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE);
278- }
279- 
280 uintptr_t enhanceCallerAddr = reinterpret_cast<uintptr_t>(__builtin_return_address(0));333 uintptr_t enhanceCallerAddr = reinterpret_cast<uintptr_t>(__builtin_return_address(0));
281- if (clientHandler != nullptr) {334+ if (handler != nullptr) {
282- clientHandler->RegisterScIdEnhance(enhanceCallerAddr, scId);335+ handler->RegisterScIdEnhance(enhanceCallerAddr, scId);
283 }336 }
284}337}
285 338 
286__attribute__((noinline)) void SecCompEnhanceAdapter::UnregisterScIdEnhance(int32_t scId)339__attribute__((noinline)) void SecCompEnhanceAdapter::UnregisterScIdEnhance(int32_t scId)
287{340{
288- if (!isEnhanceClientHandlerInit) {341+ SecCompClientEnhanceInterface* handler = GetClientHandler();
289- InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE);
290- }
291- 
292 uintptr_t enhanceCallerAddr = reinterpret_cast<uintptr_t>(__builtin_return_address(0));342 uintptr_t enhanceCallerAddr = reinterpret_cast<uintptr_t>(__builtin_return_address(0));
293- if (clientHandler != nullptr) {343+ if (handler != nullptr) {
294- clientHandler->UnregisterScIdEnhance(enhanceCallerAddr, scId);344+ handler->UnregisterScIdEnhance(enhanceCallerAddr, scId);
295 }345 }
296}346}
297 347 
298int32_t SecCompEnhanceAdapter::EnableInputEnhance()348int32_t SecCompEnhanceAdapter::EnableInputEnhance()
299{349{
300- if (!isEnhanceSrvHandlerInit) {350+ SecCompSrvEnhanceInterface* handler = GetSrvHandler();
301- InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE);351+ if (handler != nullptr) {
302- }352+ return handler->EnableInputEnhance();
303- if (srvHandler != nullptr) {
304- return srvHandler->EnableInputEnhance();
305 }353 }
306 return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE;354 return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE;
307}355}
308 356 
309int32_t SecCompEnhanceAdapter::DisableInputEnhance()357int32_t SecCompEnhanceAdapter::DisableInputEnhance()
310{358{
311- if (!isEnhanceSrvHandlerInit) {359+ SecCompSrvEnhanceInterface* handler = GetSrvHandler();
312- InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE);360+ if (handler != nullptr) {
313- }361+ return handler->DisableInputEnhance();
314- if (srvHandler != nullptr) {
315- return srvHandler->DisableInputEnhance();
316 }362 }
317 return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE;363 return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE;
318}364}
319 365 
320void SecCompEnhanceAdapter::StartEnhanceService()366void SecCompEnhanceAdapter::StartEnhanceService()
321{367{
322- if (!isEnhanceSrvHandlerInit) {368+ SecCompSrvEnhanceInterface* handler = GetSrvHandler();
323- InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE);369+ if (handler != nullptr) {
324- }370+ handler->StartEnhanceService();
325- if (srvHandler != nullptr) {
326- srvHandler->StartEnhanceService();
327 }371 }
328}372}
329 373 
330void SecCompEnhanceAdapter::ExitEnhanceService()374void SecCompEnhanceAdapter::ExitEnhanceService()
331{375{
332- if (!isEnhanceSrvHandlerInit) {376+ SecCompSrvEnhanceInterface* handler = GetSrvHandler();
333- InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE);377+ if (handler != nullptr) {
334- }378+ handler->ExitEnhanceService();
335- if (srvHandler != nullptr) {
336- srvHandler->ExitEnhanceService();
337 }379 }
338}380}
339 381 
340void SecCompEnhanceAdapter::NotifyProcessDied(int32_t pid)382void SecCompEnhanceAdapter::NotifyProcessDied(int32_t pid)
341{383{
342- if (!isEnhanceSrvHandlerInit) {384+ SecCompSrvEnhanceInterface* handler = GetSrvHandler();
343- InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE);385+ if (handler != nullptr) {
344- }386+ handler->NotifyProcessDied(pid);
345- if (srvHandler != nullptr) {
346- srvHandler->NotifyProcessDied(pid);
347 }387 }
348}388}
349 389 
350int32_t SecCompEnhanceAdapter::CheckComponentInfoEnhance(int32_t pid,390int32_t SecCompEnhanceAdapter::CheckComponentInfoEnhance(int32_t pid,
351 std::shared_ptr<SecCompBase>& compInfo, const nlohmann::json& jsonComponent)391 std::shared_ptr<SecCompBase>& compInfo, const nlohmann::json& jsonComponent)
352{392{
353- if (!isEnhanceSrvHandlerInit) {393+ SecCompSrvEnhanceInterface* handler = GetSrvHandler();
354- InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE);394+ if (handler != nullptr) {
355- }395+ return handler->CheckComponentInfoEnhance(pid, compInfo, jsonComponent);
356- if (srvHandler != nullptr) {
357- return srvHandler->CheckComponentInfoEnhance(pid, compInfo, jsonComponent);
358 }396 }
359 return SC_OK;397 return SC_OK;
360}398}
Mframeworks/enhance_adapter/test/unittest/src/sec_comp_enhance_adapter_test.cpp+178-0
@@ -14,6 +14,13 @@
14 */14 */
15 15 
16#include "sec_comp_enhance_adapter_test.h"16#include "sec_comp_enhance_adapter_test.h"
17+ 
18+#include <atomic>
19+#include <cstdlib>
20+#include <sys/wait.h>
21+#include <thread>
22+#include <vector>
23+ 
17#include <unistd.h>24#include <unistd.h>
18#include "sec_comp_err.h"25#include "sec_comp_err.h"
19#include "sec_comp_log.h"26#include "sec_comp_log.h"
@@ -27,8 +34,140 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {
27 LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompEnhanceAdapterTest"};34 LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompEnhanceAdapterTest"};
28static constexpr uint32_t SEC_COMP_ENHANCE_CFG_SIZE = 76;35static constexpr uint32_t SEC_COMP_ENHANCE_CFG_SIZE = 76;
29static constexpr uint32_t MAX_HMAC_SIZE = 160;36static constexpr uint32_t MAX_HMAC_SIZE = 160;
37+static constexpr int32_t MAX_INIT_RETRY_TIMES = 3;
38+enum class ClientInitScenario : int32_t {
39+ DLSYM_FAILED = 0,
40+ INSTANCE_NULL,
41+ INSTANCE_VALID,
42+};
43+ 
44+class MockClientEnhance final : public SecCompClientEnhanceInterface {
45+public:
46+ bool EnhanceDataPreprocess(const uintptr_t, std::string&) override
47+ {
48+ return true;
49+ }
50+ 
51+ bool EnhanceDataPreprocess(const uintptr_t, int32_t, std::string&) override
52+ {
53+ return true;
54+ }
55+ 
56+ bool EnhanceClientSerialize(const uintptr_t, OHOS::MessageParcel&, SecCompRawdata&) override
57+ {
58+ return true;
59+ }
60+ 
61+ bool EnhanceClientDeserialize(const uintptr_t, SecCompRawdata&, OHOS::MessageParcel&) override
62+ {
63+ return true;
64+ }
65+ 
66+ void RegisterScIdEnhance(const uintptr_t, int32_t) override
67+ {}
68+ 
69+ void UnregisterScIdEnhance(const uintptr_t, int32_t) override
70+ {}
71+ 
72+ void Update() override
73+ {}
74+};
75+ 
76+std::atomic_bool g_dlopenSucceed = false;
77+std::atomic_int g_dlopenCallCount = 0;
78+std::atomic_int g_dlsymCallCount = 0;
79+std::atomic_int g_getClientInstanceCallCount = 0;
80+std::atomic<ClientInitScenario> g_clientInitScenario = ClientInitScenario::DLSYM_FAILED;
81+MockClientEnhance g_mockClientEnhance;
30} // namespace82} // namespace
31 83 
84+extern "C" void* DlopenMock(const char*, int) __asm__("dlopen");
85+extern "C" void* DlsymMock(void*, const char*) __asm__("dlsym");
86+extern "C" SecCompClientEnhanceInterface* GetClientInstanceMock();
87+ 
88+extern "C" void* DlopenMock(const char*, int)
89+{
90+ g_dlopenCallCount.fetch_add(1);
91+ if (g_dlopenSucceed.load()) {
92+ return &g_mockClientEnhance;
93+ }
94+ return nullptr;
95+}
96+ 
97+extern "C" void* DlsymMock(void*, const char*)
98+{
99+ g_dlsymCallCount.fetch_add(1);
100+ if (g_clientInitScenario.load() == ClientInitScenario::DLSYM_FAILED) {
101+ return nullptr;
102+ }
103+ return reinterpret_cast<void*>(GetClientInstanceMock);
104+}
105+ 
106+extern "C" SecCompClientEnhanceInterface* GetClientInstanceMock()
107+{
108+ g_getClientInstanceCallCount.fetch_add(1);
109+ if (g_clientInitScenario.load() == ClientInitScenario::INSTANCE_NULL) {
110+ return nullptr;
111+ }
112+ return &g_mockClientEnhance;
113+}
114+ 
115+namespace {
116+bool RunClientInitScenario(ClientInitScenario scenario)
117+{
118+ pid_t pid = fork();
119+ if (pid < 0) {
120+ return false;
121+ }
122+ if (pid == 0) {
123+ g_clientInitScenario.store(scenario);
124+ g_dlopenSucceed.store(true);
125+ g_dlopenCallCount.store(0);
126+ g_dlsymCallCount.store(0);
127+ g_getClientInstanceCallCount.store(0);
128+ SecCompEnhanceAdapter::clientHandler = nullptr;
129+ SecCompEnhanceAdapter::isEnhanceClientHandlerInit = false;
130+ 
131+ SecCompEnhanceAdapter::InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE);
132+ SecCompEnhanceAdapter::InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE);
133+ const bool isEnhanceEnabled = g_dlopenCallCount.load() > 0;
134+ bool result = SecCompEnhanceAdapter::isEnhanceClientHandlerInit;
135+ if (isEnhanceEnabled) {
136+ const int32_t expectedInstanceCalls = scenario == ClientInitScenario::DLSYM_FAILED ? 0 : 1;
137+ const bool expectValidInstance = scenario == ClientInitScenario::INSTANCE_VALID;
138+ result = result && g_dlopenCallCount.load() == 1 && g_dlsymCallCount.load() == 1 &&
139+ g_getClientInstanceCallCount.load() == expectedInstanceCalls &&
140+ (SecCompEnhanceAdapter::clientHandler != nullptr) == expectValidInstance;
141+ if (expectValidInstance) {
142+ std::string componentInfo;
143+ result = result && SecCompEnhanceAdapter::EnhanceDataPreprocess(componentInfo);
144+ }
145+ } else {
146+ result = result && g_dlsymCallCount.load() == 0 && g_getClientInstanceCallCount.load() == 0 &&
147+ SecCompEnhanceAdapter::clientHandler == nullptr;
148+ }
149+ 
150+ if (scenario == ClientInitScenario::DLSYM_FAILED) {
151+ const int32_t dlopenCallCount = g_dlopenCallCount.load();
152+ SecCompEnhanceAdapter::inputHandler = nullptr;
153+ SecCompEnhanceAdapter::isEnhanceInputHandlerInit = false;
154+ SecCompEnhanceAdapter::InitEnhanceHandler(SEC_COMP_ENHANCE_INPUT_INTERFACE);
155+ SecCompEnhanceAdapter::InitEnhanceHandler(SEC_COMP_ENHANCE_INPUT_INTERFACE);
156+ const int32_t expectedDlopenCalls = dlopenCallCount + (isEnhanceEnabled ? 1 : 0);
157+ result = result && SecCompEnhanceAdapter::isEnhanceInputHandlerInit &&
158+ g_dlopenCallCount.load() == expectedDlopenCalls;
159+ }
160+ std::exit(result ? EXIT_SUCCESS : EXIT_FAILURE);
161+ }
162+ 
163+ int32_t status = 0;
164+ if (waitpid(pid, &status, 0) != pid) {
165+ return false;
166+ }
167+ return WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS;
168+} // namespace
169+}
170+ 
32void SecCompEnhanceAdapterTest::SetUpTestCase()171void SecCompEnhanceAdapterTest::SetUpTestCase()
33{172{
34 SC_LOG_INFO(LABEL, "SetUpTestCase.");173 SC_LOG_INFO(LABEL, "SetUpTestCase.");
@@ -49,6 +188,45 @@ void SecCompEnhanceAdapterTest::TearDown()
49 SC_LOG_INFO(LABEL, "TearDown.");188 SC_LOG_INFO(LABEL, "TearDown.");
50}189}
51 190 
191+/**
192+ * @tc.name: InitEnhanceHandler_001
193+ * @tc.desc: symbol failure stops initialization and dlopen failure retries at most three times
194+ * @tc.type: FUNC
195+ * @tc.require:
196+ */
197+HWTEST_F(SecCompEnhanceAdapterTest, InitEnhanceHandler_001, TestSize.Level0)
198+{
199+ constexpr size_t threadCount = 4;
200+ g_dlopenCallCount.store(0);
201+ SecCompEnhanceAdapter::InitEnhanceHandler(static_cast<EnhanceInterfaceType>(-1));
202+ EXPECT_EQ(0, g_dlopenCallCount.load());
203+ 
204+ EXPECT_TRUE(RunClientInitScenario(ClientInitScenario::DLSYM_FAILED));
205+ EXPECT_TRUE(RunClientInitScenario(ClientInitScenario::INSTANCE_NULL));
206+ EXPECT_TRUE(RunClientInitScenario(ClientInitScenario::INSTANCE_VALID));
207+ 
208+ g_dlopenCallCount.store(0);
209+ g_dlopenSucceed.store(false);
210+ std::atomic_bool hasUnexpectedResult = false;
211+ std::vector<std::thread> threads;
212+ threads.reserve(threadCount);
213+ for (size_t index = 0; index < threadCount; ++index) {
214+ threads.emplace_back([&hasUnexpectedResult]() {
215+ if (SecCompEnhanceAdapter::EnableInputEnhance() != SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE) {
216+ hasUnexpectedResult.store(true);
217+ }
218+ });
219+ }
220+ for (auto& thread : threads) {
221+ thread.join();
222+ }
223+ 
224+ EXPECT_FALSE(hasUnexpectedResult.load());
225+ const bool isEnhanceEnabled = g_dlopenCallCount.load() > 0;
226+ EXPECT_EQ(isEnhanceEnabled ? MAX_INIT_RETRY_TIMES : 0, g_dlopenCallCount.load());
227+ EXPECT_TRUE(SecCompEnhanceAdapter::isEnhanceSrvHandlerInit);
228+}
229+ 
52/**230/**
53 * @tc.name: EnhanceAdapter001231 * @tc.name: EnhanceAdapter001
54 * @tc.desc: test enhance adapter fail232 * @tc.desc: test enhance adapter fail
Mservices/security_component_service/sa/sa_main/window_info_helper.cpp+12-11
@@ -104,14 +104,16 @@ std::string GetCoveredWindowMsg(const MiniRect& windowRect)
104 104 
105static bool IsRectInWindRect(const MiniRect& windRect, const SecCompRect& secRect)105static bool IsRectInWindRect(const MiniRect& windRect, const SecCompRect& secRect)
106{106{
107+ const int32_t windRight = windRect.posX_ + static_cast<int32_t>(windRect.width_);
108+ const int32_t windBottom = windRect.posY_ + static_cast<int32_t>(windRect.height_);
107 // left or right109 // left or right
108 if ((secRect.x_ + secRect.width_ <= windRect.posX_) ||110 if ((secRect.x_ + secRect.width_ <= windRect.posX_) ||
109- (secRect.x_ >= windRect.posX_ + static_cast<int32_t>(windRect.width_))) {111+ (secRect.x_ >= windRight)) {
110 return false;112 return false;
111 }113 }
112 // top or bottom114 // top or bottom
113 if ((secRect.y_ + secRect.height_ <= windRect.posY_) ||115 if ((secRect.y_ + secRect.height_ <= windRect.posY_) ||
114- (secRect.y_ >= windRect.posY_ + static_cast<int32_t>(windRect.height_))) {116+ (secRect.y_ >= windBottom)) {
115 return false;117 return false;
116 }118 }
117 if ((GreatOrEqual(windRect.posX_, secRect.x_ + secRect.width_ - secRect.borderRadius_.rightBottom) &&119 if ((GreatOrEqual(windRect.posX_, secRect.x_ + secRect.width_ - secRect.borderRadius_.rightBottom) &&
@@ -120,24 +122,23 @@ static bool IsRectInWindRect(const MiniRect& windRect, const SecCompRect& secRec
120 secRect.y_ + secRect.height_ - secRect.borderRadius_.rightBottom, windRect.posX_, windRect.posY_);122 secRect.y_ + secRect.height_ - secRect.borderRadius_.rightBottom, windRect.posX_, windRect.posY_);
121 return !GreatNotEqual(distance, secRect.borderRadius_.rightBottom - 1.0);123 return !GreatNotEqual(distance, secRect.borderRadius_.rightBottom - 1.0);
122 }124 }
123- if ((GreatOrEqual(secRect.x_ + secRect.borderRadius_.leftBottom, windRect.posX_ + windRect.width_) &&125+ if ((GreatOrEqual(secRect.x_ + secRect.borderRadius_.leftBottom, windRight) &&
124 GreatOrEqual(windRect.posY_, secRect.y_ + secRect.height_ - secRect.borderRadius_.leftBottom))) {126 GreatOrEqual(windRect.posY_, secRect.y_ + secRect.height_ - secRect.borderRadius_.leftBottom))) {
125 auto distance = SecCompInfoHelper::GetDistance(secRect.x_ + secRect.borderRadius_.leftBottom,127 auto distance = SecCompInfoHelper::GetDistance(secRect.x_ + secRect.borderRadius_.leftBottom,
126- secRect.y_ + secRect.height_ - secRect.borderRadius_.leftBottom, windRect.posX_ + windRect.width_,128+ secRect.y_ + secRect.height_ - secRect.borderRadius_.leftBottom, windRight, windRect.posY_);
127- windRect.posY_);
128 return !GreatNotEqual(distance, secRect.borderRadius_.leftBottom - 1.0);129 return !GreatNotEqual(distance, secRect.borderRadius_.leftBottom - 1.0);
129 }130 }
130 if ((GreatOrEqual(windRect.posX_, secRect.x_ + secRect.width_ - secRect.borderRadius_.rightTop) &&131 if ((GreatOrEqual(windRect.posX_, secRect.x_ + secRect.width_ - secRect.borderRadius_.rightTop) &&
131- GreatOrEqual(secRect.y_ + secRect.borderRadius_.rightTop, windRect.posY_ + windRect.height_))) {132+ GreatOrEqual(secRect.y_ + secRect.borderRadius_.rightTop, windBottom))) {
132 auto distance = SecCompInfoHelper::GetDistance(secRect.x_ + secRect.width_ - secRect.borderRadius_.rightTop,133 auto distance = SecCompInfoHelper::GetDistance(secRect.x_ + secRect.width_ - secRect.borderRadius_.rightTop,
133- secRect.y_ + secRect.borderRadius_.rightTop, windRect.posX_, windRect.posY_ + windRect.height_);134+ secRect.y_ + secRect.borderRadius_.rightTop, windRect.posX_, windBottom);
134 return !GreatNotEqual(distance, secRect.borderRadius_.rightTop - 1.0);135 return !GreatNotEqual(distance, secRect.borderRadius_.rightTop - 1.0);
135 }136 }
136- if ((GreatOrEqual(secRect.x_ + secRect.borderRadius_.leftTop, windRect.posX_ + windRect.width_) &&137+ if ((GreatOrEqual(secRect.x_ + secRect.borderRadius_.leftTop,
137- GreatOrEqual(secRect.y_ + secRect.borderRadius_.leftTop, windRect.posY_ + windRect.height_))) {138+ windRight) &&
139+ GreatOrEqual(secRect.y_ + secRect.borderRadius_.leftTop, windBottom))) {
138 auto distance = SecCompInfoHelper::GetDistance(secRect.x_ + secRect.borderRadius_.leftTop,140 auto distance = SecCompInfoHelper::GetDistance(secRect.x_ + secRect.borderRadius_.leftTop,
139- secRect.y_ + secRect.borderRadius_.leftTop, windRect.posX_ + windRect.width_,141+ secRect.y_ + secRect.borderRadius_.leftTop, windRight, windBottom);
140- windRect.posY_ + windRect.height_);
141 return !GreatNotEqual(distance, secRect.borderRadius_.leftTop - 1.0);142 return !GreatNotEqual(distance, secRect.borderRadius_.leftTop - 1.0);
142 }143 }
143 144 
Mservices/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp+2-1
@@ -479,7 +479,8 @@ HWTEST_F(SecCompManagerTest, AddSecurityComponentToList004, TestSize.Level0)
479 managerInstance->componentMap_[pid].compList.emplace_back(entity);479 managerInstance->componentMap_[pid].compList.emplace_back(entity);
480 }480 }
481 481 
482- ASSERT_NE(managerInstance->AddSecurityComponentToList(pid, 0, entity), SC_SERVICE_ERROR_VALUE_INVALID);482+ ASSERT_EQ(SC_OK, managerInstance->AddSecurityComponentToList(pid, 0, entity));
483+ ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, managerInstance->AddSecurityComponentToList(pid, 0, entity));
483}484}
484 485 
485/**486/**
Mservices/security_component_service/sa/test/unittest/src/window_info_helper_test.cpp+36-0
@@ -394,6 +394,42 @@ HWTEST_F(WindowInfoHelperTest, CheckOtherWindowCoverComp007, TestSize.Level0)
394 ASSERT_FALSE(WindowInfoHelper::CheckOtherWindowCoverComp(0, compRect, ServiceTestCommon::TEST_USER_ID, message));394 ASSERT_FALSE(WindowInfoHelper::CheckOtherWindowCoverComp(0, compRect, ServiceTestCommon::TEST_USER_ID, message));
395}395}
396 396 
397+/**
398+ * @tc.name: CheckOtherWindowCoverComp008
399+ * @tc.desc: Test a negative-coordinate window outside the rounded corner does not cover the component
400+ * @tc.type: FUNC
401+ * @tc.require:
402+ */
403+HWTEST_F(WindowInfoHelperTest, CheckOtherWindowCoverComp008, TestSize.Level0)
404+{
405+ constexpr int32_t componentWindowId = 0;
406+ constexpr int32_t coverWindowId = 1;
407+ constexpr int32_t componentLayer = 1;
408+ constexpr int32_t coverWindowLayer = 2;
409+ constexpr int32_t windowPosition = -10;
410+ constexpr uint32_t windowSize = 5;
411+ constexpr double componentPosition = -8.0;
412+ constexpr double componentSize = 100.0;
413+ constexpr double borderRadius = 20.0;
414+ 
415+ WindowManager::GetInstance().result_ = WMError::WM_OK;
416+ sptr<UnreliableWindowInfo> compWin = new UnreliableWindowInfo();
417+ compWin->windowId_ = componentWindowId;
418+ compWin->zOrder_ = componentLayer;
419+ 
420+ sptr<UnreliableWindowInfo> cornerWin = new UnreliableWindowInfo();
421+ cornerWin->windowId_ = coverWindowId;
422+ cornerWin->zOrder_ = coverWindowLayer;
423+ cornerWin->windowRect_ = Rosen::Rect { windowPosition, windowPosition, windowSize, windowSize };
424+ WindowManager::GetInstance().info_ = { compWin, cornerWin };
425+ 
426+ SecCompRect compRect = { componentPosition, componentPosition, componentSize, componentSize };
427+ compRect.borderRadius_.leftTop = borderRadius;
428+ std::string message;
429+ EXPECT_TRUE(WindowInfoHelper::CheckOtherWindowCoverComp(
430+ componentWindowId, compRect, ServiceTestCommon::TEST_USER_ID, message));
431+}
432+ 
397/**433/**
398 * @tc.name: TryGetWindowInfo001434 * @tc.name: TryGetWindowInfo001
399 * @tc.desc: Test TryGetWindowInfo with normal windowId match435 * @tc.desc: Test TryGetWindowInfo with normal windowId match