• 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 WUKONG_WUKONG_EXCEPTION_MANAGER_H
17 #define WUKONG_WUKONG_EXCEPTION_MANAGER_H
18 
19 #include "wukong_sysevent_listener.h"
20 
21 #include "singleton.h"
22 #include "errors.h"
23 
24 #include <fstream>
25 
26 namespace OHOS {
27     namespace AppExecFwk {
28         class WuKongExceptionManager : public DelayedSingleton<WuKongExceptionManager> {
29         public:
30         bool StartCatching();
31         void StopCatching();
SetCppCrashCatching(bool isEnable)32         void SetCppCrashCatching(bool isEnable)
33         {
34             enableCppCrashCatching = isEnable;
35         }
36 
SetJsCrashCatching(bool isEnable)37         void SetJsCrashCatching(bool isEnable)
38         {
39             enableJsCrashCatching = isEnable;
40         }
41 
SetAppFreezeCatching(bool isEnable)42         void SetAppFreezeCatching(bool isEnable)
43         {
44             enableAppFreezeCatching = isEnable;
45         }
46 
GetCurrentCsvFilePath()47         std::string GetCurrentCsvFilePath()
48         {
49             return currentCsvFilePath;
50         }
51 
52         private:
53             std::shared_ptr<WuKongSysEventListener> toolListener;
54             std::string currentCsvFilePath;
55             std::ofstream csvFile;
56             bool enableCppCrashCatching;
57             bool enableJsCrashCatching;
58             bool enableAppFreezeCatching;
59         };
60     } // namespace AppExecFwk
61 } // namespace OHOS
62 
63 #endif // WUKONG_WUKONG_EXCEPTION_MANAGER_H