Do not do powerhint if current governor is not supported

am: f31c67caa8

Change-Id: I26fd744d55402df3da0685d5ec3aaf0254744be3
This commit is contained in:
Wei Wang
2017-06-27 01:09:38 +00:00
committed by android-build-merger
4 changed files with 27 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ LOCAL_SRC_FILES += power-8998.c
LOCAL_CFLAGS += -DINTERACTION_BOOST -Werror LOCAL_CFLAGS += -DINTERACTION_BOOST -Werror
LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
libbase \
liblog \ liblog \
libcutils \ libcutils \
libdl \ libdl \

View File

@@ -17,6 +17,8 @@
#define LOG_TAG "android.hardware.power@1.1-service.wahoo" #define LOG_TAG "android.hardware.power@1.1-service.wahoo"
#include <android/log.h> #include <android/log.h>
#include <android-base/file.h>
#include <android-base/strings.h>
#include <utils/Log.h> #include <utils/Log.h>
#include "Power.h" #include "Power.h"
#include "power-common.h" #include "power-common.h"
@@ -49,12 +51,18 @@ Power::Power() {
// Methods from ::android::hardware::power::V1_0::IPower follow. // Methods from ::android::hardware::power::V1_0::IPower follow.
Return<void> Power::setInteractive(bool interactive) { Return<void> Power::setInteractive(bool interactive) {
if (!isSupportedGovernor()) {
return Void();
}
power_set_interactive(interactive ? 1 : 0); power_set_interactive(interactive ? 1 : 0);
return Void(); return Void();
} }
Return<void> Power::powerHint(PowerHint hint, int32_t data) { Return<void> Power::powerHint(PowerHint hint, int32_t data) {
power_hint_t h = static_cast<power_hint_t>(hint); power_hint_t h = static_cast<power_hint_t>(hint);
if (!isSupportedGovernor()) {
return Void();
}
if (h == POWER_HINT_INTERACTION) { if (h == POWER_HINT_INTERACTION) {
mInteractionHandler.Acquire(data); mInteractionHandler.Acquire(data);
return Void(); return Void();
@@ -169,6 +177,20 @@ done:
return Void(); 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 implementation
} // namespace V1_1 } // namespace V1_1
} // namespace power } // namespace power

View File

@@ -54,6 +54,7 @@ struct Power : public IPower {
private: private:
InteractionHandler mInteractionHandler; InteractionHandler mInteractionHandler;
static bool isSupportedGovernor();
}; };
} // namespace implementation } // namespace implementation

View File

@@ -36,6 +36,9 @@
#define SCALING_MIN_FREQ "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" #define SCALING_MIN_FREQ "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"
#define ONDEMAND_GOVERNOR "ondemand" #define ONDEMAND_GOVERNOR "ondemand"
#define INTERACTIVE_GOVERNOR "interactive" #define INTERACTIVE_GOVERNOR "interactive"
#define SCHEDUTIL_GOVERNOR "schedutil"
#define SCHED_GOVERNOR "sched"
#define MSMDCVS_GOVERNOR "msm-dcvs" #define MSMDCVS_GOVERNOR "msm-dcvs"
#define SCHED_GOVERNOR "sched" #define SCHED_GOVERNOR "sched"