[T-Mobile Samsung Galaxy S 4] KaneHusky:
It's fairly evident by the number of "wifi problem" threads posted all over xda that there seems to be a huge wifi problem with Android 4.0+. I've seen multiple reports of problems and several reports of methods for fixing user-specific scenarios. In my attempts to better understand what is going on at a system level and in hopes of finding a better solution, I've tried just about all methods I've come across to solve this issue. The only "fix" that works for me is turning off WIFI Power Save Mode via *#0011#. The problem with that fix is it does not work on AOSP ROMs! Hence, I'm trying to find another solution or another method of disabling WiFi Power Save Mode within AOSP ROMs.

Background Information/Description of problem: Turn on wifi and list of available networks will appear. Regardless of being able to connect to a network or not, after 8-10 seconds, the device will scan again, it will time out and the list of available networks will disappear and any connection will be lost. Available networks cannot be seen again until wifi is successfully toggled off and back on again (note - the device seems very picky about actually turning wifi off; it wants to keep it on for some reason - this could be an issue with the multiple reporting of the wifi state in various settings).

Known "Fixes": Some people seem to have luck with certain "fix methods" where others do not.

For most people having this issue or a similar issue, disabling WiFi Power Save Mode in the Service Menu seems to allow the phone to stay connected to networks. This is also true given that the user's wireless router is configured correctly. I've seen reports of several different router models being notorious for issues with Samsung phones, most notably the D-Link DIR-655. I have the DIR-655 and I've configured it to talk nice with my phone when WiFi Power Save Mode is turned off. (I have a new router being shipped to me this week to eliminate this factor altogether)

Some have performed a factory reset with successful wifi connectivity afterwards.

Some have re/flashed a radio and had success. I would like to try reflashing a radio via recovery but we currently do no have one posted on the forum - can someone help me out here?

Some have luck by manually setting the IP address on the router and/or phone.

For the sake of being able to flash an AOSP ROM and have working wifi, I'd like to try and find what's causing this issue and try to find a solution/workaround. I've been troubleshooting and trial-and-erroring most of the weekend.

My research so far:

While looking for the specific setting being toggled via the Service Menu (*#0011#), I found that the WIFI Power Save Mode setting is referenced in /system/app/serviceModeApp_RIL/res/values/strings.xml as

<string name="powersavemode">WIFI Power Save Mode</string>

which is referenced in /system/app/serviceModeApp_RIL/res/values/public.xml as

<public type="string" name="powersavemode" id="0x7f06006b" />

That's as far as I've gotten on that road - I haven't found the "0x7f06006b" constant referenced anywhere else yet - maybe someone else knows a quicker way to search for it?

I've attempted to modify settings in wpa_supplicant.conf found in /system/etc/wifi/ and /data/misc/wifi/ with no luck.

I've attempted to use bcm4335 drivers found on other variants of the S4 but I didn't get very far - some implementations are different!

I've gathered several Logcat files for reference:

WiFi Toggle On & Connect

WiFi Connects & Disconnects

CM10.1 WiFi Toggle On Only

Various lines that stand out to me:

E/wpa_supplicant( 3911): wpa_driver_nl80211_driver_cmd: failed to issue privatecommands
E/wpa_supplicant( 3934): Line 6: unknown global field 'okc=1'.
E/wpa_supplicant( 3934): Line 6: Invalid configuration line 'okc=1'.
I/wpa_supplicant( 3934): rfkill: Cannot open RFKILL control device
E/wpa_supplicant( 3934): Could not set interface wlan0 flags (UP): Operation not permitted
E/wpa_supplicant( 3934): nl80211: Could not set interface 'wlan0' UP
E/wpa_supplicant( 3934): wlan0: Failed to initialize driver interface
E/wpa_supplicant( 6961): Can't open default ap file
E/wpa_supplicant( 6961): Failed to open config file '/mnt/shell/emulated/0/cred.conf', error: No such file or directory
E/WifiHW ( 721): can't find ctrl_interface=
E/WifiHW ( 721): ctrl_interface != /data/misc/wifi/sockets
E/WifiHW ( 721): wifi_wpa_ctrl_cleanup is skiped.
E/WifiHW ( 721): Unable to open connection to supplicant on "/data/misc/wifi/sockets/p2p0": Connection refused

I'm no expert, but those lines seem to indicate some sort of underlying permissions and/or read/write issues? Some of the files those logs reference to as not existing actually do exist on the device. I saw in one thread where someone mentioned bad partitions? In that same thread someone mentioned flashing the radio/modem to correct their issue and it worked; this is why I want to try reflashing the radio on my phone.

Another thing I want to try is using Odin to reset the entire phone back to official stock, overwriting everything including the modem but we don't have an official tar for this yet.

What I would like to see from other T-Mobile S4 users:

Logcats of someone on stock who

does not have wifi issues

turning WiFi on from an off state and leaving it for at least 15 seconds. I'd like one where the device does not connect to a network and one where it does connect to a network.

Logcats of someone on CM10.1 doing the same mentioned above.

Someone who knows more about Android than I do to interpret these logcats and provide guidance