Loading include/input/InputDevice.h +1 −1 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ enum class InputDeviceSensorReportingMode : int32_t { }; enum class InputDeviceLightType : int32_t { SINGLE = 0, MONO = 0, PLAYER_ID = 1, RGB = 2, MULTI_COLOR = 3, Loading services/inputflinger/reader/controller/PeripheralController.cpp +8 −9 Original line number Diff line number Diff line Loading @@ -104,7 +104,7 @@ void PeripheralController::Light::setRawLightBrightness(int32_t rawLightId, int3 context.setLightBrightness(rawLightId, brightness); } bool PeripheralController::SingleLight::setLightColor(int32_t color) { bool PeripheralController::MonoLight::setLightColor(int32_t color) { int32_t brightness = getAlpha(color); setRawLightBrightness(rawId, brightness); Loading Loading @@ -148,7 +148,7 @@ bool PeripheralController::MultiColorLight::setLightColor(int32_t color) { return true; } std::optional<int32_t> PeripheralController::SingleLight::getLightColor() { std::optional<int32_t> PeripheralController::MonoLight::getLightColor() { std::optional<int32_t> brightness = getRawLightBrightness(rawId); if (!brightness.has_value()) { return std::nullopt; Loading Loading @@ -234,7 +234,7 @@ std::optional<int32_t> PeripheralController::PlayerIdLight::getLightPlayerId() { return std::nullopt; } void PeripheralController::SingleLight::dump(std::string& dump) { void PeripheralController::MonoLight::dump(std::string& dump) { dump += StringPrintf(INDENT4 "Color: 0x%x\n", getLightColor().value_or(0)); } Loading Loading @@ -423,7 +423,7 @@ void PeripheralController::configureLights() { playerIdLightIds); mLights.insert_or_assign(light->id, std::move(light)); // Remove these raw lights from raw light info as they've been used to compose a // Player ID light, so we do not expose these raw lights as single lights. // Player ID light, so we do not expose these raw lights as mono lights. for (const auto& [playerId, rawId] : playerIdLightIds) { rawInfos.erase(rawId); } Loading Loading @@ -460,13 +460,12 @@ void PeripheralController::configureLights() { mLights.insert_or_assign(light->id, std::move(light)); continue; } // Construct a single LED light // Construct a Mono LED light if (DEBUG_LIGHT_DETAILS) { ALOGD("Single light Id %d name %s \n", rawInfo.id, rawInfo.name.c_str()); ALOGD("Mono light Id %d name %s \n", rawInfo.id, rawInfo.name.c_str()); } std::unique_ptr<Light> light = std::make_unique<SingleLight>(getDeviceContext(), rawInfo.name, ++mNextId, rawInfo.id); std::unique_ptr<Light> light = std::make_unique<MonoLight>(getDeviceContext(), rawInfo.name, ++mNextId, rawInfo.id); mLights.insert_or_assign(light->id, std::move(light)); } Loading services/inputflinger/reader/controller/PeripheralController.h +4 −4 Original line number Diff line number Diff line Loading @@ -78,10 +78,10 @@ private: void setRawLightBrightness(int32_t rawLightId, int32_t brightness); }; struct SingleLight : public Light { explicit SingleLight(InputDeviceContext& context, const std::string& name, int32_t id, struct MonoLight : public Light { explicit MonoLight(InputDeviceContext& context, const std::string& name, int32_t id, int32_t rawId) : Light(context, name, id, InputDeviceLightType::SINGLE), rawId(rawId) {} : Light(context, name, id, InputDeviceLightType::MONO), rawId(rawId) {} int32_t rawId; bool setLightColor(int32_t color) override; Loading services/inputflinger/tests/InputReader_test.cpp +8 −8 Original line number Diff line number Diff line Loading @@ -8743,20 +8743,20 @@ protected: } }; TEST_F(LightControllerTest, SingleLight) { RawLightInfo infoSingle = {.id = 1, TEST_F(LightControllerTest, MonoLight) { RawLightInfo infoMono = {.id = 1, .name = "Mono", .maxBrightness = 255, .flags = InputLightClass::BRIGHTNESS, .path = ""}; mFakeEventHub->addRawLightInfo(infoSingle.id, std::move(infoSingle)); mFakeEventHub->addRawLightInfo(infoMono.id, std::move(infoMono)); PeripheralController& controller = addControllerAndConfigure<PeripheralController>(); InputDeviceInfo info; controller.populateDeviceInfo(&info); const auto& ids = info.getLightIds(); ASSERT_EQ(1UL, ids.size()); ASSERT_EQ(InputDeviceLightType::SINGLE, info.getLightInfo(ids[0])->type); ASSERT_EQ(InputDeviceLightType::MONO, info.getLightInfo(ids[0])->type); ASSERT_TRUE(controller.setLightColor(ids[0], LIGHT_BRIGHTNESS)); ASSERT_EQ(controller.getLightColor(ids[0]).value_or(-1), LIGHT_BRIGHTNESS); Loading Loading
include/input/InputDevice.h +1 −1 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ enum class InputDeviceSensorReportingMode : int32_t { }; enum class InputDeviceLightType : int32_t { SINGLE = 0, MONO = 0, PLAYER_ID = 1, RGB = 2, MULTI_COLOR = 3, Loading
services/inputflinger/reader/controller/PeripheralController.cpp +8 −9 Original line number Diff line number Diff line Loading @@ -104,7 +104,7 @@ void PeripheralController::Light::setRawLightBrightness(int32_t rawLightId, int3 context.setLightBrightness(rawLightId, brightness); } bool PeripheralController::SingleLight::setLightColor(int32_t color) { bool PeripheralController::MonoLight::setLightColor(int32_t color) { int32_t brightness = getAlpha(color); setRawLightBrightness(rawId, brightness); Loading Loading @@ -148,7 +148,7 @@ bool PeripheralController::MultiColorLight::setLightColor(int32_t color) { return true; } std::optional<int32_t> PeripheralController::SingleLight::getLightColor() { std::optional<int32_t> PeripheralController::MonoLight::getLightColor() { std::optional<int32_t> brightness = getRawLightBrightness(rawId); if (!brightness.has_value()) { return std::nullopt; Loading Loading @@ -234,7 +234,7 @@ std::optional<int32_t> PeripheralController::PlayerIdLight::getLightPlayerId() { return std::nullopt; } void PeripheralController::SingleLight::dump(std::string& dump) { void PeripheralController::MonoLight::dump(std::string& dump) { dump += StringPrintf(INDENT4 "Color: 0x%x\n", getLightColor().value_or(0)); } Loading Loading @@ -423,7 +423,7 @@ void PeripheralController::configureLights() { playerIdLightIds); mLights.insert_or_assign(light->id, std::move(light)); // Remove these raw lights from raw light info as they've been used to compose a // Player ID light, so we do not expose these raw lights as single lights. // Player ID light, so we do not expose these raw lights as mono lights. for (const auto& [playerId, rawId] : playerIdLightIds) { rawInfos.erase(rawId); } Loading Loading @@ -460,13 +460,12 @@ void PeripheralController::configureLights() { mLights.insert_or_assign(light->id, std::move(light)); continue; } // Construct a single LED light // Construct a Mono LED light if (DEBUG_LIGHT_DETAILS) { ALOGD("Single light Id %d name %s \n", rawInfo.id, rawInfo.name.c_str()); ALOGD("Mono light Id %d name %s \n", rawInfo.id, rawInfo.name.c_str()); } std::unique_ptr<Light> light = std::make_unique<SingleLight>(getDeviceContext(), rawInfo.name, ++mNextId, rawInfo.id); std::unique_ptr<Light> light = std::make_unique<MonoLight>(getDeviceContext(), rawInfo.name, ++mNextId, rawInfo.id); mLights.insert_or_assign(light->id, std::move(light)); } Loading
services/inputflinger/reader/controller/PeripheralController.h +4 −4 Original line number Diff line number Diff line Loading @@ -78,10 +78,10 @@ private: void setRawLightBrightness(int32_t rawLightId, int32_t brightness); }; struct SingleLight : public Light { explicit SingleLight(InputDeviceContext& context, const std::string& name, int32_t id, struct MonoLight : public Light { explicit MonoLight(InputDeviceContext& context, const std::string& name, int32_t id, int32_t rawId) : Light(context, name, id, InputDeviceLightType::SINGLE), rawId(rawId) {} : Light(context, name, id, InputDeviceLightType::MONO), rawId(rawId) {} int32_t rawId; bool setLightColor(int32_t color) override; Loading
services/inputflinger/tests/InputReader_test.cpp +8 −8 Original line number Diff line number Diff line Loading @@ -8743,20 +8743,20 @@ protected: } }; TEST_F(LightControllerTest, SingleLight) { RawLightInfo infoSingle = {.id = 1, TEST_F(LightControllerTest, MonoLight) { RawLightInfo infoMono = {.id = 1, .name = "Mono", .maxBrightness = 255, .flags = InputLightClass::BRIGHTNESS, .path = ""}; mFakeEventHub->addRawLightInfo(infoSingle.id, std::move(infoSingle)); mFakeEventHub->addRawLightInfo(infoMono.id, std::move(infoMono)); PeripheralController& controller = addControllerAndConfigure<PeripheralController>(); InputDeviceInfo info; controller.populateDeviceInfo(&info); const auto& ids = info.getLightIds(); ASSERT_EQ(1UL, ids.size()); ASSERT_EQ(InputDeviceLightType::SINGLE, info.getLightInfo(ids[0])->type); ASSERT_EQ(InputDeviceLightType::MONO, info.getLightInfo(ids[0])->type); ASSERT_TRUE(controller.setLightColor(ids[0], LIGHT_BRIGHTNESS)); ASSERT_EQ(controller.getLightColor(ids[0]).value_or(-1), LIGHT_BRIGHTNESS); Loading