• 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 "socperf_param_parse.h"
17 
18 namespace OHOS::Rosen {
19 
ParseFeatureParam(FeatureParamMapType & featureMap,xmlNode & node)20 int32_t SOCPerfParamParse::ParseFeatureParam(FeatureParamMapType &featureMap, xmlNode &node)
21 {
22     RS_LOGI("SOCPerfParamParse start");
23     xmlNode *currNode = &node;
24     if (currNode->xmlChildrenNode == nullptr) {
25         RS_LOGD("SOCPerfParamParse 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 (ParseSOCPerfInternal(featureMap, *currNode) != PARSE_EXEC_SUCCESS) {
36             RS_LOGD("SOCPerfParamParse stop parsing, parse internal fail");
37             return PARSE_INTERNAL_FAIL;
38         }
39     }
40 
41     return PARSE_EXEC_SUCCESS;
42 }
43 
ParseSOCPerfInternal(FeatureParamMapType & featureMap,xmlNode & node)44 int32_t SOCPerfParamParse::ParseSOCPerfInternal(FeatureParamMapType &featureMap, xmlNode &node)
45 {
46     xmlNode *currNode = &node;
47 
48     auto iter = featureMap.find(FEATURE_CONFIGS[SOC_PERF]);
49     if (iter == featureMap.end()) {
50         RS_LOGD("SOCPerfParamParse stop parsing, no initializing param map");
51         return PARSE_NO_PARAM;
52     }
53     socPerfParam_ = std::static_pointer_cast<SOCPerfParam>(iter->second);
54 
55     // Start Parse Feature Params
56     int xmlParamType = GetXmlNodeAsInt(*currNode);
57     auto name = ExtractPropertyValue("name", *currNode);
58     auto val = ExtractPropertyValue("value", *currNode);
59     if (xmlParamType == PARSE_XML_FEATURE_SWITCH) {
60         bool isEnabled = ParseFeatureSwitch(val);
61         if (name == "MultilayersSocperfEnabled") {
62             socPerfParam_->SetMultilayersSOCPerfEnable(isEnabled);
63             RS_LOGI("SOCPerfParamParse parse MultilayersSocperfEnabled %{public}d",
64                 socPerfParam_->IsMultilayersSOCPerfEnable());
65         } else if (name == "UnlockSocperfEnabled") {
66             socPerfParam_->SetUnlockSOCPerfEnable(isEnabled);
67             RS_LOGI("SOCPerfParamParse parse UnlockSocperfEnabled %{public}d",
68                 socPerfParam_->IsUnlockSOCPerfEnable());
69         } else if (name == "BlurSocperfEnabled") {
70             socPerfParam_->SetBlurSOCPerfEnable(isEnabled);
71             RS_LOGI("SOCPerfParamParse parse BlurSocperfEnabled %{public}d",
72                 socPerfParam_->IsBlurSOCPerfEnable());
73         }
74     }
75     return PARSE_EXEC_SUCCESS;
76 }
77 } // namespace OHOS::Rosen