How does Android account for hardware changes in each individual device? I recently wanted to use the fingerprint scanner on my Galaxy S6 in an app and doubted if Android would have classes pertaining to it (it does), which led me to ask:

Does Android add classes to its library for every minor hardware feature on every device that supports Android (like the fingerprint scanner on the Galaxy S6) even the obscure ones that maybe only 1 device has? If not, how would one access those hardware features?
Most hardware-specific code doesn't come from AOSP1, but is provided by the corresponding manufacturer (often as so-called binary blobs). This is especially true for "exotic components" (like your "fingerprint sensor") – but also for more common components as the camera. Which BTW also is one of the reasons why there isn't a "generic ROM" fitting all devices.2



1: Android Open Source Project
2: see Why is it that Android still can't be installed as regular OS? and Can I install any ROM for my Android device?