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