How does Android Marshmallow decide which WiFi network to automatically join? For example I have two networks:


Two networks - one open hotspot network and one closed private network using WPA.
User has access to both networks
User has recently connected to both.
Both networks have the same signal strength.


Which network is automatically joined? Is it random?
There is this file /data/misc/wifi/wpa_supplicant.conf

Each Network you saved is listed there.

When multiple network blocks are listed in this configuration file, the highest priority one is selected for use or, if multiple networks with the same priority are identified, the first one listed in the configuration file is used.

(copy from http://www.freebsd.org/cgi/man.cgi?wpa_supplicant.conf(5), I think Android behaves the same)