• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 INPUT_MONITOR_H
17 #define INPUT_MONITOR_H
18 
19 #include <map>
20 #include <mutex>
21 #include "perf_constants.h"
22 #include "perf_model.h"
23 
24 namespace OHOS {
25 namespace HiviewDFX {
26 
27 class InputMonitor {
28 public:
29     static InputMonitor& GetInstance();
30     void RecordInputEvent(PerfActionType type, PerfSourceType sourceType, int64_t time);
31     int64_t GetInputTime(const std::string& sceneId, PerfActionType type, const std::string& note);
32     PerfSourceType GetSourceType();
33     int64_t GetVsyncTime();
34     void SetVsyncTime(int64_t val);
35 private:
36     mutable std::mutex mMutex;
37     std::map<PerfActionType, int64_t> mInputTime;
38     int64_t mVsyncTime {0};
39     PerfSourceType mSourceType {UNKNOWN_SOURCE};
40 };
41 
42 }
43 }
44 
45 #endif // INPUT_MONITOR_H