2018-05-02 07:42:53 -04:00
|
|
|
/*
|
2021-04-27 06:26:32 -04:00
|
|
|
* Copyright (C) 2017-2020 The LineageOS Project
|
2018-05-02 07:42:53 -04:00
|
|
|
*
|
2021-09-12 15:27:59 -04:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2018-05-02 07:42:53 -04:00
|
|
|
*/
|
2020-04-14 17:05:38 -04:00
|
|
|
|
2021-04-27 06:26:32 -04:00
|
|
|
#pragma once
|
2018-05-02 07:42:53 -04:00
|
|
|
|
|
|
|
#include <android/hardware/light/2.0/ILight.h>
|
2020-04-14 17:05:38 -04:00
|
|
|
|
2021-04-27 06:26:32 -04:00
|
|
|
#include <unordered_map>
|
2020-04-14 03:29:09 -04:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
namespace hardware {
|
|
|
|
namespace light {
|
|
|
|
namespace V2_0 {
|
|
|
|
namespace implementation {
|
2018-05-02 07:42:53 -04:00
|
|
|
|
2021-04-27 06:26:32 -04:00
|
|
|
using ::android::hardware::Return;
|
|
|
|
using ::android::hardware::light::V2_0::ILight;
|
|
|
|
using ::android::hardware::light::V2_0::LightState;
|
|
|
|
using ::android::hardware::light::V2_0::Status;
|
|
|
|
using ::android::hardware::light::V2_0::Type;
|
|
|
|
|
2019-08-06 15:43:10 -04:00
|
|
|
class Light : public ILight {
|
2020-04-14 17:05:38 -04:00
|
|
|
public:
|
2021-04-27 06:26:32 -04:00
|
|
|
Light();
|
|
|
|
|
2020-04-14 17:05:38 -04:00
|
|
|
Return<Status> setLight(Type type, const LightState& state) override;
|
|
|
|
Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override;
|
2020-04-14 03:29:09 -04:00
|
|
|
|
2020-04-14 17:05:38 -04:00
|
|
|
private:
|
2021-04-27 06:26:32 -04:00
|
|
|
void setLightBacklight(Type type, const LightState& state);
|
|
|
|
void setLightButtons(Type type, const LightState& state);
|
|
|
|
void setLightNotification(Type type, const LightState& state);
|
|
|
|
void applyNotificationState(const LightState& state);
|
|
|
|
|
|
|
|
uint32_t max_button_brightness_;
|
|
|
|
uint32_t max_led_brightness_;
|
|
|
|
uint32_t max_screen_brightness_;
|
|
|
|
|
|
|
|
std::unordered_map<Type, std::function<void(Type type, const LightState&)>> lights_{
|
|
|
|
{Type::BACKLIGHT, [this](auto&&... args) { setLightBacklight(args...); }},
|
|
|
|
{Type::BATTERY, [this](auto&&... args) { setLightNotification(args...); }},
|
|
|
|
{Type::NOTIFICATIONS, [this](auto&&... args) { setLightNotification(args...); }}};
|
|
|
|
|
|
|
|
// Keep sorted in the order of importance.
|
|
|
|
std::array<std::pair<Type, LightState>, 2> notif_states_ = {{
|
|
|
|
{Type::NOTIFICATIONS, {}},
|
|
|
|
{Type::BATTERY, {}},
|
|
|
|
}};
|
|
|
|
|
|
|
|
std::vector<std::string> buttons_;
|
2018-05-02 07:42:53 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace implementation
|
|
|
|
} // namespace V2_0
|
|
|
|
} // namespace light
|
|
|
|
} // namespace hardware
|
|
|
|
} // namespace android
|