eclipse / paho.mqtt.android

MQTT Android
Other
2.89k stars 865 forks source link

Use AndroidHighResolutionTimer for elapsed time #425

Open powturns opened 3 years ago

powturns commented 3 years ago

This timer uses SystemClock.elapsedRealtimeNanos to calculate the high resolution timing value, which advances time when the device is asleep.

Fixes a bug introduced by the paho.mqtt.java library when it was changed to track elapsed time using System.nanoTime. However, on android, nanoTime does not advance when the device is in a deep sleep. As a result, pings may not be sent frequently enough, resulting in client disconnects.

See: https://github.com/eclipse/paho.mqtt.java/issues/278 https://github.com/eclipse/paho.mqtt.java/issues/774

Signed-off-by: Dustin Thomson dthomson@51systems.com

Please make sure that the following boxes are checked before submitting your Pull Request, thank you!