summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-02-20 14:45:59 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-02-20 14:45:59 +0000
commitb22e2fcc53268690d919466b8785f7194e74a77d (patch)
tree772593ef8d4adb6c96de32a89d8f5876ae17918d
parentb8cdd7cd92e97f25cfd82ebde91e543367b10aae (diff)
parentc7c14bd8d4232b4680500ebf1b5cc4506eb30b4a (diff)
downloadyukawa-b22e2fcc53268690d919466b8785f7194e74a77d.tar.gz
Merge "Implement stable AIDL lights HAL for Yukawa" am: 2c826915fe am: 298dd1ae1d am: c7c14bd8d4
Change-Id: I6ee9741af9e9ff899030306de8c0c00aa759f54e
-rw-r--r--device-yukawa.mk5
-rw-r--r--lights/Android.bp14
-rw-r--r--lights/Android.mk29
-rw-r--r--lights/lights.c370
-rw-r--r--lights/lights.cpp215
-rw-r--r--lights/lights.rc7
-rw-r--r--lights/lights.xml6
-rw-r--r--sepolicy/file_contexts1
-rw-r--r--yukawa/BoardConfig.mk1
-rw-r--r--yukawa/manifest.xml11
10 files changed, 245 insertions, 414 deletions
diff --git a/device-yukawa.mk b/device-yukawa.mk
index c77439e..ef1b744 100644
--- a/device-yukawa.mk
+++ b/device-yukawa.mk
@@ -7,9 +7,8 @@ $(call inherit-product, device/amlogic/yukawa/device-common.mk)
ifeq ($(TARGET_VIM3L),)
# Light HAL
PRODUCT_PACKAGES += \
- lights.yukawa \
- android.hardware.light@2.0-impl:64 \
- android.hardware.light@2.0-service
+ android.hardware.light-service \
+ lights-yukawa
PRODUCT_PROPERTY_OVERRIDES += ro.hardware.lights=yukawa
diff --git a/lights/Android.bp b/lights/Android.bp
new file mode 100644
index 0000000..46c7712
--- /dev/null
+++ b/lights/Android.bp
@@ -0,0 +1,14 @@
+cc_binary {
+ name: "lights-yukawa",
+ relative_install_path: "hw",
+ init_rc: ["lights.rc"],
+ vintf_fragments: ["lights.xml"],
+ vendor: true,
+ shared_libs: [
+ "libbase",
+ "libbinder_ndk",
+ "android.hardware.light-ndk_platform",
+ ],
+
+ srcs: ["lights.cpp"],
+}
diff --git a/lights/Android.mk b/lights/Android.mk
deleted file mode 100644
index 14b1715..0000000
--- a/lights/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := lights.c
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MULTILIB := first
-LOCAL_HEADER_LIBRARIES := libhardware_headers
-LOCAL_SHARED_LIBRARIES := libc libcutils liblog
-LOCAL_CFLAGS += -Wall -Werror
-LOCAL_MODULE := lights.yukawa
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/lights/lights.c b/lights/lights.c
deleted file mode 100644
index da8203e..0000000
--- a/lights/lights.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#include <cutils/properties.h>
-#include <log/log.h>
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-
-#include <linux/i2c-dev.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-
-#include <hardware/lights.h>
-
-static pthread_once_t g_init = PTHREAD_ONCE_INIT;
-static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
-
-char const*const RED_LED_FILE =
- "/sys/class/leds/sei610:red:power/brightness";
-
-char const*const BLUE_LED_FILE =
- "/sys/class/leds/sei610:blue:bt/brightness";
-
-#define LA_P0_ENABLE 0x12
-#define LA_P1_ENABLE 0x13
-#define LA_RED0_ADDR 0x20
-#define LA_GREEN0_ADDR 0x21
-#define LA_BLUE0_ADDR 0x22
-#define LA_RED1_ADDR 0x23
-#define LA_GREEN1_ADDR 0x24
-#define LA_BLUE1_ADDR 0x25
-#define LA_RED2_ADDR 0x26
-#define LA_GREEN2_ADDR 0x27
-#define LA_BLUE2_ADDR 0x28
-#define LA_RED3_ADDR 0x29
-#define LA_GREEN3_ADDR 0x2A
-#define LA_BLUE3_ADDR 0x2B
-#define LA_RESET_ADDR 0x7F
-char const*const ARRAY_LED_DEVICE = "/dev/i2c-0";
-const int i2c_dev_addr = (0xB6 >> 1); /* 0x5B */
-
-struct yukawa_light_device_t {
- struct light_device_t hw_device;
- struct light_state_t state;
- int fd;
- pthread_mutex_t la_lock;
- pthread_cond_t la_cv;
- pthread_t la_thread;
- int la_end;
-};
-
-/**
- * device methods
- */
-
-void init_globals(void)
-{
- pthread_mutex_init(&g_lock, NULL);
-}
-
-static int sys_write_int(int fd, int value)
-{
- char buffer[16];
- size_t bytes;
- ssize_t amount;
-
- bytes = snprintf(buffer, sizeof(buffer), "%d\n", value);
- if (bytes >= sizeof(buffer))
- return -EINVAL;
- amount = write(fd, buffer, bytes);
- return amount == -1 ? -errno : 0;
-}
-
-static int rgb_to_brightness(struct light_state_t const* state)
-{
- int color = state->color & 0x00ffffff;
- return ((77*((color>>16)&0x00ff)) +
- (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;
-}
-
-static int set_light_bluetooth(struct light_device_t* dev,
- struct light_state_t const* state)
-{
- struct yukawa_light_device_t* ldev = (struct yukawa_light_device_t*)dev;
- int blue = rgb_to_brightness(state);
-
- pthread_mutex_lock(&g_lock);
- if (ldev->fd <= 0) {
- ldev->fd = open(BLUE_LED_FILE, O_WRONLY);
- if (ldev->fd < 0) {
- pthread_mutex_unlock(&g_lock);
- return -errno;
- }
- }
- ldev->state = *state;
- sys_write_int(ldev->fd, blue);
- pthread_mutex_unlock(&g_lock);
- return 0;
-}
-
-static int set_light_battery(struct light_device_t* dev,
- struct light_state_t const* state)
-{
- struct yukawa_light_device_t* ldev = (struct yukawa_light_device_t*)dev;
- int red = rgb_to_brightness(state);
-
- pthread_mutex_lock(&g_lock);
- if (ldev->fd <= 0) {
- ldev->fd = open(RED_LED_FILE, O_WRONLY);
- if (ldev->fd < 0) {
- pthread_mutex_unlock(&g_lock);
- return -errno;
- }
- }
- ldev->state = *state;
- sys_write_int(ldev->fd, red);
- pthread_mutex_unlock(&g_lock);
- return 0;
-}
-
-static int write8reg8(int fd, uint8_t regaddr, uint8_t cmd)
-{
- uint8_t buf[2];
-
- buf[0] = regaddr;
- buf[1] = cmd;
- if (write(fd, buf, 2) != 2)
- return -1;
- return 0;
-}
-
-void *led_array_thread_loop(void *context)
-{
- struct yukawa_light_device_t* ldev = (struct yukawa_light_device_t*)context;
- useconds_t la_sleep;
- unsigned int i = 0;
-
- while (1) {
- pthread_mutex_lock(&ldev->la_lock);
- write8reg8(ldev->fd, LA_P0_ENABLE, 0xFF);
- write8reg8(ldev->fd, LA_P1_ENABLE, 0xFF);
- if (ldev->la_end == 1) {
- ALOGE("%s: Exit", __func__);
- break;
- }
- if (ldev->state.flashMode == LIGHT_FLASH_TIMED) {
- switch (i & 0x3) {
- case 3: /* LED4: P0_5, P0_6, P0_7 */
- write8reg8(ldev->fd, LA_P0_ENABLE, 0x1F);
- break;
- case 2: /* LED3: P0_2, P0_3, P0_4 */
- write8reg8(ldev->fd, LA_P0_ENABLE, 0xE3);
- break;
- case 1: /* LED2: P1_3, P0_0, P0_1 */
- write8reg8(ldev->fd, LA_P0_ENABLE, 0xFC);
- write8reg8(ldev->fd, LA_P1_ENABLE, 0xF7);
- break;
- case 0: /* LED1: P1_0, P1_1, P1_2 */
- write8reg8(ldev->fd, LA_P1_ENABLE, 0xF8);
- break;
- }
- i = (i == 3) ? 0 : i + 1;
- la_sleep = ldev->state.flashOnMS * 1000;
- } else {
- if (ldev->state.color != 0) {
- write8reg8(ldev->fd, LA_P0_ENABLE, 0x00);
- write8reg8(ldev->fd, LA_P1_ENABLE, 0x00);
- }
- pthread_cond_wait(&ldev->la_cv, &ldev->la_lock);
- la_sleep = 0;
- }
- pthread_mutex_unlock(&ldev->la_lock);
- usleep(la_sleep);
- }
- pthread_mutex_unlock(&ldev->la_lock);
- return NULL;
-}
-
-static int set_array_light_unlocked(struct light_device_t* dev,
- struct light_state_t const* state)
-{ /* Color format is ARGB */
- struct yukawa_light_device_t* ldev = (struct yukawa_light_device_t*)dev;
- int red, green, blue, fmode;
-
- ALOGD("%s mode %d, colorRGB=%08X, onMS=%d, offMS=%d\n",
- __func__, state->flashMode, state->color, state->flashOnMS,
- state->flashOffMS);
-
- if (ldev->fd <= 0)
- return -1;
-
- pthread_mutex_lock(&ldev->la_lock);
-
- fmode = ldev->state.flashMode;
- ldev->state = *state;
-
- red = (state->color >> 16) & 0xFF;
- green = (state->color >> 8) & 0xFF;
- blue = state->color & 0xFF;
-
- write8reg8(ldev->fd, LA_RED0_ADDR, red);
- write8reg8(ldev->fd, LA_GREEN0_ADDR, green);
- write8reg8(ldev->fd, LA_BLUE0_ADDR, blue);
-
- write8reg8(ldev->fd, LA_RED1_ADDR, red);
- write8reg8(ldev->fd, LA_GREEN1_ADDR, green);
- write8reg8(ldev->fd, LA_BLUE1_ADDR, blue);
-
- write8reg8(ldev->fd, LA_RED2_ADDR, red);
- write8reg8(ldev->fd, LA_GREEN2_ADDR, green);
- write8reg8(ldev->fd, LA_BLUE2_ADDR, blue);
-
- write8reg8(ldev->fd, LA_RED3_ADDR, red);
- write8reg8(ldev->fd, LA_GREEN3_ADDR, green);
- write8reg8(ldev->fd, LA_BLUE3_ADDR, blue);
-
- if (fmode != LIGHT_FLASH_TIMED) {
- if (state->color == 0) {
- write8reg8(ldev->fd, LA_P0_ENABLE, 0xFF);
- write8reg8(ldev->fd, LA_P1_ENABLE, 0xFF);
- } else {
- write8reg8(ldev->fd, LA_P0_ENABLE, 0x00);
- write8reg8(ldev->fd, LA_P1_ENABLE, 0x00);
- }
- }
-
- if (fmode != state->flashMode)
- pthread_cond_signal(&ldev->la_cv);
- pthread_mutex_unlock(&ldev->la_lock);
-
- return 0;
-}
-
-static int set_light_notifications(struct light_device_t* dev,
- struct light_state_t const* state)
-{
- struct yukawa_light_device_t* ldev = (struct yukawa_light_device_t*)dev;
- int ret;
-
- pthread_mutex_lock(&g_lock);
- if (ldev->fd <= 0) {
- ldev->fd = open(ARRAY_LED_DEVICE, O_RDWR);
- if (ldev->fd < 0) {
- pthread_mutex_unlock(&g_lock);
- return -errno;
- }
- if (ioctl(ldev->fd, I2C_SLAVE, i2c_dev_addr) < 0) {
- ALOGE("%s: Error setting slave addr\n", __func__);
- close(ldev->fd);
- ldev->fd = 0;
- pthread_mutex_unlock(&g_lock);
- return -errno;
- }
- write8reg8(ldev->fd, LA_RESET_ADDR, 0x00);
- }
-
- if (ldev->la_thread == 0) {
- pthread_cond_init(&ldev->la_cv, NULL);
- pthread_mutex_init(&ldev->la_lock, NULL);
- pthread_create(&ldev->la_thread, (const pthread_attr_t *)NULL,
- led_array_thread_loop, dev);
- }
-
- ret = set_array_light_unlocked(dev, state);
- pthread_mutex_unlock(&g_lock);
- return ret;
-}
-
-static int set_light_attention(struct light_device_t* dev,
- struct light_state_t const* state)
-{
- set_light_notifications(dev, state);
- return 0;
-}
-
-/** Close the lights device */
-static int close_lights(struct light_device_t* dev)
-{
- struct yukawa_light_device_t* ldev = (struct yukawa_light_device_t*)dev;
-
- if (ldev) {
- if (ldev->la_thread > 0) {
- pthread_mutex_lock(&ldev->la_lock);
- ldev->la_end = 1;
- pthread_cond_signal(&ldev->la_cv);
- pthread_mutex_unlock(&ldev->la_lock);
- pthread_join(ldev->la_thread, NULL);
- }
- if (ldev->fd > 0)
- close(ldev->fd);
- free(ldev);
- }
- return 0;
-}
-
-/*
- * module methods
- */
-
-/* Open a new instance of a lights device using name */
-static int open_lights(const struct hw_module_t* module, char const* name,
- struct hw_device_t** device)
-{
- int (*set_light)(struct light_device_t* dev,
- struct light_state_t const* state);
- struct yukawa_light_device_t *ldev;
-
- if (strcmp(LIGHT_ID_BATTERY, name) == 0)
- set_light = set_light_battery;
- else if (strcmp(LIGHT_ID_BLUETOOTH, name) == 0)
- set_light = set_light_bluetooth;
- else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name))
- set_light = set_light_notifications;
- else if (0 == strcmp(LIGHT_ID_ATTENTION, name))
- set_light = set_light_attention;
- else
- return -EINVAL;
-
- pthread_once(&g_init, init_globals);
-
- ldev = calloc(1, sizeof(struct yukawa_light_device_t));
-
- if (!ldev)
- return -ENOMEM;
-
- ldev->hw_device.common.tag = HARDWARE_DEVICE_TAG;
- ldev->hw_device.common.version = LIGHTS_DEVICE_API_VERSION_2_0;
- ldev->hw_device.common.module = (struct hw_module_t*)module;
- ldev->hw_device.common.close = (int (*)(struct hw_device_t*))close_lights;
- ldev->hw_device.set_light = set_light;
-
- *device = (struct hw_device_t*)ldev;
- return 0;
-}
-
-static struct hw_module_methods_t lights_module_methods = {
- .open = open_lights,
-};
-
-/*
- * The lights Module
- */
-struct hw_module_t HAL_MODULE_INFO_SYM = {
- .tag = HARDWARE_MODULE_TAG,
- .version_major = 1,
- .version_minor = 0,
- .id = LIGHTS_HARDWARE_MODULE_ID,
- .name = "Lights Module",
- .author = "Google, Inc.",
- .methods = &lights_module_methods,
-};
diff --git a/lights/lights.cpp b/lights/lights.cpp
new file mode 100644
index 0000000..44f0655
--- /dev/null
+++ b/lights/lights.cpp
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <array>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <linux/i2c-dev.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+
+#include <aidl/android/hardware/light/BnLights.h>
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+
+using ::aidl::android::hardware::light::BnLights;
+using ::aidl::android::hardware::light::HwLight;
+using ::aidl::android::hardware::light::HwLightState;
+using ::aidl::android::hardware::light::ILights;
+using ::aidl::android::hardware::light::LightType;
+using ::ndk::ScopedAStatus;
+using ::ndk::SharedRefBase;
+
+static pthread_once_t g_init = PTHREAD_ONCE_INIT;
+static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
+
+struct LightAddress {
+ uint8_t red;
+ uint8_t green;
+ uint8_t blue;
+};
+
+char const* const RED_LED_FILE = "/sys/class/leds/sei610:red:power/brightness";
+
+char const* const BLUE_LED_FILE = "/sys/class/leds/sei610:blue:bt/brightness";
+
+std::array<LightAddress, 4> const lightAddrs = {
+ LightAddress{0x20, 0x21, 0x22}, LightAddress{0x23, 0x24, 0x25},
+ LightAddress{0x26, 0x27, 0x28}, LightAddress{0x29, 0x2A, 0x2B}};
+
+#define LA_P0_ENABLE 0x12
+#define LA_P1_ENABLE 0x13
+#define LA_RESET_ADDR 0x7F
+char const* const ARRAY_LED_DEVICE = "/dev/i2c-0";
+const int i2c_dev_addr = (0xB6 >> 1); /* 0x5B */
+
+static int sys_write_int(int fd, int value) {
+ char buffer[16];
+ size_t bytes;
+ ssize_t amount;
+
+ bytes = snprintf(buffer, sizeof(buffer), "%d\n", value);
+ if (bytes >= sizeof(buffer)) return -EINVAL;
+ amount = write(fd, buffer, bytes);
+ return amount == -1 ? -errno : 0;
+}
+
+static int write8reg8(int fd, uint8_t regaddr, uint8_t cmd) {
+ uint8_t buf[2];
+
+ buf[0] = regaddr;
+ buf[1] = cmd;
+ if (write(fd, buf, 2) != 2) return -1;
+ return 0;
+}
+
+class Lights : public BnLights {
+ private:
+ std::vector<HwLight> availableLights;
+
+ void addLight(LightType const type, int const ordinal) {
+ HwLight light{};
+ light.id = availableLights.size();
+ light.type = type;
+ light.ordinal = ordinal;
+ availableLights.emplace_back(light);
+ }
+
+ int rgbToBrightness(int color) {
+ int const r = ((color >> 16) & 0xFF) * 77 / 255;
+ int const g = ((color >> 8) & 0xFF) * 150 / 255;
+ int const b = (color & 0xFF) * 29 / 255;
+ return (r << 16) | (g << 8) | b;
+ }
+
+ int writeLedArray(const char* path, LightAddress const& addr, int color) {
+ int const fd = open(path, O_RDWR);
+ if (fd < 0) {
+ LOG(ERROR) << "COULD NOT OPEN ARRAY_LED_DEVICE " << path;
+ return fd;
+ }
+ if (ioctl(fd, I2C_SLAVE, i2c_dev_addr) < 0) {
+ LOG(ERROR) << "Error setting slave addr";
+ close(fd);
+ return -errno;
+ }
+
+ write8reg8(fd, addr.red, ((color >> 16) & 0xFF));
+ write8reg8(fd, addr.green, ((color >> 8) & 0xFF));
+ write8reg8(fd, addr.blue, (color)&0xFF);
+
+ write8reg8(fd, LA_P0_ENABLE, 0x00);
+ write8reg8(fd, LA_P1_ENABLE, 0x00);
+
+ close(fd);
+ return 0;
+ }
+
+ void writeLed(const char* path, int color) {
+ int fd = open(path, O_WRONLY);
+ if (fd < 0) {
+ LOG(ERROR) << "COULD NOT OPEN LED_DEVICE " << path;
+ return;
+ }
+
+ sys_write_int(fd, color);
+ close(fd);
+ }
+
+ public:
+ Lights() : BnLights() {
+ pthread_mutex_init(&g_lock, NULL);
+
+ addLight(LightType::BACKLIGHT, 0);
+ addLight(LightType::KEYBOARD, 0);
+ addLight(LightType::BUTTONS, 0);
+ addLight(LightType::BATTERY, 0);
+ addLight(LightType::NOTIFICATIONS, 0);
+ addLight(LightType::ATTENTION, 0);
+ addLight(LightType::BLUETOOTH, 0);
+ addLight(LightType::WIFI, 0);
+
+ for (int i = 0; i < 4; i++) {
+ addLight(LightType::MICROPHONE, i);
+ }
+
+ writeLed(RED_LED_FILE, rgbToBrightness(0x00000000));
+ writeLed(BLUE_LED_FILE, rgbToBrightness(0xFFFFFFFF));
+ }
+
+ ScopedAStatus setLightState(int id, const HwLightState& state) override {
+ if (!(0 <= id && id < availableLights.size())) {
+ LOG(ERROR) << "Light id " << (int32_t)id << " does not exist.";
+ return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+ }
+
+ int const color = rgbToBrightness(state.color);
+ HwLight const& light = availableLights[id];
+
+ int ret = 0;
+
+ switch (light.type) {
+ case LightType::MICROPHONE:
+ ret = writeLedArray(ARRAY_LED_DEVICE, lightAddrs[light.ordinal], color);
+ break;
+ case LightType::BATTERY:
+ writeLed(RED_LED_FILE, color);
+ break;
+ case LightType::BLUETOOTH:
+ writeLed(BLUE_LED_FILE, color);
+ break;
+ }
+
+ if (ret == 0) {
+ return ScopedAStatus::ok();
+ } else {
+ return ScopedAStatus::fromServiceSpecificError(ret);
+ }
+ }
+
+ ScopedAStatus getLights(std::vector<HwLight>* lights) override {
+ for (auto i = availableLights.begin(); i != availableLights.end(); i++) {
+ lights->push_back(*i);
+ }
+ return ScopedAStatus::ok();
+ }
+};
+
+int main() {
+ ABinderProcess_setThreadPoolMaxThreadCount(0);
+
+ std::shared_ptr<Lights> light = SharedRefBase::make<Lights>();
+
+ const std::string instance = std::string() + ILights::descriptor + "/default";
+ binder_status_t status = AServiceManager_addService(light->asBinder().get(), instance.c_str());
+
+ if (status != STATUS_OK) {
+ LOG(ERROR) << "Could not register" << instance;
+ // should abort, but don't want crash loop for local testing
+ }
+
+ ABinderProcess_joinThreadPool();
+
+ return 1; // should not reach
+}
diff --git a/lights/lights.rc b/lights/lights.rc
new file mode 100644
index 0000000..b89ec96
--- /dev/null
+++ b/lights/lights.rc
@@ -0,0 +1,7 @@
+service vendor.lights-yukawa /vendor/bin/hw/lights-yukawa
+ class hal
+ user system
+ group system
+ # FIXME: actually do this
+ # shutting off lights while powering-off
+ shutdown critical
diff --git a/lights/lights.xml b/lights/lights.xml
new file mode 100644
index 0000000..db604d6
--- /dev/null
+++ b/lights/lights.xml
@@ -0,0 +1,6 @@
+<manifest version="1.0" type="device">
+ <hal format="aidl">
+ <name>android.hardware.light</name>
+ <fqname>ILights/default</fqname>
+ </hal>
+</manifest>
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 70e2ce5..d86eed3 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -19,6 +19,7 @@
# files in /vendor
/(vendor|system/vendor)/lib(64)?/hw/gralloc\.yukawa\.so u:object_r:same_process_hal_file:s0
/vendor/bin/hw/android\.hardware\.health@2\.0-service\.yukawa u:object_r:hal_health_default_exec:s0
+/vendor/bin/hw/lights-yukawa u:object_r:hal_light_default_exec:s0
# /data
/dev/block/platform/soc/ffe07000\.mmc/by-name/userdata u:object_r:userdata_block_device:s0
diff --git a/yukawa/BoardConfig.mk b/yukawa/BoardConfig.mk
index 2ce7314..8fc98c7 100644
--- a/yukawa/BoardConfig.mk
+++ b/yukawa/BoardConfig.mk
@@ -1,7 +1,6 @@
include device/amlogic/yukawa/BoardConfigCommon.mk
ifeq ($(TARGET_VIM3L),)
-DEVICE_MANIFEST_FILE += device/amlogic/yukawa/yukawa/manifest.xml
TARGET_BOOTLOADER_BOARD_NAME := sei610
else
TARGET_BOOTLOADER_BOARD_NAME := vim3l
diff --git a/yukawa/manifest.xml b/yukawa/manifest.xml
deleted file mode 100644
index 3752589..0000000
--- a/yukawa/manifest.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<manifest version="1.0" type="device" target-level="3">
- <hal format="hidl">
- <name>android.hardware.light</name>
- <transport>hwbinder</transport>
- <version>2.0</version>
- <interface>
- <name>ILight</name>
- <instance>default</instance>
- </interface>
- </hal>
-</manifest>