[Desire Android Development] PaulW21781:
Thought I may aswell get this up... I'm just writing up what I've found out myself since looking into it from last night. It may be of no use, it may help a basis of discussion for sorting this, or it may just disappear into the depths of XDA never to be seen again :)

Ok, as everyone pretty much knows, any FroYo (Ported or AOSP-built) ROM has an issue, where the WiFi suffers from extremely high latency and/or dropped packets when the phone is asleep, regardless if the power options are set or not (Settings -> Wireless and Blah -> WiFi -> Advanced)

Now... I've done some looking about on google, and found this thread

http://code.google.com/p/android/issues/detail?id=9781

This pretty much explains things bang on... I do also suffer from these problems (the streaming and such dropping out), but others have absolutely no throughput, this seems dependant on MAC address...

Those whose MAC starts with 00:23 seem to only suffer from high pings and the odd dropped packet.

Those whose MAX starts with 38:E7 seem to suffer 100% dropped packets.

(I'm not sure if there are any other MAC addresses)

So... According to the Google link above, it relates to a problem with how PSP (PowerSave Mode) is handled, aswell as possibly incompatibilities with certain makes of routers.

So what do we need to do?

Ideally, we need to make sure that any-and-all Wake-Locks are registered and managed correctly, or a quick dirty method, disable and-and-all mentions to any powersaving methods in either the Kernel Driver for the WiFi, FroYo itself for any sort of WiFi lock, or both... I've looked at the Kernel source (specifically /drivers/net/wireless/bcm4329/dhd_cdc.c) as mentioned on Lines 678 and 679 is:

/* Set PowerSave mode */
dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode, sizeof(power_mode));

I did first try just disabling that completely, but it prevented the WiFi from even starting... Maybe a hook, or check on the power_mode variable needs to be looked into, see whats passed when PowerSave is sent (screen off) and override it with what the default setting for ON is? This line does also exist on 532 and 551, but 678 is the only area where it implicitly says PowerSave. (I need to read through the whole source file and work a flowchart out of how it works)

Then again, I could be barking up the wrong tree, but out of all the files in that folder, this is the *only* mention I could find at 3am last night...

The only other problem I can see is that the firmware for the WiFi is actually closed-source, and is ripped directly from existing HTC-based ROMS. So modifying this would be extremely difficult.

Now, people have said this issue doesn't show on ROMs released from HTC directly, but when I was still using WWE 1.15 and WWE 1.21-based ROMs, I had the same amount of hight latency pings and the odd packet drop as I do now with FroYo. (my MAC is 00:23) I've not tested the leaked 2.2 ROMs from HTC, so have no knowledge if this problem is fixed in there.

I also came across this (this is an email I was sent) this relates to a program called WiFi Fixer which appears to be working on most N1 devices... (this was found in a discussion originally I think from one of the linked threads from the google bug report above... I'll check and re-link when I can find the original source)

However, using said app on the Desire causes the WiFi to completely stop working all together, and I experienced no joy with any other options it gives to try resolve this issue. Feel free to try it yourself, the hacks it does are non-permanent (it runs as a service) and as soon as its uninstalled, everything will go back to normal.

So yeah...

Modify the Kernel Source

Modify FroYo AOSP methods for sleeping

Modify both (possibly)

or something else...