How does Android chooses among multiple access points? I have been doing a lot of research on this. Unfortunately I was not able to find how, by default, Android chooses among multiple access points.

For instance, if a user walks into a mall and there are 3 hotspots within range, how does the device select which access point to connect to?

-Does the device select the AP based in the order in which they are in the Wi-Fi stack? 
-Does the device select the AP based on signal strength only? 
-Does the device select the AP randomly?


Also, as the user physically moves from the coverage of AP A to the coverage of AP B:

-Does the device stay connected with AP A until it is out of range?
-Does the device transition from AP A to AP B somewhere along the way (sort of like a soft handoff)?


Thank you in advance.
I believe this is device-dependent and is not necessarily managed by Android.  The template wpa_supplicant.conf in /system/etc/wifi/ on my Vibrant says this:


  By default, wpa_supplicant requests driver to perform AP scanning and then uses the scan results to select a suitable AP.  Another alternative is to allow the driver to take care of AP scanning and selection and use wpa_supplicant just to process EAPOL frames based on IEEE 802.11 association information from the driver.


This is controlled by setting the ap_scan variable in the in-use configuration file, /etc/wifi/wpa_supplicant.conf.  Mine is set to 1, which is the default above.  So I guess the question is, at least for my device, how does wpa_supplicant select a suitable AP?

It selects between networks based on explicit priorities given in /data/wifi/bcm_supp.conf.  For networks in the same priority group it selects based on "security policy, signal strength, etc." though the exact algorithm is not given.  In the case where ap_scan is 2 and scan_ssid is 1, the algorithm is simple: The first available network in the list is selected.  New networks are added to the file in the order they're encountered from what I understand; it does not list individual APs, so I assume they are handled dynamically according to whatever algorithm the supplicant is using.

I know that doesn't fully answer your question, but hopefully it's useful.