Custom ROMs of Android are preferred, because Google is an advertising data intelligence company. Who wants a creepy surveillance advertising company powering their phone?
Do your research before buying a new phone.
Using a custom ROM has a pre-requisite of unlocked bootloader capabilities (some phones, like OnePlus allow you to do this simply by clicking a button in settings). A general rule of thumb: before you buy, search online for instructions on how to unlock the bootloader of said device - if the steps required are beyond your skill level, look for an easier phone.
Decide first, what OS you want to use and then check support to see what phones are capable. Avoid buying phones from cellular companies, because they look out for #1 (themselves) and there's a high probability you'll be restricted on what you're able to do with the device.
Example: Want to run Lineage OS? Check their downloads and see what phones are supported. Research on any phone that looks interesting and within your budget, ensure it will work with your provider (GSM for AT&T, T-Mobile, etc) or CDMA (US Cellular, Verizon, etc.) - then purchase an unlocked phone (not restricted to a specific carrier).
Options:
- microG Lineage OS (preferred; has Google spoofing built-in, which is necessary if you want push notifications)
- Lineage OS - Vanilla Lineage, no push notifications w/out Google crap, else you'll need patches (microG apps + Tingle) to spoof them
- UBPorts - Ubuntu Linux on your phone
- Replicant - Blob-less Android, approved by the Free Software Foundation
App Stores:
- F-Droid - Download their apk, slide it onto your SD card or internal storage > Double-click to install. Free & open source apps.
- Aurora Store - Access to Play Store apps, without needing Google for anything
- De-Googling Android with Lineage OS
- Downloading APKs from one Android to Another
- Sideloading - Firmware upgrades or apps
- Disable IPv6 - init.d script
- Wireshark - tcpdump with Wireshark
- Disabling System Apps
- Updating a hosts file
- Custom Time Server - Otherwise defaults to Google servers
- Upgrading a Major Version - Major version jumps; ie. v16 > v17
Troubleshooting
- Suspicious Network Activity - Determine the source of unwanted network requests
- No root - No root over ADB with Magisk
- Updates - Updating Oneplus 9
- Wi-fi No Internet - Networking and firewall issues
- Hidden SSIDs - Wifi doesn't connect to hidden SSIDs