Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiFi lock doesn't work, how to prevent wifi power save?

I had done an app that transform the phone into a webcam and use the phone connection to send image to internet web space.

I'm using ad activity that set an Alarm Manager to execute a Service every 5 or 15 minutes. To perform the entire execution of the Service I do a wake lock, but it's dropped when service finisched.

All this works perfect with mobile connection but doesn't do the same with wifi.

I had set in wifi options th policy "NEVER" for wifi sleep. But after a time (not always the same) the phone seems to go on power save mode: wifi icon is yet on status bar but the phone isn't able to connect. Even is i use browser...so I must disconnect and manually reconnect. The message in the logcat: notify conn break (IOEx), close connection Even with phone plugged on power!!!

why? (1)

Doing experiment with another app formed by an activity that start a service always running with a wake lock. So i have added the wifi lock to be sure of connectivity, but also this method sometimes runs and some other not. Always the same notify conn break (IOEx), close connection why? (2)

The last experiment is derived from the first app (alarm manager) and to be sure that the wifi doesn't go on sleep/power save mode (witch one??) i have turn the phone in airplane mode after the execution of the code and i turn it off (connection on) when the cycle begin. This work ok for two days, but after only sometimes it's work (each hour or two instead each 5 minutes, or sometimes doesn't work for an entire day and then restart without any reason..). So, why airplane mode sometimes doesn't re-establish the prewious wifi connection? (and some other times it does?) (3)

The phone is a Samsung Galaxy ACE with originale 2.2 and is ALWAYS plugged to charge.

like image 761
Lork Avatar asked Dec 16 '11 08:12

Lork


1 Answers

To keep device from entering 'power save mode', try to use wifi lock of type WIFI_MODE_FULL_HIGH_PERF It's not public available until android 3.1.
but you can still use it by hard-coding, the value of WIFI_MODE_FULL_HIGH_PERF is 3(int).
I tried it on a pre-3.1 device. It works like a charm! good luck!

like image 180
accuya Avatar answered Nov 15 '22 01:11

accuya