diff options
| -rw-r--r-- | include/input/InputDevice.h | 3 | ||||
| -rw-r--r-- | services/inputflinger/reader/EventHub.cpp | 3 | ||||
| -rw-r--r-- | services/inputflinger/reader/controller/PeripheralController.cpp | 11 | ||||
| -rw-r--r-- | services/inputflinger/reader/include/EventHub.h | 2 | ||||
| -rw-r--r-- | services/inputflinger/tests/InputReader_test.cpp | 22 |
5 files changed, 36 insertions, 5 deletions
diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h index 57b659d9ee..663c0c4bcb 100644 --- a/include/input/InputDevice.h +++ b/include/input/InputDevice.h @@ -128,8 +128,9 @@ enum class InputDeviceLightType : int32_t { INPUT = 0, PLAYER_ID = 1, KEYBOARD_BACKLIGHT = 2, + KEYBOARD_MIC_MUTE = 3, - ftl_last = KEYBOARD_BACKLIGHT + ftl_last = KEYBOARD_MIC_MUTE }; enum class InputDeviceLightCapability : uint32_t { diff --git a/services/inputflinger/reader/EventHub.cpp b/services/inputflinger/reader/EventHub.cpp index 3ca691efba..fe70a51b81 100644 --- a/services/inputflinger/reader/EventHub.cpp +++ b/services/inputflinger/reader/EventHub.cpp @@ -123,7 +123,8 @@ static const std::unordered_map<std::string, InputLightClass> LIGHT_CLASSES = {"multi_index", InputLightClass::MULTI_INDEX}, {"multi_intensity", InputLightClass::MULTI_INTENSITY}, {"max_brightness", InputLightClass::MAX_BRIGHTNESS}, - {"kbd_backlight", InputLightClass::KEYBOARD_BACKLIGHT}}; + {"kbd_backlight", InputLightClass::KEYBOARD_BACKLIGHT}, + {"mic_mute", InputLightClass::KEYBOARD_MIC_MUTE}}; // Mapping for input multicolor led class node names. // https://www.kernel.org/doc/html/latest/leds/leds-class-multicolor.html diff --git a/services/inputflinger/reader/controller/PeripheralController.cpp b/services/inputflinger/reader/controller/PeripheralController.cpp index eabf591dbf..27b9d23ff5 100644 --- a/services/inputflinger/reader/controller/PeripheralController.cpp +++ b/services/inputflinger/reader/controller/PeripheralController.cpp @@ -505,9 +505,14 @@ void PeripheralController::configureLights() { // Check the rest of raw light infos for (const auto& [rawId, rawInfo] : rawInfos) { - InputDeviceLightType type = keyboardBacklightIds.find(rawId) != keyboardBacklightIds.end() - ? InputDeviceLightType::KEYBOARD_BACKLIGHT - : InputDeviceLightType::INPUT; + InputDeviceLightType type; + if (keyboardBacklightIds.find(rawId) != keyboardBacklightIds.end()) { + type = InputDeviceLightType::KEYBOARD_BACKLIGHT; + } else if (rawInfo.flags.test(InputLightClass::KEYBOARD_MIC_MUTE)) { + type = InputDeviceLightType::KEYBOARD_MIC_MUTE; + } else { + type = InputDeviceLightType::INPUT; + } // If the node is multi-color led, construct a MULTI_COLOR light if (rawInfo.flags.test(InputLightClass::MULTI_INDEX) && diff --git a/services/inputflinger/reader/include/EventHub.h b/services/inputflinger/reader/include/EventHub.h index a7e06756d0..39d2f5baab 100644 --- a/services/inputflinger/reader/include/EventHub.h +++ b/services/inputflinger/reader/include/EventHub.h @@ -177,6 +177,8 @@ enum class InputLightClass : uint32_t { MAX_BRIGHTNESS = 0x00000080, /* The input light has kbd_backlight name */ KEYBOARD_BACKLIGHT = 0x00000100, + /* The input light has mic_mute name */ + KEYBOARD_MIC_MUTE = 0x00000200, }; enum class InputBatteryClass : uint32_t { diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp index 1d46c9a1e2..cfe239e414 100644 --- a/services/inputflinger/tests/InputReader_test.cpp +++ b/services/inputflinger/tests/InputReader_test.cpp @@ -10598,6 +10598,28 @@ TEST_F(LightControllerTest, MonoLight) { ASSERT_EQ(controller.getLightColor(lights[0].id).value_or(-1), LIGHT_BRIGHTNESS); } +TEST_F(LightControllerTest, MonoKeyboardMuteLight) { + RawLightInfo infoMono = {.id = 1, + .name = "mono_keyboard_mute", + .maxBrightness = 255, + .flags = InputLightClass::BRIGHTNESS | + InputLightClass::KEYBOARD_MIC_MUTE, + .path = ""}; + mFakeEventHub->addRawLightInfo(infoMono.id, std::move(infoMono)); + + PeripheralController& controller = addControllerAndConfigure<PeripheralController>(); + std::list<NotifyArgs> unused = + mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), + /*changes=*/{}); + + InputDeviceInfo info; + controller.populateDeviceInfo(&info); + std::vector<InputDeviceLightInfo> lights = info.getLights(); + ASSERT_EQ(1U, lights.size()); + ASSERT_EQ(InputDeviceLightType::KEYBOARD_MIC_MUTE, lights[0].type); + ASSERT_EQ(0U, lights[0].preferredBrightnessLevels.size()); +} + TEST_F(LightControllerTest, MonoKeyboardBacklight) { RawLightInfo infoMono = {.id = 1, .name = "mono_keyboard_backlight", |