From de33daea0c20ba4aa3517ff6077ab2cb6ef88a7e Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Thu, 1 Oct 2020 14:13:46 +0200 Subject: [PATCH] power: Allow device specific hooks for setMode, isModeSupported * Some devices may want to implement custom hooks Change-Id: Icb2d66471ec649a69b1e69849fd86282775052cb --- Android.mk | 5 +++++ Power.cpp | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Android.mk b/Android.mk index b46fdc6..e1c3da3 100644 --- a/Android.mk +++ b/Android.mk @@ -83,6 +83,11 @@ endif endif # End of board specific list +ifneq ($(TARGET_POWERHAL_MODE_EXT),) + LOCAL_CFLAGS += -DMODE_EXT + LOCAL_SRC_FILES += ../../../../$(TARGET_POWERHAL_MODE_EXT) +endif + ifneq ($(TARGET_POWERHAL_SET_INTERACTIVE_EXT),) LOCAL_CFLAGS += -DSET_INTERACTIVE_EXT LOCAL_SRC_FILES += ../../../../$(TARGET_POWERHAL_SET_INTERACTIVE_EXT) diff --git a/Power.cpp b/Power.cpp index ec7fec0..35d49fe 100644 --- a/Power.cpp +++ b/Power.cpp @@ -59,12 +59,22 @@ namespace hardware { namespace power { namespace impl { +#ifdef MODE_EXT +extern bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return); +extern bool setDeviceSpecificMode(Mode type, bool enabled); +#endif + void setInteractive(bool interactive) { set_interactive(interactive ? 1:0); } ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) { LOG(INFO) << "Power setMode: " << static_cast(type) << " to: " << enabled; +#ifdef MODE_EXT + if (setDeviceSpecificMode(type, enabled)) { + return ndk::ScopedAStatus::ok(); + } +#endif switch(type){ #ifdef TAP_TO_WAKE_NODE case Mode::DOUBLE_TAP_TO_WAKE: @@ -105,6 +115,11 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) { ndk::ScopedAStatus Power::isModeSupported(Mode type, bool* _aidl_return) { LOG(INFO) << "Power isModeSupported: " << static_cast(type); +#ifdef MODE_EXT + if (isDeviceSpecificModeSupported(type, _aidl_return)) { + return ndk::ScopedAStatus::ok(); + } +#endif switch(type){ case Mode::EXPENSIVE_RENDERING: if (is_expensive_rendering_supported()) {