1 /* 2 * Copyright (c) 2024-2024 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 #ifndef BRIGHTNESS_CONFIG_PARSER_H 17 #define BRIGHTNESS_CONFIG_PARSER_H 18 19 #include <unordered_map> 20 #include <cJSON.h> 21 22 namespace OHOS { 23 namespace DisplayPowerMgr { 24 struct ScreenData { 25 int displayId{0}; 26 int sensorId{0}; // SENSOR_TYPE_ID_AMBIENT_LIGHT = 5, SENSOR_TYPE_ID_AMBIENT_LIGHT1 = 16 27 }; 28 29 namespace BrightnessConfig { 30 struct Data { 31 std::unordered_map<int, ScreenData> displayModeMap { // UNKNOWN = 0, FULL = 1, MAIN = 2, SUB = 3, COORDINATION = 4 32 { 0, {0, 16}}, 33 { 1, {0, 16}}, 34 { 2, {5, 5}} 35 }; 36 std::unordered_map<int, ScreenData> foldStatusModeMap { // UNKNOWN = 0, EXPAND = 1, FOLDED = 2, HALF_FOLD = 3; 37 { 0, { 0, 16 } }, 38 { 1, { 0, 16 } }, 39 { 2, { 5, 5 } }, 40 { 3, { 0, 16 } } 41 }; 42 }; 43 } 44 class BrightnessConfigParser { 45 public: 46 BrightnessConfigParser() = default; 47 virtual ~BrightnessConfigParser() = default; 48 BrightnessConfigParser(const BrightnessConfigParser&) = delete; 49 BrightnessConfigParser& operator=(const BrightnessConfigParser&) = delete; 50 BrightnessConfigParser(BrightnessConfigParser&&) = delete; 51 BrightnessConfigParser& operator=(BrightnessConfigParser&&) = delete; 52 53 static bool ParseConfig(BrightnessConfig::Data& data); 54 static bool ParseConfigJsonRoot(const std::string& fileContent, BrightnessConfig::Data& data); 55 static void PrintConfig(const BrightnessConfig::Data& data); 56 }; 57 } // namespace DisplayPowerMgr 58 } // namespace OHOS 59 #endif // BRIGHTNESS_CONFIG_PARSER_H 60