• 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 "multiscreen_param_parse.h"
17 
18 namespace OHOS::Rosen {
19 
ParseFeatureParam(FeatureParamMapType & featureMap,xmlNode & node)20 int32_t MultiScreenParamParse::ParseFeatureParam(FeatureParamMapType &featureMap, xmlNode &node)
21 {
22     RS_LOGI("MultiScreenParamParse start");
23     xmlNode *currNode = &node;
24     if (currNode->xmlChildrenNode == nullptr) {
25         RS_LOGW("MultiScreenParamParse 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 (ParseMultiScreenInternal(featureMap, *currNode) != PARSE_EXEC_SUCCESS) {
36             RS_LOGW("MultiScreenParamParse stop parsing, parse internal fail");
37             return PARSE_INTERNAL_FAIL;
38         }
39     }
40     RS_LOGI("MultiScreenParamParse end, isExternalScreenSecure: %{public}d, isSlrScaleEnabled: %{public}d,"
41         " isRsReportHwcDead: %{public}d, isRsSetScreenPowerStatus: %{public}d",
42         multiScreenParam_->IsExternalScreenSecure(), multiScreenParam_->IsSlrScaleEnabled(),
43         multiScreenParam_->IsRsReportHwcDead(), multiScreenParam_->IsRsSetScreenPowerStatus());
44     return PARSE_EXEC_SUCCESS;
45 }
46 
ParseMultiScreenInternal(FeatureParamMapType & featureMap,xmlNode & node)47 int32_t MultiScreenParamParse::ParseMultiScreenInternal(FeatureParamMapType &featureMap, xmlNode &node)
48 {
49     xmlNode *currNode = &node;
50 
51     auto iter = featureMap.find(FEATURE_CONFIGS[MULTISCREEN]);
52     if (iter == featureMap.end()) {
53         RS_LOGW("MultiScreenParamParse stop parsing, no initializing param map");
54         return PARSE_NO_PARAM;
55     }
56     multiScreenParam_ = std::static_pointer_cast<MultiScreenParam>(iter->second);
57     if (!multiScreenParam_) {
58         RS_LOGW("MultiScreenParamParse stop parsing, multiScreenParam_ is null");
59         return PARSE_ERROR;
60     }
61     // Start Parse Feature Params
62     int xmlParamType = GetXmlNodeAsInt(*currNode);
63     auto name = ExtractPropertyValue("name", *currNode);
64     auto val = ExtractPropertyValue("value", *currNode);
65     if (xmlParamType == PARSE_XML_FEATURE_SWITCH) {
66         bool isEnabled = ParseFeatureSwitch(val);
67         if (name == "IsExternalScreenSecure") {
68             multiScreenParam_->SetExternalScreenSecure(isEnabled);
69         } else if (name == "IsSlrScaleEnabled") {
70             multiScreenParam_->SetSlrScaleEnabled(isEnabled);
71         } else if (name == "IsRsReportHwcDead") {
72             multiScreenParam_->SetRsReportHwcDead(isEnabled);
73         } else if (name == "IsRsSetScreenPowerStatus") {
74             multiScreenParam_->SetRsSetScreenPowerStatus(isEnabled);
75         }
76     }
77     return PARSE_EXEC_SUCCESS;
78 }
79 } // namespace OHOS::Rosen