Besides high quality hardware support and device availability. The fact of the matter is the core of Android is OPEN SOURCE. I can and have built every last bit of software on my Moto X4 thanks to LineageOS, which is based on AOSP.
[0] https://wiki.lineageos.org/devices/payton/build#extract-prop...