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 16 #ifndef ANIMATION_CONFIG_H 17 #define ANIMATION_CONFIG_H 18 19 #include <fstream> 20 #include <memory> 21 #include <mutex> 22 #include <string> 23 24 #include "nocopyable.h" 25 #include <nlohmann/json.hpp> 26 27 namespace OHOS { 28 namespace PowerMgr { 29 struct CommonInfo { 30 int x; 31 int y; 32 int w; 33 int h; 34 std::string id; 35 std::string type; 36 bool visible; 37 }; 38 39 struct LabelComponentInfo { 40 uint8_t fontSize; 41 std::string text; 42 std::string align; 43 std::string fontColor; 44 std::string bgColor; 45 struct CommonInfo common; 46 }; 47 48 struct ImageComponentInfo { 49 std::string resPath; 50 std::string filePrefix; 51 uint32_t imgCnt; 52 uint32_t updInterval; 53 struct CommonInfo common; 54 }; 55 56 class AnimationConfig : public NoCopyable { 57 public: 58 bool ParseConfig(); 59 std::pair<ImageComponentInfo, LabelComponentInfo> GetCharingAnimationInfo(); 60 LabelComponentInfo GetCharingPromptInfo(); 61 LabelComponentInfo GetNotCharingPromptInfo(); 62 63 private: 64 void ParseAnimationConfig(nlohmann::json& jsonObj); 65 void ParseLackPowerChargingConfig(nlohmann::json& jsonObj); 66 void ParseLackPowerNotChargingConfig(nlohmann::json& jsonObj); 67 void ParseAnimationImage(nlohmann::json& component, ImageComponentInfo& info); 68 void ParseAnimationLabel(nlohmann::json& component, LabelComponentInfo& info); 69 std::pair<ImageComponentInfo, LabelComponentInfo> animationInfo_; 70 LabelComponentInfo chargingInfo_; 71 LabelComponentInfo notChargingInfo_; 72 nlohmann::json configObj_; 73 }; 74 } // namespace PowerMgr 75 } // namespace OHOS 76 #endif 77