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 #include "sec_comp_base.h"
16
17 #include "sec_comp_err.h"
18 #include "sec_comp_log.h"
19
20 namespace OHOS {
21 namespace Security {
22 namespace SecurityComponent {
23 namespace {
24 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompBase"};
25 }
26
27 const std::string JsonTagConstants::JSON_RECT = "rect";
28 const std::string JsonTagConstants::JSON_SC_TYPE = "type";
29 const std::string JsonTagConstants::JSON_NODE_ID = "nodeId";
30 const std::string JsonTagConstants::JSON_RECT_X = "x";
31 const std::string JsonTagConstants::JSON_RECT_Y = "y";
32 const std::string JsonTagConstants::JSON_RECT_WIDTH = "width";
33 const std::string JsonTagConstants::JSON_RECT_HEIGHT = "height";
34 const std::string JsonTagConstants::JSON_WINDOW_RECT = "windowRect";
35 const std::string JsonTagConstants::JSON_SIZE_TAG = "size";
36 const std::string JsonTagConstants::JSON_FONT_SIZE_TAG = "fontSize";
37 const std::string JsonTagConstants::JSON_ICON_SIZE_TAG = "iconSize";
38 const std::string JsonTagConstants::JSON_PADDING_SIZE_TAG = "paddingSize";
39 const std::string JsonTagConstants::JSON_PADDING_LEFT_TAG = "left";
40 const std::string JsonTagConstants::JSON_PADDING_TOP_TAG = "top";
41 const std::string JsonTagConstants::JSON_PADDING_RIGHT_TAG = "right";
42 const std::string JsonTagConstants::JSON_PADDING_BOTTOM_TAG = "bottom";
43 const std::string JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG = "textIconSpace";
44 const std::string JsonTagConstants::JSON_RECT_WIDTH_TAG = "width";
45 const std::string JsonTagConstants::JSON_RECT_HEIGHT_TAG = "height";
46 const std::string JsonTagConstants::JSON_COLORS_TAG = "colors";
47 const std::string JsonTagConstants::JSON_FONT_COLOR_TAG = "fontColor";
48 const std::string JsonTagConstants::JSON_ICON_COLOR_TAG = "iconColor";
49 const std::string JsonTagConstants::JSON_BG_COLOR_TAG = "bgColor";
50 const std::string JsonTagConstants::JSON_BORDER_TAG = "border";
51 const std::string JsonTagConstants::JSON_BORDER_WIDTH_TAG = "borderWidth";
52 const std::string JsonTagConstants::JSON_PARENT_TAG = "parent";
53 const std::string JsonTagConstants::JSON_PARENT_EFFECT_TAG = "parentEffect";
54 const std::string JsonTagConstants::JSON_IS_CLIPPED_TAG = "isClipped";
55 const std::string JsonTagConstants::JSON_TOP_CLIP_TAG = "topClip";
56 const std::string JsonTagConstants::JSON_BOTTOM_CLIP_TAG = "bottomClip";
57 const std::string JsonTagConstants::JSON_LEFT_CLIP_TAG = "leftClip";
58 const std::string JsonTagConstants::JSON_RIGHT_CLIP_TAG = "rightClip";
59 const std::string JsonTagConstants::JSON_PARENT_TAG_TAG = "parentTag";
60 const std::string JsonTagConstants::JSON_STYLE_TAG = "style";
61 const std::string JsonTagConstants::JSON_TEXT_TAG = "text";
62 const std::string JsonTagConstants::JSON_ICON_TAG = "icon";
63 const std::string JsonTagConstants::JSON_BG_TAG = "bg";
64 const std::string JsonTagConstants::JSON_WINDOW_ID = "windowId";
65 const std::string JsonTagConstants::JSON_DISPLAY_ID = "displayId";
66 const std::string JsonTagConstants::JSON_CROSS_AXIS_STATE = "crossAxisState";
67
ParseDimension(const nlohmann::json & json,const std::string & tag,DimensionT & res)68 bool SecCompBase::ParseDimension(const nlohmann::json& json, const std::string& tag, DimensionT& res)
69 {
70 if ((json.find(tag) == json.end()) || !json.at(tag).is_number_float()) {
71 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
72 return false;
73 }
74
75 res = json.at(tag).get<double>();
76 return true;
77 }
78
ParseColor(const nlohmann::json & json,const std::string & tag,SecCompColor & res)79 bool SecCompBase::ParseColor(const nlohmann::json& json, const std::string& tag, SecCompColor& res)
80 {
81 if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) {
82 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
83 return false;
84 }
85
86 res.value = json.at(tag).get<uint32_t>();
87 return true;
88 }
89
ParseBool(const nlohmann::json & json,const std::string & tag,bool & res)90 bool SecCompBase::ParseBool(const nlohmann::json& json, const std::string& tag, bool& res)
91 {
92 if ((json.find(tag) == json.end()) || !json.at(tag).is_boolean()) {
93 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
94 return false;
95 }
96
97 res = json.at(tag).get<bool>();
98 return true;
99 }
100
ParseString(const nlohmann::json & json,const std::string & tag,std::string & res)101 bool SecCompBase::ParseString(const nlohmann::json& json, const std::string& tag, std::string& res)
102 {
103 if ((json.find(tag) == json.end()) || !json.at(tag).is_string()) {
104 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
105 return false;
106 }
107
108 res = json.at(tag).get<std::string>();
109 return true;
110 }
111
ParsePadding(const nlohmann::json & json,const std::string & tag,PaddingSize & res)112 bool SecCompBase::ParsePadding(const nlohmann::json& json, const std::string& tag, PaddingSize& res)
113 {
114 if ((json.find(tag) == json.end()) || !json.at(tag).is_object()) {
115 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
116 return false;
117 }
118
119 auto jsonPadding = json.at(tag);
120 if (!ParseDimension(jsonPadding, JsonTagConstants::JSON_PADDING_TOP_TAG, res.top)) {
121 return false;
122 }
123 if (!ParseDimension(jsonPadding, JsonTagConstants::JSON_PADDING_RIGHT_TAG, res.right)) {
124 return false;
125 }
126 if (!ParseDimension(jsonPadding, JsonTagConstants::JSON_PADDING_BOTTOM_TAG, res.bottom)) {
127 return false;
128 }
129 if (!ParseDimension(jsonPadding, JsonTagConstants::JSON_PADDING_LEFT_TAG, res.left)) {
130 return false;
131 }
132 return true;
133 }
134
ParseColors(const nlohmann::json & json,const std::string & tag)135 bool SecCompBase::ParseColors(const nlohmann::json& json, const std::string& tag)
136 {
137 if ((json.find(tag) == json.end()) || !json.at(tag).is_object()) {
138 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
139 return false;
140 }
141 auto jsonColors = json.at(tag);
142 if (!ParseColor(jsonColors, JsonTagConstants::JSON_FONT_COLOR_TAG, fontColor_)) {
143 return false;
144 }
145 if (!ParseColor(jsonColors, JsonTagConstants::JSON_ICON_COLOR_TAG, iconColor_)) {
146 return false;
147 }
148 if (!ParseColor(jsonColors, JsonTagConstants::JSON_BG_COLOR_TAG, bgColor_)) {
149 return false;
150 }
151 return true;
152 }
153
ParseBorders(const nlohmann::json & json,const std::string & tag)154 bool SecCompBase::ParseBorders(const nlohmann::json& json, const std::string& tag)
155 {
156 if ((json.find(tag) == json.end()) || !json.at(tag).is_object()) {
157 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
158 return false;
159 }
160 auto jsonBorder = json.at(tag);
161 return ParseDimension(jsonBorder, JsonTagConstants::JSON_BORDER_WIDTH_TAG, borderWidth_);
162 }
163
ParseSize(const nlohmann::json & json,const std::string & tag)164 bool SecCompBase::ParseSize(const nlohmann::json& json, const std::string& tag)
165 {
166 if ((json.find(tag) == json.end()) || !json.at(tag).is_object()) {
167 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
168 return false;
169 }
170
171 auto jsonSize = json.at(tag);
172 if (!ParseDimension(jsonSize, JsonTagConstants::JSON_FONT_SIZE_TAG, fontSize_)) {
173 return false;
174 }
175
176 if (!ParseDimension(jsonSize, JsonTagConstants::JSON_ICON_SIZE_TAG, iconSize_)) {
177 return false;
178 }
179
180 if (!ParseDimension(jsonSize, JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, textIconSpace_)) {
181 return false;
182 }
183
184 if (!ParsePadding(jsonSize, JsonTagConstants::JSON_PADDING_SIZE_TAG, padding_)) {
185 return false;
186 }
187
188 return true;
189 }
190
ParseParent(const nlohmann::json & json,const std::string & tag)191 bool SecCompBase::ParseParent(const nlohmann::json& json, const std::string& tag)
192 {
193 if ((json.find(tag) == json.end()) || !json.at(tag).is_object()) {
194 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
195 return false;
196 }
197 auto jsonParent = json.at(tag);
198 if (!ParseBool(jsonParent, JsonTagConstants::JSON_PARENT_EFFECT_TAG, parentEffect_)) {
199 return false;
200 }
201 if (!ParseBool(jsonParent, JsonTagConstants::JSON_IS_CLIPPED_TAG, isClipped_)) {
202 return false;
203 }
204 if (!ParseDimension(jsonParent, JsonTagConstants::JSON_TOP_CLIP_TAG, topClip_)) {
205 return false;
206 }
207 if (!ParseDimension(jsonParent, JsonTagConstants::JSON_BOTTOM_CLIP_TAG, bottomClip_)) {
208 return false;
209 }
210 if (!ParseDimension(jsonParent, JsonTagConstants::JSON_LEFT_CLIP_TAG, leftClip_)) {
211 return false;
212 }
213 if (!ParseDimension(jsonParent, JsonTagConstants::JSON_RIGHT_CLIP_TAG, rightClip_)) {
214 return false;
215 }
216 if (!ParseString(jsonParent, JsonTagConstants::JSON_PARENT_TAG_TAG, parentTag_)) {
217 return false;
218 }
219 return true;
220 }
221
ParseRect(const nlohmann::json & json,const std::string & tag,SecCompRect & rect)222 bool SecCompBase::ParseRect(const nlohmann::json& json, const std::string& tag, SecCompRect& rect)
223 {
224 if ((json.find(tag) == json.end()) || !json.at(tag).is_object()) {
225 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
226 return false;
227 }
228
229 auto jsonSize = json.at(tag);
230 if (!ParseDimension(jsonSize, JsonTagConstants::JSON_RECT_X, rect.x_)) {
231 return false;
232 }
233
234 if (!ParseDimension(jsonSize, JsonTagConstants::JSON_RECT_Y, rect.y_)) {
235 return false;
236 }
237
238 if (!ParseDimension(jsonSize, JsonTagConstants::JSON_RECT_WIDTH, rect.width_)) {
239 return false;
240 }
241
242 if (!ParseDimension(jsonSize, JsonTagConstants::JSON_RECT_HEIGHT, rect.height_)) {
243 return false;
244 }
245
246 return true;
247 }
248
ParseType(const nlohmann::json & json,const std::string & tag)249 bool SecCompBase::ParseType(const nlohmann::json& json, const std::string& tag)
250 {
251 if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) {
252 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
253 return false;
254 }
255 int32_t value = json.at(tag).get<int32_t>();
256 if ((value <= static_cast<int32_t>(SecCompType::UNKNOWN_SC_TYPE)) ||
257 (value >= static_cast<int32_t>(SecCompType::MAX_SC_TYPE))) {
258 SC_LOG_ERROR(LABEL, "scType value is invalid.");
259 return false;
260 }
261 type_ = static_cast<SecCompType>(value);
262
263 return true;
264 }
265
ParseValue(const nlohmann::json & json,const std::string & tag,int32_t & value)266 bool SecCompBase::ParseValue(const nlohmann::json& json, const std::string& tag, int32_t& value)
267 {
268 if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) {
269 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
270 return false;
271 }
272 value = json.at(tag).get<int32_t>();
273
274 return true;
275 }
276
ParseDisplayId(const nlohmann::json & json,const std::string & tag)277 bool SecCompBase::ParseDisplayId(const nlohmann::json& json, const std::string& tag)
278 {
279 if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) {
280 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
281 return false;
282 }
283 displayId_ = json.at(tag).get<uint64_t>();
284
285 return true;
286 }
287
ParseCrossAxisState(const nlohmann::json & json,const std::string & tag)288 bool SecCompBase::ParseCrossAxisState(const nlohmann::json& json, const std::string& tag)
289 {
290 if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) {
291 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
292 return false;
293 }
294 int32_t value = json.at(tag).get<int32_t>();
295 if ((value < static_cast<int32_t>(CrossAxisState::STATE_INVALID)) ||
296 (value > static_cast<int32_t>(CrossAxisState::STATE_NO_CROSS))) {
297 SC_LOG_ERROR(LABEL, "Cross axis state: %{public}d is invalid.", value);
298 return false;
299 }
300 crossAxisState_ = static_cast<CrossAxisState>(value);
301
302 return true;
303 }
304
FromJson(const nlohmann::json & jsonSrc)305 bool SecCompBase::FromJson(const nlohmann::json& jsonSrc)
306 {
307 SC_LOG_DEBUG(LABEL, "Button info %{public}s.", jsonSrc.dump().c_str());
308 if (!ParseType(jsonSrc, JsonTagConstants::JSON_SC_TYPE)) {
309 return false;
310 }
311 if (!ParseValue(jsonSrc, JsonTagConstants::JSON_NODE_ID, nodeId_)) {
312 return false;
313 }
314 if (!ParseRect(jsonSrc, JsonTagConstants::JSON_RECT, rect_)) {
315 return false;
316 }
317 if (!ParseRect(jsonSrc, JsonTagConstants::JSON_WINDOW_RECT, windowRect_)) {
318 return false;
319 }
320 if (!ParseSize(jsonSrc, JsonTagConstants::JSON_SIZE_TAG)) {
321 return false;
322 }
323 if (!ParseColors(jsonSrc, JsonTagConstants::JSON_COLORS_TAG)) {
324 return false;
325 }
326 if (!ParseBorders(jsonSrc, JsonTagConstants::JSON_BORDER_TAG)) {
327 return false;
328 }
329 if (!ParseParent(jsonSrc, JsonTagConstants::JSON_PARENT_TAG)) {
330 return false;
331 }
332 if (!ParseStyle(jsonSrc, JsonTagConstants::JSON_STYLE_TAG)) {
333 return false;
334 }
335 if (!ParseValue(jsonSrc, JsonTagConstants::JSON_WINDOW_ID, windowId_)) {
336 return false;
337 }
338 if (!ParseDisplayId(jsonSrc, JsonTagConstants::JSON_DISPLAY_ID)) {
339 return false;
340 }
341 if (!ParseCrossAxisState(jsonSrc, JsonTagConstants::JSON_CROSS_AXIS_STATE)) {
342 return false;
343 }
344
345 return true;
346 }
347
ToJson(nlohmann::json & jsonRes) const348 void SecCompBase::ToJson(nlohmann::json& jsonRes) const
349 {
350 jsonRes[JsonTagConstants::JSON_SC_TYPE] = type_;
351 jsonRes[JsonTagConstants::JSON_NODE_ID] = nodeId_;
352 jsonRes[JsonTagConstants::JSON_RECT] = nlohmann::json {
353 {JsonTagConstants::JSON_RECT_X, rect_.x_},
354 {JsonTagConstants::JSON_RECT_Y, rect_.y_},
355 {JsonTagConstants::JSON_RECT_WIDTH, rect_.width_},
356 {JsonTagConstants::JSON_RECT_HEIGHT, rect_.height_}
357 };
358 jsonRes[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json {
359 {JsonTagConstants::JSON_RECT_X, windowRect_.x_},
360 {JsonTagConstants::JSON_RECT_Y, windowRect_.y_},
361 {JsonTagConstants::JSON_RECT_WIDTH, windowRect_.width_},
362 {JsonTagConstants::JSON_RECT_HEIGHT, windowRect_.height_}
363 };
364 nlohmann::json jsonPadding = nlohmann::json {
365 { JsonTagConstants::JSON_PADDING_TOP_TAG, padding_.top },
366 { JsonTagConstants::JSON_PADDING_RIGHT_TAG, padding_.right },
367 { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, padding_.bottom },
368 { JsonTagConstants::JSON_PADDING_LEFT_TAG, padding_.left },
369 };
370
371 jsonRes[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
372 { JsonTagConstants::JSON_FONT_SIZE_TAG, fontSize_ },
373 { JsonTagConstants::JSON_ICON_SIZE_TAG, iconSize_ },
374 { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, textIconSpace_ },
375 { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
376 };
377
378 jsonRes[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
379 { JsonTagConstants::JSON_FONT_COLOR_TAG, fontColor_.value },
380 { JsonTagConstants::JSON_ICON_COLOR_TAG, iconColor_.value },
381 { JsonTagConstants::JSON_BG_COLOR_TAG, bgColor_.value }
382 };
383
384 jsonRes[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json {
385 { JsonTagConstants::JSON_BORDER_WIDTH_TAG, borderWidth_ },
386 };
387 jsonRes[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json {
388 { JsonTagConstants::JSON_PARENT_EFFECT_TAG, parentEffect_ },
389 { JsonTagConstants::JSON_IS_CLIPPED_TAG, isClipped_ },
390 { JsonTagConstants::JSON_TOP_CLIP_TAG, topClip_ },
391 { JsonTagConstants::JSON_BOTTOM_CLIP_TAG, bottomClip_ },
392 { JsonTagConstants::JSON_LEFT_CLIP_TAG, leftClip_ },
393 { JsonTagConstants::JSON_RIGHT_CLIP_TAG, rightClip_ },
394 { JsonTagConstants::JSON_PARENT_TAG_TAG, parentTag_ },
395 };
396
397 jsonRes[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
398 { JsonTagConstants::JSON_TEXT_TAG, text_ },
399 { JsonTagConstants::JSON_ICON_TAG, icon_ },
400 { JsonTagConstants::JSON_BG_TAG, bg_ },
401 };
402 jsonRes[JsonTagConstants::JSON_WINDOW_ID] = windowId_;
403 jsonRes[JsonTagConstants::JSON_DISPLAY_ID] = displayId_;
404 jsonRes[JsonTagConstants::JSON_CROSS_AXIS_STATE] = crossAxisState_;
405 }
406
ToJsonStr() const407 std::string SecCompBase::ToJsonStr() const
408 {
409 nlohmann::json json;
410 ToJson(json);
411 return json.dump();
412 }
413
CompareComponentBasicInfo(SecCompBase * other,bool isRectCheck) const414 bool SecCompBase::CompareComponentBasicInfo(SecCompBase *other, bool isRectCheck) const
415 {
416 if (other == nullptr) {
417 SC_LOG_ERROR(LABEL, "other is nullptr.");
418 return false;
419 }
420
421 SecCompRect rect = other->rect_;
422 SecCompRect windowRect = other->windowRect_;
423 if (isRectCheck) {
424 rect = rect_;
425 windowRect = windowRect_;
426 }
427
428 auto leftValue = std::tie(type_, fontSize_, iconSize_, textIconSpace_, padding_.top, padding_.right,
429 padding_.bottom, padding_.left, fontColor_.value, bgColor_.value, iconColor_.value, borderWidth_,
430 rect, windowRect);
431 auto rightValue = std::tie(other->type_, other->fontSize_, other->iconSize_, other->textIconSpace_,
432 other->padding_.top, other->padding_.right, other->padding_.bottom, other->padding_.left,
433 other->fontColor_.value, other->bgColor_.value, other->iconColor_.value, other->borderWidth_,
434 other->rect_, other->windowRect_);
435
436 return (leftValue == rightValue);
437 }
438
ParseStyle(const nlohmann::json & json,const std::string & tag)439 bool SecCompBase::ParseStyle(const nlohmann::json& json, const std::string& tag)
440 {
441 if ((json.find(tag) == json.end()) || !json.at(tag).is_object()) {
442 SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str());
443 return false;
444 }
445 auto jsonStyle = json.at(tag);
446 if (jsonStyle.find(JsonTagConstants::JSON_TEXT_TAG) == jsonStyle.end() ||
447 !jsonStyle.at(JsonTagConstants::JSON_TEXT_TAG).is_number()) {
448 SC_LOG_ERROR(LABEL, "Json=%{public}s tag is invalid.", tag.c_str());
449 return false;
450 }
451 if (jsonStyle.find(JsonTagConstants::JSON_ICON_TAG) == jsonStyle.end() ||
452 !jsonStyle.at(JsonTagConstants::JSON_ICON_TAG).is_number()) {
453 SC_LOG_ERROR(LABEL, "Json=%{public}s tag is invalid.", tag.c_str());
454 return false;
455 }
456 if (jsonStyle.find(JsonTagConstants::JSON_BG_TAG) == jsonStyle.end() ||
457 !jsonStyle.at(JsonTagConstants::JSON_BG_TAG).is_number()) {
458 SC_LOG_ERROR(LABEL, "Json=%{public}s tag is invalid.", tag.c_str());
459 return false;
460 }
461 text_ = jsonStyle.at(JsonTagConstants::JSON_TEXT_TAG).get<int32_t>();
462 icon_ = jsonStyle.at(JsonTagConstants::JSON_ICON_TAG).get<int32_t>();
463 if (!IsTextIconTypeValid()) {
464 SC_LOG_ERROR(LABEL, "text or icon is invalid.");
465 return false;
466 }
467 bg_ = static_cast<SecCompBackground>(jsonStyle.at(JsonTagConstants::JSON_BG_TAG).get<int32_t>());
468 if ((bg_ <= SecCompBackground::UNKNOWN_BG) || (bg_ >= SecCompBackground::MAX_BG_TYPE)) {
469 SC_LOG_ERROR(LABEL, "bg is invalid.");
470 return false;
471 }
472 return true;
473 }
474 } // namespace base
475 } // namespace Security
476 } // namespace OHOS
477