summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Murray <timmurray@google.com>2017-07-14 13:54:37 -0700
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-08-22 23:15:35 +0000
commit1d9a6c4fba6e11d0da94060f7937e7b31301401f (patch)
treed8b9d5f7b91033072dc87af8cdce2ac23bb355d1
parent42929e36d3a4ba9b9624d39849e3f44963205cf9 (diff)
downloadbase-1d9a6c4fba6e11d0da94060f7937e7b31301401f.tar.gz
power: throttle interaction hints
Don't send power HAL interaction hints more than every 100ms. Also can send userActivity calls every 100ms too (down from 500ms). Test: power HAL doesn't run every 8ms Bug: 63632697 Change-Id: Ic986f6fc51e58f8060f7bf2d2ac61a9906be5c1f (cherry picked from commit c203016b590230092d1385fdeac5a3a7d3206e33)
-rw-r--r--services/core/jni/com_android_server_power_PowerManagerService.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp
index c722629a28f4..c71614d69b0b 100644
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
@@ -62,7 +62,7 @@ std::mutex gPowerHalMutex;
static nsecs_t gLastEventTime[USER_ACTIVITY_EVENT_LAST + 1];
// Throttling interval for user activity calls.
-static const nsecs_t MIN_TIME_BETWEEN_USERACTIVITIES = 500 * 1000000L; // 500ms
+static const nsecs_t MIN_TIME_BETWEEN_USERACTIVITIES = 100 * 1000000L; // 100ms
// ----------------------------------------------------------------------------
@@ -101,14 +101,6 @@ static void processReturn(const Return<void> &ret, const char* functionName) {
}
void android_server_PowerManagerService_userActivity(nsecs_t eventTime, int32_t eventType) {
- // Tell the power HAL when user activity occurs.
- gPowerHalMutex.lock();
- if (getPowerHal()) {
- Return<void> ret = gPowerHal->powerHint(PowerHint::INTERACTION, 0);
- processReturn(ret, "powerHint");
- }
- gPowerHalMutex.unlock();
-
if (gPowerManagerServiceObj) {
// Throttle calls into user activity by event type.
// We're a little conservative about argument checking here in case the caller
@@ -123,6 +115,17 @@ void android_server_PowerManagerService_userActivity(nsecs_t eventTime, int32_t
return;
}
gLastEventTime[eventType] = eventTime;
+
+
+ // Tell the power HAL when user activity occurs.
+ gPowerHalMutex.lock();
+ if (getPowerHal()) {
+ Return<void> ret;
+ ret = gPowerHal->powerHint(PowerHint::INTERACTION, 0);
+ processReturn(ret, "powerHint");
+ }
+ gPowerHalMutex.unlock();
+
}
JNIEnv* env = AndroidRuntime::getJNIEnv();