diff options
author | Divya Sharma <divyash@codeaurora.org> | 2020-08-19 11:05:09 -0700 |
---|---|---|
committer | Divya Sharma <divyash@codeaurora.org> | 2020-08-19 11:05:14 -0700 |
commit | 063eef3671b50b09b75f477464251e34c85ba9ed (patch) | |
tree | 09edbcb1bdbd9c3feab4ad3959d65fe2ba752076 | |
parent | 77f8677228ee7be44f9ce5ca53b2eedc5ee89560 (diff) |
Revert "Update Lights HAL to return supported lights only."
This reverts commit 77f8677228ee7be44f9ce5ca53b2eedc5ee89560.
Change-Id: I22e1829b24d8290211a2bc6b51cc84c5608b5cd0
-rw-r--r-- | lights/Lights.cpp | 24 | ||||
-rw-r--r-- | lights/Lights.h | 3 |
2 files changed, 12 insertions, 15 deletions
diff --git a/lights/Lights.cpp b/lights/Lights.cpp index 1e6f27b..aa288b0 100644 --- a/lights/Lights.cpp +++ b/lights/Lights.cpp @@ -56,34 +56,32 @@ light_device_t* getLightDevice(const char* name) { } Lights::Lights() { - std::map<int, light_device_t*> lights; + std::map<LightType, light_device_t*> lights; std::vector<HwLight> availableLights; - int lightCount =0; for(auto const &pair : kLogicalLights) { LightType type = pair.first; const char* name = pair.second; light_device_t* lightDevice = getLightDevice(name); - lightCount++; if (lightDevice != nullptr) { - HwLight hwLight{}; - hwLight.id = (int)type; - hwLight.type = type; - hwLight.ordinal = 0; - lights[hwLight.id] = lightDevice; - availableLights.emplace_back(hwLight); + lights[type] = lightDevice; } + HwLight hwLight{}; + hwLight.id = availableLights.size(); + hwLight.type = type; + hwLight.ordinal = 0; + availableLights.emplace_back(hwLight); } mAvailableLights = availableLights; mLights = lights; - maxLights = lightCount; } ndk::ScopedAStatus Lights::setLightState(int id, const HwLightState& state) { - if (id >= maxLights) { + if (id >= mAvailableLights.size()) { ALOGE("Invalid Light id : %d", id); - return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } - auto it = mLights.find(id); + HwLight const& light = mAvailableLights[id]; + auto it = mLights.find(light.type); if (it == mLights.end()) { ALOGE("Light not supported"); return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); diff --git a/lights/Lights.h b/lights/Lights.h index 89d0cfe..879ea55 100644 --- a/lights/Lights.h +++ b/lights/Lights.h @@ -33,9 +33,8 @@ class Lights : public BnLights { ndk::ScopedAStatus getLights(std::vector<HwLight>* types) override; private: - std::map<int, light_device_t*> mLights; + std::map<LightType, light_device_t*> mLights; std::vector<HwLight> mAvailableLights; - int maxLights; }; } // namespace light |