[wifi][Tweak]Change Wi-Fi idle time before wifi sleep (title changed)

kobridge

Senior Member
Jan 10, 2012
1,710
3,459
0
Jacksonville, FL
The information in here is only tested on the ICS (Stock based roms) and (stock or repacked kernels). It's not been tested on any other roms. So, if you want to apply the tweak that I provided in here, do it with your own risk. I'm here to help or share the good and bad things but not responsible for any bricked phones.

Update: Wifi Sleeps well! But you need to understand what's going on here.

We are expecting wifi to sleep when the screen is off and 'Keep Wi-Fi on during sleep' is set to 'Never'.

But wifi does not go to sleep mode even every options are satisfied on ICS stock roms with Stock or Rogue repacked Kernel).

I tried many ways to make it sleep (from settings, from build.prop tweaks and from through the init.d script) but none of those worked. Only the way to make it sleep is turning off the wifi manually before turning off the screen.

There is one workaround that making the wifi sleep during the screen off. The method is using Wifi Fixer app from google market but it does not work 100 %. Sometimes, it makes wifi sleep but other times, nothing happens.

So, anyone who is expecting wifi sleeps by any tweaks or by wifi option changes, don't expect it any more. There's no hope yet. For me, I'm waiting for the next build to test this function out.

There's some additional information at http://forum.xda-developers.com/showthread.php?t=1625299 and check wifi section.

If anyone knows the method to make wifi sleep on stock rom/kernel, please post your info here. There are some tools that we can use to check wifi is sleeping or not during the sleep mode. I'm currently using Battery Widget Pro.

Because I've tested lots of things so far, if you know the methond or if it works on your phone, please show how it works and screenshots if possible.

[Update] Wifi sleeps finally as I wanted!
OK. Here is the story.
One specific app mis-led me to wroing conclusion - Battery Monitor Widget Pro (v2.2.4). This app shows that wifi is always on if wifi is turned on. This app does not exclude the time wifi was turned off during the sleep mode.

Plus, there's some pre-allocated time to make the wifi sleep after the screen turned off. For most of Android phones, it seems like this value is 15 minutes. So, even the screen is off, wifi does not enter to the sleep mode immediately. Phone spend 15 minutes after the screen off, and kill the wifi session if wifi option was set to never (keep wi-fi on during sleep).

How to check whether wifi sleeps or not :
Do NOT use Battery Monitor Widget to check the wifi status.
You can easily check it from the stock Battery app. Settings > Battery > click on the graph > check wi-fi status if there is any gap (means sleep or turned off).

Then, How to change the default 15 minutes value to make the phone sleep early?

Update 5/16/12 - Fixed wifiSleepWait tweak, so it works without any manual database handling. The below is just for informational. Now you don't need to manually create a row into the table.

There were one or two information available on XDA but nothing is correctly applicable to Epic 4G Touch. So, here is the tweak that I made for E4GT.

To do this you will need root explorer -
1. move to the folder, /data/data/com.android.providers.settings/
2. copy the databases folder to your /sdcard
3. Move to /sdcard/databases click settings.db
4. select secure
5. it will ask you which editor you are going to use. If you installed sqlite then select sqlite, otherwise use root explorer (only at first time)
6.Check if there is column name 'wifi_idle_ms'. If there is, then change the value to whatever mili seconds you want. For example, 10000 = 10 seconds, 30000=30seconds. If you want to wait 15 minutes until wifi sleep, then 15*60000 = ?
7.If there is no 'wifi_idle_ms' row, the click long time anywhere on the table. It will show you the actions, select new record. Do not change _id, put the 'wifi_idle_ms' in the name field (without quote sign) and put the value explained above. For me, I just put the 10000 (for 10 seconds). Click save.
8. Now you can see the value changed or row created. Exit editor and move up to /sdcard. Copy (or Move) databases folder to original location (/data/data/com.android.providers.settings/). Sometime, the copy is not successful because database is currently being used. If it's not copied, then try it agaon to copy until it's successful. For me, it was successful on second try.
9. Reboot the phone and click the power button shortly to change to screen off mode(sleep mode).
10. After the time passed defined in above, click the power button again and notice that phone was working on 4G or 3G mode and not wifi mode. Phone will try to reconnect wifi after the screen turned on.
11. That's it. Now you can change the idle time until wifi turned off as much as you want.

The above was the manual way to change the wifi_idle_ms value from database. But there is another way to change this values automatically. The method is using sqlite and of course you need to know the sql query.
In my case, I tried to add this sqlite query statement into my init.d tweak but only update sql command worked and insert was not successful. Maybe I need someone's help to get this insert statement successful.
In here, I'm adding only the update tweak which can be added into init.d. What this mean is, at first time you have to insert the database row manually but once it's created, you can update the idle value during the boot thru init.d script.

Because you don't need to run this init.d script everytime on boot, once you update the value, change the permission to 644 and it won't run again until you change it back to 755.

To run this init.d script, you will need sqlite3 - http://chensun.net/android-development/install-sqlite3-on-google-nexus-one/54/
Download it and simply move to /system/xbin foler. Assign the same permission like other files on the same folder.
Of course, you also need root access and busybox.

The init.d script will be found at http://forum.xda-developers.com/showthread.php?t=1625299
70wifiSleepWait_kobridge.zip (previous version)
70wifiSleepWait_kobridge.v2.zip (current)
 
Last edited:

nabbed

Senior Member
Aug 15, 2010
2,365
342
153
This info is just for the ICS (Stock based roms) and (stock or repacked kernels) users.

We are expecting wifi to sleep when the screen is off and 'Keep Wi-Fi on during sleep' is set to 'Never'.

But wifi does not go to sleep mode even every options are satisfied on ICS stock roms with Stock or Rogue repacked Kernel).

I tried many ways to make it sleep (from settings, from build.prop tweaks and from through the init.d script) but none of those worked. Only the way to make it sleep is turning off the wifi manually before turning off the screen.

There is one workaround that making the wifi sleep during the screen off. The method is using Wifi Fixer app from google market but it does not work 100 %. Sometimes, it makes wifi sleep but other times, nothing happens.

So, anyone who is expecting wifi sleeps by any tweaks or by wifi option changes, don't expect it any more. There's no hope yet. For me, I'm waiting for the next build to test this function out.

There's some additional information at http://forum.xda-developers.com/showthread.php?t=1625299 and check wifi section.

If anyone knows the method to make wifi sleep on stock rom/kernel, please post your info here. There are some tools that we can use to check wifi is sleeping or not during the sleep mode. I'm currently using Battery Widget Pro.

Because I've tested lots of things so far, if you know the methond or if it works on your phone, please show how it works and screenshots if possible.
Maybe it cannot sleep when sync is on?
I imagine that wifi is needed for weather/news/etc updates and clould2device services.
 

KCRic

Senior Member
Aug 4, 2010
1,230
268
0
Overland Park
Huh? Mine sleeps just fine unless I set it to never sleep.

That aside - you are aware that you're better off leaving wifi on anyway, right? It uses less battery power than the cell radio does. Just an FYI ;)
 

kobridge

Senior Member
Jan 10, 2012
1,710
3,459
0
Jacksonville, FL
Finally figured out everything!
Took whole one day to find out everything!

First, most importantly, WiFi sleeps!

I'm going to explain what happend and how we could make wifi sleeps better in op section.

edit. Partially updated. I'm checking now if I can make a script to change the leading time that is required before wifi actually sleep.
 
Last edited:

kobridge

Senior Member
Jan 10, 2012
1,710
3,459
0
Jacksonville, FL
Finally figured out everything!
Took whole one day to find out everything!

First, most importantly, WiFi sleeps!

I'm going to explain what happend and how we could make wifi sleeps better in op section.

edit. Partially updated. I'm checking now if I can make a script to change the leading time that is required before wifi actually sleep.
All updates are done! Enjoy your ability having control over wifi idle time!
 

JohnCorleone

Senior Member
Dec 19, 2010
16,188
5,864
0
Whittier,CA
You know, upon further testing, idle battery drain on 3g is pretty damn good as well. I am in a lousy signal area during the day and I have been leaving wifi on 24/7 so a lot of battery got wasted from the phone searching and finding wifi to connect to. Tomorrow I will disable wifi while at work but...

Sent from my SPH-D710 using Xparent Blue Tapatalk 2
 

Attachments

kobridge

Senior Member
Jan 10, 2012
1,710
3,459
0
Jacksonville, FL
You know, upon further testing, idle battery drain on 3g is pretty damn good as well. I am in a lousy signal area during the day and I have been leaving wifi on 24/7 so a lot of battery got wasted from the phone searching and finding wifi to connect to. Tomorrow I will disable wifi while at work but...

Sent from my SPH-D710 using Xparent Blue Tapatalk 2
Based on your screenshot, it seems like you are wasting the battery by turned wifi on wifi 24x7.
 

JohnCorleone

Senior Member
Dec 19, 2010
16,188
5,864
0
Whittier,CA
Based on your screenshot, it seems like you are wasting the battery by turned wifi on wifi 24x7.
I agree. While I am around the house say going to the store its minimal but when going to work in NYC I am picking up wifi i cant connect to every 10 feet so its definitely negatively effecting battery
 

kobridge

Senior Member
Jan 10, 2012
1,710
3,459
0
Jacksonville, FL
Maybe it cannot sleep when sync is on?
I imagine that wifi is needed for weather/news/etc updates and clould2device services.
I think there is a little difference of understand about what has the control over other services/fuctions.
Usually weather/news apps are dependent on wifi or 4g services. Those apps usually do not control the wifi or 4G and many times only able to communicate wifi or 4G are turned on. Those services cannot hold the wifi/4G connections even those services are still running.

That aside - you are aware that you're better off leaving wifi on anyway, right? It uses less battery power than the cell radio does. Just an FYI ;)
That's not true. It's totally based on the signal strength. Usually 3G is not fast but do not use battery as much as wifi when the signal is weak on both wifi and 3G.
 
Last edited:
  • Like
Reactions: TeamERA

tdunham

Recognized Contributor
Jun 21, 2008
13,686
36,462
0
TampaBay
Not to question yiur style kobridge, but I beleive there is a spelling error in the tittle =D
Sent from my SPH-D710 using xda premium
Looks like he fixed it just for you. ;)

[wifi][Tweak]Chage Wi-Fi idle time before sleep (title changed)

Edit: Well, not ^^^ ALL of it is fixed yet. :rolleyes:
 
Last edited:
  • Like
Reactions: kobridge

kobridge

Senior Member
Jan 10, 2012
1,710
3,459
0
Jacksonville, FL
Not to question yiur style kobridge, but I beleive there is a spelling error in the tittle =D
Sent from my SPH-D710 using xda premium
Looks like he fixed it just for you. ;)

[wifi][Tweak]Chage Wi-Fi idle time before sleep (title changed)

Edit: Well, not ^^^ ALL of it is fixed yet. :rolleyes:
Thank you both of you! Sometimes, simple mistake is not to catch because it's too simple!
 

kobridge

Senior Member
Jan 10, 2012
1,710
3,459
0
Jacksonville, FL
will this tweak work if I set wifi to "only when plugged in"
I think the right answer is No.
When phone is plugged in - wifi is always connected even after the screen turned off. So, this tweak would not work while phone is plugged in.

When phone is unplugged - wifi will stay offline always. So, this tweak is not applicable.

If you set the option to "Always" - wifi will stay connected during the screen off. So, this tweak does not work.

If you set the option to "Never" - This tweak only works for this option.

The purpose of this tweak is minimizing the waiting(idle) time until wifi moves to sleep mode after the screen turned off.
 
Last edited:
  • Like
Reactions: edlee

kobridge

Senior Member
Jan 10, 2012
1,710
3,459
0
Jacksonville, FL
Kobridge, i came through this topic after some searching for a problem of mine.
I see you know some basics...

If you have some time, take a look at this... that wifi issue is driving me really mad !!!

http://forum.xda-developers.com/showthread.php?t=1673514


thnx in advance :)
For this, I believe it's related to the value of wifi.supplicant_scan_interval which is normally defined at build.prop.
Check out the value from there.
These days the value 180 (3minutes) are normal for tweaking purpose. But for EPIC 4G Touch's case, it's default is 5seconds (causing lots of battery drain if you are moving around).

For example, if wifi is not available from some location, then your phone will try to searchthe available wifi network after x amount of times. If this value is too big, then it will look like wifi is not connected (so most of you, just try to reconnect the wifi manually before time comes). If the value is too small, again it causes the battery drain.
Once the wifi is connected, it keeps the connection based on the wifi policy. But if the connection is lost, then it will try again to search!
 
  • Like
Reactions: morx

morx

Senior Member
Dec 3, 2010
303
39
58
First of all, REALLY REALLY REALLY Really thank you for the reply mate.

My wifi supp value is set at "10"

I know this value only works when there are not any "known" access points in range.

The thing is, that it NEVER connects with screen off or on when i get back in range.

It only does it when i go to wifi settings (refreshes the list and connects without touching anything more!).

(of course, my wifi battery saving policy is set to "never" while screen is off)


Wifi stays on but it freezes AP scanning, while screen is off i guess.

Would a logcat help? Any tips about how to capture a good log about that issue?