Merge "Add InputDevice stats atom logging" into sc-dev
This commit is contained in:
commit
277ee042b5
4 changed files with 47 additions and 29 deletions
|
@ -148,6 +148,11 @@ TEST(Flags, EqualsOperator_DontShareState) {
|
|||
ASSERT_NE(flags1, flags2);
|
||||
}
|
||||
|
||||
TEST(Flags, GetValue) {
|
||||
Flags<TestFlags> flags = TestFlags::ONE | TestFlags::TWO;
|
||||
ASSERT_EQ(flags.get(), 0x3);
|
||||
}
|
||||
|
||||
TEST(Flags, String_NoFlags) {
|
||||
Flags<TestFlags> flags;
|
||||
ASSERT_EQ(flags.string(), "0x0");
|
||||
|
|
|
@ -68,6 +68,7 @@ cc_defaults {
|
|||
"libcutils",
|
||||
"libinput",
|
||||
"liblog",
|
||||
"libstatslog",
|
||||
"libui",
|
||||
"libutils",
|
||||
],
|
||||
|
|
|
@ -37,13 +37,14 @@
|
|||
|
||||
// #define LOG_NDEBUG 0
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <input/KeyCharacterMap.h>
|
||||
#include <input/KeyLayoutMap.h>
|
||||
#include <input/VirtualKeyMap.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <statslog.h>
|
||||
#include <utils/Errors.h>
|
||||
#include <utils/Log.h>
|
||||
#include <utils/Timers.h>
|
||||
|
@ -1461,7 +1462,7 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz
|
|||
for (auto it = mUnattachedVideoDevices.begin(); it != mUnattachedVideoDevices.end();
|
||||
it++) {
|
||||
std::unique_ptr<TouchVideoDevice>& videoDevice = *it;
|
||||
if (tryAddVideoDevice(*device, videoDevice)) {
|
||||
if (tryAddVideoDeviceLocked(*device, videoDevice)) {
|
||||
// videoDevice was transferred to 'device'
|
||||
it = mUnattachedVideoDevices.erase(it);
|
||||
break;
|
||||
|
@ -1771,6 +1772,13 @@ void EventHub::unregisterVideoDeviceFromEpollLocked(const TouchVideoDevice& vide
|
|||
}
|
||||
}
|
||||
|
||||
void EventHub::reportDeviceAddedForStatisticsLocked(const InputDeviceIdentifier& identifier,
|
||||
Flags<InputDeviceClass> classes) {
|
||||
android::util::stats_write(android::util::INPUTDEVICE_REGISTERED, identifier.name.c_str(),
|
||||
identifier.vendor, identifier.product, identifier.version,
|
||||
identifier.bus, identifier.uniqueId.c_str(), classes.get());
|
||||
}
|
||||
|
||||
void EventHub::openDeviceLocked(const std::string& devicePath) {
|
||||
// If an input device happens to register around the time when EventHub's constructor runs, it
|
||||
// is possible that the same input event node (for example, /dev/input/event3) will be noticed
|
||||
|
@ -2076,7 +2084,7 @@ void EventHub::openVideoDeviceLocked(const std::string& devicePath) {
|
|||
}
|
||||
// Transfer ownership of this video device to a matching input device
|
||||
for (const auto& [id, device] : mDevices) {
|
||||
if (tryAddVideoDevice(*device, videoDevice)) {
|
||||
if (tryAddVideoDeviceLocked(*device, videoDevice)) {
|
||||
return; // 'device' now owns 'videoDevice'
|
||||
}
|
||||
}
|
||||
|
@ -2088,8 +2096,8 @@ void EventHub::openVideoDeviceLocked(const std::string& devicePath) {
|
|||
mUnattachedVideoDevices.push_back(std::move(videoDevice));
|
||||
}
|
||||
|
||||
bool EventHub::tryAddVideoDevice(EventHub::Device& device,
|
||||
std::unique_ptr<TouchVideoDevice>& videoDevice) {
|
||||
bool EventHub::tryAddVideoDeviceLocked(EventHub::Device& device,
|
||||
std::unique_ptr<TouchVideoDevice>& videoDevice) {
|
||||
if (videoDevice->getName() != device.identifier.name) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2163,6 +2171,7 @@ void EventHub::createVirtualKeyboardLocked() {
|
|||
}
|
||||
|
||||
void EventHub::addDeviceLocked(std::unique_ptr<Device> device) {
|
||||
reportDeviceAddedForStatisticsLocked(device->identifier, device->classes);
|
||||
mOpeningDevices.push_back(std::move(device));
|
||||
}
|
||||
|
||||
|
|
|
@ -570,8 +570,8 @@ private:
|
|||
/**
|
||||
* Create a new device for the provided path.
|
||||
*/
|
||||
void openDeviceLocked(const std::string& devicePath);
|
||||
void openVideoDeviceLocked(const std::string& devicePath);
|
||||
void openDeviceLocked(const std::string& devicePath) REQUIRES(mLock);
|
||||
void openVideoDeviceLocked(const std::string& devicePath) REQUIRES(mLock);
|
||||
/**
|
||||
* Try to associate a video device with an input device. If the association succeeds,
|
||||
* the videoDevice is moved into the input device. 'videoDevice' will become null if this
|
||||
|
@ -579,39 +579,42 @@ private:
|
|||
* Return true if the association succeeds.
|
||||
* Return false otherwise.
|
||||
*/
|
||||
bool tryAddVideoDevice(Device& device, std::unique_ptr<TouchVideoDevice>& videoDevice);
|
||||
void createVirtualKeyboardLocked();
|
||||
void addDeviceLocked(std::unique_ptr<Device> device);
|
||||
void assignDescriptorLocked(InputDeviceIdentifier& identifier);
|
||||
bool tryAddVideoDeviceLocked(Device& device, std::unique_ptr<TouchVideoDevice>& videoDevice)
|
||||
REQUIRES(mLock);
|
||||
void createVirtualKeyboardLocked() REQUIRES(mLock);
|
||||
void addDeviceLocked(std::unique_ptr<Device> device) REQUIRES(mLock);
|
||||
void assignDescriptorLocked(InputDeviceIdentifier& identifier) REQUIRES(mLock);
|
||||
|
||||
void closeDeviceByPathLocked(const std::string& devicePath);
|
||||
void closeVideoDeviceByPathLocked(const std::string& devicePath);
|
||||
void closeDeviceLocked(Device& device);
|
||||
void closeAllDevicesLocked();
|
||||
void closeDeviceByPathLocked(const std::string& devicePath) REQUIRES(mLock);
|
||||
void closeVideoDeviceByPathLocked(const std::string& devicePath) REQUIRES(mLock);
|
||||
void closeDeviceLocked(Device& device) REQUIRES(mLock);
|
||||
void closeAllDevicesLocked() REQUIRES(mLock);
|
||||
|
||||
status_t registerFdForEpoll(int fd);
|
||||
status_t unregisterFdFromEpoll(int fd);
|
||||
status_t registerDeviceForEpollLocked(Device& device);
|
||||
void registerVideoDeviceForEpollLocked(const TouchVideoDevice& videoDevice);
|
||||
status_t unregisterDeviceFromEpollLocked(Device& device);
|
||||
void unregisterVideoDeviceFromEpollLocked(const TouchVideoDevice& videoDevice);
|
||||
status_t registerDeviceForEpollLocked(Device& device) REQUIRES(mLock);
|
||||
void registerVideoDeviceForEpollLocked(const TouchVideoDevice& videoDevice) REQUIRES(mLock);
|
||||
status_t unregisterDeviceFromEpollLocked(Device& device) REQUIRES(mLock);
|
||||
void unregisterVideoDeviceFromEpollLocked(const TouchVideoDevice& videoDevice) REQUIRES(mLock);
|
||||
|
||||
status_t scanDirLocked(const std::string& dirname);
|
||||
status_t scanVideoDirLocked(const std::string& dirname);
|
||||
void scanDevicesLocked();
|
||||
status_t readNotifyLocked();
|
||||
status_t scanDirLocked(const std::string& dirname) REQUIRES(mLock);
|
||||
status_t scanVideoDirLocked(const std::string& dirname) REQUIRES(mLock);
|
||||
void scanDevicesLocked() REQUIRES(mLock);
|
||||
status_t readNotifyLocked() REQUIRES(mLock);
|
||||
|
||||
Device* getDeviceByDescriptorLocked(const std::string& descriptor) const;
|
||||
Device* getDeviceLocked(int32_t deviceId) const;
|
||||
Device* getDeviceByPathLocked(const std::string& devicePath) const;
|
||||
Device* getDeviceByDescriptorLocked(const std::string& descriptor) const REQUIRES(mLock);
|
||||
Device* getDeviceLocked(int32_t deviceId) const REQUIRES(mLock);
|
||||
Device* getDeviceByPathLocked(const std::string& devicePath) const REQUIRES(mLock);
|
||||
/**
|
||||
* Look through all available fd's (both for input devices and for video devices),
|
||||
* and return the device pointer.
|
||||
*/
|
||||
Device* getDeviceByFdLocked(int fd) const;
|
||||
Device* getDeviceByFdLocked(int fd) const REQUIRES(mLock);
|
||||
|
||||
int32_t getNextControllerNumberLocked(const std::string& name);
|
||||
void releaseControllerNumberLocked(int32_t num);
|
||||
int32_t getNextControllerNumberLocked(const std::string& name) REQUIRES(mLock);
|
||||
void releaseControllerNumberLocked(int32_t num) REQUIRES(mLock);
|
||||
void reportDeviceAddedForStatisticsLocked(const InputDeviceIdentifier& identifier,
|
||||
Flags<InputDeviceClass> classes) REQUIRES(mLock);
|
||||
|
||||
// Protect all internal state.
|
||||
mutable std::mutex mLock;
|
||||
|
|
Loading…
Reference in a new issue