power: Allow device specific hooks for setMode, isModeSupported
* Some devices may want to implement custom hooks
Change-Id: Icb2d66471ec649a69b1e69849fd86282775052cb
diff --git a/Android.mk b/Android.mk
index b46fdc6..e1c3da3 100644
--- a/Android.mk
+++ b/Android.mk
@@ -83,6 +83,11 @@
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 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<int32_t>(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::isModeSupported(Mode type, bool* _aidl_return) {
LOG(INFO) << "Power isModeSupported: " << static_cast<int32_t>(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()) {