1 /* 2 * Copyright (c) 2021 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 FREEZE_VENDOR_H 17 #define FREEZE_VENDOR_H 18 19 #include <set> 20 #include <string> 21 #include <vector> 22 23 #include "faultlog_info.h" 24 #include "freeze_common.h" 25 #include "log_store_ex.h" 26 #include "power_mgr_client.h" 27 #include "smart_parser.h" 28 #include "watch_point.h" 29 30 namespace OHOS { 31 namespace HiviewDFX { 32 class Vendor { 33 public: Vendor(std::shared_ptr<FreezeCommon> fc)34 explicit Vendor(std::shared_ptr<FreezeCommon> fc) : freezeCommon_(fc) {}; ~Vendor()35 ~Vendor() {}; 36 Vendor& operator=(const Vendor&) = delete; 37 Vendor(const Vendor&) = delete; 38 39 bool Init(); 40 std::string GetTimeString(unsigned long long timestamp) const; 41 void DumpEventInfo(std::ostringstream& oss, const std::string& header, const WatchPoint& watchPoint) const; 42 void InitLogInfo(const WatchPoint& watchPoint, std::string& type, std::string& retPath, 43 std::string& tmpLogPath, std::string& tmpLogName) const; 44 void InitLogBody(const std::vector<WatchPoint>& list, std::ostringstream& body, 45 bool& isFileExists) const; 46 std::string MergeEventLog( 47 const WatchPoint &watchPoint, const std::vector<WatchPoint>& list, 48 const std::vector<FreezeResult>& result) const; 49 bool ReduceRelevanceEvents(std::list<WatchPoint>& list, const FreezeResult& result) const; 50 51 private: 52 static void FormatProcessName(std::string& processName); 53 std::string SendFaultLog(const WatchPoint &watchPoint, const std::string& logPath, const std::string& type) const; 54 void MergeFreezeJsonFile(const WatchPoint &watchPoint, const std::vector<WatchPoint>& list) const; 55 static std::string GetDisPlayPowerInfo(); 56 static std::string GetPowerStateString(OHOS::PowerMgr::PowerState state); 57 58 std::unique_ptr<LogStoreEx> logStore_ = nullptr; 59 std::shared_ptr<FreezeCommon> freezeCommon_ = nullptr; 60 }; 61 } // namespace HiviewDFX 62 } // namespace OHOS 63 #endif // FREEZE_VENDOR_H 64