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