• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #include "watchdog.h"
17 
18 #include "watchdog_inner.h"
19 
20 namespace OHOS {
21 namespace HiviewDFX {
Watchdog()22 Watchdog::Watchdog()
23 {
24 }
25 
~Watchdog()26 Watchdog::~Watchdog()
27 {
28 }
29 
AddThread(const std::string & name,std::shared_ptr<AppExecFwk::EventHandler> handler,TimeOutCallback timeOutCallback,uint64_t interval)30 int Watchdog::AddThread(const std::string &name, std::shared_ptr<AppExecFwk::EventHandler> handler,
31     TimeOutCallback timeOutCallback, uint64_t interval)
32 {
33     return WatchdogInner::GetInstance().AddThread(name, handler, timeOutCallback, interval);
34 }
35 
AddThread(const std::string & name,std::shared_ptr<AppExecFwk::EventHandler> handler,uint64_t interval)36 int Watchdog::AddThread(const std::string &name, std::shared_ptr<AppExecFwk::EventHandler> handler,  uint64_t interval)
37 {
38     return WatchdogInner::GetInstance().AddThread(name, handler, nullptr, interval);
39 }
40 
RunOneShotTask(const std::string & name,Task && task,uint64_t delay)41 void Watchdog::RunOneShotTask(const std::string& name, Task&& task, uint64_t delay)
42 {
43     return WatchdogInner::GetInstance().RunOneShotTask(name, std::move(task), delay);
44 }
45 
RunPeriodicalTask(const std::string & name,Task && task,uint64_t interval,uint64_t delay)46 void Watchdog::RunPeriodicalTask(const std::string& name, Task&& task, uint64_t interval, uint64_t delay)
47 {
48     return WatchdogInner::GetInstance().RunPeriodicalTask(name, std::move(task), interval, delay);
49 }
50 
StopWatchdog()51 void Watchdog::StopWatchdog()
52 {
53     return WatchdogInner::GetInstance().StopWatchdog();
54 }
55 
InitFfrtWatchdog()56 void Watchdog::InitFfrtWatchdog()
57 {
58     return WatchdogInner::GetInstance().InitFfrtWatchdog();
59 }
60 
SetBundleInfo(const std::string & bundleName,const std::string & bundleVersion)61 void Watchdog::SetBundleInfo(const std::string& bundleName, const std::string& bundleVersion)
62 {
63     return WatchdogInner::GetInstance().SetBundleInfo(bundleName, bundleVersion);
64 }
65 
SetForeground(const bool & isForeground)66 void Watchdog::SetForeground(const bool& isForeground)
67 {
68     return WatchdogInner::GetInstance().SetForeground(isForeground);
69 }
70 
GetForeground()71 bool Watchdog::GetForeground()
72 {
73     return WatchdogInner::GetInstance().GetForeground();
74 }
75 
RemovePeriodicalTask(const std::string & name)76 void Watchdog::RemovePeriodicalTask(const std::string& name)
77 {
78     WatchdogInner::GetInstance().RemoveInnerTask(name);
79 }
80 
RemoveThread(const std::string & name)81 void Watchdog::RemoveThread(const std::string& name)
82 {
83     WatchdogInner::GetInstance().RemoveInnerTask(name);
84 }
85 
InitMainLooperWatcher(WatchdogBeginFunc * beginFunc,WatchdogEndFunc * endFunc)86 void Watchdog::InitMainLooperWatcher(WatchdogBeginFunc* beginFunc, WatchdogEndFunc* endFunc)
87 {
88     WatchdogInner::GetInstance().InitMainLooperWatcher(beginFunc, endFunc);
89 }
90 
SetAppDebug(bool isAppDebug)91 void Watchdog::SetAppDebug(bool isAppDebug)
92 {
93     WatchdogInner::GetInstance().SetAppDebug(isAppDebug);
94 }
95 
GetAppDebug()96 bool Watchdog::GetAppDebug()
97 {
98     return WatchdogInner::GetInstance().GetAppDebug();
99 }
100 
SetEventConfig(std::map<std::string,std::string> paramsMap)101 int Watchdog::SetEventConfig(std::map<std::string, std::string> paramsMap)
102 {
103     return WatchdogInner::GetInstance().SetEventConfig(paramsMap);
104 }
105 
SetSpecifiedProcessName(const std::string & name)106 void Watchdog::SetSpecifiedProcessName(const std::string& name)
107 {
108     WatchdogInner::GetInstance().SetSpecifiedProcessName(name);
109 }
110 
SetScrollState(bool isScroll)111 void Watchdog::SetScrollState(bool isScroll)
112 {
113     WatchdogInner::GetInstance().SetScrollState(isScroll);
114 }
115 
StartSample(int duration,int interval,std::string & outFile)116 void Watchdog::StartSample(int duration, int interval, std::string& outFile)
117 {
118     WatchdogInner::GetInstance().StartSample(duration, interval, outFile);
119 }
120 } // end of namespace HiviewDFX
121 } // end of namespace OHOS
122