Android 8.0 Oreo brings a bunch of interesting features such as the ability to automatically turn on WiFi when your device is within the range of a saved network. Unfortunately, this feature is currently disabled on Nexus 5X and 6P in the final release of Android Oreo, despite being available for all devices with the Developer Preview versions.
With due credit to XDA Developers, curious Nexus 5X and 6P users can now re-enable this feature effortlessly using a few ADB commands. The best part is that it does not require your device to be rooted.
Android 8.0 Oreo or above should be installed on your Nexus 5X/6P.
Keep a USB cable handy for connecting your device to computer.
Ensure that the ADB command-line utility is downloaded and installed on your computer. A third-party ADB installer is recommended as the Google version is not so user-friendly.
Make sure that USB Debugging mode is turned on by going to Settings > System > About Phone. Now tap the build number seven times until you receive a popup message confirming that your Developer privileges are unlocked.
Now hit Back, tap on Developer Options and then toggle or enable 'USB Debugging' option.
How to Enable 'Turn on WiFi automatically' via ADB Commands
Connect your Nexus 5X/6P to computer. If you are on Windows, just hit the Windows key and R key simultaneously. Then type 'cmd' in the ensuing context menu and hit Enter.
If you are on Mac, open the Terminal app via Spotlight search. If using Linux/Ubuntu, just launch the Terminal app via the command line interface.
With the Terminal app open and your device connected to the computer, just type 'adb devices' at the command prompt and hit Enter. Your computer should now detect all connected Android devices. If prompted to allow USB debugging service on your phone or tablet, just select 'Always allow from this computer' and hit OK.
You should now be seeing the full list of connected devices, if you got all the steps right. If not, just repeat the steps from scratch.
In case you got it right, just type in the following commands and hit Enter after each one:
settings put global wifi_wakeup_available 1
settings put global wifi_wakeup_enabled 1
That's it. You should now see the option to 'Turn on WiFi automatically' from the Wi-Fi section of the Settings app.
If you want to disable the feature, just run the commands again and use a zero instead of the '1' at the end.
[Source: XDA Developers]