samsung: doze: Prevent a pm wakeup with a timestamp in the future

Prevents:

java.lang.IllegalArgumentException: event time must not be in the future
at android.os.Parcel.readException(Parcel.java:1550)
        at android.os.Parcel.readException(Parcel.java:1499)
        at android.os.IPowerManager$Stub$Proxy.wakeUp(IPowerManager.java:550)
        at android.os.PowerManager.wakeUp(PowerManager.java:666)
        at com.cyanogenmod.settings.device.SamsungDozeService$SamsungProximitySensor.shouldPulse(SamsungDozeService.java:95)
        at com.cyanogenmod.settings.device.SamsungDozeService$SamsungProximitySensor.onSensorChanged(SamsungDozeService.java:75)
        at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:405)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:143)
        at android.os.Looper.loop(Looper.java:122)
        at android.app.ActivityThread.main(ActivityThread.java:5289)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)

Change-Id: I8ed248271d67216e531b124bf27101fa538f1195
Signed-off-by: Brandon McAnsh <brandon.mcansh@gmail.com>
tirimbino
Brandon McAnsh 9 years ago committed by Jan Altensen
parent 3198b9b632
commit 73c756d2b4
No known key found for this signature in database
GPG Key ID: 3E45BB95F7AD33DA
  1. 6
      doze/src/com/cyanogenmod/settings/device/SamsungDozeService.java

@ -32,6 +32,7 @@ import android.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
import android.util.Log; import android.util.Log;
import java.lang.System;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.List; import java.util.List;
@ -87,6 +88,11 @@ public class SamsungDozeService extends Service {
} }
private boolean shouldPulse(long timestamp) { private boolean shouldPulse(long timestamp) {
// Never pulse if the timestamp is from the future
if (timestamp > System.nanoTime()) {
return false;
}
long delta = timestamp - mInPocketTime; long delta = timestamp - mInPocketTime;
if (mHandwaveGestureEnabled && mPocketGestureEnabled) { if (mHandwaveGestureEnabled && mPocketGestureEnabled) {

Loading…
Cancel
Save