Ahmed
Ahmed

Reputation: 15069

For Wifi performance is there a need to keep wake lock?

I have service running in android to sync files when user wants. This is not a 24/7 service, only runs for a period of file transfers over wifi, so the user when done transferring files quits the app and therefore the service exits.

So the scenario could be that user has left the mobile and it might get locked/screen off automatically.

Regardless of screen on or off is there a way to ensure wifi is always performing the same with low latency ? There are multiple apis in relation to this, Wifi lock, Wifi-sleep-policy, screen lock .. People seem to use a combination of them to keep good wireless performance .

Is wifi lock enough to ensure it ? or do I need to use combination of APIs ?

Thank you.

EDIT: this post was helpful PARTIAL_WAKE_LOCK vs SCREEN_DIM_WAKE_LOCK in download thread

Upvotes: 1

Views: 622

Answers (1)

A--C
A--C

Reputation: 36449

To be on the safe side, a WifiLock as well as a WakeLock would be optimal, with the WakeLock being the more important lock to aquire. The WakeLock ensures the device stays on, and the WifiLock ensures the radio is operating. This should ensure consistent latency. However, you can't expect anything when it comes to data transfers so have your app be ready to handle random connection losses.

Upvotes: 1

Related Questions