power-mediatek: Avoid excessive interaction hinting where possible

* Don't re-hint if the duration of the previous interaction hint
  can cover the duration of the new hint.

* Shamelessly kanged from change I43d1e2f2cbd6713baa132be7eb475243a8d4a5c6 on
  android_vendor_qcom_opensource_power.

Change-Id: I2129e3390c4eb5d7bc1795f6f9a54794b894cc95
Signed-off-by: bengris32 <bengris32@protonmail.ch>
This commit is contained in:
bengris32
2023-10-26 22:31:30 +01:00
parent 5c3773739d
commit c6cb2c536d

View File

@@ -92,6 +92,13 @@ void Power::handleInteractionHint(int32_t targetDuration) {
return;
}
if (durationMs <= mPreviousInteractionDuration) {
// don't hint if previous hint's duration covers this hint's duration
if (elapsedTime <= (mPreviousInteractionDuration - durationMs)) {
return;
}
}
mPreviousInteractionTime = currentInteractionTime;
mPreviousInteractionDuration = durationMs;