• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #ifndef HIVIEW_EVENT_LOG_ACTIVE_KEY_EVENT_H
16 #define HIVIEW_EVENT_LOG_ACTIVE_KEY_EVENT_H
17 
18 #include <memory>
19 #include <string>
20 
21 #include "event_thread_pool.h"
22 #include "log_store_ex.h"
23 
24 #include "input_manager.h"
25 
26 namespace OHOS {
27 namespace HiviewDFX {
28 class ActiveKeyEvent {
29 public:
30     ActiveKeyEvent();
31     ~ActiveKeyEvent();
32     ActiveKeyEvent& operator=(const ActiveKeyEvent&) = delete;
33     ActiveKeyEvent(const ActiveKeyEvent&) = delete;
34 
35     void Init(std::shared_ptr<EventThreadPool> eventPool, std::shared_ptr<LogStoreEx> logStore);
36     static int64_t SystemTimeMillisecond();
37 
38 private:
39     void InitSubscribe(std::set<int32_t> preKeys, int32_t finalKey, int32_t count, int32_t holdTime);
40     void CombinationKeyHandle(std::shared_ptr<MMI::KeyEvent> keyEvent);
41     void CombinationKeyCallback(std::shared_ptr<MMI::KeyEvent> keyEvent);
42     void HitraceCapture();
43     void SysMemCapture(int fd);
44     void DumpCapture(int fd);
45 
46     const uint64_t initDelay_ = 5000;
47     std::list<int32_t> subscribeIds_;
48     std::shared_ptr<EventThreadPool> eventPool_;
49     std::shared_ptr<LogStoreEx> logStore_;
50     uint64_t triggeringTime_;
51 
52     static const inline std::string CMD_LIST[] = {
53         "cmd:w",
54         "cmd:rs",
55         "cmd:a",
56         "k:SysRqFile",
57         "cmd:p",
58         "cmd:d",
59         "cmd:c",
60     };
61 };
62 } // namespace HiviewDFX
63 } // namespace OHOS
64 #endif // HIVIEW_EVENT_LOG_ACTIVE_KEY_EVENT_H