From d3e7105606493098a74bc606f701c7d1e4e5ff85 Mon Sep 17 00:00:00 2001 From: Patrick Lower Date: Wed, 5 Aug 2015 10:51:03 -0400 Subject: [PATCH] samsung: doze: properly fix future timestamp error Previously attempted fix at review.cyanogenmod.org/#/c/104083/ The timestamp isn't in the future, that would be impossible. The real issue is the timestamp from the SensorEvent is a true timestamp, the System.nanoTime is nanoseconds since boot. So the previous patch would always return false and never pulse. I've simply changed it so that the wakeup call gets sent the current System.nanoTime in milliseconds since boot so it does not think the event came from the future since the wakeUp method expects uptimeMillis, not true world time. Change-Id: I78f5e9d61107caf9c3bf6c10fa7c5bb400082294 --- .../cyanogenmod/settings/device/SamsungDozeService.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/doze/src/com/cyanogenmod/settings/device/SamsungDozeService.java b/doze/src/com/cyanogenmod/settings/device/SamsungDozeService.java index f8a175e4..149f84b1 100644 --- a/doze/src/com/cyanogenmod/settings/device/SamsungDozeService.java +++ b/doze/src/com/cyanogenmod/settings/device/SamsungDozeService.java @@ -88,17 +88,12 @@ public class SamsungDozeService extends Service { } private boolean shouldPulse(long timestamp) { - // Never pulse if the timestamp is from the future - if (timestamp > System.nanoTime()) { - return false; - } - long delta = timestamp - mInPocketTime; if (mHandwaveGestureEnabled && mPocketGestureEnabled) { return true; } else if (mProximityWakeEnabled && (delta < POCKET_DELTA_NS)) { - mPowerManager.wakeUp(TimeUnit.NANOSECONDS.toMillis(timestamp)); + mPowerManager.wakeUp(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); return false; } else if (mHandwaveGestureEnabled && !mPocketGestureEnabled) { return delta < POCKET_DELTA_NS;