Wifi sleep policy and wifi lock which one overrides when both conflict? - android

If an android user has setup the WIFI SLEEP POLICY (KEEP WIFI ON DURING SLEEP) to NEVER, that is wifi should sleep when phone is locked or sleep.
And an app aquires a Wifi wake lock when the phone is not sleeping. While the app keeps the lock if the phones sleeps which setting should prevail ?
Sleep policy ? which tells that wifi should turn off
or the lock aquired by the app ? which attempts to keep wifi ON
There is no clear explanation about this in android documentation any tips would be great as I don't want redundant code in my app

Related

ADB wifi unreachable when it looses connection in device with wake lock (CPU only)?

I am using wake lock on my Nexus 4 to force it to stay awake (I am using wake lock with CPU only option). However, after sometime, ADB wifi looses connecting and I am unable to reconnect to it again unless I turn the screen back on.
Does anyone know solution to this problem? I have the need to keep the screen off, while still be able to access phone via ADB wifi.
You need a wifi lock - check the docs here. In short, the CPU lock won't keep the wifi radio on too - you need a separate (wifi) lock for that.

Types of wake locks in android?

How many types of wake locks in android and what are they?
1) Wake lock
2) WiFi lock
do we have any other locks other than above 2?
do we have any lock for avoiding the 3G modem (Data connection) to avoid it from going to sleep mode due to inactivity?
Please let me know if any have idea on the same.
Thanks.
do we have any other locks other than above 2?
Not really.
do we have any lock for avoiding the 3G modem (Data connection) to avoid it from going to sleep mode due to inactivity?
No, because the mobile data connection does not go into sleep mode. While the mobile data connection does go through various power states, it automatically switches between them as necessary, and if you have an outstanding connection, it will not go into standby.

Different possibilites for keeping wifi radio turned on?

I have been reading as much as I can regarding the developer docs for the Android SDK about the following:
Wifi wakelock
WifiManager.WIFI_MODE_FULL_HIGH_PERF
Wifi sleep policy
They all make sense in their own context but I can't see the "big picture" so to speak.
I guess that both the wifi wakelock and the WIFI_MODE_FULL_HIGH_PERF setting overrides the user sleep policy. Is that right?
If I have the sleep policy on "Never", and I just make experimental APK:s for myself which is downloading stuff in the background via wifi, I guess I don't need the wifi wake lock nor the WIFI_MODE_FULL_HIGH_PERF?
The code I have seen using a wifi wake lock has also acquired a power wake lock. Is there any occasion where I only want to acquire the wifi lock but not the power lock?
If the device goes into a deep sleep and shuts down wi-fi radio, the wi-fi lock will wake it back up when the lock is acquired. Correct, this is regardless of your wi-fi policy.
I think you have it backwards- the policy question says "Keep Wi-Fi on during sleep" so if you want to avoid the need for wifi locks, you would choose the "Always" option value. I'd like to see a battery consumption analysis of Wi-Fi stay connected, versus sporadic 4G in deep sleep...
I have never needed or used a power wake lock. Just system and wifi, and everything has worked fine for me to perform the functions desired.

what does it mean "Wifi Watchdog Service (android.server.ServerThread) does not require the watchdog"?

I have implemented one application which talks over TCP/IP to the server via Wi-Fi, it has to talk to server even device goes to sleep mode so for that I implemented Partial wake lock so even though device goes to sleep mode CPU will be turned on so Wi-Fi also be turned on.
Problem: If I keep the device for longer duration around 7-8 hrs idle with my application running , it seems like device goes to deep sleep mode and when i checked the logcat i found the message : "Wifi Watchdog Service (android.server.ServerThread) for wifi does not require the watchdog".
Not able to undertsand why this message display for the router?
Can anyone put some good inputs regarding this?
Regards,
Piks

how to avoid deep sleep mode in android phone programmatically?

I have develop one android application which will talk to server 24*7 over WiFi but when phone goes to sleep mode it stops talking to server means socket is getting closed so for resolving this I added code to acquire partial wake lock in service onCreate() and release it on OnDestroy() method o service so even though phone goes to sleep mode my application can talk to the server.
Problem is: If you keep the device idle for longer period (more than 8 hours ), it stops communicating with the server and WiFi turned off. I heard about deep sleep mode of device, in this case it will shutdown CPU,WiFi etc.. so how to restrict it for getting CPU and Wifi turned off?
Please help me with some sample example.
Regards,
Piks
I assume you have tried full wake lock as well?

Categories

Resources