Merge "power: throttle interaction hints" into oc-dr1-dev

This commit is contained in:
Tim Murray
2017-07-17 23:16:41 +00:00
committed by Android (Google) Code Review

View File

@@ -63,7 +63,7 @@ std::mutex gPowerHalMutex;
static nsecs_t gLastEventTime[USER_ACTIVITY_EVENT_LAST + 1]; static nsecs_t gLastEventTime[USER_ACTIVITY_EVENT_LAST + 1];
// Throttling interval for user activity calls. // 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
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -103,19 +103,6 @@ static void processReturn(const Return<void> &ret, const char* functionName) {
} }
void android_server_PowerManagerService_userActivity(nsecs_t eventTime, int32_t eventType) { 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;
if (gPowerHalV1_1 != nullptr) {
ret = gPowerHalV1_1->powerHintAsync(PowerHint::INTERACTION, 0);
} else {
ret = gPowerHalV1_0->powerHint(PowerHint::INTERACTION, 0);
}
processReturn(ret, "powerHint");
}
gPowerHalMutex.unlock();
if (gPowerManagerServiceObj) { if (gPowerManagerServiceObj) {
// Throttle calls into user activity by event type. // Throttle calls into user activity by event type.
// We're a little conservative about argument checking here in case the caller // We're a little conservative about argument checking here in case the caller
@@ -130,6 +117,21 @@ void android_server_PowerManagerService_userActivity(nsecs_t eventTime, int32_t
return; return;
} }
gLastEventTime[eventType] = eventTime; gLastEventTime[eventType] = eventTime;
// Tell the power HAL when user activity occurs.
gPowerHalMutex.lock();
if (getPowerHal()) {
Return<void> ret;
if (gPowerHalV1_1 != nullptr) {
ret = gPowerHalV1_1->powerHintAsync(PowerHint::INTERACTION, 0);
} else {
ret = gPowerHalV1_0->powerHint(PowerHint::INTERACTION, 0);
}
processReturn(ret, "powerHint");
}
gPowerHalMutex.unlock();
} }
JNIEnv* env = AndroidRuntime::getJNIEnv(); JNIEnv* env = AndroidRuntime::getJNIEnv();