Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99f2c3c0 authored by DingYong's avatar DingYong Committed by Josep del Rio
Browse files

Add mic mute keyboard led. (2/2)

Change-Id: I6e18c9d99d562aec112fc8ecb3d4e916285368c6
Test: Built
parent b83e1d62
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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 {
+2 −1
Original line number Diff line number Diff line
@@ -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
+8 −3
Original line number Diff line number Diff line
@@ -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) &&
+2 −0
Original line number Diff line number Diff line
@@ -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 {
+22 −0
Original line number Diff line number Diff line
@@ -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",