blob: b256cc9a4009b113f97be99139f48d7fd592a363 [file] [log] [blame]
Jan Altensen53afa332019-07-09 22:43:47 +02001/*
2 * Copyright (C) 2019 The LineageOS Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
18#define ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
19
20#include <android/hardware/light/2.0/ILight.h>
21#include <hidl/MQDescriptor.h>
22#include <hidl/Status.h>
23#include <fstream>
24#include <unordered_map>
25#include "samsung_lights.h"
26
27namespace android {
28namespace hardware {
29namespace light {
30namespace V2_0 {
31namespace implementation {
32
33using ::android::sp;
34using ::android::hardware::hidl_array;
35using ::android::hardware::hidl_memory;
36using ::android::hardware::hidl_string;
37using ::android::hardware::hidl_vec;
38using ::android::hardware::Return;
39using ::android::hardware::Void;
40
41struct Light : public ILight {
42 Light();
43
44 Return<Status> setLight(Type type, const LightState& state) override;
45 Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override;
46
47 private:
48 void handleBacklight(const LightState& state);
49#ifdef BUTTON_BRIGHTNESS_NODE
50 void handleButtons(const LightState& state);
51#endif
52 void handleBattery(const LightState& state);
53 void handleNotifications(const LightState& state);
54 void handleAttention(const LightState& state);
55 void setNotificationLED();
56 uint32_t rgbToBrightness(const LightState& state);
57 uint32_t calibrateColor(uint32_t color, int32_t brightness);
58
59 LightState mAttentionState;
60 LightState mBatteryState;
61 LightState mNotificationState;
62
63 std::mutex mLock;
64 std::unordered_map<Type, std::function<void(const LightState&)>> mLights;
65};
66
67} // namespace implementation
68} // namespace V2_0
69} // namespace light
70} // namespace hardware
71} // namespace android
72
73#endif // ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H