diff --git a/power/Android.mk b/power/Android.mk index 9fade788..f2e29188 100644 --- a/power/Android.mk +++ b/power/Android.mk @@ -44,6 +44,7 @@ LOCAL_SRC_FILES += power-8998.c LOCAL_CFLAGS += -DINTERACTION_BOOST -Werror LOCAL_SHARED_LIBRARIES := \ + libbase \ liblog \ libcutils \ libdl \ diff --git a/power/Power.cpp b/power/Power.cpp index bf8f6c8b..c7ddf499 100644 --- a/power/Power.cpp +++ b/power/Power.cpp @@ -17,6 +17,8 @@ #define LOG_TAG "android.hardware.power@1.1-service.wahoo" #include +#include +#include #include #include "Power.h" #include "power-common.h" @@ -49,12 +51,18 @@ Power::Power() { // Methods from ::android::hardware::power::V1_0::IPower follow. Return Power::setInteractive(bool interactive) { + if (!isSupportedGovernor()) { + return Void(); + } power_set_interactive(interactive ? 1 : 0); return Void(); } Return Power::powerHint(PowerHint hint, int32_t data) { power_hint_t h = static_cast(hint); + if (!isSupportedGovernor()) { + return Void(); + } if (h == POWER_HINT_INTERACTION) { mInteractionHandler.Acquire(data); return Void(); @@ -169,6 +177,20 @@ done: return Void(); } +bool Power::isSupportedGovernor() { + std::string buf; + if (android::base::ReadFileToString(SCALING_GOVERNOR_PATH, &buf)) { + buf = android::base::Trim(buf); + } + // Only support EAS 1.2, legacy EAS and HMP + if (buf == SCHEDUTIL_GOVERNOR || buf == SCHED_GOVERNOR || buf == INTERACTIVE_GOVERNOR) { + return true; + } else { + ALOGE("Governor not supported by powerHAL, skipping"); + return false; + } +} + } // namespace implementation } // namespace V1_1 } // namespace power diff --git a/power/Power.h b/power/Power.h index 0db0ed52..143f06b9 100644 --- a/power/Power.h +++ b/power/Power.h @@ -54,6 +54,7 @@ struct Power : public IPower { private: InteractionHandler mInteractionHandler; + static bool isSupportedGovernor(); }; } // namespace implementation diff --git a/power/power-common.h b/power/power-common.h index 82a173fb..aff3cd24 100644 --- a/power/power-common.h +++ b/power/power-common.h @@ -36,6 +36,9 @@ #define SCALING_MIN_FREQ "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" #define ONDEMAND_GOVERNOR "ondemand" #define INTERACTIVE_GOVERNOR "interactive" +#define SCHEDUTIL_GOVERNOR "schedutil" +#define SCHED_GOVERNOR "sched" + #define MSMDCVS_GOVERNOR "msm-dcvs" #define SCHED_GOVERNOR "sched"