diff options
author | 2021-01-06 18:45:18 -0800 | |
---|---|---|
committer | 2021-02-22 16:19:29 -0800 | |
commit | 3fdbfef367514df07b0cf158fc24fe72aca0541f (patch) | |
tree | ef7afcbe6f8f35ccd83c55a1511019c3240b072e /libs/input/InputDevice.cpp | |
parent | 97792f96d7760311383ca9c94590d5039a025583 (diff) |
Support Inputdevice LightsManager feature in frameworks.
Add lights manager support to input frameworks.
Bug: 161633625
Test: atest LightsManagerTest, atest InputDeviceLightsManagerTest
Change-Id: Ie00357bce0f6c98e9eada5e0a79f93f48e7a4d1b
Diffstat (limited to 'libs/input/InputDevice.cpp')
-rw-r--r-- | libs/input/InputDevice.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp index 698cf6eebc..ffcc1cd93a 100644 --- a/libs/input/InputDevice.cpp +++ b/libs/input/InputDevice.cpp @@ -170,7 +170,8 @@ InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) mHasButtonUnderPad(other.mHasButtonUnderPad), mHasSensor(other.mHasSensor), mMotionRanges(other.mMotionRanges), - mSensors(other.mSensors) {} + mSensors(other.mSensors), + mLights(other.mLights) {} InputDeviceInfo::~InputDeviceInfo() { } @@ -193,6 +194,7 @@ void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t control mHasSensor = false; mMotionRanges.clear(); mSensors.clear(); + mLights.clear(); } const InputDeviceInfo::MotionRange* InputDeviceInfo::getMotionRange( @@ -229,6 +231,13 @@ void InputDeviceInfo::addSensorInfo(const InputDeviceSensorInfo& info) { mSensors.insert_or_assign(info.type, info); } +void InputDeviceInfo::addLightInfo(const InputDeviceLightInfo& info) { + if (mLights.find(info.id) != mLights.end()) { + ALOGW("Light id %d already exists, will be replaced by new light added.", info.id); + } + mLights.insert_or_assign(info.id, info); +} + const std::vector<InputDeviceSensorType> InputDeviceInfo::getSensorTypes() { std::vector<InputDeviceSensorType> types; for (const auto& [type, info] : mSensors) { @@ -245,4 +254,20 @@ const InputDeviceSensorInfo* InputDeviceInfo::getSensorInfo(InputDeviceSensorTyp return &it->second; } +const std::vector<int32_t> InputDeviceInfo::getLightIds() { + std::vector<int32_t> ids; + for (const auto& [id, info] : mLights) { + ids.push_back(id); + } + return ids; +} + +const InputDeviceLightInfo* InputDeviceInfo::getLightInfo(int32_t id) { + auto it = mLights.find(id); + if (it == mLights.end()) { + return nullptr; + } + return &it->second; +} + } // namespace android |