Loading services/inputflinger/EventHub.h +2 −4 Original line number Diff line number Diff line Loading @@ -146,12 +146,11 @@ extern uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses); * which keys are currently down. Finally, the event hub keeps track of the capabilities of * individual input devices, such as their class and the set of key codes that they support. */ class EventHubInterface : public virtual RefBase { protected: class EventHubInterface { public: EventHubInterface() { } virtual ~EventHubInterface() { } public: // Synthetic raw event type codes produced when devices are added or removed. enum { // Sent when a device is added. Loading Loading @@ -319,7 +318,6 @@ public: virtual void dump(std::string& dump); virtual void monitor(); protected: virtual ~EventHub(); private: Loading services/inputflinger/InputReader.cpp +11 −6 Original line number Diff line number Diff line Loading @@ -260,12 +260,17 @@ static void synthesizeButtonKeys(InputReaderContext* context, int32_t action, // --- InputReader --- InputReader::InputReader(const sp<EventHubInterface>& eventHub, InputReader::InputReader(std::shared_ptr<EventHubInterface> eventHub, const sp<InputReaderPolicyInterface>& policy, const sp<InputListenerInterface>& listener) : mContext(this), mEventHub(eventHub), mPolicy(policy), mNextSequenceNum(1), mGlobalMetaState(0), mGeneration(1), mDisableVirtualKeysTimeout(LLONG_MIN), mNextTimeout(LLONG_MAX), const sp<InputListenerInterface>& listener) : mContext(this), mEventHub(eventHub), mPolicy(policy), mNextSequenceNum(1), mGlobalMetaState(0), mGeneration(1), mDisableVirtualKeysTimeout(LLONG_MIN), mNextTimeout(LLONG_MAX), mConfigurationChangesToRefresh(0) { mQueuedListener = new QueuedInputListener(listener); Loading services/inputflinger/InputReader.h +7 −4 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ public: */ class InputReader : public InputReaderInterface { public: InputReader(const sp<EventHubInterface>& eventHub, InputReader(std::shared_ptr<EventHubInterface> eventHub, const sp<InputReaderPolicyInterface>& policy, const sp<InputListenerInterface>& listener); virtual ~InputReader(); Loading Loading @@ -181,7 +181,10 @@ private: Condition mReaderIsAliveCondition; sp<EventHubInterface> mEventHub; // This could be unique_ptr, but due to the way InputReader tests are written, // it is made shared_ptr here. In the tests, an EventHub reference is retained by the test // in parallel to passing it to the InputReader. std::shared_ptr<EventHubInterface> mEventHub; sp<InputReaderPolicyInterface> mPolicy; sp<QueuedInputListener> mQueuedListener; Loading services/inputflinger/InputReaderFactory.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ namespace android { sp<InputReaderInterface> createInputReader( const sp<InputReaderPolicyInterface>& policy, const sp<InputListenerInterface>& listener) { return new InputReader(new EventHub(), policy, listener); return new InputReader(std::make_unique<EventHub>(), policy, listener); } } // namespace android No newline at end of file services/inputflinger/tests/InputReader_test.cpp +20 −24 Original line number Diff line number Diff line Loading @@ -325,14 +325,13 @@ class FakeEventHub : public EventHubInterface { List<RawEvent> mEvents; std::unordered_map<int32_t /*deviceId*/, std::vector<TouchVideoFrame>> mVideoFrames; protected: public: virtual ~FakeEventHub() { for (size_t i = 0; i < mDevices.size(); i++) { delete mDevices.valueAt(i); } } public: FakeEventHub() { } void addDevice(int32_t deviceId, const std::string& name, uint32_t classes) { Loading Loading @@ -760,7 +759,7 @@ private: // --- FakeInputReaderContext --- class FakeInputReaderContext : public InputReaderContext { sp<EventHubInterface> mEventHub; std::shared_ptr<EventHubInterface> mEventHub; sp<InputReaderPolicyInterface> mPolicy; sp<InputListenerInterface> mListener; int32_t mGlobalMetaState; Loading @@ -769,12 +768,14 @@ class FakeInputReaderContext : public InputReaderContext { uint32_t mNextSequenceNum; public: FakeInputReaderContext(const sp<EventHubInterface>& eventHub, FakeInputReaderContext(std::shared_ptr<EventHubInterface> eventHub, const sp<InputReaderPolicyInterface>& policy, const sp<InputListenerInterface>& listener) : mEventHub(eventHub), mPolicy(policy), mListener(listener), mGlobalMetaState(0), mNextSequenceNum(1) { } const sp<InputListenerInterface>& listener) : mEventHub(eventHub), mPolicy(policy), mListener(listener), mGlobalMetaState(0), mNextSequenceNum(1) {} virtual ~FakeInputReaderContext() { } Loading Loading @@ -999,12 +1000,10 @@ class InstrumentedInputReader : public InputReader { InputDevice* mNextDevice; public: InstrumentedInputReader(const sp<EventHubInterface>& eventHub, InstrumentedInputReader(std::shared_ptr<EventHubInterface> eventHub, const sp<InputReaderPolicyInterface>& policy, const sp<InputListenerInterface>& listener) : InputReader(eventHub, policy, listener), mNextDevice(nullptr) { } const sp<InputListenerInterface>& listener) : InputReader(eventHub, policy, listener), mNextDevice(nullptr) {} virtual ~InstrumentedInputReader() { if (mNextDevice) { Loading Loading @@ -1232,11 +1231,11 @@ class InputReaderTest : public testing::Test { protected: sp<TestInputListener> mFakeListener; sp<FakeInputReaderPolicy> mFakePolicy; sp<FakeEventHub> mFakeEventHub; std::shared_ptr<FakeEventHub> mFakeEventHub; sp<InstrumentedInputReader> mReader; virtual void SetUp() { mFakeEventHub = new FakeEventHub(); mFakeEventHub = std::make_unique<FakeEventHub>(); mFakePolicy = new FakeInputReaderPolicy(); mFakeListener = new TestInputListener(); Loading @@ -1248,7 +1247,6 @@ protected: mFakeListener.clear(); mFakePolicy.clear(); mFakeEventHub.clear(); } void addDevice(int32_t deviceId, const std::string& name, uint32_t classes, Loading Loading @@ -1575,7 +1573,7 @@ protected: static const int32_t DEVICE_CONTROLLER_NUMBER; static const uint32_t DEVICE_CLASSES; sp<FakeEventHub> mFakeEventHub; std::shared_ptr<FakeEventHub> mFakeEventHub; sp<FakeInputReaderPolicy> mFakePolicy; sp<TestInputListener> mFakeListener; FakeInputReaderContext* mFakeContext; Loading @@ -1583,7 +1581,7 @@ protected: InputDevice* mDevice; virtual void SetUp() { mFakeEventHub = new FakeEventHub(); mFakeEventHub = std::make_unique<FakeEventHub>(); mFakePolicy = new FakeInputReaderPolicy(); mFakeListener = new TestInputListener(); mFakeContext = new FakeInputReaderContext(mFakeEventHub, mFakePolicy, mFakeListener); Loading @@ -1601,7 +1599,6 @@ protected: delete mFakeContext; mFakeListener.clear(); mFakePolicy.clear(); mFakeEventHub.clear(); } }; Loading Loading @@ -1770,14 +1767,14 @@ protected: static const int32_t DEVICE_CONTROLLER_NUMBER; static const uint32_t DEVICE_CLASSES; sp<FakeEventHub> mFakeEventHub; std::shared_ptr<FakeEventHub> mFakeEventHub; sp<FakeInputReaderPolicy> mFakePolicy; sp<TestInputListener> mFakeListener; FakeInputReaderContext* mFakeContext; InputDevice* mDevice; virtual void SetUp() { mFakeEventHub = new FakeEventHub(); mFakeEventHub = std::make_unique<FakeEventHub>(); mFakePolicy = new FakeInputReaderPolicy(); mFakeListener = new TestInputListener(); mFakeContext = new FakeInputReaderContext(mFakeEventHub, mFakePolicy, mFakeListener); Loading @@ -1795,7 +1792,6 @@ protected: delete mFakeContext; mFakeListener.clear(); mFakePolicy.clear(); mFakeEventHub.clear(); } void addConfigurationProperty(const char* key, const char* value) { Loading Loading
services/inputflinger/EventHub.h +2 −4 Original line number Diff line number Diff line Loading @@ -146,12 +146,11 @@ extern uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses); * which keys are currently down. Finally, the event hub keeps track of the capabilities of * individual input devices, such as their class and the set of key codes that they support. */ class EventHubInterface : public virtual RefBase { protected: class EventHubInterface { public: EventHubInterface() { } virtual ~EventHubInterface() { } public: // Synthetic raw event type codes produced when devices are added or removed. enum { // Sent when a device is added. Loading Loading @@ -319,7 +318,6 @@ public: virtual void dump(std::string& dump); virtual void monitor(); protected: virtual ~EventHub(); private: Loading
services/inputflinger/InputReader.cpp +11 −6 Original line number Diff line number Diff line Loading @@ -260,12 +260,17 @@ static void synthesizeButtonKeys(InputReaderContext* context, int32_t action, // --- InputReader --- InputReader::InputReader(const sp<EventHubInterface>& eventHub, InputReader::InputReader(std::shared_ptr<EventHubInterface> eventHub, const sp<InputReaderPolicyInterface>& policy, const sp<InputListenerInterface>& listener) : mContext(this), mEventHub(eventHub), mPolicy(policy), mNextSequenceNum(1), mGlobalMetaState(0), mGeneration(1), mDisableVirtualKeysTimeout(LLONG_MIN), mNextTimeout(LLONG_MAX), const sp<InputListenerInterface>& listener) : mContext(this), mEventHub(eventHub), mPolicy(policy), mNextSequenceNum(1), mGlobalMetaState(0), mGeneration(1), mDisableVirtualKeysTimeout(LLONG_MIN), mNextTimeout(LLONG_MAX), mConfigurationChangesToRefresh(0) { mQueuedListener = new QueuedInputListener(listener); Loading
services/inputflinger/InputReader.h +7 −4 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ public: */ class InputReader : public InputReaderInterface { public: InputReader(const sp<EventHubInterface>& eventHub, InputReader(std::shared_ptr<EventHubInterface> eventHub, const sp<InputReaderPolicyInterface>& policy, const sp<InputListenerInterface>& listener); virtual ~InputReader(); Loading Loading @@ -181,7 +181,10 @@ private: Condition mReaderIsAliveCondition; sp<EventHubInterface> mEventHub; // This could be unique_ptr, but due to the way InputReader tests are written, // it is made shared_ptr here. In the tests, an EventHub reference is retained by the test // in parallel to passing it to the InputReader. std::shared_ptr<EventHubInterface> mEventHub; sp<InputReaderPolicyInterface> mPolicy; sp<QueuedInputListener> mQueuedListener; Loading
services/inputflinger/InputReaderFactory.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ namespace android { sp<InputReaderInterface> createInputReader( const sp<InputReaderPolicyInterface>& policy, const sp<InputListenerInterface>& listener) { return new InputReader(new EventHub(), policy, listener); return new InputReader(std::make_unique<EventHub>(), policy, listener); } } // namespace android No newline at end of file
services/inputflinger/tests/InputReader_test.cpp +20 −24 Original line number Diff line number Diff line Loading @@ -325,14 +325,13 @@ class FakeEventHub : public EventHubInterface { List<RawEvent> mEvents; std::unordered_map<int32_t /*deviceId*/, std::vector<TouchVideoFrame>> mVideoFrames; protected: public: virtual ~FakeEventHub() { for (size_t i = 0; i < mDevices.size(); i++) { delete mDevices.valueAt(i); } } public: FakeEventHub() { } void addDevice(int32_t deviceId, const std::string& name, uint32_t classes) { Loading Loading @@ -760,7 +759,7 @@ private: // --- FakeInputReaderContext --- class FakeInputReaderContext : public InputReaderContext { sp<EventHubInterface> mEventHub; std::shared_ptr<EventHubInterface> mEventHub; sp<InputReaderPolicyInterface> mPolicy; sp<InputListenerInterface> mListener; int32_t mGlobalMetaState; Loading @@ -769,12 +768,14 @@ class FakeInputReaderContext : public InputReaderContext { uint32_t mNextSequenceNum; public: FakeInputReaderContext(const sp<EventHubInterface>& eventHub, FakeInputReaderContext(std::shared_ptr<EventHubInterface> eventHub, const sp<InputReaderPolicyInterface>& policy, const sp<InputListenerInterface>& listener) : mEventHub(eventHub), mPolicy(policy), mListener(listener), mGlobalMetaState(0), mNextSequenceNum(1) { } const sp<InputListenerInterface>& listener) : mEventHub(eventHub), mPolicy(policy), mListener(listener), mGlobalMetaState(0), mNextSequenceNum(1) {} virtual ~FakeInputReaderContext() { } Loading Loading @@ -999,12 +1000,10 @@ class InstrumentedInputReader : public InputReader { InputDevice* mNextDevice; public: InstrumentedInputReader(const sp<EventHubInterface>& eventHub, InstrumentedInputReader(std::shared_ptr<EventHubInterface> eventHub, const sp<InputReaderPolicyInterface>& policy, const sp<InputListenerInterface>& listener) : InputReader(eventHub, policy, listener), mNextDevice(nullptr) { } const sp<InputListenerInterface>& listener) : InputReader(eventHub, policy, listener), mNextDevice(nullptr) {} virtual ~InstrumentedInputReader() { if (mNextDevice) { Loading Loading @@ -1232,11 +1231,11 @@ class InputReaderTest : public testing::Test { protected: sp<TestInputListener> mFakeListener; sp<FakeInputReaderPolicy> mFakePolicy; sp<FakeEventHub> mFakeEventHub; std::shared_ptr<FakeEventHub> mFakeEventHub; sp<InstrumentedInputReader> mReader; virtual void SetUp() { mFakeEventHub = new FakeEventHub(); mFakeEventHub = std::make_unique<FakeEventHub>(); mFakePolicy = new FakeInputReaderPolicy(); mFakeListener = new TestInputListener(); Loading @@ -1248,7 +1247,6 @@ protected: mFakeListener.clear(); mFakePolicy.clear(); mFakeEventHub.clear(); } void addDevice(int32_t deviceId, const std::string& name, uint32_t classes, Loading Loading @@ -1575,7 +1573,7 @@ protected: static const int32_t DEVICE_CONTROLLER_NUMBER; static const uint32_t DEVICE_CLASSES; sp<FakeEventHub> mFakeEventHub; std::shared_ptr<FakeEventHub> mFakeEventHub; sp<FakeInputReaderPolicy> mFakePolicy; sp<TestInputListener> mFakeListener; FakeInputReaderContext* mFakeContext; Loading @@ -1583,7 +1581,7 @@ protected: InputDevice* mDevice; virtual void SetUp() { mFakeEventHub = new FakeEventHub(); mFakeEventHub = std::make_unique<FakeEventHub>(); mFakePolicy = new FakeInputReaderPolicy(); mFakeListener = new TestInputListener(); mFakeContext = new FakeInputReaderContext(mFakeEventHub, mFakePolicy, mFakeListener); Loading @@ -1601,7 +1599,6 @@ protected: delete mFakeContext; mFakeListener.clear(); mFakePolicy.clear(); mFakeEventHub.clear(); } }; Loading Loading @@ -1770,14 +1767,14 @@ protected: static const int32_t DEVICE_CONTROLLER_NUMBER; static const uint32_t DEVICE_CLASSES; sp<FakeEventHub> mFakeEventHub; std::shared_ptr<FakeEventHub> mFakeEventHub; sp<FakeInputReaderPolicy> mFakePolicy; sp<TestInputListener> mFakeListener; FakeInputReaderContext* mFakeContext; InputDevice* mDevice; virtual void SetUp() { mFakeEventHub = new FakeEventHub(); mFakeEventHub = std::make_unique<FakeEventHub>(); mFakePolicy = new FakeInputReaderPolicy(); mFakeListener = new TestInputListener(); mFakeContext = new FakeInputReaderContext(mFakeEventHub, mFakePolicy, mFakeListener); Loading @@ -1795,7 +1792,6 @@ protected: delete mFakeContext; mFakeListener.clear(); mFakePolicy.clear(); mFakeEventHub.clear(); } void addConfigurationProperty(const char* key, const char* value) { Loading