How the bucket is selected
The system compares the panel's ppi to the six bucket values and picks the nearest one. There is no interpolation: a 400 ppi panel and a 460 ppi panel both resolve to xxhdpi at 480. This coarse snapping is deliberate, because a continuous range of scale factors would make it impossible to know which asset size to ship.
What actually matters in practice
In modern Android development you will mostly ship vector drawables and let them scale, which makes the folder structure largely irrelevant for icons. It still matters for photographic assets and for any bitmap you cannot vectorise. Ship xxhdpi as your baseline and let the system downscale; upscaling from mdpi looks visibly soft on any current phone.
The bucket also affects memory. A full-screen bitmap at xxxhdpi is 2.25 times the pixel count of the same image at xxhdpi, and this is a common cause of jank on mid-range hardware. If your app targets budget devices, test with xxhdpi assets rather than the highest density you can produce.
Where devices actually land
Almost every phone sold since roughly 2016 resolves to xxhdpi. Budget 720p devices can land on hdpi or xhdpi. Tablets often sit at mdpi or hdpi because their ppi is low relative to their size. xxxhdpi appears on some high-density flagships, but the visual difference against xxhdpi is small enough that many teams do not ship it at all.
To see which bucket a specific phone uses, look it up in the device database.