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& pubLogPathName, 43 std::string& processName, std::string& isScbPro) const; 44 void InitLogBody(const std::vector<WatchPoint>& list, std::ostringstream& body, 45 bool& isFileExists, WatchPoint &watchPoint) const; 46 bool JudgeSysWarningEvent(const std::string& stringId, std::string& type, const std::string& processName, 47 const std::vector<WatchPoint>& list, const std::vector<FreezeResult>& result) const; 48 std::string MergeEventLog(WatchPoint &watchPoint, const std::vector<WatchPoint>& list, 49 const std::vector<FreezeResult>& result) const; 50 51 private: 52 std::string SendFaultLog(const WatchPoint &watchPoint, const std::string& logPath, const std::string& type, 53 const std::string& processName, const std::string& isScbPro) 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 static void CheckProcessName(std::string& processName, std::string& isScbPro); 58 59 std::unique_ptr<LogStoreEx> logStore_ = nullptr; 60 std::shared_ptr<FreezeCommon> freezeCommon_ = nullptr; 61 }; 62 } // namespace HiviewDFX 63 } // namespace OHOS 64 #endif // FREEZE_VENDOR_H 65