From c6cb2c536db042a62d9c05c152bd21e1ea6beb9e Mon Sep 17 00:00:00 2001 From: bengris32 Date: Thu, 26 Oct 2023 22:31:30 +0100 Subject: [PATCH] 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 --- aidl/power-mediatek/Power.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/aidl/power-mediatek/Power.cpp b/aidl/power-mediatek/Power.cpp index 41de967..8fd3028 100644 --- a/aidl/power-mediatek/Power.cpp +++ b/aidl/power-mediatek/Power.cpp @@ -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;