You are not lucky that your service is beautiful without wakelock. Your device has never slept.
If you plugged in USB and turned on the power, your device will not sleep. After all, what is the point of saving energy if you have a ready-made supply for its use?
You need to connect to your device using adb over IP (adb connect) and then logcat from there to see if you are all watching the expected logs.
EDIT: Forgot to answer the question.
If you want your service to constantly do something, you need to keep wakelock. Keep in mind that wakelock persistent storage is basically the No. 1 sin in mobile programming. You must NEVER CONSTANT PERMANENT PROTECTION .
Since your service monitors data usage, then there is no need for wakelock, because if the device is sleeping, then there is no data to register.
EDIT 2: Let the experiment!
Hmmm. Sleep is hard to get, so let go directly to the nuclear option.
Modify your code so that instead of actually loading data, you will save some metadata instead to let you know that you saved data with a specific timestamp. Also, change your code so that you can track power events, and mark them with a time stamp. If you can, save all this data in memory so that we donβt have too much system code.
Put your phone in airplane mode. Right, disconnect all external connections. Also, do not use ADB or logcat or anything like that.
Kill all unnecessary applications. Remove is better.
Start the service as the user will use the user interface. DO NOT USE ANY VARIETY TEST; TESTS CAN PREVENT DREAM (it's hard to know anything for sure on Android, because drowsiness is an OEM thing).
Wait a while.
Reset your time stamped logs. You probably will not get accurate data about when the dream occurred, even if it even tells you that you were sleeping. But you should be able to get it out of the odd order of power events when you move on to the state you were in.
source share