After I upgraded my Nexus 5 to Lollipop 5.1, it does not automatically connect to wi-fi because Google is blocked in China and then the phone treated it as no network connection.
I have tried the solution here: How to disable captive portal detection? How to remove exclamation mark on Wi-Fi or signal icon in Lollipop?
However, it only removed the exclamation mark besides the wi-fi signal symbol, but the phone still won't connect to that wi-fi automatically.