power: Make powerHAL compatible for passthrough HIDL design
Test: Power hint is received
Bug: 31177288
Bug: 32158500
Change-Id: Ia65f6b50d091a02199565af1d8855ec7473e7323
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
diff --git a/device.mk b/device.mk
index 1389222..9bdd8eb 100644
--- a/device.mk
+++ b/device.mk
@@ -482,7 +482,13 @@
# Power HAL
PRODUCT_PACKAGES += \
power.bullhead \
- thermal.bullhead
+ thermal.bullhead \
+ android.hardware.power@1.0-impl \
+
+ifeq ($(ENABLE_TREBLE), true)
+PRODUCT_PACKAGES += \
+ android.hardware.power@1.0-service
+endif
# Modem debugger/misc
ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
diff --git a/power/power.c b/power/power.c
index 25a5d60..857c58c 100644
--- a/power/power.c
+++ b/power/power.c
@@ -94,10 +94,6 @@
static int display_hint_sent;
int display_boost;
-static struct hw_module_methods_t power_module_methods = {
- .open = NULL,
-};
-
static void power_init(struct power_module *module)
{
ALOGI("QCOM power HAL initing.");
@@ -669,6 +665,44 @@
return 0;
}
+static int power_open(const hw_module_t* module, const char* name,
+ hw_device_t** device)
+{
+ ALOGD("%s: enter; name=%s", __FUNCTION__, name);
+ int retval = 0; /* 0 is ok; -1 is error */
+
+ if (strcmp(name, POWER_HARDWARE_MODULE_ID) == 0) {
+ power_module_t *dev = (power_module_t *)calloc(1,
+ sizeof(power_module_t));
+
+ if (dev) {
+ /* Common hw_device_t fields */
+ dev->common.tag = HARDWARE_MODULE_TAG;
+ dev->common.module_api_version = POWER_MODULE_API_VERSION_0_5;
+ dev->common.module_api_version = HARDWARE_HAL_API_VERSION;
+
+ dev->init = power_init;
+ dev->powerHint = power_hint;
+ dev->setInteractive = set_interactive;
+ dev->get_number_of_platform_modes = get_number_of_platform_modes;
+ dev->get_platform_low_power_stats = get_platform_low_power_stats;
+ dev->get_voter_list = get_voter_list;
+
+ *device = (hw_device_t*)dev;
+ } else
+ retval = -ENOMEM;
+ } else {
+ retval = -EINVAL;
+ }
+
+ ALOGD("%s: exit %d", __FUNCTION__, retval);
+ return retval;
+}
+
+static struct hw_module_methods_t power_module_methods = {
+ .open = power_open,
+};
+
struct power_module HAL_MODULE_INFO_SYM = {
.common = {
.tag = HARDWARE_MODULE_TAG,