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 ANR_MANAGER_H 17 #define ANR_MANAGER_H 18 19 #include "singleton.h" 20 21 #include "uds_server.h" 22 23 namespace OHOS { 24 namespace MMI { 25 class ANRManager final { 26 DECLARE_DELAYED_SINGLETON(ANRManager); 27 public: 28 DISALLOW_COPY_AND_MOVE(ANRManager); 29 void Init(UDSServer& udsServer); 30 bool TriggerANR(int32_t type, int64_t time, SessionPtr sess); 31 int32_t SetANRNoticedPid(int32_t anrPid); 32 void OnSessionLost(SessionPtr session); 33 void AddTimer(int32_t type, int32_t id, int64_t currentTime, SessionPtr sess); 34 int32_t MarkProcessed(int32_t pid, int32_t eventType, int32_t eventId); 35 void RemoveTimers(SessionPtr sess); 36 void RemoveTimersByType(SessionPtr sess, int32_t type); 37 private: 38 int32_t anrNoticedPid_ { -1 }; 39 UDSServer *udsServer_ { nullptr }; 40 int32_t anrTimerCount_ { 0 }; 41 int32_t pid_ { -1 }; 42 }; 43 44 #define ANRMgr ::OHOS::DelayedSingleton<ANRManager>::GetInstance() 45 } // namespace MMI 46 } // namespace OHOS 47 #endif // ANR_MANAGER_H