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
tirimbino
Patrick Lower 10 years ago committed by Jan Altensen
parent 73c756d2b4
commit d3e7105606
No known key found for this signature in database
GPG Key ID: 3E45BB95F7AD33DA
  1. 7
      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;

Loading…
Cancel
Save