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 "log_store_ex.h" 22 #include "input_manager.h" 23 #include "ffrt.h" 24 25 namespace OHOS { 26 namespace HiviewDFX { 27 class ActiveKeyEvent { 28 public: 29 ActiveKeyEvent(); 30 ~ActiveKeyEvent(); 31 ActiveKeyEvent& operator=(const ActiveKeyEvent&) = delete; 32 ActiveKeyEvent(const ActiveKeyEvent&) = delete; 33 34 void Init(std::shared_ptr<LogStoreEx> logStore); 35 static int64_t SystemTimeMillisecond(); 36 37 private: 38 void InitSubscribe(std::set<int32_t> preKeys, int32_t finalKey, int32_t count, int32_t holdTime); 39 void CombinationKeyHandle(std::shared_ptr<MMI::KeyEvent> keyEvent); 40 void CombinationKeyCallback(std::shared_ptr<MMI::KeyEvent> keyEvent); 41 void HitraceCapture(); 42 void SysMemCapture(int fd); 43 void DumpCapture(int fd); 44 45 mutable ffrt::mutex mutex_; 46 const uint64_t initDelay_ = 5000; 47 std::list<int32_t> subscribeIds_; 48 std::shared_ptr<LogStoreEx> logStore_; 49 uint64_t triggeringTime_; 50 uint8_t taskOutDeps = 0; 51 int reportLimit_ = 0; 52 53 static const inline std::string CMD_LIST[] = { 54 "cmd:w", 55 "cmd:rs", 56 "cmd:a", 57 "k:SysRqFile", 58 "cmd:p", 59 "cmd:d", 60 "cmd:c", 61 }; 62 }; 63 } // namespace HiviewDFX 64 } // namespace OHOS 65 #endif // HIVIEW_EVENT_LOG_ACTIVE_KEY_EVENT_H