1 /*
2 * Copyright (c) 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 #include "core/components_ng/pattern/security_component/security_component_handler.h"
17 #include "ui/base/geometry/dimension.h"
18
19 #include "adapter/ohos/entrance/ace_container.h"
20 #include "base/geometry/dimension.h"
21 #include "base/utils/system_properties.h"
22 #include "core/components_ng/pattern/button/button_layout_property.h"
23 #include "core/components_ng/pattern/security_component/security_component_log.h"
24 #include "core/components_ng/pattern/window_scene/scene/system_window_scene.h"
25 #include "core/components_ng/property/gradient_property.h"
26 #include "core/components_v2/inspector/inspector_constants.h"
27
28 namespace OHOS::Ace::NG {
29 using namespace OHOS::Security;
30 using namespace OHOS::Security::SecurityComponent;
31 namespace {
32 constexpr uint64_t SECOND_TO_MILLISECOND = 1000;
33 constexpr float HALF = 2.0f;
34 const std::string SEC_COMP_ID = "security component id = ";
35 const std::string SEC_COMP_TYPE = ", security component type = ";
36 }
37
38 static std::vector<uintptr_t> g_callList = {
39 reinterpret_cast<uintptr_t>(SecurityComponentHandler::RegisterSecurityComponent),
40 reinterpret_cast<uintptr_t>(SecurityComponentHandler::UpdateSecurityComponent),
41 reinterpret_cast<uintptr_t>(SecurityComponentHandler::ReportSecurityComponentClickEventInner)
42 };
43
44 SecurityComponentProbe SecurityComponentHandler::probe;
45 SecurityComponent::SecCompUiRegister uiRegister(g_callList, &SecurityComponentHandler::probe);
46
GetDisplayOffset(RefPtr<FrameNode> & node,double & offsetX,double & offsetY)47 bool SecurityComponentHandler::GetDisplayOffset(RefPtr<FrameNode>& node, double& offsetX, double& offsetY)
48 {
49 double x = node->GetTransformRelativeOffset().GetX();
50 double y = node->GetTransformRelativeOffset().GetY();
51 auto container = Container::Current();
52 CHECK_NULL_RETURN(container, false);
53 auto pipelineContext = container->GetPipelineContext();
54 CHECK_NULL_RETURN(pipelineContext, false);
55 auto windowOffset = pipelineContext->GetDisplayWindowRectInfo().GetOffset();
56 offsetX = x + windowOffset.GetX();
57 offsetY = y + windowOffset.GetY();
58 return true;
59 }
60
GetWindowRect(RefPtr<FrameNode> & node,OHOS::Security::SecurityComponent::SecCompRect & winRect)61 bool SecurityComponentHandler::GetWindowRect(RefPtr<FrameNode>& node,
62 OHOS::Security::SecurityComponent::SecCompRect& winRect)
63 {
64 auto container = Container::Current();
65 CHECK_NULL_RETURN(container, false);
66 auto pipelineContext = container->GetPipelineContext();
67 CHECK_NULL_RETURN(pipelineContext, false);
68 auto rect = pipelineContext->GetDisplayWindowRectInfo();
69 winRect.x_ = rect.Left();
70 winRect.y_ = rect.Top();
71 winRect.width_ = rect.Right() - rect.Left();
72 winRect.height_ = rect.Bottom() - rect.Top();
73 return true;
74 }
75
CheckOpacity(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)76 bool SecurityComponentHandler::CheckOpacity(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext,
77 std::string& message)
78 {
79 if (node->GetTag() == V2::MENU_WRAPPER_ETS_TAG) {
80 return false;
81 }
82 if (renderContext->GetOpacity().has_value() &&
83 !NearEqual(renderContext->GetOpacity().value(), 1.0f)) {
84 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s opacity = %{public}f, " \
85 "security component is invalid", node->GetTag().c_str(), renderContext->GetOpacity().value());
86 message = ", attribute opacity of parent component " + node->GetTag() +
87 "(id = " + std::to_string(node->GetId()) + ") is set, opacity = " +
88 std::to_string(renderContext->GetOpacity().value());
89 return true;
90 }
91 return false;
92 }
93
CheckBrightness(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)94 bool SecurityComponentHandler::CheckBrightness(const RefPtr<FrameNode>& node,
95 const RefPtr<RenderContext>& renderContext, std::string& message)
96 {
97 if (renderContext->GetFrontBrightness().has_value() &&
98 !NearEqual(renderContext->GetFrontBrightness().value().Value(), 1.0f)) {
99 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s brightness = %{public}f, " \
100 "security component is invalid", node->GetTag().c_str(),
101 renderContext->GetFrontBrightness().value().Value());
102 message = ", attribute brightness of parent component " + node->GetTag() +
103 "(id = " + std::to_string(node->GetId()) + ") is set, brightness = " +
104 std::to_string(renderContext->GetFrontBrightness().value().Value());
105 return true;
106 }
107 return false;
108 }
109
CheckVisibility(const RefPtr<FrameNode> & node,RefPtr<LayoutProperty> & layoutProperty,std::string & message)110 bool SecurityComponentHandler::CheckVisibility(const RefPtr<FrameNode>& node, RefPtr<LayoutProperty>& layoutProperty,
111 std::string& message)
112 {
113 if (layoutProperty->GetVisibility().has_value() &&
114 (layoutProperty->GetVisibility().value() != VisibleType::VISIBLE)) {
115 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s is not visible, security component is invalid",
116 node->GetTag().c_str());
117 message = ", attribute visibility of parent component " + node->GetTag() +
118 "(id = " + std::to_string(node->GetId()) + ") is set, parent component is not visible";
119 return true;
120 }
121 return false;
122 }
123
CheckBlur(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)124 bool SecurityComponentHandler::CheckBlur(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext,
125 std::string& message)
126 {
127 if (renderContext->GetFrontBlurRadius().has_value() &&
128 GreatNotEqual(renderContext->GetFrontBlurRadius().value().ConvertToPx(), 0.0f)) {
129 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s blur is set, security component is invalid",
130 node->GetTag().c_str());
131 message = ", attribute blur of parent component " + node->GetTag() +
132 "(id = " + std::to_string(node->GetId()) + ") is set";
133 return true;
134 }
135 return false;
136 }
137
CheckForegroundBlurStyle(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)138 bool SecurityComponentHandler::CheckForegroundBlurStyle(const RefPtr<FrameNode>& node,
139 const RefPtr<RenderContext>& renderContext, std::string& message)
140 {
141 auto blurStyleOption = renderContext->GetFrontBlurStyle();
142 if (blurStyleOption.has_value() && (blurStyleOption->blurStyle != BlurStyle::NO_MATERIAL) &&
143 (!NearEqual(blurStyleOption->scale, 0.0))) {
144 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s foregroundBlurStyle is set, " \
145 "security component is invalid", node->GetTag().c_str());
146 message = ", attribute foregroundBlurStyle of parent component " +
147 node->GetTag() + "(id = " + std::to_string(node->GetId()) + ") is set";
148 return true;
149 }
150 return false;
151 }
152
CheckBlendMode(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)153 bool SecurityComponentHandler::CheckBlendMode(const RefPtr<FrameNode>& node,
154 const RefPtr<RenderContext>& renderContext, std::string& message)
155 {
156 auto blendMode = renderContext->GetBackBlendMode();
157 if (blendMode.has_value() && blendMode != BlendMode::NONE && blendMode != BlendMode::SRC_OVER) {
158 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s blendMode is set, " \
159 "security component is invalid", node->GetTag().c_str());
160 message = ", attribute blendMode of parent component " +
161 node->GetTag() + "(id = " + std::to_string(node->GetId()) + ") is set";
162 return true;
163 }
164 return false;
165 }
166
GetBorderRect(const RefPtr<FrameNode> & parentNode,std::vector<RectF> & borderRects)167 bool SecurityComponentHandler::GetBorderRect(const RefPtr<FrameNode>& parentNode, std::vector<RectF>& borderRects)
168 {
169 auto renderContext = parentNode->GetRenderContext();
170 CHECK_NULL_RETURN(renderContext, false);
171 auto borderWidth = renderContext->GetBorderWidth();
172 CHECK_NULL_RETURN(borderWidth, false);
173 auto parentRect = renderContext->GetPaintRectWithTransform();
174 parentRect.SetOffset(parentNode->GetPositionToScreenWithTransform());
175 auto borderColor = renderContext->GetBorderColor();
176 auto leftIsTransparent = borderColor && borderColor->leftColor.has_value() &&
177 (borderColor->leftColor.value() == Color::TRANSPARENT);
178 auto rightIsTransparent = borderColor && borderColor->rightColor.has_value() &&
179 (borderColor->rightColor.value() == Color::TRANSPARENT);
180 auto topIsTransparent = borderColor && borderColor->topColor.has_value() &&
181 (borderColor->topColor.value() == Color::TRANSPARENT);
182 auto bottomIsTransparent = borderColor && borderColor->bottomColor.has_value() &&
183 (borderColor->bottomColor.value() == Color::TRANSPARENT);
184
185 if (borderWidth->leftDimen.has_value() && GreatNotEqual(borderWidth->leftDimen.value().ConvertToPx(), 1.0) &&
186 !leftIsTransparent) {
187 auto leftWidth = borderWidth->leftDimen.value().ConvertToPx();
188 borderRects.emplace_back(RectF(parentRect.GetX(), parentRect.GetY(), leftWidth, parentRect.Height()));
189 }
190 if (borderWidth->rightDimen.has_value() && GreatNotEqual(borderWidth->rightDimen.value().ConvertToPx(), 1.0) &&
191 !rightIsTransparent) {
192 auto rightWidth = borderWidth->rightDimen.value().ConvertToPx();
193 borderRects.emplace_back(RectF(parentRect.GetX() + parentRect.Width() - rightWidth, parentRect.GetY(),
194 rightWidth, parentRect.Height()));
195 }
196 if (borderWidth->topDimen.has_value() && GreatNotEqual(borderWidth->topDimen.value().ConvertToPx(), 1.0) &&
197 !topIsTransparent) {
198 auto topWidth = borderWidth->topDimen.value().ConvertToPx();
199 borderRects.emplace_back(RectF(parentRect.GetX(), parentRect.GetY(), parentRect.Width(), topWidth));
200 }
201 if (borderWidth->bottomDimen.has_value() && GreatNotEqual(borderWidth->bottomDimen.value().ConvertToPx(), 1.0) &&
202 !bottomIsTransparent) {
203 auto bottomWidth = borderWidth->bottomDimen.value().ConvertToPx();
204 borderRects.emplace_back(RectF(parentRect.GetX(), parentRect.GetY() + parentRect.Height() - bottomWidth,
205 parentRect.Width(), bottomWidth));
206 }
207 return true;
208 }
209
CheckParentBorder(const RefPtr<FrameNode> & parentNode,const RectF & scRect,std::string & message)210 bool SecurityComponentHandler::CheckParentBorder(const RefPtr<FrameNode>& parentNode, const RectF& scRect,
211 std::string& message)
212 {
213 std::vector<RectF> borderRects;
214 if (!GetBorderRect(parentNode, borderRects)) {
215 return false;
216 }
217 for (const auto& rect : borderRects) {
218 if (!rect.IsInnerIntersectWithRound(scRect)) {
219 continue;
220 }
221 SC_LOG_ERROR("SecurityComponentCheckFail: security component is covered by the border of parent" \
222 " %{public}s", parentNode->GetTag().c_str());
223 message = ", security component is covered by the border of parent component " +
224 parentNode->GetTag() + "(id = " + std::to_string(parentNode->GetId()) + ")";
225 return true;
226 }
227
228 return false;
229 }
230
GetLinearGradientBlurRatio(std::vector<std::pair<float,float>> & fractionStops)231 float SecurityComponentHandler::GetLinearGradientBlurRatio(std::vector<std::pair<float, float>>& fractionStops)
232 {
233 float ratio = 1.0;
234 int32_t size = static_cast<int32_t>(fractionStops.size());
235 for (auto i = 0; i < size; i++) {
236 auto fraction = fractionStops[i];
237 if (NearEqual(fraction.first, 0.0)) {
238 ratio = fraction.second;
239 } else {
240 break;
241 }
242 }
243 return ratio;
244 }
245
CheckDistance(const float & deltaY,const float & radius,const float & distance,const int32_t & multiplier)246 bool SecurityComponentHandler::CheckDistance(const float& deltaY, const float& radius, const float& distance,
247 const int32_t& multiplier)
248 {
249 if (NearEqual(radius, 0.0)) {
250 if (GreatNotEqual(deltaY * multiplier, 0.0)) {
251 if (GreatNotEqual(distance, 1.0)) {
252 return true;
253 }
254 }
255 return false;
256 }
257
258 if (GreatOrEqual(deltaY * multiplier, 0.0)) {
259 return true;
260 }
261 if (LessNotEqual(distance, (radius - 1) * (radius - 1))) {
262 return true;
263 }
264 return false;
265 }
266
CheckDiagonalLinearGradientBlur(const RectF & parentRect,const RectF & rect,const NG::GradientDirection direction,const float & ratio,const float & radius)267 bool SecurityComponentHandler::CheckDiagonalLinearGradientBlur(const RectF& parentRect, const RectF& rect,
268 const NG::GradientDirection direction, const float& ratio, const float& radius)
269 {
270 Point dest;
271 Point src;
272 float gradient;
273 int32_t multiplier = 0;
274 switch (direction) {
275 case GradientDirection::LEFT_TOP:
276 dest.SetX(rect.GetX() + radius);
277 dest.SetY(rect.GetY() + radius);
278 src.SetX(parentRect.GetX() + (1 - ratio) * parentRect.Width());
279 src.SetY(parentRect.GetY() + (1 - ratio) * parentRect.Height());
280 gradient = (0 - parentRect.Width()) / parentRect.Height();
281 multiplier = 1;
282 break;
283 case GradientDirection::LEFT_BOTTOM:
284 dest.SetX(rect.GetX() + radius);
285 dest.SetY(rect.GetY() + rect.Height() - radius);
286 src.SetX(parentRect.GetX() + (1 - ratio) * parentRect.Width());
287 src.SetY(parentRect.GetY() + ratio * parentRect.Height());
288 gradient = parentRect.Width() / parentRect.Height();
289 multiplier = -1;
290 break;
291 case GradientDirection::RIGHT_TOP:
292 dest.SetX(rect.GetX() + rect.Width() - radius);
293 dest.SetY(rect.GetY() + radius);
294 src.SetX(parentRect.GetX() + ratio * parentRect.Width());
295 src.SetY(parentRect.GetY() + (1 - ratio) * parentRect.Height());
296 gradient = parentRect.Width() / parentRect.Height();
297 multiplier = 1;
298 break;
299 case GradientDirection::RIGHT_BOTTOM:
300 dest.SetX(rect.GetX() + rect.Width() - radius);
301 dest.SetY(rect.GetY() + rect.Height() - radius);
302 src.SetX(parentRect.GetX() + ratio * parentRect.Width());
303 src.SetY(parentRect.GetY() + ratio * parentRect.Height());
304 gradient = (0 - parentRect.Width()) / parentRect.Height();
305 multiplier = -1;
306 break;
307 default:
308 return false;
309 }
310
311 float deltaY = gradient * dest.GetX() + src.GetY() - gradient * src.GetX() - dest.GetY();
312 auto distance = (deltaY * deltaY) / (1 + gradient * gradient);
313 return CheckDistance(deltaY, radius, distance, multiplier);
314 }
315
GetBorderRadius(RefPtr<FrameNode> & node,const NG::GradientDirection direction)316 float SecurityComponentHandler::GetBorderRadius(RefPtr<FrameNode>& node, const NG::GradientDirection direction)
317 {
318 RectF rect = node->GetTransformRectRelativeToWindow();
319 auto maxRadius = std::min(rect.Width(), rect.Height()) / HALF;
320 auto layoutProperty = AceType::DynamicCast<SecurityComponentLayoutProperty>(node->GetLayoutProperty());
321 CHECK_NULL_RETURN(layoutProperty, 0.0);
322 if (layoutProperty->GetBackgroundType() == static_cast<int32_t>(ButtonType::CIRCLE) ||
323 layoutProperty->GetBackgroundType() == static_cast<int32_t>(ButtonType::CAPSULE)) {
324 return maxRadius;
325 }
326
327 RefPtr<FrameNode> buttonNode = GetSecCompChildNode(node, V2::BUTTON_ETS_TAG);
328 CHECK_NULL_RETURN(buttonNode, 0.0);
329 auto bgProp = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
330 CHECK_NULL_RETURN(bgProp, 0.0);
331 auto borderRadius = bgProp->GetBorderRadius();
332 float radius = 0.0;
333
334 switch (direction) {
335 case GradientDirection::LEFT_TOP:
336 if (borderRadius.has_value() && borderRadius->radiusTopLeft.has_value()) {
337 auto obtainedRadius = borderRadius->radiusTopLeft.value().ConvertToPx();
338 radius = GreatNotEqual(obtainedRadius, maxRadius) ? maxRadius : obtainedRadius;
339 }
340 return radius;
341 case GradientDirection::LEFT_BOTTOM:
342 if (borderRadius.has_value() && borderRadius->radiusBottomLeft.has_value()) {
343 auto obtainedRadius = borderRadius->radiusBottomLeft.value().ConvertToPx();
344 radius = GreatNotEqual(obtainedRadius, maxRadius) ? maxRadius : obtainedRadius;
345 }
346 return radius;
347 case GradientDirection::RIGHT_TOP:
348 if (borderRadius.has_value() && borderRadius->radiusTopRight.has_value()) {
349 auto obtainedRadius = borderRadius->radiusTopRight.value().ConvertToPx();
350 radius = GreatNotEqual(obtainedRadius, maxRadius) ? maxRadius : obtainedRadius;
351 }
352 return radius;
353 case GradientDirection::RIGHT_BOTTOM:
354 if (borderRadius.has_value() && borderRadius->radiusBottomRight.has_value()) {
355 auto obtainedRadius = borderRadius->radiusBottomRight.value().ConvertToPx();
356 radius = GreatNotEqual(obtainedRadius, maxRadius) ? maxRadius : obtainedRadius;
357 }
358 return radius;
359 default:
360 return radius;
361 }
362 return radius;
363 }
364
CheckLinearGradientBlur(const RefPtr<FrameNode> & parentNode,RefPtr<FrameNode> & node,bool & isBlured,double & blurRadius)365 bool SecurityComponentHandler::CheckLinearGradientBlur(const RefPtr<FrameNode>& parentNode,
366 RefPtr<FrameNode>& node, bool& isBlured, double& blurRadius)
367 {
368 RectF parentRect = parentNode->GetTransformRectRelativeToWindow();
369 if (NearEqual(parentRect.Width(), 0.0) || NearEqual(parentRect.Height(), 0.0)) {
370 return false;
371 }
372
373 RectF rect = node->GetTransformRectRelativeToWindow();
374 const auto& parentRender = parentNode->GetRenderContext();
375 CHECK_NULL_RETURN(parentRender, false);
376 auto linearGradientBlurPara = parentRender->GetLinearGradientBlur();
377 CHECK_NULL_RETURN(linearGradientBlurPara, false);
378 isBlured = true;
379 blurRadius = linearGradientBlurPara->blurRadius_.ConvertToPx();
380 float ratio = GetLinearGradientBlurRatio(linearGradientBlurPara->fractionStops_);
381 if (NearEqual(ratio, 1.0)) {
382 return false;
383 }
384
385 float radius = 0.0;
386 switch (linearGradientBlurPara->direction_) {
387 case GradientDirection::LEFT:
388 return GreatNotEqual((parentRect.GetX() + parentRect.Width() - rect.GetX()) / parentRect.Width(), ratio);
389 case GradientDirection::TOP:
390 return GreatNotEqual((parentRect.GetY() + parentRect.Height() - rect.GetY()) / parentRect.Height(), ratio);
391 case GradientDirection::RIGHT:
392 return GreatNotEqual((rect.GetX() + rect.Width() - parentRect.GetX()) / parentRect.Width(), ratio);
393 case GradientDirection::BOTTOM:
394 return GreatNotEqual((rect.GetY() + rect.Height() - parentRect.GetY()) / parentRect.Height(), ratio);
395 case GradientDirection::LEFT_TOP:
396 case GradientDirection::LEFT_BOTTOM:
397 case GradientDirection::RIGHT_TOP:
398 case GradientDirection::RIGHT_BOTTOM:
399 radius = GetBorderRadius(node, linearGradientBlurPara->direction_);
400 return CheckDiagonalLinearGradientBlur(parentRect, rect,
401 linearGradientBlurPara->direction_, ratio, radius);
402 default:
403 return false;
404 }
405 }
406
CheckGrayScale(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)407 bool SecurityComponentHandler::CheckGrayScale(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext,
408 std::string& message)
409 {
410 if (renderContext->GetFrontGrayScale().has_value() &&
411 GreatNotEqual(renderContext->GetFrontGrayScale().value().ConvertToVp(), 0.0f)) {
412 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s grayscale is set, security component is invalid",
413 node->GetTag().c_str());
414 message = ", attribute grayscale of parent component " + node->GetTag() + "(id = " +
415 std::to_string(node->GetId()) + ") is set";
416 return true;
417 }
418 return false;
419 }
420
CheckSaturate(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)421 bool SecurityComponentHandler::CheckSaturate(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext,
422 std::string& message)
423 {
424 if (renderContext->GetFrontSaturate().has_value() &&
425 !NearEqual(renderContext->GetFrontSaturate().value().ConvertToVp(), 1.0f)) {
426 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s saturate is set, security component is invalid",
427 node->GetTag().c_str());
428 message = ", attribute saturate of parent component " + node->GetTag() +
429 "(id = " + std::to_string(node->GetId()) + ") is set";
430 return true;
431 }
432 return false;
433 }
434
CheckContrast(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)435 bool SecurityComponentHandler::CheckContrast(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext,
436 std::string& message)
437 {
438 if (renderContext->GetFrontContrast().has_value() &&
439 !NearEqual(renderContext->GetFrontContrast().value().ConvertToVp(), 1.0f)) {
440 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s contrast is set, security component is invalid",
441 node->GetTag().c_str());
442 message = ", attribute contrast of parent component " + node->GetTag() +
443 "(id = " + std::to_string(node->GetId()) + ") is set";
444 return true;
445 }
446 return false;
447 }
448
CheckInvert(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)449 bool SecurityComponentHandler::CheckInvert(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext,
450 std::string& message)
451 {
452 if (renderContext->GetFrontInvert().has_value() && renderContext->GetFrontInvert()->index() == 0 &&
453 !NearEqual(std::get<float>(renderContext->GetFrontInvert().value()), 0.0f)) {
454 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s invert is set, security component is invalid",
455 node->GetTag().c_str());
456 message = ", attribute invert of parent component " + node->GetTag() +
457 "(id = " + std::to_string(node->GetId()) + ") is set";
458 return true;
459 }
460 return false;
461 }
462
CheckSepia(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)463 bool SecurityComponentHandler::CheckSepia(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext,
464 std::string& message)
465 {
466 if (renderContext->GetFrontSepia().has_value() &&
467 !NearEqual(renderContext->GetFrontSepia().value().ConvertToVp(), 0.0f)) {
468 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s sepia is set, security component is invalid",
469 node->GetTag().c_str());
470 message = ", attribute sepia of parent component " + node->GetTag() +
471 "(id = " + std::to_string(node->GetId()) + ") is set";
472 return true;
473 }
474 return false;
475 }
476
CheckHueRotate(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)477 bool SecurityComponentHandler::CheckHueRotate(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext,
478 std::string& message)
479 {
480 if (renderContext->GetFrontHueRotate().has_value() &&
481 !NearEqual(renderContext->GetFrontHueRotate().value(), 0.0f) &&
482 !NearEqual(renderContext->GetFrontHueRotate().value(), 360.0f)) {
483 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s hueRotate is set, security component is invalid",
484 node->GetTag().c_str());
485 message = ", attribute hueRotate of parent component " + node->GetTag() +
486 "(id = " + std::to_string(node->GetId()) + ") is set";
487 return true;
488 }
489 return false;
490 }
491
CheckColorBlend(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)492 bool SecurityComponentHandler::CheckColorBlend(const RefPtr<FrameNode>& node,
493 const RefPtr<RenderContext>& renderContext, std::string& message)
494 {
495 if (renderContext->GetFrontColorBlend().has_value() &&
496 (renderContext->GetFrontColorBlend().value() != Color::TRANSPARENT)) {
497 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s colorBlend is set, security component is invalid",
498 node->GetTag().c_str());
499 message = ", attribute colorBlend of parent component " + node->GetTag() +
500 "(id = " + std::to_string(node->GetId()) + ") is set";
501 return true;
502 }
503 return false;
504 }
505
CheckClipMask(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)506 bool SecurityComponentHandler::CheckClipMask(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext,
507 std::string& message)
508 {
509 if (renderContext->GetClipMask().has_value()) {
510 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s clip mask is set, security component is invalid",
511 node->GetTag().c_str());
512 message = ", attribute maskShape of parent component " + node->GetTag() +
513 "(id = " + std::to_string(node->GetId()) + ") is set";
514 return true;
515 }
516 return false;
517 }
518
CheckForegroundColor(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)519 bool SecurityComponentHandler::CheckForegroundColor(const RefPtr<FrameNode>& node,
520 const RefPtr<RenderContext>& renderContext, std::string& message)
521 {
522 if (renderContext->GetForegroundColor().has_value()) {
523 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s foregroundColor is set, " \
524 "security component is invalid", node->GetTag().c_str());
525 message = ", attribute foregroundColor of parent component " + node->GetTag() +
526 "(id = " + std::to_string(node->GetId()) + ") is set";
527 return true;
528 }
529 return false;
530 }
531
CheckSphericalEffect(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)532 bool SecurityComponentHandler::CheckSphericalEffect(const RefPtr<FrameNode>& node,
533 const RefPtr<RenderContext>& renderContext, std::string& message)
534 {
535 if (renderContext->GetSphericalEffect().has_value() &&
536 !NearEqual(renderContext->GetSphericalEffect().value(), 0.0f)) {
537 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s sphericalEffect is set, " \
538 "security component is invalid", node->GetTag().c_str());
539 message = ", attribute sphericalEffect of parent component " + node->GetTag() +
540 "(id = " + std::to_string(node->GetId()) + ") is set";
541 return true;
542 }
543 return false;
544 }
545
CheckLightUpEffect(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)546 bool SecurityComponentHandler::CheckLightUpEffect(const RefPtr<FrameNode>& node,
547 const RefPtr<RenderContext>& renderContext, std::string& message)
548 {
549 if (renderContext->GetLightUpEffect().has_value()) {
550 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s lightUpEffect is set, " \
551 "security component is invalid", node->GetTag().c_str());
552 message = ", attribute lightUpEffect of parent component " + node->GetTag() +
553 "(id = " + std::to_string(node->GetId()) + ") is set";
554 return true;
555 }
556 return false;
557 }
558
CheckPixelStretchEffect(const RefPtr<FrameNode> & node,const RefPtr<RenderContext> & renderContext,std::string & message)559 bool SecurityComponentHandler::CheckPixelStretchEffect(const RefPtr<FrameNode>& node,
560 const RefPtr<RenderContext>& renderContext, std::string& message)
561 {
562 if (renderContext->GetPixelStretchEffect().has_value()) {
563 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s pixelStretchEffect is set, " \
564 "security component is invalid", node->GetTag().c_str());
565 message = ", attribute pixelStretchEffect of parent component " + node->GetTag() +
566 "(id = " + std::to_string(node->GetId()) + ") is set";
567 return true;
568 }
569 return false;
570 }
571
CheckRenderEffect(RefPtr<FrameNode> & node,std::string & message)572 bool SecurityComponentHandler::CheckRenderEffect(RefPtr<FrameNode>& node, std::string& message)
573 {
574 const auto& renderContext = node->GetRenderContext();
575 CHECK_NULL_RETURN(renderContext, false);
576 auto layoutProperty = node->GetLayoutProperty();
577 CHECK_NULL_RETURN(layoutProperty, false);
578
579 if (CheckOpacity(node, renderContext, message) || CheckBrightness(node, renderContext, message) ||
580 CheckVisibility(node, layoutProperty, message) || CheckBlur(node, renderContext, message) ||
581 CheckGrayScale(node, renderContext, message) || CheckSaturate(node, renderContext, message) ||
582 CheckContrast(node, renderContext, message) || CheckInvert(node, renderContext, message) ||
583 CheckSepia(node, renderContext, message) || CheckHueRotate(node, renderContext, message) ||
584 CheckColorBlend(node, renderContext, message) || CheckClipMask(node, renderContext, message) ||
585 CheckForegroundColor(node, renderContext, message) || CheckSphericalEffect(node, renderContext, message) ||
586 CheckLightUpEffect(node, renderContext, message) || CheckPixelStretchEffect(node, renderContext, message) ||
587 CheckForegroundBlurStyle(node, renderContext, message) || CheckBlendMode(node, renderContext, message)) {
588 return true;
589 }
590 return false;
591 }
592
GetClipErrorMsg(const std::string & scId,const std::string & scType,const RectF & visibleRect,const RectF & frameRect,const RefPtr<FrameNode> & parentNode)593 std::string GetClipErrorMsg(const std::string& scId, const std::string& scType,
594 const RectF& visibleRect, const RectF& frameRect, const RefPtr<FrameNode>& parentNode)
595 {
596 std::string message = "The id of " + scType + " is " + scId +
597 ", attribute clip of parent component " + parentNode->GetTag() +
598 "(id = " + std::to_string(parentNode->GetId()) + ") is set, " + scType +
599 " is not completely displayed. The rect of visible part is {width = " +
600 std::to_string(visibleRect.Width()) +
601 ", height = " + std::to_string(visibleRect.Height()) +
602 "}, the real size of " + scType + " is {width = " +
603 std::to_string(frameRect.Width()) +
604 ", height = " + std::to_string(frameRect.Height()) + "}";
605 return message;
606 }
607
IsSecComponentClipped(RefPtr<FrameNode> & parentNode,RectF & visibleRect,const RectF & frameRect,OHOS::Security::SecurityComponent::SecCompBase & buttonInfo)608 bool SecurityComponentHandler::IsSecComponentClipped(RefPtr<FrameNode>& parentNode,
609 RectF& visibleRect, const RectF& frameRect, OHOS::Security::SecurityComponent::SecCompBase& buttonInfo)
610 {
611 GetVisibleRect(parentNode, visibleRect);
612 bool isClipped = IsOutOfParentWithRound(visibleRect, frameRect, buttonInfo);
613 buttonInfo.isClipped_ = isClipped;
614 buttonInfo.parentTag_ = parentNode->GetTag();
615
616 if (isClipped && (visibleRect.IsValid() || frameRect.IsValid())) {
617 SC_LOG_ERROR("SecurityComponentCheckFail: Parents clip is set, " \
618 "security component is not completely displayed.");
619 SC_LOG_ERROR("visibleWidth: %{public}f, visibleHeight: %{public}f, " \
620 "frameWidth: %{public}f, frameHeight: %{public}f",
621 visibleRect.Width(), visibleRect.Height(), frameRect.Width(), frameRect.Height());
622 return true;
623 }
624 return false;
625 }
626
CheckParentNodesEffect(RefPtr<FrameNode> & node,OHOS::Security::SecurityComponent::SecCompBase & buttonInfo,std::string & message)627 bool SecurityComponentHandler::CheckParentNodesEffect(RefPtr<FrameNode>& node,
628 OHOS::Security::SecurityComponent::SecCompBase& buttonInfo, std::string& message)
629 {
630 RefPtr<RenderContext> renderContext = node->GetRenderContext();
631 CHECK_NULL_RETURN(renderContext, false);
632 auto frameRect = renderContext->GetPaintRectWithTransform();
633 frameRect.SetOffset(node->GetPositionToScreenWithTransform());
634 auto visibleRect = frameRect;
635 auto parent = node->GetParent();
636 std::string scId = std::to_string(node->GetId());
637 std::string scType = node->GetTag();
638 while (parent != nullptr) {
639 auto parentNode = AceType::DynamicCast<FrameNode>(parent);
640 if (parentNode == nullptr) {
641 parent = parent->GetParent();
642 continue;
643 }
644 if (parentNode->CheckTopWindowBoundary()) {
645 break;
646 }
647 if (CheckRenderEffect(parentNode, message) || CheckParentBorder(parentNode, frameRect, message)) {
648 message = SEC_COMP_ID + scId + SEC_COMP_TYPE + scType + message;
649 return true;
650 }
651 if (CheckLinearGradientBlur(parentNode, node, buttonInfo.hasNonCompatileChange_, buttonInfo.blurRadius_)) {
652 SC_LOG_ERROR("SecurityComponentCheckFail: Parent %{public}s LinearGradientBlur is set, " \
653 "security component is invalid", parentNode->GetTag().c_str());
654 message = SEC_COMP_ID + scId + SEC_COMP_TYPE + scType +
655 ", attribute linearGradientBlur of parent component " +
656 node->GetTag() + " is set";
657 return true;
658 }
659 RefPtr<RenderContext> parentRenderContext = parentNode->GetRenderContext();
660 if ((parentRenderContext == nullptr) ||
661 !parentRenderContext->GetClipEdge().value_or(false)) {
662 parent = parent->GetParent();
663 continue;
664 }
665 if (IsSecComponentClipped(parentNode, visibleRect, frameRect, buttonInfo)) {
666 message = GetClipErrorMsg(scId, scType, visibleRect, frameRect, parentNode);
667 return true;
668 }
669 parent = parent->GetParent();
670 }
671 return false;
672 }
673
GetVisibleRect(RefPtr<FrameNode> & node,RectF & visibleRect)674 void SecurityComponentHandler::GetVisibleRect(RefPtr<FrameNode>& node, RectF& visibleRect)
675 {
676 auto renderContext = node->GetRenderContext();
677 CHECK_NULL_VOID(renderContext);
678 RectF parentRect = renderContext->GetPaintRectWithTransform();
679 parentRect.SetOffset(node->GetPositionToScreenWithTransform());
680 visibleRect = visibleRect.Constrain(parentRect);
681 }
682
IsOutOfParentWithRound(const RectF & visibleRect,const RectF & renderRect,OHOS::Security::SecurityComponent::SecCompBase & buttonInfo)683 bool SecurityComponentHandler::IsOutOfParentWithRound(const RectF& visibleRect, const RectF& renderRect,
684 OHOS::Security::SecurityComponent::SecCompBase& buttonInfo)
685 {
686 if (!visibleRect.IsValid() || !renderRect.IsValid()) {
687 return true;
688 }
689
690 if (NearEqual(visibleRect.Width(), 0.0) || NearEqual(visibleRect.Height(), 0.0) ||
691 NearEqual(renderRect.Width(), 0.0) || NearEqual(renderRect.Height(), 0.0)) {
692 return true;
693 }
694
695 buttonInfo.leftClip_ = visibleRect.Left() - renderRect.Left();
696 buttonInfo.rightClip_ = renderRect.Right() - visibleRect.Right();
697 buttonInfo.topClip_ = visibleRect.Top() - renderRect.Top();
698 buttonInfo.bottomClip_ = renderRect.Bottom() - visibleRect.Bottom();
699
700 return LessNotEqual(renderRect.Left() + 1.0, visibleRect.Left()) ||
701 GreatNotEqual(renderRect.Right(), visibleRect.Right() + 1.0) ||
702 LessNotEqual(renderRect.Top() + 1.0, visibleRect.Top()) ||
703 GreatNotEqual(renderRect.Bottom(), visibleRect.Bottom() + 1.0);
704 }
705
GetWindowSceneWindowId(RefPtr<FrameNode> & node,uint32_t & windId)706 bool SecurityComponentHandler::GetWindowSceneWindowId(RefPtr<FrameNode>& node, uint32_t& windId)
707 {
708 CHECK_NULL_RETURN(node, false);
709 auto parent = node->GetParent();
710 while (parent != nullptr && parent->GetTag() != V2::WINDOW_SCENE_ETS_TAG) {
711 parent = parent->GetParent();
712 }
713 CHECK_NULL_RETURN(parent, false);
714 auto windowSceneFrameNode = AceType::DynamicCast<FrameNode>(parent);
715 CHECK_NULL_RETURN(windowSceneFrameNode, false);
716 auto windowScene = windowSceneFrameNode->GetPattern<SystemWindowScene>();
717 CHECK_NULL_RETURN(windowScene, false);
718 auto session = windowScene->GetSession();
719 CHECK_NULL_RETURN(session, false);
720
721 windId = static_cast<uint32_t>(session->GetPersistentId());
722 return true;
723 }
724
GetPaddingInfo(OHOS::Security::SecurityComponent::SecCompBase & buttonInfo,RefPtr<FrameNode> & node)725 bool SecurityComponentHandler::GetPaddingInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo,
726 RefPtr<FrameNode>& node)
727 {
728 CHECK_NULL_RETURN(node, false);
729 auto layoutProperty = AceType::DynamicCast<SecurityComponentLayoutProperty>(node->GetLayoutProperty());
730 CHECK_NULL_RETURN(layoutProperty, false);
731 auto pipeline = node->GetContextRefPtr();
732 CHECK_NULL_RETURN(pipeline, false);
733 auto theme = pipeline->GetTheme<SecurityComponentTheme>();
734 CHECK_NULL_RETURN(theme, false);
735 buttonInfo.padding_.top =
736 layoutProperty->GetBackgroundTopPadding().value_or(theme->GetBackgroundTopPadding()).ConvertToVp();
737 buttonInfo.padding_.right =
738 layoutProperty->GetBackgroundRightPadding().value_or(theme->GetBackgroundRightPadding()).ConvertToVp();
739 buttonInfo.padding_.bottom =
740 layoutProperty->GetBackgroundBottomPadding().value_or(theme->GetBackgroundBottomPadding()).ConvertToVp();
741 buttonInfo.padding_.left =
742 layoutProperty->GetBackgroundLeftPadding().value_or(theme->GetBackgroundLeftPadding()).ConvertToVp();
743 buttonInfo.textIconSpace_ =
744 layoutProperty->GetTextIconSpace().value_or(theme->GetTextIconSpace()).ConvertToVp();
745 return true;
746 }
747
InitBaseInfo(OHOS::Security::SecurityComponent::SecCompBase & buttonInfo,RefPtr<FrameNode> & node)748 bool SecurityComponentHandler::InitBaseInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo,
749 RefPtr<FrameNode>& node)
750 {
751 CHECK_NULL_RETURN(node, false);
752 buttonInfo.nodeId_ = node->GetId();
753 if (!GetPaddingInfo(buttonInfo, node)) {
754 SC_LOG_WARN("InitBaseInfoWarning: Get padding info failed");
755 return false;
756 }
757
758 if (!GetDisplayOffset(node, buttonInfo.rect_.x_, buttonInfo.rect_.y_)) {
759 SC_LOG_WARN("InitBaseInfoWarning: Get display offset failed");
760 return false;
761 }
762
763 if (!GetWindowRect(node, buttonInfo.windowRect_)) {
764 SC_LOG_WARN("InitBaseInfoWarning: Get window rect failed");
765 return false;
766 }
767 auto render = node->GetRenderContext();
768 CHECK_NULL_RETURN(render, false);
769 auto rect = render->GetPaintRectWithTransform();
770 buttonInfo.rect_.width_ = rect.Width();
771 buttonInfo.rect_.height_ = rect.Height();
772 auto container = AceType::DynamicCast<Platform::AceContainer>(Container::Current());
773 CHECK_NULL_RETURN(container, false);
774 uint32_t windId = container->GetWindowId();
775 auto pipeline = node->GetContextRefPtr();
776 CHECK_NULL_RETURN(pipeline, false);
777 if (pipeline->IsFocusWindowIdSetted()) {
778 windId = pipeline->GetFocusWindowId();
779 }
780 if (container->IsScenceBoardWindow()) {
781 GetWindowSceneWindowId(node, windId);
782 }
783 buttonInfo.windowId_ = static_cast<int32_t>(windId);
784 buttonInfo.crossAxisState_ = CrossAxisState::STATE_INVALID;
785 auto instanceId = pipeline->GetInstanceId();
786 auto window = Platform::AceContainer::GetUIWindow(instanceId);
787 if (window) {
788 buttonInfo.crossAxisState_ = static_cast<CrossAxisState>(window->GetCrossAxisState());
789 }
790 uint64_t displayId = container->GetDisplayId();
791 if (displayId == Rosen::DISPLAY_ID_INVALID) {
792 SC_LOG_WARN("InitBaseInfoWarning: Get displayId failed, using default displayId");
793 displayId = 0;
794 }
795 buttonInfo.displayId_ = displayId;
796 return true;
797 }
798
InitSCIconInfo(OHOS::Security::SecurityComponent::SecCompBase & buttonInfo,RefPtr<FrameNode> & iconNode)799 bool InitSCIconInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo,
800 RefPtr<FrameNode>& iconNode)
801 {
802 if (iconNode != nullptr) {
803 CHECK_NULL_RETURN(iconNode->GetGeometryNode(), false);
804 auto iconProp = iconNode->GetLayoutProperty<ImageLayoutProperty>();
805 CHECK_NULL_RETURN(iconProp, false);
806 CHECK_NULL_RETURN(iconProp->GetCalcLayoutConstraint(), false);
807 auto width = iconProp->GetCalcLayoutConstraint()->selfIdealSize->Width();
808 CHECK_EQUAL_RETURN(width.has_value(), false, false);
809 buttonInfo.iconSize_ = width->GetDimension().ConvertToVp();
810 auto fillColor = iconProp->GetImageSourceInfo()->GetFillColor();
811 CHECK_EQUAL_RETURN(fillColor.has_value(), false, false);
812 buttonInfo.iconColor_.value = fillColor->GetValue();
813 }
814 return true;
815 }
816
InitSCTextInfo(OHOS::Security::SecurityComponent::SecCompBase & buttonInfo,RefPtr<FrameNode> & textNode)817 bool InitSCTextInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo,
818 RefPtr<FrameNode>& textNode)
819 {
820 if (textNode != nullptr) {
821 auto textProp = textNode->GetLayoutProperty<TextLayoutProperty>();
822 CHECK_NULL_RETURN(textProp, false);
823 auto pipeline = textNode->GetContextRefPtr();
824 CHECK_NULL_RETURN(pipeline, false);
825 auto theme = pipeline->GetTheme<SecurityComponentTheme>();
826 CHECK_NULL_RETURN(theme, false);
827 if (textProp->GetFontSize().has_value()) {
828 buttonInfo.fontSize_ = textProp->GetFontSize()->Value();
829 } else {
830 buttonInfo.fontSize_ = theme->GetFontSize().Value();
831 }
832 if (textProp->GetTextColor().has_value()) {
833 buttonInfo.fontColor_.value = textProp->GetTextColor().value().GetValue();
834 }
835 }
836 return true;
837 }
838
InitSCButtonInfo(OHOS::Security::SecurityComponent::SecCompBase & buttonInfo,RefPtr<FrameNode> & buttonNode)839 bool InitSCButtonInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo,
840 RefPtr<FrameNode>& buttonNode)
841 {
842 if (buttonNode != nullptr) {
843 const auto& renderContext = buttonNode->GetRenderContext();
844 CHECK_NULL_RETURN(renderContext, false);
845 if (renderContext->GetBackgroundColor().has_value()) {
846 buttonInfo.bgColor_.value = renderContext->GetBackgroundColor().value().GetValue();
847 }
848
849 auto bgProp = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
850 CHECK_NULL_RETURN(bgProp, false);
851 const auto& borderWidth = bgProp->GetBorderWidthProperty();
852 if (borderWidth != nullptr) {
853 if (borderWidth->leftDimen.has_value()) {
854 buttonInfo.borderWidth_ = borderWidth->leftDimen.value().ConvertToVp();
855 }
856 }
857 }
858 return true;
859 }
860
InitChildInfo(OHOS::Security::SecurityComponent::SecCompBase & buttonInfo,RefPtr<FrameNode> & node)861 bool SecurityComponentHandler::InitChildInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo,
862 RefPtr<FrameNode>& node)
863 {
864 RefPtr<FrameNode> iconNode = GetSecCompChildNode(node, V2::IMAGE_ETS_TAG);
865 if (!InitSCIconInfo(buttonInfo, iconNode)) {
866 return false;
867 }
868
869 RefPtr<FrameNode> symbolIconNode = GetSecCompChildNode(node, V2::SYMBOL_ETS_TAG);
870 if (symbolIconNode != nullptr) {
871 CHECK_NULL_RETURN(symbolIconNode->GetGeometryNode(), false);
872 auto iconProp = symbolIconNode->GetLayoutProperty<TextLayoutProperty>();
873 CHECK_NULL_RETURN(iconProp, false);
874 }
875
876 RefPtr<FrameNode> textNode = GetSecCompChildNode(node, V2::TEXT_ETS_TAG);
877 if (!InitSCTextInfo(buttonInfo, textNode)) {
878 return false;
879 }
880
881 RefPtr<FrameNode> buttonNode = GetSecCompChildNode(node, V2::BUTTON_ETS_TAG);
882 if (!InitSCButtonInfo(buttonInfo, buttonNode)) {
883 return false;
884 }
885
886 if (!InitBaseInfo(buttonInfo, node)) {
887 return false;
888 }
889 return true;
890 }
891
WriteButtonInfo(const RefPtr<OHOS::Ace::NG::SecurityComponentLayoutProperty> & layoutProperty,RefPtr<FrameNode> & node,OHOS::Security::SecurityComponent::SecCompBase & buttonInfo,std::string & message)892 void SecurityComponentHandler::WriteButtonInfo(
893 const RefPtr<OHOS::Ace::NG::SecurityComponentLayoutProperty>& layoutProperty,
894 RefPtr<FrameNode>& node, OHOS::Security::SecurityComponent::SecCompBase& buttonInfo,
895 std::string& message)
896 {
897 buttonInfo.parentEffect_ = CheckParentNodesEffect(node, buttonInfo, message);
898 buttonInfo.text_ = layoutProperty->GetSecurityComponentDescription().value();
899 buttonInfo.icon_ = layoutProperty->GetIconStyle().value();
900 buttonInfo.bg_ = static_cast<SecCompBackground>(
901 layoutProperty->GetBackgroundType().value());
902
903 RectF rect = node->GetTransformRectRelativeToWindow();
904 auto maxRadius = std::min(rect.Width(), rect.Height()) / HALF;
905 if (layoutProperty->GetBackgroundType() == static_cast<int32_t>(ButtonType::CIRCLE) ||
906 layoutProperty->GetBackgroundType() == static_cast<int32_t>(ButtonType::CAPSULE)) {
907 buttonInfo.borderRadius_.leftBottom = maxRadius;
908 buttonInfo.borderRadius_.leftTop = maxRadius;
909 buttonInfo.borderRadius_.rightBottom = maxRadius;
910 buttonInfo.borderRadius_.rightTop = maxRadius;
911 } else {
912 RefPtr<FrameNode> buttonNode = GetSecCompChildNode(node, V2::BUTTON_ETS_TAG);
913 CHECK_NULL_VOID(buttonNode);
914 auto bgProp = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
915 CHECK_NULL_VOID(bgProp);
916 const auto& borderRadius = bgProp->GetBorderRadius();
917 if (borderRadius.has_value()) {
918 buttonInfo.borderRadius_.leftBottom = borderRadius->radiusBottomLeft.value_or(Dimension(0.0)).ConvertToPx();
919 buttonInfo.borderRadius_.leftTop = borderRadius->radiusTopLeft.value_or(Dimension(0.0)).ConvertToPx();
920 buttonInfo.borderRadius_.rightBottom =
921 borderRadius->radiusBottomRight.value_or(Dimension(0.0)).ConvertToPx();
922 buttonInfo.borderRadius_.rightTop = borderRadius->radiusTopRight.value_or(Dimension(0.0)).ConvertToPx();
923 }
924 }
925
926 if (SystemProperties::GetDeviceType() == DeviceType::WEARABLE) {
927 buttonInfo.isWearableDevice_ = true;
928 }
929 }
930
InitButtonInfo(std::string & componentInfo,RefPtr<FrameNode> & node,SecCompType & scType,std::string & message)931 bool SecurityComponentHandler::InitButtonInfo(std::string& componentInfo, RefPtr<FrameNode>& node, SecCompType& scType,
932 std::string& message)
933 {
934 CHECK_NULL_RETURN(node, false);
935 auto layoutProperty = AceType::DynamicCast<SecurityComponentLayoutProperty>(node->GetLayoutProperty());
936 CHECK_NULL_RETURN(layoutProperty, false);
937 std::string type = node->GetTag();
938 if (type == V2::LOCATION_BUTTON_ETS_TAG) {
939 LocationButton buttonInfo;
940 WriteButtonInfo(layoutProperty, node, buttonInfo, message);
941 buttonInfo.type_ = SecCompType::LOCATION_COMPONENT;
942 scType = SecCompType::LOCATION_COMPONENT;
943 if (!InitChildInfo(buttonInfo, node)) {
944 return false;
945 }
946 componentInfo = buttonInfo.ToJsonStr();
947 } else if (type == V2::PASTE_BUTTON_ETS_TAG) {
948 PasteButton buttonInfo;
949 WriteButtonInfo(layoutProperty, node, buttonInfo, message);
950 buttonInfo.type_ = SecCompType::PASTE_COMPONENT;
951 scType = SecCompType::PASTE_COMPONENT;
952 if (!InitChildInfo(buttonInfo, node)) {
953 return false;
954 }
955 componentInfo = buttonInfo.ToJsonStr();
956 } else if (type == V2::SAVE_BUTTON_ETS_TAG) {
957 SaveButton buttonInfo;
958 WriteButtonInfo(layoutProperty, node, buttonInfo, message);
959 buttonInfo.type_ = SecCompType::SAVE_COMPONENT;
960 scType = SecCompType::SAVE_COMPONENT;
961 if (!InitChildInfo(buttonInfo, node)) {
962 return false;
963 }
964 componentInfo = buttonInfo.ToJsonStr();
965 } else {
966 return false;
967 }
968 return true;
969 }
970
UpdateClipRect(NG::RectF & clipRect,NG::RectF & paintRect)971 NG::RectF SecurityComponentHandler::UpdateClipRect(NG::RectF& clipRect, NG::RectF& paintRect)
972 {
973 if (clipRect.IsIntersectWith(paintRect)) {
974 return clipRect.IntersectRectT(paintRect);
975 }
976
977 return NG::RectF(0.0, 0.0, 0.0, 0.0);
978 }
979
UpdatePaintRect(NG::RectF & paintRect,NG::RectF & clipRect)980 NG::RectF SecurityComponentHandler::UpdatePaintRect(NG::RectF& paintRect, NG::RectF& clipRect)
981 {
982 if (NearEqual(clipRect.Width(), -1.0) && NearEqual(clipRect.Height(), -1.0)) {
983 return paintRect;
984 }
985
986 if (paintRect.IsIntersectWith(clipRect)) {
987 return paintRect.IntersectRectT(clipRect);
988 }
989
990 return NG::RectF(0.0, 0.0, 0.0, 0.0);
991 }
992
RegisterSecurityComponent(RefPtr<FrameNode> & node,int32_t & scId)993 int32_t SecurityComponentHandler::RegisterSecurityComponent(RefPtr<FrameNode>& node, int32_t& scId)
994 {
995 SecurityComponentHandler::probe.InitProbeTask();
996 std::string componentInfo;
997 SecCompType type;
998 std::string message;
999 if (!InitButtonInfo(componentInfo, node, type, message)) {
1000 return -1;
1001 }
1002 int32_t ret = SecCompKit::RegisterSecurityComponent(
1003 type, componentInfo, scId);
1004 return ret;
1005 }
1006
UpdateSecurityComponent(RefPtr<FrameNode> & node,int32_t & scId)1007 int32_t SecurityComponentHandler::UpdateSecurityComponent(RefPtr<FrameNode>& node, int32_t& scId)
1008 {
1009 std::string componentInfo;
1010 SecCompType type;
1011 std::string message;
1012 if (!InitButtonInfo(componentInfo, node, type, message)) {
1013 return -1;
1014 }
1015 int32_t ret = SecCompKit::UpdateSecurityComponent(scId, componentInfo);
1016 return ret;
1017 }
1018
UnregisterSecurityComponent(int32_t & scId)1019 int32_t SecurityComponentHandler::UnregisterSecurityComponent(int32_t& scId)
1020 {
1021 if (scId == -1) {
1022 return -1;
1023 }
1024 int32_t ret = SecCompKit::UnregisterSecurityComponent(scId);
1025 return ret;
1026 }
1027
IsContextTransparent(const RefPtr<FrameNode> & frameNode)1028 bool SecurityComponentHandler::IsContextTransparent(const RefPtr<FrameNode>& frameNode)
1029 {
1030 const RefPtr<RenderContext> renderContext = frameNode->GetRenderContext();
1031 CHECK_NULL_RETURN(renderContext, false);
1032 auto layoutProperty = frameNode->GetLayoutProperty();
1033 CHECK_NULL_RETURN(layoutProperty, false);
1034 if (renderContext->GetOpacity().has_value() && renderContext->GetOpacity().value() == 0.0) {
1035 return true;
1036 }
1037 if (static_cast<int32_t>(layoutProperty->GetVisibility().value_or(VisibleType::VISIBLE)) != 0) {
1038 return true;
1039 }
1040 return false;
1041 }
1042
CheckContainerTags(const RefPtr<FrameNode> & frameNode)1043 bool SecurityComponentHandler::CheckContainerTags(const RefPtr<FrameNode>& frameNode)
1044 {
1045 static std::set<std::string> containerComponentTags = { "Flex", "Stack", "Row", "Column", "WindowScene", "root",
1046 "Swiper", "Grid", "GridItem", "page", "stage", "FormComponent", "Tabs", "TabContent", "ColumnSplit",
1047 "FolderStack", "GridCol", "GridRow", "RelativeContainer", "RowSplit", "List", "Scroll", "WaterFlow",
1048 "SideBarContainer", "Refresh", "Navigator", "ListItemGroup", "ListItem", "Hyperlink", "FormLink", "FlowItem",
1049 "Counter", "Custom", "overlay" };
1050
1051 const RefPtr<RenderContext> renderContext = frameNode->GetRenderContext();
1052 CHECK_NULL_RETURN(renderContext, false);
1053 if (containerComponentTags.find(frameNode->GetTag()) != containerComponentTags.end() &&
1054 renderContext->GetBackgroundColor()->ColorToString().compare("#00000000") == 0) {
1055 return true;
1056 }
1057 return false;
1058 }
1059
IsInModalPage(const RefPtr<UINode> & node)1060 bool SecurityComponentHandler::IsInModalPage(const RefPtr<UINode>& node)
1061 {
1062 RefPtr<UINode> tmpNode = node;
1063 while (tmpNode) {
1064 if (tmpNode->GetTag() == V2::MODAL_PAGE_TAG) {
1065 return true;
1066 }
1067 tmpNode = tmpNode->GetParent();
1068 }
1069 return false;
1070 }
1071
CheckSecurityComponentStatus(const RefPtr<UINode> & root,NodeMaps & maps,int32_t secNodeId,NG::RectF & clipRect,std::string & message)1072 bool SecurityComponentHandler::CheckSecurityComponentStatus(const RefPtr<UINode>& root, NodeMaps& maps,
1073 int32_t secNodeId, NG::RectF& clipRect, std::string& message)
1074 {
1075 bool res = false;
1076 RectF paintRect;
1077
1078 auto frameNode = AceType::DynamicCast<NG::FrameNode>(root);
1079 if (frameNode) {
1080 paintRect = frameNode->GetTransformRectRelativeToWindow();
1081 if (IsSecurityComponent(frameNode) && (frameNode->GetId() == secNodeId)) {
1082 if (IsInModalPage(root)) {
1083 return false;
1084 }
1085 return CheckRectIntersect(paintRect, secNodeId, maps.nodeId2Rect, maps.nodeId2Zindex, message);
1086 }
1087 }
1088 auto& children = root->GetChildren();
1089 for (auto child = children.rbegin(); child != children.rend(); ++child) {
1090 auto node = AceType::DynamicCast<NG::FrameNode>(*child);
1091 if (node && (IsContextTransparent(node) || !node->IsActive())) {
1092 continue;
1093 }
1094 NG::RectF bakClipRect = clipRect;
1095 if (frameNode && frameNode->GetRenderContext() &&
1096 frameNode->GetRenderContext()->GetClipEdge().has_value() && frameNode->GetRenderContext()->GetClipEdge()) {
1097 if (NearEqual(clipRect.Width(), -1.0) && NearEqual(clipRect.Height(), -1.0)) {
1098 clipRect = paintRect;
1099 } else {
1100 clipRect = UpdateClipRect(clipRect, paintRect);
1101 }
1102 }
1103 res |= CheckSecurityComponentStatus(*child, maps, secNodeId, clipRect, message);
1104 clipRect = bakClipRect;
1105 }
1106
1107 if (frameNode && frameNode->GetTag() != V2::SHEET_WRAPPER_TAG && !CheckContainerTags(frameNode)) {
1108 paintRect = UpdatePaintRect(paintRect, clipRect);
1109 maps.nodeId2Rect[frameNode->GetId()] = std::make_pair(frameNode->GetTag(), paintRect);
1110 }
1111 return res;
1112 }
1113
CheckRectIntersect(const RectF & dest,int32_t secNodeId,const std::unordered_map<int32_t,std::pair<std::string,NG::RectF>> & nodeId2Rect,std::unordered_map<int32_t,int32_t> & nodeId2Zindex,std::string & message)1114 bool SecurityComponentHandler::CheckRectIntersect(const RectF& dest, int32_t secNodeId,
1115 const std::unordered_map<int32_t, std::pair<std::string, NG::RectF>>& nodeId2Rect,
1116 std::unordered_map<int32_t, int32_t>& nodeId2Zindex, std::string& message)
1117 {
1118 for (const auto& originRect : nodeId2Rect) {
1119 if (originRect.second.second.IsInnerIntersectWithRound(dest) &&
1120 (nodeId2Zindex[secNodeId] <= nodeId2Zindex[originRect.first]) &&
1121 (!NearEqual(originRect.second.second.Width(), 0.0) && !NearEqual(originRect.second.second.Height(), 0.0))) {
1122 SC_LOG_ERROR("SecurityComponentCheckFail: Security component id = %{public}d " \
1123 "is covered by id = %{public}d.", secNodeId, originRect.first);
1124 message = ", security component is covered by component " + originRect.second.first +
1125 "(id = " + std::to_string(originRect.first) +
1126 "), the size of security component is (x = " +
1127 std::to_string(dest.GetX()) +
1128 ", y = " + std::to_string(dest.GetY()) +
1129 ", width = " + std::to_string(dest.Width()) +
1130 ", height = " + std::to_string(dest.Height()) +
1131 "), the size of the component of covering security component "
1132 "is (x = " + std::to_string(originRect.second.second.GetX()) +
1133 ", y = " + std::to_string(originRect.second.second.GetY()) +
1134 ", width = " + std::to_string(originRect.second.second.Width()) +
1135 ", height = " + std::to_string(originRect.second.second.Height()) + ")";
1136 return true;
1137 }
1138 }
1139 return false;
1140 }
1141
IsSecurityComponent(RefPtr<FrameNode> & node)1142 bool SecurityComponentHandler::IsSecurityComponent(RefPtr<FrameNode>& node)
1143 {
1144 return node->GetTag() == V2::LOCATION_BUTTON_ETS_TAG || node->GetTag() == V2::PASTE_BUTTON_ETS_TAG ||
1145 node->GetTag() == V2::SAVE_BUTTON_ETS_TAG;
1146 }
1147
GetNodeZIndex(const RefPtr<UINode> & root)1148 int32_t SecurityComponentHandler::GetNodeZIndex(const RefPtr<UINode>& root)
1149 {
1150 int32_t zIndex;
1151 auto node = AceType::DynamicCast<NG::FrameNode>(root);
1152 if (node) {
1153 const RefPtr<RenderContext> renderContext = node->GetRenderContext();
1154 if (!renderContext) {
1155 zIndex = 0;
1156 } else {
1157 zIndex = renderContext->GetZIndexValue(ZINDEX_DEFAULT_VALUE);
1158 }
1159 } else {
1160 zIndex = 0;
1161 }
1162
1163 return zIndex;
1164 }
1165
UpdateAllZindex(const RefPtr<UINode> & root,std::unordered_map<int32_t,int32_t> & nodeId2Zindex)1166 void SecurityComponentHandler::UpdateAllZindex(const RefPtr<UINode>& root,
1167 std::unordered_map<int32_t, int32_t>& nodeId2Zindex)
1168 {
1169 if (nodeId2Zindex.count(root->GetId()) == 0) {
1170 nodeId2Zindex[root->GetId()] = GetNodeZIndex(root);
1171 }
1172 auto& children = root->GetChildren();
1173 for (auto child = children.begin(); child != children.end(); ++child) {
1174 int32_t nodeZIndex = GetNodeZIndex(*child);
1175 nodeId2Zindex[(*child)->GetId()] = std::max(nodeZIndex, nodeId2Zindex[root->GetId()]);
1176 UpdateAllZindex(*child, nodeId2Zindex);
1177 }
1178 }
1179
CheckComponentCoveredStatus(int32_t secNodeId,std::string & message)1180 bool SecurityComponentHandler::CheckComponentCoveredStatus(int32_t secNodeId, std::string& message)
1181 {
1182 auto pipeline = PipelineContext::GetCurrentContextSafely();
1183 CHECK_NULL_RETURN(pipeline, false);
1184 RefPtr<UINode> root = pipeline->GetRootElement();
1185 CHECK_NULL_RETURN(root, false);
1186 NodeMaps maps;
1187 UpdateAllZindex(root, maps.nodeId2Zindex);
1188 NG::RectF clipRect = NG::RectF(-1.0, -1.0, -1.0, -1.0);
1189 if (CheckSecurityComponentStatus(root, maps, secNodeId, clipRect, message)) {
1190 return true;
1191 }
1192 return false;
1193 }
1194
ReportSecurityComponentClickEventInner(int32_t & scId,RefPtr<FrameNode> & node,SecCompClickEvent & event,Security::SecurityComponent::OnFirstUseDialogCloseFunc && callback,std::string & message)1195 int32_t SecurityComponentHandler::ReportSecurityComponentClickEventInner(int32_t& scId,
1196 RefPtr<FrameNode>& node, SecCompClickEvent& event,
1197 Security::SecurityComponent::OnFirstUseDialogCloseFunc&& callback, std::string& message)
1198 {
1199 std::string componentInfo;
1200 SecCompType type;
1201 std::string invalidEffectMsg;
1202 auto ret = InitButtonInfo(componentInfo, node, type, message);
1203 if (!message.empty()) {
1204 invalidEffectMsg = message;
1205 }
1206 if (!ret) {
1207 return -1;
1208 }
1209 auto container = AceType::DynamicCast<Platform::AceContainer>(Container::Current());
1210 CHECK_NULL_RETURN(container, -1);
1211 sptr<IRemoteObject> token = container->GetToken();
1212 if (container->GetParentToken() != nullptr) {
1213 token = container->GetParentToken();
1214 }
1215 SecCompInfo secCompInfo{ scId, componentInfo, event };
1216 int32_t res = SecCompKit::ReportSecurityComponentClickEvent(
1217 secCompInfo, token, std::move(callback), message);
1218 if (!message.empty() && message != "PARENT_HAVE_INVALID_EFFECT") {
1219 message = SEC_COMP_ID + std::to_string(node->GetId()) + SEC_COMP_TYPE + node->GetTag() + message;
1220 }
1221
1222 if (res == SC_SERVICE_ERROR_COMPONENT_INFO_INVALID && !message.empty() &&
1223 message == "PARENT_HAVE_INVALID_EFFECT") {
1224 message = invalidEffectMsg;
1225 }
1226 return res;
1227 }
1228
CheckSecurityComponentTextLimits(const RefPtr<FrameNode> & node,std::string & message)1229 bool SecurityComponentHandler::CheckSecurityComponentTextLimits(const RefPtr<FrameNode>& node, std::string& message)
1230 {
1231 auto layoutProperty = AceType::DynamicCast<SecurityComponentLayoutProperty>(node->GetLayoutProperty());
1232 if (layoutProperty && layoutProperty->GetIsMaxLineLimitExceeded().has_value() &&
1233 layoutProperty->GetIsMaxLineLimitExceeded().value()) {
1234 SC_LOG_ERROR("SecurityComponentCheckFail: The text of the security component is cliped by lines.");
1235 message = SEC_COMP_ID + std::to_string(node->GetId()) + SEC_COMP_TYPE +
1236 node->GetTag() + ", the text of the security component is cliped by lines";
1237 return true;
1238 }
1239 if (layoutProperty && layoutProperty->GetIsTextLimitExceeded().has_value() &&
1240 layoutProperty->GetIsTextLimitExceeded().value()) {
1241 SC_LOG_ERROR("SecurityComponentCheckFail: The text of the security component is out of range.");
1242 message = SEC_COMP_ID + std::to_string(node->GetId()) + SEC_COMP_TYPE +
1243 node->GetTag() + ", the text of the security component is out of range";
1244 return true;
1245 }
1246 return false;
1247 }
1248
ReportSecurityComponentClickEvent(int32_t & scId,RefPtr<FrameNode> & node,GestureEvent & event,Security::SecurityComponent::OnFirstUseDialogCloseFunc && callback,std::string & message)1249 int32_t SecurityComponentHandler::ReportSecurityComponentClickEvent(int32_t& scId,
1250 RefPtr<FrameNode>& node, GestureEvent& event,
1251 Security::SecurityComponent::OnFirstUseDialogCloseFunc&& callback,
1252 std::string& message)
1253 {
1254 SecCompClickEvent secEvent;
1255 secEvent.type = ClickEventType::POINT_EVENT_TYPE;
1256 #ifdef SECURITY_COMPONENT_ENABLE
1257 secEvent.point.touchX = event.GetDisplayX();
1258 secEvent.point.touchY = event.GetDisplayY();
1259 auto pointerEvent = event.GetPointerEvent();
1260 uint8_t defaultData = 0;
1261 std::vector<uint8_t> dataBuffer;
1262 if (pointerEvent == nullptr) {
1263 SC_LOG_WARN("SecurityComponentClickEventWarning: Receive a NULL pointerEvent, set default data.");
1264 secEvent.extraInfo.data = &defaultData;
1265 secEvent.extraInfo.dataSize = 1;
1266 secEvent.point.timestamp = 0;
1267 } else {
1268 dataBuffer = pointerEvent->GetEnhanceData();
1269 if (dataBuffer.size() > 0) {
1270 secEvent.extraInfo.data = dataBuffer.data();
1271 secEvent.extraInfo.dataSize = dataBuffer.size();
1272 }
1273 std::chrono::microseconds microseconds(pointerEvent->GetActionTime());
1274 TimeStamp time(microseconds);
1275 secEvent.point.timestamp =
1276 static_cast<uint64_t>(time.time_since_epoch().count()) / SECOND_TO_MILLISECOND;
1277 }
1278 #endif
1279 if (CheckSecurityComponentTextLimits(node, message)) {
1280 return -1;
1281 }
1282 if (CheckComponentCoveredStatus(node->GetId(), message)) {
1283 SC_LOG_ERROR("SecurityComponentCheckFail: Security component is covered by another component.");
1284 message = SEC_COMP_ID + std::to_string(node->GetId()) + SEC_COMP_TYPE + node->GetTag() + message;
1285 return -1;
1286 }
1287
1288 return ReportSecurityComponentClickEventInner(scId, node, secEvent, std::move(callback), message);
1289 }
1290
ReportSecurityComponentClickEvent(int32_t & scId,RefPtr<FrameNode> & node,const KeyEvent & event,Security::SecurityComponent::OnFirstUseDialogCloseFunc && callback)1291 int32_t SecurityComponentHandler::ReportSecurityComponentClickEvent(int32_t& scId,
1292 RefPtr<FrameNode>& node, const KeyEvent& event,
1293 Security::SecurityComponent::OnFirstUseDialogCloseFunc&& callback)
1294 {
1295 SecCompClickEvent secEvent;
1296 secEvent.type = ClickEventType::KEY_EVENT_TYPE;
1297
1298 secEvent.key.timestamp =
1299 static_cast<uint64_t>(event.timeStamp.time_since_epoch().count()) / SECOND_TO_MILLISECOND;
1300 secEvent.key.keyCode = static_cast<int32_t>(event.code);
1301 auto data = event.enhanceData;
1302 if (data.size() > 0) {
1303 secEvent.extraInfo.data = data.data();
1304 secEvent.extraInfo.dataSize = data.size();
1305 }
1306 auto layoutProperty = AceType::DynamicCast<SecurityComponentLayoutProperty>(node->GetLayoutProperty());
1307 if (layoutProperty && layoutProperty->GetIsMaxLineLimitExceeded().has_value() &&
1308 layoutProperty->GetIsMaxLineLimitExceeded().value()) {
1309 SC_LOG_ERROR("SecurityComponentCheckFail: The text of the security component is cliped by lines.");
1310 return -1;
1311 }
1312 if (layoutProperty && layoutProperty->GetIsTextLimitExceeded().has_value() &&
1313 layoutProperty->GetIsTextLimitExceeded().value()) {
1314 SC_LOG_ERROR("SecurityComponentCheckFail: The text of the security component is out of range.");
1315 return -1;
1316 }
1317 std::string message;
1318 if (CheckComponentCoveredStatus(node->GetId(), message)) {
1319 SC_LOG_ERROR("SecurityComponentCheckFail: Security component is covered by another component.");
1320 return -1;
1321 }
1322 return ReportSecurityComponentClickEventInner(scId, node, secEvent, std::move(callback), message);
1323 }
1324
IsSecurityComponentServiceExist()1325 bool SecurityComponentHandler::IsSecurityComponentServiceExist()
1326 {
1327 return SecCompKit::IsServiceExist();
1328 }
1329
LoadSecurityComponentService()1330 bool SecurityComponentHandler::LoadSecurityComponentService()
1331 {
1332 return SecCompKit::LoadService();
1333 }
1334
IsSystemAppCalling()1335 bool SecurityComponentHandler::IsSystemAppCalling()
1336 {
1337 return SecCompKit::IsSystemAppCalling();
1338 }
1339 } // namespace OHOS::Ace::NG
1340