zenfone6: Drop custom HAL light

Change-Id: I3767fdb2c775e69cacb4e0441933a50084ff3697
diff --git a/device.mk b/device.mk
index c1c5ed5..f914e72 100755
--- a/device.mk
+++ b/device.mk
@@ -129,10 +129,6 @@
     VisualizationWallpapers \
     librs_jni
 
-# Lights
-PRODUCT_PACKAGES += \
-    android.hardware.light@2.0-service.asus_msmnile
-
 # NFC - NQ (NXP)
 #PRODUCT_PACKAGES += \
     Tag \
diff --git a/lights/.clang-format b/lights/.clang-format
deleted file mode 100644
index ae4a451..0000000
--- a/lights/.clang-format
+++ /dev/null
@@ -1,11 +0,0 @@
-BasedOnStyle: Google
-AccessModifierOffset: -2
-AllowShortFunctionsOnASingleLine: Inline
-ColumnLimit: 100
-CommentPragmas: NOLINT:.*
-DerivePointerAlignment: false
-IndentWidth: 4
-PointerAlignment: Left
-TabWidth: 4
-UseTab: Never
-PenaltyExcessCharacter: 32
diff --git a/lights/Android.bp b/lights/Android.bp
deleted file mode 100644
index 34491a6..0000000
--- a/lights/Android.bp
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (C) 2018 The LineageOS 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.
-
-cc_binary {
-    name: "android.hardware.light@2.0-service.asus_msmnile",
-    defaults: ["hidl_defaults"],
-    stem: "android.hardware.light@2.0-service",
-    init_rc: ["android.hardware.light@2.0-service.rc"],
-    vendor: false,
-    product_overlay_specific: true,
-    relative_install_path: "hw",
-    srcs: ["service.cpp", "Light.cpp"],
-    shared_libs: [
-        "android.hardware.light@2.0",
-        "libbase",
-        "libhardware",
-        "libhidlbase",
-        "libhidltransport",
-        "libhwbinder",
-        "liblog",
-        "libutils",
-    ],
-    overrides: [
-        "light",
-    ],
-}
\ No newline at end of file
diff --git a/lights/Light.cpp b/lights/Light.cpp
deleted file mode 100644
index 2ffa6b1..0000000
--- a/lights/Light.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2014, 2017-2018 The  Linux Foundation. All rights reserved.
- * Not a contribution
- * Copyright (C) 2008 The Android Open Source Project
- * Copyright (C) 2018-2019 The LineageOS 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.
- */
-
-#define LOG_TAG "LightsService"
-
-#include "Light.h"
-#include <android-base/logging.h>
-#include <fstream>
-
-namespace {
-/*
- * Write value to path and close file.
- */
-template <typename T>
-static void set(const std::string& path, const T& value) {
-    std::ofstream file(path);
-
-    if (!file.is_open()) {
-        LOG(DEBUG) << "failed to open path " << path;
-        return;
-    }
-
-    file << value;
-
-    if (file.fail()) {
-        LOG(DEBUG) << "failed to write " << value
-                   << "to " << path;
-    }
-}
-
-/*
- * Read from path and close file.
- * Return def in case of any failure.
- */
-template <typename T>
-static T get(const std::string& path, const T& def) {
-    std::ifstream file(path);
-    T result;
-
-    if (!file.is_open()) {
-        LOG(DEBUG) << "failed to open path " << path;
-        return def;
-    }
-
-    file >> result;
-
-    if (file.fail()) {
-        LOG(DEBUG) << "failed to read from " << path;
-        return def;
-    }
-
-    return result;
-}
-}  // anonymous namespace
-
-namespace android {
-namespace hardware {
-namespace light {
-namespace V2_0 {
-namespace implementation {
-
-static constexpr int kDefaultMaxBrightness = 255;
-static constexpr char kBreath[] = "breath";
-static constexpr char kBrightness[] = "brightness";
-static constexpr char kDelayOff[] = "delay_off";
-static constexpr char kDelayOn[] = "delay_on";
-
-static uint32_t rgbToBrightness(const LightState& state) {
-    uint32_t color = state.color & 0x00ffffff;
-    return ((77 * ((color >> 16) & 0x00ff))
-            + (150 * ((color >> 8) & 0x00ff))
-            + (29 * (color & 0x00ff))) >> 8;
-}
-
-Light::Light() {
-    mLights.emplace(Type::ATTENTION, std::bind(&Light::handleNotification, this, std::placeholders::_1, 0));
-    mLights.emplace(Type::BACKLIGHT, std::bind(&Light::handleBacklight, this, std::placeholders::_1));
-    mLights.emplace(Type::BATTERY, std::bind(&Light::handleNotification, this, std::placeholders::_1, 1));
-    mLights.emplace(Type::NOTIFICATIONS, std::bind(&Light::handleNotification, this, std::placeholders::_1, 2));
-}
-
-void Light::handleBacklight(const LightState& state) {
-    uint32_t maxBrightness = get("/sys/class/backlight/panel0-backlight/max_brightness", kDefaultMaxBrightness);
-    uint32_t sentBrightness = rgbToBrightness(state);
-    uint32_t brightness = sentBrightness * maxBrightness / kDefaultMaxBrightness;
-    LOG(DEBUG) << "Writing backlight brightness " << brightness
-               << " (orig " << sentBrightness << ")";
-    set("/sys/class/backlight/panel0-backlight/brightness", brightness);
-}
-
-void Light::handleNotification(const LightState& state, size_t index) {
-    mLightStates.at(index) = state;
-
-    LightState stateToUse = mLightStates.front();
-    for (const auto& lightState : mLightStates) {
-        if (lightState.color & 0xffffff) {
-            stateToUse = lightState;
-            break;
-        }
-    }
-
-    std::map<std::string, int> colorValues;
-    colorValues["red"] = (stateToUse.color >> 16) & 0xff;
-    colorValues["green"] = (stateToUse.color >> 8) & 0xff;
-
-    auto makeLedPath = [](const std::string& led, const char op[]) -> std::string {
-        return "/sys/class/leds/" + led + "/" + op;
-    };
-
-    // Disable all blinking before starting
-    for (const auto& entry : colorValues) {
-        set(makeLedPath(entry.first, kBreath), 0);
-    }
-
-    if (state.flashMode == Flash::TIMED) {
-        for (const auto& entry : colorValues) {
-            set(makeLedPath(entry.first, kDelayOff), state.flashOffMs);
-            set(makeLedPath(entry.first, kDelayOn), state.flashOnMs);
-        }
-
-        // Start blinking
-        for (const auto& entry : colorValues) {
-            set(makeLedPath(entry.first, kBreath), entry.second);
-        }
-    } else {
-        for (const auto& entry : colorValues) {
-            set(makeLedPath(entry.first, kBrightness), entry.second);
-        }
-    }
-}
-
-Return<Status> Light::setLight(Type type, const LightState& state) {
-    auto it = mLights.find(type);
-
-    if (it == mLights.end()) {
-        return Status::LIGHT_NOT_SUPPORTED;
-    }
-
-    // Lock global mutex until light state is updated.
-    std::lock_guard<std::mutex> lock(mLock);
-
-    it->second(state);
-
-    return Status::SUCCESS;
-}
-
-Return<void> Light::getSupportedTypes(getSupportedTypes_cb _hidl_cb) {
-    std::vector<Type> types;
-
-    for (auto const& light : mLights) {
-        types.push_back(light.first);
-    }
-
-    _hidl_cb(types);
-
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace light
-}  // namespace hardware
-}  // namespace android
diff --git a/lights/Light.h b/lights/Light.h
deleted file mode 100644
index a19d6e6..0000000
--- a/lights/Light.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2018 The LineageOS 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.
- */
-
-#ifndef ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
-#define ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
-
-#include <android/hardware/light/2.0/ILight.h>
-#include <hardware/lights.h>
-#include <hidl/Status.h>
-#include <unordered_map>
-#include <mutex>
-
-namespace android {
-namespace hardware {
-namespace light {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-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;
-
-class Light : public ILight {
-  public:
-    Light();
-
-    Return<Status> setLight(Type type, const LightState& state) override;
-    Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override;
-
-  private:
-    void handleBacklight(const LightState& state);
-    void handleNotification(const LightState& state, size_t index);
-
-    std::mutex mLock;
-    std::unordered_map<Type, std::function<void(const LightState&)>> mLights;
-    std::array<LightState, 3> mLightStates;
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace light
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
diff --git a/lights/android.hardware.light@2.0-service.rc b/lights/android.hardware.light@2.0-service.rc
deleted file mode 100644
index b54ca95..0000000
--- a/lights/android.hardware.light@2.0-service.rc
+++ /dev/null
@@ -1,7 +0,0 @@
-service vendor.light-hal-2-0 /vendor/bin/hw/android.hardware.light@2.0-service
-    interface android.hardware.light@2.0::ILight default
-    class hal
-    user system
-    group system
-    # shutting off lights while powering-off
-    shutdown critical
diff --git a/lights/service.cpp b/lights/service.cpp
deleted file mode 100644
index 423263d..0000000
--- a/lights/service.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2018 The LineageOS 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.
- */
-
-#define LOG_TAG "android.hardware.light@2.0-service.asus_msmnile"
-
-#include <android-base/logging.h>
-#include <hidl/HidlTransportSupport.h>
-
-#include "Light.h"
-
-using android::hardware::configureRpcThreadpool;
-using android::hardware::joinRpcThreadpool;
-
-using android::hardware::light::V2_0::ILight;
-using android::hardware::light::V2_0::implementation::Light;
-
-using android::OK;
-using android::sp;
-using android::status_t;
-
-int main() {
-    status_t status;
-    sp<ILight> service = nullptr;
-
-    LOG(INFO) << "Light HAL service 2.0 is starting.";
-
-    service = new Light();
-    if (service == nullptr) {
-        LOG(ERROR) << "Can not create an instance of Light HAL Iface, exiting.";
-        goto shutdown;
-    }
-
-    configureRpcThreadpool(1, true /*callerWillJoin*/);
-
-    status = service->registerAsService();
-    if (status != OK) {
-        LOG(ERROR) << "Could not register service for Light HAL Iface (" << status << ")";
-        goto shutdown;
-    }
-
-    LOG(INFO) << "Light HAL service is ready.";
-    joinRpcThreadpool();
-    // Should not pass this line
-
-shutdown:
-    // In normal operation, we don't expect the thread pool to exit
-    LOG(ERROR) << "Light HAL service is shutting down.";
-    return 1;
-}
diff --git a/sepolicy/private/file.te b/sepolicy/private/file.te
index aea529b..6bc562f 100644
--- a/sepolicy/private/file.te
+++ b/sepolicy/private/file.te
@@ -8,10 +8,6 @@
 type voucher_file, file_type;
 type xrom_file, file_type;
 
-# Lights
-type sysfs_rg_led, sysfs_type, fs_type;
-type sysfs_graphics, sysfs_type, fs_type;
-
 # Offscreen Gestures
 type sysfs_gesture, sysfs_type, fs_type;
 type proc_touchscreen, proc_type, sysfs_type, fs_type;
diff --git a/sepolicy/private/file_contexts b/sepolicy/private/file_contexts
index d400ee9..558ea20 100644
--- a/sepolicy/private/file_contexts
+++ b/sepolicy/private/file_contexts
@@ -11,9 +11,6 @@
 /voucher(/.*)?          u:object_r:voucher_file:s0
 /xrom(/.*)?             u:object_r:xrom_file:s0
 
-# HALs
-/(product|system/product)/vendor_overlay/[0-9]+/bin/hw/android\.hardware\.light@2\.0-service	u:object_r:hal_light_default_exec:s0
-
 # Vendor overlay
 /(product|system/product)/vendor_overlay/[0-9]+/etc(/.*)?	u:object_r:vendor_configs_file:s0
 /(product|system/product)/vendor_overlay/[0-9]+/lib(64)?/hw	u:object_r:vendor_hal_file:s0
diff --git a/sepolicy/private/hal_light.te b/sepolicy/private/hal_light.te
deleted file mode 100644
index 67b5b9e..0000000
--- a/sepolicy/private/hal_light.te
+++ /dev/null
@@ -1 +0,0 @@
-allow hal_light sysfs_rg_led:file getattr;
\ No newline at end of file