1 /* 2 * Copyright (c) 2022 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 HIVIEWDFX_FREEZE_COMMON_H 17 #define HIVIEWDFX_FREEZE_COMMON_H 18 19 #include <list> 20 #include <memory> 21 #include <set> 22 #include <vector> 23 24 #include "rule_cluster.h" 25 26 namespace OHOS { 27 namespace HiviewDFX { 28 const std::string FREEZE_DETECTOR_PLUGIN_NAME = "FreezeDetector"; 29 const std::string FREEZE_DETECTOR_PLUGIN_VERSION = "1.0"; 30 class FreezeCommon { 31 public: 32 static const int MILLISECOND = 1000; 33 static const int SYSTEM_RESULT_ID = 1; 34 static const int APPLICATION_RESULT_ID = 0; 35 static const inline std::string COLON = ":"; 36 static const inline std::string EVENT_DOMAIN = "DOMAIN"; 37 static const inline std::string EVENT_STRINGID = "STRINGID"; 38 static const inline std::string EVENT_TIMESTAMP = "TIMESTAMP"; 39 static const inline std::string EVENT_PID = "PID"; 40 static const inline std::string EVENT_TID = "TID"; 41 static const inline std::string EVENT_UID = "UID"; 42 static const inline std::string EVENT_PACKAGE_NAME = "PACKAGE_NAME"; 43 static const inline std::string EVENT_PROCESS_NAME = "PROCESS_NAME"; 44 static const inline std::string EVENT_MSG = "MSG"; 45 static const inline std::string SYSEVENT_PIPELINE = "SysEventPipeline"; 46 47 FreezeCommon(); 48 ~FreezeCommon(); 49 50 bool Init(); 51 bool IsFreezeEvent(const std::string& domain, const std::string& stringId) const; 52 bool IsApplicationEvent(const std::string& domain, const std::string& stringId) const; 53 bool IsBetaVersion() const; 54 bool IsSystemEvent(const std::string& domain, const std::string& stringId) const; 55 bool IsSystemResult(const FreezeResult& result) const; 56 bool IsApplicationResult(const FreezeResult& result) const; 57 std::set<std::string> GetPrincipalStringIds() const; GetFreezeRuleCluster()58 std::shared_ptr<FreezeRuleCluster> GetFreezeRuleCluster() const 59 { 60 return freezeRuleCluster_; 61 } 62 63 private: 64 std::shared_ptr<FreezeRuleCluster> freezeRuleCluster_; 65 }; 66 } // namespace HiviewDFX 67 } // namespace OHOS 68 #endif // HIVIEWDFX_FREEZE_COMMON_H