blob: c95907540ac307d48c52d25d36b6b08742bc9061 [file] [log] [blame]
Prabir Pradhanaddf8e92023-04-06 00:28:48 +00001/*
2 * Copyright 2023 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include "InputListener.h"
20
21namespace android {
22
23/**
24 * Logs metrics about registered input devices and their usages.
25 *
26 * Not thread safe. Must be called from a single thread.
27 */
28class InputDeviceMetricsCollectorInterface : public InputListenerInterface {
29public:
30 /**
31 * Dump the state of the interaction blocker.
32 * This method may be called on any thread (usually by the input manager on a binder thread).
33 */
34 virtual void dump(std::string& dump) = 0;
35};
36
37class InputDeviceMetricsCollector : public InputDeviceMetricsCollectorInterface {
38public:
39 explicit InputDeviceMetricsCollector(InputListenerInterface& listener);
40 ~InputDeviceMetricsCollector() override = default;
41
42 void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
43 void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override;
44 void notifyKey(const NotifyKeyArgs& args) override;
45 void notifyMotion(const NotifyMotionArgs& args) override;
46 void notifySwitch(const NotifySwitchArgs& args) override;
47 void notifySensor(const NotifySensorArgs& args) override;
48 void notifyVibratorState(const NotifyVibratorStateArgs& args) override;
49 void notifyDeviceReset(const NotifyDeviceResetArgs& args) override;
50 void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override;
51
52 void dump(std::string& dump) override;
53
54private:
55 InputListenerInterface& mNextListener;
56};
57
58} // namespace android