Wi-Fi Sleep Policy and how it works

1,139 views
Skip to first unread message

<Lado Kumsiashvili>

unread,
Dec 28, 2011, 6:11:11 AM12/28/11
to android-platform
Hi. With Galaxy Nexus I've noticed that this setting does not work, as
i expect it to be. Wi-Fi is kept activated on most of the time,
nevertheless what I configure.
On the Galaxy Nexus the default 15 Minutes are used for assume the
devices is idle. Only after that the Wi-Fi should be disabled, if not
locked. I've also change his idle timeout to one minute, to test this
problem better, but this is the same.

There are three values for "Keep Wi-Fi on during sleep"

* Always
* Only when plugged in
* Never (increases data usage)

I've tested with CPU Spy (from market) and also checked the android's
built in bat stats. The devices sleeps but the Wi-Fi is on (the device
is pingable). But this is not always so. Sometimes it gets deactivated
and when I turn on the screen it gets activated.

On my Galaxy S2 this worked just a charm. Screen off -> after a couple
minutes Wi-Fi gets disabled. But this was possible with a certain
kernel I think or some custom rom.

So the question is, why the Wi-FI is kept after the Idle timeout?

<Lado Kumsiashvili>

unread,
Dec 29, 2011, 6:16:05 AM12/29/11
to android-platform
I've checked the sources and find out, that if an app has a WiFi lock,
then the Wi-Fi won't asleep. But I've tested with fresh flashed rom
with disabled sync. So there is no reason to somebody to keep the Wi-
Fi lock. This happens event if I have Data enabled. So Could the code
in WifiService.java be buggy?

dan raaka

unread,
Dec 29, 2011, 10:39:07 AM12/29/11
to android-...@googlegroups.com
Src : http://developer.android.com/reference/android/net/wifi/WifiManager.WifiLock.html

Allows an application to keep the Wi-Fi radio awake. Normally the Wi-Fi radio may turn off when the user has not used the device in a while. Acquiring a WifiLock will keep the radio on until the lock is released. Multiple applications may hold WifiLocks, and the radio will only be allowed to turn off when no WifiLocks are held in any application.

Before using a WifiLock, consider carefully if your application requires Wi-Fi access, or could function over a mobile network, if available. A program that needs to download large files should hold a WifiLock to ensure that the download will complete, but a program whose network usage is occasional or low-bandwidth should not hold a WifiLock to avoid adversely affecting battery life.

Note that WifiLocks cannot override the user-level "Wi-Fi Enabled" setting, nor Airplane Mode. They simply keep the radio from turning off when Wi-Fi is already on but the device is idle.

Any application using a WifiLock must request the android.permission.WAKE_LOCK permission in an <uses-permission> element of the application's manifest.


-Dan


--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.


<Lado Kumsiashvili>

unread,
Jan 4, 2012, 10:31:04 AM1/4/12
to android-platform
Here is what I found. I do not know whether it is a bug or a feature.

Keep Wi-Fi on during sleep ist set to never.

If the device goes to Deep Sleep the setting is not honored and the Wi-
Fi is kept.

If the devices has a wake lock or a partial wak lock (it must not go
in the deep sleep), as example connected charger or usb cable or the
app "Wake Lock - PowerManager", than the Wi-Fi sleep setting is
honored and the Wi-Fi gets disabled after the idle timeout.

So what it is a bug or a feature?

Here also the issue
http://code.google.com/p/android/issues/detail?id=23211


On 29 Dez. 2011, 12:16, "<Lado Kumsiashvili>" <herrl...@gmail.com>
wrote:
> I've checked the sources and find out, that if an app has aWiFilock,
> then theWi-Fiwon't asleep. But I've tested with fresh flashed rom
> with disabled sync. So there is no reason to somebody to keep theWi-Filock. This happens event if I have Data enabled. So Could the code
> in WifiService.java be buggy?
>
> On 28 Dez., 12:11, "<Lado Kumsiashvili>" <herrl...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi. With Galaxy Nexus I've noticed that this setting does not work, as
> > i expect it to be.Wi-Fiis kept activated on most of the time,
> > nevertheless what I configure.
> > On the Galaxy Nexus the default 15 Minutes are used for assume the
> > devices is idle. Only after that theWi-Fishould be disabled, if not
> > locked. I've also change his idle timeout to one minute, to test this
> > problem better, but this is the same.
>
> > There are three values for "KeepWi-Fion duringsleep"
>
> > * Always
> > * Only when plugged in
> > * Never (increases data usage)
>
> > I've tested with CPU Spy (from market) and also checked the android's
> > built in bat stats. The devices sleeps but theWi-Fiis on (the device
> > is pingable). But this is not always so. Sometimes it gets deactivated
> > and when I turn on the screen it gets activated.
>
> > On my Galaxy S2 this worked just a charm. Screen off -> after a couple
> > minutesWi-Figets disabled. But this was possible with a certain
> > kernel I think or some custom rom.
>
> > So the question is, why theWi-FIis kept after the Idle timeout?
Reply all
Reply to author
Forward
0 new messages