Loading include/input/InputDevice.h +2 −6 Original line number Original line Diff line number Diff line Loading @@ -257,13 +257,9 @@ public: return mMotionRanges; return mMotionRanges; } } const InputDeviceSensorInfo* getSensorInfo(InputDeviceSensorType type); std::vector<InputDeviceSensorInfo> getSensors(); const std::vector<InputDeviceSensorType> getSensorTypes(); std::vector<InputDeviceLightInfo> getLights(); const std::vector<int32_t> getLightIds(); const InputDeviceLightInfo* getLightInfo(int32_t id); private: private: int32_t mId; int32_t mId; Loading libs/input/InputDevice.cpp +10 −24 Original line number Original line Diff line number Diff line Loading @@ -247,36 +247,22 @@ void InputDeviceInfo::addLightInfo(const InputDeviceLightInfo& info) { mLights.insert_or_assign(info.id, info); mLights.insert_or_assign(info.id, info); } } const std::vector<InputDeviceSensorType> InputDeviceInfo::getSensorTypes() { std::vector<InputDeviceSensorInfo> InputDeviceInfo::getSensors() { std::vector<InputDeviceSensorType> types; std::vector<InputDeviceSensorInfo> infos; infos.reserve(mSensors.size()); for (const auto& [type, info] : mSensors) { for (const auto& [type, info] : mSensors) { types.push_back(type); infos.push_back(info); } } return types; return infos; } } const InputDeviceSensorInfo* InputDeviceInfo::getSensorInfo(InputDeviceSensorType type) { std::vector<InputDeviceLightInfo> InputDeviceInfo::getLights() { auto it = mSensors.find(type); std::vector<InputDeviceLightInfo> infos; if (it == mSensors.end()) { infos.reserve(mLights.size()); return nullptr; } return &it->second; } const std::vector<int32_t> InputDeviceInfo::getLightIds() { std::vector<int32_t> ids; for (const auto& [id, info] : mLights) { for (const auto& [id, info] : mLights) { ids.push_back(id); infos.push_back(info); } return ids; } const InputDeviceLightInfo* InputDeviceInfo::getLightInfo(int32_t id) { auto it = mLights.find(id); if (it == mLights.end()) { return nullptr; } } return &it->second; return infos; } } } // namespace android } // namespace android services/inputflinger/include/InputReaderBase.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -113,9 +113,9 @@ public: /* Get battery status of a particular input device. */ /* Get battery status of a particular input device. */ virtual std::optional<int32_t> getBatteryStatus(int32_t deviceId) = 0; virtual std::optional<int32_t> getBatteryStatus(int32_t deviceId) = 0; virtual std::vector<int32_t> getLightIds(int32_t deviceId) = 0; virtual std::vector<InputDeviceLightInfo> getLights(int32_t deviceId) = 0; virtual const InputDeviceLightInfo* getLightInfo(int32_t deviceId, int32_t lightId) = 0; virtual std::vector<InputDeviceSensorInfo> getSensors(int32_t deviceId) = 0; /* Return true if the device can send input events to the specified display. */ /* Return true if the device can send input events to the specified display. */ virtual bool canDispatchToDisplay(int32_t deviceId, int32_t displayId) = 0; virtual bool canDispatchToDisplay(int32_t deviceId, int32_t displayId) = 0; Loading services/inputflinger/reader/InputDevice.cpp +8 −7 Original line number Original line Diff line number Diff line Loading @@ -89,8 +89,7 @@ void InputDevice::setEnabled(bool enabled, nsecs_t when) { } } void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) { void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) { InputDeviceInfo deviceInfo; InputDeviceInfo deviceInfo = getDeviceInfo(); getDeviceInfo(&deviceInfo); dump += StringPrintf(INDENT "Device %d: %s\n", deviceInfo.getId(), dump += StringPrintf(INDENT "Device %d: %s\n", deviceInfo.getId(), deviceInfo.getDisplayName().c_str()); deviceInfo.getDisplayName().c_str()); Loading Loading @@ -417,15 +416,17 @@ void InputDevice::updateExternalStylusState(const StylusState& state) { for_each_mapper([state](InputMapper& mapper) { mapper.updateExternalStylusState(state); }); for_each_mapper([state](InputMapper& mapper) { mapper.updateExternalStylusState(state); }); } } void InputDevice::getDeviceInfo(InputDeviceInfo* outDeviceInfo) { InputDeviceInfo InputDevice::getDeviceInfo() { outDeviceInfo->initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal, InputDeviceInfo outDeviceInfo; outDeviceInfo.initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal, mHasMic); mHasMic); for_each_mapper( for_each_mapper( [outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(outDeviceInfo); }); [&outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(&outDeviceInfo); }); if (mController) { if (mController) { mController->populateDeviceInfo(outDeviceInfo); mController->populateDeviceInfo(&outDeviceInfo); } } return outDeviceInfo; } } int32_t InputDevice::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) { int32_t InputDevice::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) { Loading services/inputflinger/reader/InputReader.cpp +12 −18 Original line number Original line Diff line number Diff line Loading @@ -406,9 +406,7 @@ void InputReader::getExternalStylusDevicesLocked(std::vector<InputDeviceInfo>& o for (auto& devicePair : mDevices) { for (auto& devicePair : mDevices) { std::shared_ptr<InputDevice>& device = devicePair.second; std::shared_ptr<InputDevice>& device = devicePair.second; if (device->getClasses().test(InputDeviceClass::EXTERNAL_STYLUS) && !device->isIgnored()) { if (device->getClasses().test(InputDeviceClass::EXTERNAL_STYLUS) && !device->isIgnored()) { InputDeviceInfo info; outDevices.push_back(device->getDeviceInfo()); device->getDeviceInfo(&info); outDevices.push_back(info); } } } } } } Loading Loading @@ -498,9 +496,7 @@ std::vector<InputDeviceInfo> InputReader::getInputDevicesLocked() const { for (const auto& [device, eventHubIds] : mDeviceToEventHubIdsMap) { for (const auto& [device, eventHubIds] : mDeviceToEventHubIdsMap) { if (!device->isIgnored()) { if (!device->isIgnored()) { InputDeviceInfo info; outInputDevices.push_back(device->getDeviceInfo()); device->getDeviceInfo(&info); outInputDevices.push_back(info); } } } } return outInputDevices; return outInputDevices; Loading Loading @@ -695,28 +691,26 @@ std::optional<int32_t> InputReader::getBatteryStatus(int32_t deviceId) { return std::nullopt; return std::nullopt; } } std::vector<int32_t> InputReader::getLightIds(int32_t deviceId) { std::vector<InputDeviceLightInfo> InputReader::getLights(int32_t deviceId) { std::scoped_lock _l(mLock); std::scoped_lock _l(mLock); InputDevice* device = findInputDeviceLocked(deviceId); InputDevice* device = findInputDeviceLocked(deviceId); if (device) { if (device == nullptr) { InputDeviceInfo info; device->getDeviceInfo(&info); return info.getLightIds(); } return {}; return {}; } } const InputDeviceLightInfo* InputReader::getLightInfo(int32_t deviceId, int32_t lightId) { return device->getDeviceInfo().getLights(); } std::vector<InputDeviceSensorInfo> InputReader::getSensors(int32_t deviceId) { std::scoped_lock _l(mLock); std::scoped_lock _l(mLock); InputDevice* device = findInputDeviceLocked(deviceId); InputDevice* device = findInputDeviceLocked(deviceId); if (device) { if (device == nullptr) { InputDeviceInfo info; return {}; device->getDeviceInfo(&info); return info.getLightInfo(lightId); } } return nullptr; return device->getDeviceInfo().getSensors(); } } bool InputReader::setLightColor(int32_t deviceId, int32_t lightId, int32_t color) { bool InputReader::setLightColor(int32_t deviceId, int32_t lightId, int32_t color) { Loading Loading
include/input/InputDevice.h +2 −6 Original line number Original line Diff line number Diff line Loading @@ -257,13 +257,9 @@ public: return mMotionRanges; return mMotionRanges; } } const InputDeviceSensorInfo* getSensorInfo(InputDeviceSensorType type); std::vector<InputDeviceSensorInfo> getSensors(); const std::vector<InputDeviceSensorType> getSensorTypes(); std::vector<InputDeviceLightInfo> getLights(); const std::vector<int32_t> getLightIds(); const InputDeviceLightInfo* getLightInfo(int32_t id); private: private: int32_t mId; int32_t mId; Loading
libs/input/InputDevice.cpp +10 −24 Original line number Original line Diff line number Diff line Loading @@ -247,36 +247,22 @@ void InputDeviceInfo::addLightInfo(const InputDeviceLightInfo& info) { mLights.insert_or_assign(info.id, info); mLights.insert_or_assign(info.id, info); } } const std::vector<InputDeviceSensorType> InputDeviceInfo::getSensorTypes() { std::vector<InputDeviceSensorInfo> InputDeviceInfo::getSensors() { std::vector<InputDeviceSensorType> types; std::vector<InputDeviceSensorInfo> infos; infos.reserve(mSensors.size()); for (const auto& [type, info] : mSensors) { for (const auto& [type, info] : mSensors) { types.push_back(type); infos.push_back(info); } } return types; return infos; } } const InputDeviceSensorInfo* InputDeviceInfo::getSensorInfo(InputDeviceSensorType type) { std::vector<InputDeviceLightInfo> InputDeviceInfo::getLights() { auto it = mSensors.find(type); std::vector<InputDeviceLightInfo> infos; if (it == mSensors.end()) { infos.reserve(mLights.size()); return nullptr; } return &it->second; } const std::vector<int32_t> InputDeviceInfo::getLightIds() { std::vector<int32_t> ids; for (const auto& [id, info] : mLights) { for (const auto& [id, info] : mLights) { ids.push_back(id); infos.push_back(info); } return ids; } const InputDeviceLightInfo* InputDeviceInfo::getLightInfo(int32_t id) { auto it = mLights.find(id); if (it == mLights.end()) { return nullptr; } } return &it->second; return infos; } } } // namespace android } // namespace android
services/inputflinger/include/InputReaderBase.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -113,9 +113,9 @@ public: /* Get battery status of a particular input device. */ /* Get battery status of a particular input device. */ virtual std::optional<int32_t> getBatteryStatus(int32_t deviceId) = 0; virtual std::optional<int32_t> getBatteryStatus(int32_t deviceId) = 0; virtual std::vector<int32_t> getLightIds(int32_t deviceId) = 0; virtual std::vector<InputDeviceLightInfo> getLights(int32_t deviceId) = 0; virtual const InputDeviceLightInfo* getLightInfo(int32_t deviceId, int32_t lightId) = 0; virtual std::vector<InputDeviceSensorInfo> getSensors(int32_t deviceId) = 0; /* Return true if the device can send input events to the specified display. */ /* Return true if the device can send input events to the specified display. */ virtual bool canDispatchToDisplay(int32_t deviceId, int32_t displayId) = 0; virtual bool canDispatchToDisplay(int32_t deviceId, int32_t displayId) = 0; Loading
services/inputflinger/reader/InputDevice.cpp +8 −7 Original line number Original line Diff line number Diff line Loading @@ -89,8 +89,7 @@ void InputDevice::setEnabled(bool enabled, nsecs_t when) { } } void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) { void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) { InputDeviceInfo deviceInfo; InputDeviceInfo deviceInfo = getDeviceInfo(); getDeviceInfo(&deviceInfo); dump += StringPrintf(INDENT "Device %d: %s\n", deviceInfo.getId(), dump += StringPrintf(INDENT "Device %d: %s\n", deviceInfo.getId(), deviceInfo.getDisplayName().c_str()); deviceInfo.getDisplayName().c_str()); Loading Loading @@ -417,15 +416,17 @@ void InputDevice::updateExternalStylusState(const StylusState& state) { for_each_mapper([state](InputMapper& mapper) { mapper.updateExternalStylusState(state); }); for_each_mapper([state](InputMapper& mapper) { mapper.updateExternalStylusState(state); }); } } void InputDevice::getDeviceInfo(InputDeviceInfo* outDeviceInfo) { InputDeviceInfo InputDevice::getDeviceInfo() { outDeviceInfo->initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal, InputDeviceInfo outDeviceInfo; outDeviceInfo.initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal, mHasMic); mHasMic); for_each_mapper( for_each_mapper( [outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(outDeviceInfo); }); [&outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(&outDeviceInfo); }); if (mController) { if (mController) { mController->populateDeviceInfo(outDeviceInfo); mController->populateDeviceInfo(&outDeviceInfo); } } return outDeviceInfo; } } int32_t InputDevice::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) { int32_t InputDevice::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) { Loading
services/inputflinger/reader/InputReader.cpp +12 −18 Original line number Original line Diff line number Diff line Loading @@ -406,9 +406,7 @@ void InputReader::getExternalStylusDevicesLocked(std::vector<InputDeviceInfo>& o for (auto& devicePair : mDevices) { for (auto& devicePair : mDevices) { std::shared_ptr<InputDevice>& device = devicePair.second; std::shared_ptr<InputDevice>& device = devicePair.second; if (device->getClasses().test(InputDeviceClass::EXTERNAL_STYLUS) && !device->isIgnored()) { if (device->getClasses().test(InputDeviceClass::EXTERNAL_STYLUS) && !device->isIgnored()) { InputDeviceInfo info; outDevices.push_back(device->getDeviceInfo()); device->getDeviceInfo(&info); outDevices.push_back(info); } } } } } } Loading Loading @@ -498,9 +496,7 @@ std::vector<InputDeviceInfo> InputReader::getInputDevicesLocked() const { for (const auto& [device, eventHubIds] : mDeviceToEventHubIdsMap) { for (const auto& [device, eventHubIds] : mDeviceToEventHubIdsMap) { if (!device->isIgnored()) { if (!device->isIgnored()) { InputDeviceInfo info; outInputDevices.push_back(device->getDeviceInfo()); device->getDeviceInfo(&info); outInputDevices.push_back(info); } } } } return outInputDevices; return outInputDevices; Loading Loading @@ -695,28 +691,26 @@ std::optional<int32_t> InputReader::getBatteryStatus(int32_t deviceId) { return std::nullopt; return std::nullopt; } } std::vector<int32_t> InputReader::getLightIds(int32_t deviceId) { std::vector<InputDeviceLightInfo> InputReader::getLights(int32_t deviceId) { std::scoped_lock _l(mLock); std::scoped_lock _l(mLock); InputDevice* device = findInputDeviceLocked(deviceId); InputDevice* device = findInputDeviceLocked(deviceId); if (device) { if (device == nullptr) { InputDeviceInfo info; device->getDeviceInfo(&info); return info.getLightIds(); } return {}; return {}; } } const InputDeviceLightInfo* InputReader::getLightInfo(int32_t deviceId, int32_t lightId) { return device->getDeviceInfo().getLights(); } std::vector<InputDeviceSensorInfo> InputReader::getSensors(int32_t deviceId) { std::scoped_lock _l(mLock); std::scoped_lock _l(mLock); InputDevice* device = findInputDeviceLocked(deviceId); InputDevice* device = findInputDeviceLocked(deviceId); if (device) { if (device == nullptr) { InputDeviceInfo info; return {}; device->getDeviceInfo(&info); return info.getLightInfo(lightId); } } return nullptr; return device->getDeviceInfo().getSensors(); } } bool InputReader::setLightColor(int32_t deviceId, int32_t lightId, int32_t color) { bool InputReader::setLightColor(int32_t deviceId, int32_t lightId, int32_t color) { Loading