All, Due to a hardware deficiency, whenever I wake up my device from suspend, my wifi connection status changes to 'disconnected'. My team and I have ported several other platforms before to this device and, for each one, we had to unload my device driver and restart any services that were associated with it before the connection could be established. On our previous iterations, we used apm for power management which made running a simple script on resume trivially simple. With Android, however, it seems that there isn't a reasonable way to shoe-horn this process in.
My first attempt was to create a broadcast receiver which consumed the 'ACTION_SCREEN_ON' intent and run setWifiEnabled(false); setWifiEnabled (true); when the intent was seen. Since these calls don't seem to be synchronous, I added a 'while(wifiManager.isWifiEnabled()) {Thread.sleep(1000);}' to wait for the first action to run. (Yes, I know this is a hack). This actually WORKED for a hardware suspend (when I hit the power button on my device) but NOT for a screen timeout. After this setback, I started tracing back through the networking code and found the WifiService.java that seemed to already be consuming the ACTION_SCREEN_ON intent and doing stuff (albeit apparently asynchronously with messages). I have tried several different ways to get my down / up mechanism to work (in the updateWifiState() and setWifiEnabledBlocking() methods) but to no avail. This whole mechanism seems so interdependent upon itself that adding special blocks to bring down the driver and supplicant only appear to add instability and break things. Can someone who is familiar with this whole mechanism let me know if I'm even LOOKING IN THE RIGHT PLACE or not? Ideally, since the WifiService.java turns on the whole shebang from the persisted state, I should be able to add some sort of call during the resume to just unload the driver and stop the supplicant so that everything starts in a reasonable state. (maybe in the init.<device>.rc?) Thanks, Ben Friedberg --~--~---------~--~----~------------~-------~--~----~ unsubscribe: android-porting+unsubscr...@googlegroups.com website: http://groups.google.com/group/android-porting -~----------~----~----~----~------~----~------~--~---