From 120b62c385d21d7f2700c9960e6b67c3aecc7874 Mon Sep 17 00:00:00 2001 From: ronaxdevil Date: Fri, 29 Nov 2019 09:55:54 +0530 Subject: [PATCH] sanders: update power hal --- BoardConfig.mk | 6 +- device.mk | 2 + power/Android.mk | 17 +-- power/Power.cpp | 103 ++++++++++++++++++ power/Power.h | 74 +++++++++++++ power/android.hardware.power@1.2-service.rc | 4 + power/{power.c => power-common.c} | 82 +++----------- power/power-common.h | 22 +++- power/power-msmnile.c | 112 ++++++++++++++++++++ power/service.cpp | 81 ++++++++++++++ sepolicy/vendor/file_contexts | 6 +- 11 files changed, 427 insertions(+), 82 deletions(-) create mode 100644 power/Power.cpp create mode 100644 power/Power.h create mode 100644 power/android.hardware.power@1.2-service.rc rename power/{power.c => power-common.c} (61%) create mode 100644 power/power-msmnile.c create mode 100644 power/service.cpp diff --git a/BoardConfig.mk b/BoardConfig.mk index 4bdecc1..a1c73b2 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -78,11 +78,7 @@ TARGET_KERNEL_HEADER_ARCH := arm64 TARGET_KERNEL_CONFIG := sanders_defconfig TARGET_KERNEL_SOURCE := kernel/motorola/msm8953 TARGET_KERNEL_CLANG_COMPILE := true -#TARGET_KERNEL_CROSS_COMPILE_PREFIX := aarch64-linux-android- -#TARGET_KERNEL_CLANG_PATH := $(PWD)/prebuilts/clang/host/$(HOST_OS)-x86/clang-r353983d/bin -#TARGET_KERNEL_CLANG_VERSION := 9.0.4 -TARGET_KERNEL_CLANG_VERSION := 6194136 - +KERNEL_TOOLCHAIN_PATH := $(TOP)/prebuilts/clang/host/linux-x86/clang-r353983d/bin/clang # Audio BOARD_SUPPORTS_SOUND_TRIGGER_HAL := true diff --git a/device.mk b/device.mk index 9186038..2d426ec 100644 --- a/device.mk +++ b/device.mk @@ -335,7 +335,9 @@ PRODUCT_COPY_FILES += \ # Power PRODUCT_PACKAGES += \ + android.hardware.power@1.0-impl \ android.hardware.power@1.2-service \ + power.qcom # Powerhint configuration file PRODUCT_COPY_FILES += \ diff --git a/power/Android.mk b/power/Android.mk index a607483..662f283 100644 --- a/power/Android.mk +++ b/power/Android.mk @@ -1,30 +1,31 @@ LOCAL_PATH := $(call my-dir) -ifeq ($(call is-vendor-board-platform,QCOM),true) - # HAL module implemenation stored in # hw/..so include $(CLEAR_VARS) LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_SHARED_LIBRARIES := liblog libcutils libdl libxml2 +LOCAL_SHARED_LIBRARIES := liblog libcutils libdl libxml2 libbase libhidlbase libhidltransport libutils android.hardware.power@1.2 LOCAL_HEADER_LIBRARIES += libutils_headers LOCAL_HEADER_LIBRARIES += libhardware_headers -LOCAL_SRC_FILES := power.c metadata-parser.c utils.c list.c hint-data.c powerhintparser.c +LOCAL_SRC_FILES := power-common.c metadata-parser.c utils.c list.c hint-data.c powerhintparser.c service.cpp Power.cpp LOCAL_C_INCLUDES := external/libxml2/include \ external/icu/icu4c/source/common -# Include target-specific files. LOCAL_SRC_FILES += power-8953.c ifeq ($(TARGET_USES_INTERACTION_BOOST),true) LOCAL_CFLAGS += -DINTERACTION_BOOST endif -LOCAL_MODULE := power.qcom +ifneq ($(TARGET_TAP_TO_WAKE_NODE),) + LOCAL_CFLAGS += -DTAP_TO_WAKE_NODE=\"$(TARGET_TAP_TO_WAKE_NODE)\" +endif + +LOCAL_MODULE := android.hardware.power@1.2-service +LOCAL_INIT_RC := android.hardware.power@1.2-service.rc LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable LOCAL_VENDOR_MODULE := true -include $(BUILD_SHARED_LIBRARY) +include $(BUILD_EXECUTABLE) -endif diff --git a/power/Power.cpp b/power/Power.cpp new file mode 100644 index 0000000..b765b7f --- /dev/null +++ b/power/Power.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define LOG_TAG "QTI PowerHAL" + +#include +#include +#include "Power.h" +#include "power-common.h" + +namespace android { +namespace hardware { +namespace power { +namespace V1_2 { +namespace implementation { + +using ::android::hardware::power::V1_0::Feature; +using ::android::hardware::power::V1_0::PowerHint; +using ::android::hardware::power::V1_0::PowerStatePlatformSleepState; +using ::android::hardware::power::V1_0::Status; +using ::android::hardware::power::V1_1::PowerStateSubsystem; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; + +Power::Power() { + power_init(); +} + +Return Power::setInteractive(bool interactive) { + set_interactive(interactive ? 1:0); + return Void(); +} + +Return Power::powerHint(PowerHint_1_0 hint, int32_t data) { + + power_hint(static_cast(hint), data ? (&data) : NULL); + return Void(); +} + +Return Power::setFeature(Feature feature, bool activate) { + set_feature(static_cast(feature), activate ? 1 : 0); + return Void(); +} + +Return Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) { + + hidl_vec states; + states.resize(0); + + _hidl_cb(states, Status::SUCCESS); + return Void(); +} + +Return Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) { + + hidl_vec subsystems; + + _hidl_cb(subsystems, Status::SUCCESS); + return Void(); +} + +Return Power::powerHintAsync(PowerHint_1_0 hint, int32_t data) { + + return powerHint(hint, data); +} + +Return Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) { + + return powerHint(static_cast (hint), data); +} + +} // namespace implementation +} // namespace V1_2 +} // namespace power +} // namespace hardware +} // namespace android diff --git a/power/Power.h b/power/Power.h new file mode 100644 index 0000000..a787590 --- /dev/null +++ b/power/Power.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ANDROID_HARDWARE_POWER_V1_2_POWER_H +#define ANDROID_HARDWARE_POWER_V1_2_POWER_H + +#include +#include +#include +#include + +namespace android { +namespace hardware { +namespace power { +namespace V1_2 { +namespace implementation { + +using ::android::hardware::power::V1_0::Feature; +using PowerHint_1_0 = ::android::hardware::power::V1_0::PowerHint; +using PowerHint_1_2 = ::android::hardware::power::V1_2::PowerHint; +using ::android::hardware::power::V1_2::IPower; +using ::android::hardware::Return; +using ::android::hardware::Void; + +struct Power : public IPower { + // Methods from ::android::hardware::power::V1_0::IPower follow. + + Power(); + + Return setInteractive(bool interactive) override; + Return powerHint(PowerHint_1_0 hint, int32_t data) override; + Return setFeature(Feature feature, bool activate) override; + Return getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override; + + // Methods from ::android::hardware::power::V1_1::IPower follow + Return getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override; + Return powerHintAsync(PowerHint_1_0 hint, int32_t data) override; + // Methods from ::android::hardware::power::V1_2::IPower follow + Return powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) override; +}; + +} // namespace implementation +} // namespace V1_2 +} // namespace power +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_POWER_V1_2_POWER_H diff --git a/power/android.hardware.power@1.2-service.rc b/power/android.hardware.power@1.2-service.rc new file mode 100644 index 0000000..8a1c347 --- /dev/null +++ b/power/android.hardware.power@1.2-service.rc @@ -0,0 +1,4 @@ +service vendor.power-hal-1-2 /vendor/bin/hw/android.hardware.power@1.2-service + class hal + user system + group system diff --git a/power/power.c b/power/power-common.c similarity index 61% rename from power/power.c rename to power/power-common.c index 2206fa9..45b04e7 100644 --- a/power/power.c +++ b/power/power-common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -50,14 +50,7 @@ static struct hint_handles handles[NUM_HINTS]; -static int power_device_open(const hw_module_t* module, const char* name, - hw_device_t** device); - -static struct hw_module_methods_t power_module_methods = { - .open = power_device_open, -}; - -static void power_init(struct power_module *module) +void power_init() { ALOGI("Initing"); @@ -67,7 +60,7 @@ static void power_init(struct power_module *module) } } -int __attribute__ ((weak)) power_hint_override(struct power_module *module, power_hint_t hint, +int __attribute__ ((weak)) power_hint_override(power_hint_t hint, void *data) { return HINT_NONE; @@ -76,11 +69,10 @@ int __attribute__ ((weak)) power_hint_override(struct power_module *module, powe /* Declare function before use */ void interaction(int duration, int num_args, int opt_list[]); -static void power_hint(struct power_module *module, power_hint_t hint, - void *data) +void power_hint(power_hint_t hint, void *data) { /* Check if this hint has been overridden. */ - if (power_hint_override(module, hint, data) == HINT_HANDLED) { + if (power_hint_override(hint, data) == HINT_HANDLED) { /* The power_hint has been handled. We can skip the rest. */ return; } @@ -120,12 +112,12 @@ static void power_hint(struct power_module *module, power_hint_t hint, } } -int __attribute__ ((weak)) set_interactive_override(struct power_module *module, int on) +int __attribute__ ((weak)) set_interactive_override(int on) { return HINT_NONE; } -void set_interactive(struct power_module *module, int on) +void set_interactive(int on) { if (!on) { /* Send Display OFF hint to perf HAL */ @@ -135,63 +127,23 @@ void set_interactive(struct power_module *module, int on) perf_hint_enable(VENDOR_HINT_DISPLAY_ON, 0); } - if (set_interactive_override(module, on) == HINT_HANDLED) { + if (set_interactive_override(on) == HINT_HANDLED) { return; } ALOGI("Got set_interactive hint"); } -static int power_device_open(const hw_module_t* module, const char* name, - hw_device_t** device) +void set_feature(feature_t feature, int state) { - int status = -EINVAL; - if (module && name && device) { - if (!strcmp(name, POWER_HARDWARE_MODULE_ID)) { - power_module_t *dev = (power_module_t *)malloc(sizeof(*dev)); - - if(dev) { - memset(dev, 0, sizeof(*dev)); - - if(dev) { - /* initialize the fields */ - dev->common.module_api_version = POWER_MODULE_API_VERSION_0_2; - dev->common.tag = HARDWARE_DEVICE_TAG; - dev->init = power_init; - dev->powerHint = power_hint; - dev->setInteractive = set_interactive; - /* At the moment we support 0.2 APIs */ - dev->setFeature = NULL, - dev->get_number_of_platform_modes = NULL, - dev->get_platform_low_power_stats = NULL, - dev->get_voter_list = NULL, - *device = (hw_device_t*)dev; - status = 0; - } else { - status = -ENOMEM; - } - } - else { - status = -ENOMEM; - } - } + switch (feature) { +#ifdef TAP_TO_WAKE_NODE + case POWER_FEATURE_DOUBLE_TAP_TO_WAKE: + sysfs_write(TAP_TO_WAKE_NODE, state ? "1" : "0"); + break; +#endif + default: + break; } - - return status; } -struct power_module HAL_MODULE_INFO_SYM = { - .common = { - .tag = HARDWARE_MODULE_TAG, - .module_api_version = POWER_MODULE_API_VERSION_0_2, - .hal_api_version = HARDWARE_HAL_API_VERSION, - .id = POWER_HARDWARE_MODULE_ID, - .name = "QTI Power HAL", - .author = "QTI", - .methods = &power_module_methods, - }, - - .init = power_init, - .powerHint = power_hint, - .setInteractive = set_interactive, -}; diff --git a/power/power-common.h b/power/power-common.h index e374e46..6abc725 100644 --- a/power/power-common.h +++ b/power/power-common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013, 2018-2019 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -26,6 +26,13 @@ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef __POWER_COMMON_H__ +#define __POWER_COMMON_H__ + +#ifdef __cplusplus +extern "C" { +#endif + #define NODE_MAX (64) #define SCALING_GOVERNOR_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" @@ -42,9 +49,22 @@ #define HINT_HANDLED (0) #define HINT_NONE (-1) +#include + enum CPU_GOV_CHECK { CPU0 = 0, CPU1 = 1, CPU2 = 2, CPU3 = 3 }; + +void power_init(void); +void power_hint(power_hint_t hint, void *data); +void set_interactive(int on); +void set_feature(feature_t feature, int state); + +#ifdef __cplusplus +} +#endif + +#endif //__POWER_COMMON_H___ diff --git a/power/power-msmnile.c b/power/power-msmnile.c new file mode 100644 index 0000000..7000079 --- /dev/null +++ b/power/power-msmnile.c @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#define LOG_NIDEBUG 0 + +#include +#include +#include +#include +#include +#include +#include + +#define LOG_TAG "QTI PowerHAL" +#include +#include +#include + +#include "power-common.h" + +static int display_fd; +#define SYS_DISPLAY_PWR "/sys/kernel/hbtp/display_pwr" + +int set_interactive_override(int on) +{ + static const char *display_on = "1"; + static const char *display_off = "0"; + char err_buf[80]; + static int init_interactive_hint = 0; + static int set_i_count = 0; + int rc = 0; + + set_i_count ++; + ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count); + + if (init_interactive_hint == 0) + { + //First time the display is turned off + display_fd = TEMP_FAILURE_RETRY(open(SYS_DISPLAY_PWR, O_RDWR)); + if (display_fd < 0) { + strerror_r(errno,err_buf,sizeof(err_buf)); + ALOGE("Error opening %s: %s\n", SYS_DISPLAY_PWR, err_buf); + } + else + init_interactive_hint = 1; + } + else + if (!on ) { + /* Display off. */ + rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off))); + if (rc < 0) { + strerror_r(errno,err_buf,sizeof(err_buf)); + ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf); + } + } + else { + /* Display on */ + rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on))); + if (rc < 0) { + strerror_r(errno,err_buf,sizeof(err_buf)); + ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf); + } + } + + return HINT_HANDLED; +} + +void interaction(int duration, int num_args, int opt_list[]); + +int power_hint_override(power_hint_t hint, void *data) +{ + int ret_val = HINT_NONE; + switch(hint) { + case POWER_HINT_INTERACTION: + { + int resources[] = {0x40800100, 0x514}; + int duration = 100; + interaction(duration, sizeof(resources)/sizeof(resources[0]), resources); + ret_val = HINT_HANDLED; + } + default: + break; + } + return ret_val; +} diff --git a/power/service.cpp b/power/service.cpp new file mode 100644 index 0000000..902c661 --- /dev/null +++ b/power/service.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define LOG_TAG "android.hardware.power@1.2-service" + +#include +#include +#include +#include "Power.h" + +using android::sp; +using android::status_t; +using android::OK; + +// libhwbinder: +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; + +// Generated HIDL files +using android::hardware::power::V1_2::IPower; +using android::hardware::power::V1_2::implementation::Power; + +int main() { + + status_t status; + android::sp service = nullptr; + + ALOGI("Power HAL Service 1.2 is starting."); + + service = new Power(); + if (service == nullptr) { + ALOGE("Can not create an instance of Power HAL interface."); + + goto shutdown; + } + + configureRpcThreadpool(1, true /*callerWillJoin*/); + + status = service->registerAsService(); + if (status != OK) { + ALOGE("Could not register service for Power HAL(%d).", status); + goto shutdown; + } + + ALOGI("Power Service is ready"); + joinRpcThreadpool(); + //Should not pass this line + +shutdown: + // In normal operation, we don't expect the thread pool to exit + + ALOGE("Power Service is shutting down"); + return 1; +} + diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index d444954..752bb83 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -115,9 +115,9 @@ /data/system/perfd(/.*)? u:object_r:perfd_data_file:s0 /data/oemnvitems(/.*)? u:object_r:nv_data_file:s0 -/system/vendor/bin/perfd u:object_r:perfd_exec:s0 -/system/vendor/bin/hw/android\.hardware\.power@1\.1-service-qti u:object_r:hal_power_default_exec:s0 -/system/vendor/radio(/.*)? u:object_r:radio_data_file:s0 +/(vendor|system/vendor)/bin/perfd u:object_r:perfd_exec:s0 +/(vendor|system/vendor)/bin/hw/android\.hardware\.power@1\.2-service u:object_r:hal_power_default_exec:s0 +#/(vendor|system/vendor)/radio(/.*)? u:object_r:radio_data_file:s0 /system/vendor/bin/qmi_motext_hook u:object_r:rild_exec:s0