• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 "accessibility_param_parse.h"
17 
18 namespace OHOS::Rosen {
19 
ParseFeatureParam(FeatureParamMapType & featureMap,xmlNode & node)20 int32_t AccessibilityParamParse::ParseFeatureParam(FeatureParamMapType &featureMap, xmlNode &node)
21 {
22     RS_LOGI("AccessibilityParamParse start");
23     xmlNode *currNode = &node;
24     if (currNode->xmlChildrenNode == nullptr) {
25         RS_LOGD("AccessibilityParamParse stop parsing, no children nodes");
26         return PARSE_GET_CHILD_FAIL;
27     }
28 
29     currNode = currNode->xmlChildrenNode;
30     for (; currNode; currNode = currNode->next) {
31         if (currNode->type != XML_ELEMENT_NODE) {
32             continue;
33         }
34 
35         if (ParseAccessibilityInternal(featureMap, *currNode) != PARSE_EXEC_SUCCESS) {
36             RS_LOGD("AccessibilityParamParse stop parsing, parse internal fail");
37             return PARSE_INTERNAL_FAIL;
38         }
39     }
40     return PARSE_EXEC_SUCCESS;
41 }
42 
ParseAccessibilityInternal(FeatureParamMapType & featureMap,xmlNode & node)43 int32_t AccessibilityParamParse::ParseAccessibilityInternal(FeatureParamMapType &featureMap, xmlNode &node)
44 {
45     xmlNode *currNode = &node;
46 
47     // Start Parse Feature Params
48     int xmlParamType = GetXmlNodeAsInt(*currNode);
49     auto name = ExtractPropertyValue("name", *currNode);
50     auto val = ExtractPropertyValue("value", *currNode);
51     if (xmlParamType == PARSE_XML_FEATURE_SWITCH) {
52         bool isEnabled = ParseFeatureSwitch(val);
53         if (name == "HighContrastEnabled") {
54             AccessibilityParam::SetHighContrastEnabled(isEnabled);
55             RS_LOGI("AccessibilityParamParse parse HighContrastEnabled %{public}d",
56                     AccessibilityParam::IsHighContrastEnabled());
57         } else if (name == "CurtainScreenEnabled") {
58             AccessibilityParam::SetCurtainScreenEnabled(isEnabled);
59             RS_LOGI("AccessibilityParamParse parse CurtainScreenEnabled %{public}d",
60                     AccessibilityParam::IsCurtainScreenEnabled());
61         } else if (name == "ColorReverseEnabled") {
62             AccessibilityParam::SetColorReverseEnabled(isEnabled);
63             RS_LOGI("AccessibilityParamParse parse ColorReverseEnabled %{public}d",
64                     AccessibilityParam::IsColorReverseEnabled());
65         } else if (name == "ColorCorrectionEnabled") {
66             AccessibilityParam::SetColorCorrectionEnabled(isEnabled);
67             RS_LOGI("AccessibilityParamParse parse ColorCorrectionEnabled %{public}d",
68                     AccessibilityParam::IsColorCorrectionEnabled());
69         } else {
70             RS_LOGI("AccessibilityParamParse parse %{public}s is not support!", name.c_str());
71         }
72     }
73 
74     return PARSE_EXEC_SUCCESS;
75 }
76 
77 } // namespace OHOS::Rosen