Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78701217 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 230c78ce c203016b
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -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();