Android deep sleep and Traccar client app

Chip5 months ago

Hello,

I noticed there is a new version of Traccar client for Android (5.17) and I installed it immediately. My hope was that the new app is able to override the phone's resistance not to allow background to run indefinitely long. However that was not the case. I still see this issue with a couple of newer phones.

I am now testing a LG Rebel 4 with Android 6 with basic installation out of the box. Similar results were achived with a Samsung phone before. The hidden client 5.17 is installed and it was manually selected not to do phone's battery optimization. Phone location is on High Accuracy (GPS and Networks) and app location accuracy is on Medium. Anyway I tried many location combinations with similar results.

What happens is that once the app starts and reports location (60 secs interval), everything looks normal for a while. I leave the phone untouched, the screen goes black, there is no other activity on phone. The app keeps reporting data to the server as supposed to. However after about 1 hour the server receives no more locations from the device. When I check the app log, and I learn that after about 1 hour there simply was no more reporting performed, there was no error listed. The moment I touch the phone and screen is unlocked, the app starts sending location again, like it woke up from a deep sleep.

So what I think is happening is that the phone has a timeout (configurable or not) after which the system goes into a deep sleep mode and all background apps are suspended even those with wake_lock implemented. So pretty much unless there is some activity on the phone, the app is unable to perform continous location reporting for more than 1 hour.

In the past with older phones one could put the Traccar app back to life to report location again during idle time by simply sending a SMS message to the phone. When message was received, the screen would turn on and that was enough to make device alive again so that wake_lock was able to help the app to report location for another hour. Unfortunaltely new Android implementations no longer turn the home screen on and wake up the phone. The message is received, the front LED changes color and a sound is played, but the phone is still in the deep sleep so the Traccar app doesnt wake up to report.

A quick fix, if I may suggest, would be for the app to issue an alert before the deep sleep occurs, which is about 60 minutes after phone becomes idle. The alert should be minimal, discrete, without any sound or any other distraction. That would be enough to keep the app alive indefinitely.

Thanks,
Chip

Anton Tananaev5 months ago

There are no changes on the hidden or regular version of the app. The only difference is on the one from Google Play store.

What alert are you talking about?

Chip5 months ago

I am not app developer so I may have used incorrect terminology. I was thinking at AlarmManager or JobScheduler.
I believe JobScheduler is one of the recommeded alternative to wake_lock:
https://developer.android.com/training/scheduling/wakelock

Chip

Anton Tananaev5 months ago

I don't think job scheduler would help. Alarm manager might help, but I still want to know why it happens.

Chip5 months ago

Me too, I would like to understand why is this happening on so many phones, especially on newer generation, so if there is some special setting, I would manually adjust on the phone. I can perform any tests you want me to on my phone. Trouble is that it takes time. For 1 hour and sometimes even more the app is reporting correctly the location. Ideally would be for you if you have a physical phone that you dont have much apps to be active (not emulator) and leave it idle for a few hours. You may see this problem eventually.

Chip

davejh4 months ago

I don't get this problem at all. My phone is s9