• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 HIREACE_TIME = "HITRACE_TIME";
46     static const inline std::string SYSRQ_TIME = "SYSRQ_TIME";
47     static const inline std::string SYSEVENT_PIPELINE = "SysEventPipeline";
48 
49     FreezeCommon();
50     ~FreezeCommon();
51 
52     bool Init();
53     bool IsFreezeEvent(const std::string& domain, const std::string& stringId) const;
54     bool IsApplicationEvent(const std::string& domain, const std::string& stringId) const;
55     bool IsBetaVersion() const;
56     bool IsSystemEvent(const std::string& domain, const std::string& stringId) const;
57     bool IsSystemResult(const FreezeResult& result) const;
58     bool IsApplicationResult(const FreezeResult& result) const;
59     std::set<std::string> GetPrincipalStringIds() const;
GetFreezeRuleCluster()60     std::shared_ptr<FreezeRuleCluster> GetFreezeRuleCluster() const
61     {
62         return freezeRuleCluster_;
63     }
64 
65 private:
66     std::shared_ptr<FreezeRuleCluster> freezeRuleCluster_;
67 };
68 }  // namespace HiviewDFX
69 }  // namespace OHOS
70 #endif // HIVIEWDFX_FREEZE_COMMON_H