Finding source of WiFi Connection Failures A while ago I got a used S5. I rooted it and put CM 13.0 on it, and was very happy with it until it started to fail to connect to any WiFi, on the WiFi setup page stating "WiFi Connection Failure". This happened on any WiFi with this phone, while all other devices would connect just fine with these networks. My router at home (FritzBox) laconically remarks "WiFi device logged off" in its event log. At the same time, 4G worked just fine and I also could connect by Bluetooth-tethering through an old phone I had. Only the WiFi failed. 

I was pretty sure it was a configuration problem, but I didn't find what was wrong and my attempts – from deleting and re-adding the connections until just wiping all of /data/misc/wifi as described here – didn't help. 

So I decided to wipe the whole phone. Since saving all your settings and accounts to re-install on the same device is a bit error-prone (if you don't want to feed it all to google), I got myself a new (used) S5, transferred everything over, and all was good. I then wiped the old one and, just as I suspected, the reset phone connects to any WiFi just fine. :-/

However, a couple of days ago the new S5 started to exhibit the very same behavior. I can now again no longer log into WiFi networks. I have again tried the obvious (deleted the connections, wiped /data/misc/wifi) – but all to no avail. Since I do not want to go through the hassle of having two phones and transferring everything from one phone to the other every other month, I guess I will have to get to the bottom of this now. This is a Linux system, after all, so there must be some logs of what's happening somewhere. Unfortunately I'm not a Unix aficionado, so I do not know this stuff by heart. So here is my question: 

Where do I look to find out what's happening? What do I look at? Where do I start? 

Any pointers are most welcome.
OK, after lots of pulled hair and bitten nails, I think I have found a solution. Rather than closing this question it might be better if I share my findings on the off-chance that someone having this problem might find the solution through google. 

First off, I installed aLogCat Root, and waded through lots of debug output. That got me 


    "Wifi connection closed with errorCode 20"


and


    "Client connection lost with reason: 4"


Googling found lots of issues, most of which obviously did not apply here, while the rest less obviously didn't. None of the solutions helped me. 

However, due to the many times I rebooted while trying all these fixes, at some point the nagging message after reboot making me aware that my Location services are disabled caught my eye and I thought I could give this a try. Well. 

I enabled Location and WiFi works now.

I confirmed it by undoing all the other things I had tried, none of which broke WiFi. However, the very moment I disable Location, WiFi stops working.

To me this isn't obvious at all, and if someone can shed some light on this, I'd be happy to get educated.