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 POWERMGR_VIBRATOR_SOURCE_PARSER_H 17 #define POWERMGR_VIBRATOR_SOURCE_PARSER_H 18 19 #include <memory> 20 #include <string> 21 #include "json/value.h" 22 23 namespace OHOS { 24 namespace PowerMgr { 25 class VibratorSource { 26 public: 27 static const constexpr char* ENABLE_KEY = "enable"; 28 static const constexpr char* TYPE_KEY = "type"; VibratorSource(std::string scene,bool enable,std::string type)29 VibratorSource(std::string scene, bool enable, std::string type) : scene_(scene), enable_(enable), type_(type) {}; VibratorSource()30 VibratorSource() {}; 31 ~VibratorSource() = default; IsEnable()32 bool IsEnable() const 33 { 34 return enable_; 35 } GetType()36 std::string GetType() const 37 { 38 return type_; 39 } GetScene()40 std::string GetScene() const 41 { 42 return scene_; 43 } 44 private: 45 std::string scene_; 46 bool enable_ = false; 47 std::string type_; 48 }; 49 50 class VibratorSourceParser { 51 public: 52 std::vector<VibratorSource> ParseSources( 53 const std::string& etcPath, const std::string& vendorPath, const std::string& systemPath); 54 55 private: 56 std::vector<VibratorSource> ParseSources(const std::string& config); 57 void GetTargetPath(std::string& targetPath, 58 const std::string& etcPath, const std::string& vendorPath, const std::string& systemPath); 59 void ParseSourcesProc(std::vector<VibratorSource>& sources, Json::Value& valueObj, std::string& key); 60 }; 61 } // namespace PowerMgr 62 } // namespace OHOS 63 64 #endif // POWERMGR_VIBRATOR_SOURCE_PARSER_H