1c29fa5a6Sopenharmony_ci/* 2c29fa5a6Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3c29fa5a6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4c29fa5a6Sopenharmony_ci * you may not use this file except in compliance with the License. 5c29fa5a6Sopenharmony_ci * You may obtain a copy of the License at 6c29fa5a6Sopenharmony_ci * 7c29fa5a6Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8c29fa5a6Sopenharmony_ci * 9c29fa5a6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10c29fa5a6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11c29fa5a6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12c29fa5a6Sopenharmony_ci * See the License for the specific language governing permissions and 13c29fa5a6Sopenharmony_ci * limitations under the License. 14c29fa5a6Sopenharmony_ci */ 15c29fa5a6Sopenharmony_ci 16c29fa5a6Sopenharmony_ci#ifndef ANR_MANAGER_H 17c29fa5a6Sopenharmony_ci#define ANR_MANAGER_H 18c29fa5a6Sopenharmony_ci 19c29fa5a6Sopenharmony_ci#include "nocopyable.h" 20c29fa5a6Sopenharmony_ci#include "singleton.h" 21c29fa5a6Sopenharmony_ci 22c29fa5a6Sopenharmony_ci#include "uds_server.h" 23c29fa5a6Sopenharmony_ci#include "uds_session.h" 24c29fa5a6Sopenharmony_ci 25c29fa5a6Sopenharmony_cinamespace OHOS { 26c29fa5a6Sopenharmony_cinamespace MMI { 27c29fa5a6Sopenharmony_ciclass ANRManager final { 28c29fa5a6Sopenharmony_ci DECLARE_DELAYED_SINGLETON(ANRManager); 29c29fa5a6Sopenharmony_cipublic: 30c29fa5a6Sopenharmony_ci DISALLOW_COPY_AND_MOVE(ANRManager); 31c29fa5a6Sopenharmony_ci void Init(UDSServer& udsServer); 32c29fa5a6Sopenharmony_ci bool TriggerANR(int32_t type, int64_t time, SessionPtr sess); 33c29fa5a6Sopenharmony_ci int32_t SetANRNoticedPid(int32_t anrPid); 34c29fa5a6Sopenharmony_ci void OnSessionLost(SessionPtr session); 35c29fa5a6Sopenharmony_ci void AddTimer(int32_t type, int32_t id, int64_t currentTime, SessionPtr sess); 36c29fa5a6Sopenharmony_ci int32_t MarkProcessed(int32_t pid, int32_t eventType, int32_t eventId); 37c29fa5a6Sopenharmony_ci void RemoveTimers(SessionPtr sess); 38c29fa5a6Sopenharmony_ci void RemoveTimersByType(SessionPtr sess, int32_t type); 39c29fa5a6Sopenharmony_ciprivate: 40c29fa5a6Sopenharmony_ci int32_t anrNoticedPid_ { -1 }; 41c29fa5a6Sopenharmony_ci UDSServer *udsServer_ { nullptr }; 42c29fa5a6Sopenharmony_ci int32_t anrTimerCount_ { 0 }; 43c29fa5a6Sopenharmony_ci int32_t pid_ { -1 }; 44c29fa5a6Sopenharmony_ci}; 45c29fa5a6Sopenharmony_ci 46c29fa5a6Sopenharmony_ci#define ANRMgr ::OHOS::DelayedSingleton<ANRManager>::GetInstance() 47c29fa5a6Sopenharmony_ci} // namespace MMI 48c29fa5a6Sopenharmony_ci} // namespace OHOS 49c29fa5a6Sopenharmony_ci#endif // ANR_MANAGER_H