This is not exactly true, you are calculating an approximation of the dpi but not the actual dpi.
pixelRatio intervienes between real pixel and independent pixel:
real pixel distance (px) = pixelRatio * independente pixel distance (dp)
exemple with Huawei Y9s (2019) metrics from https://yesviz.com/devices.php
width in independant pixel = 360 dp
width in real pixel = 1080 px
density in independant pixel = 130 dip
density in real pixel = 391 dpi
ratio = 3
the upper formula gives us: 360dp * 3 ≈ 1080px => all good
but ratio = 3
is different from : dpi / 160 = 391 /160 = 2.44
Android makes a confusion between the actual independant density and the bucket density value. (https://www.youtube.com/watch?v=zhszwkcay2A)
But the rendering is different, if you show a div of 320dp on two apple devices :
Ipad Pro 12.9'' (2020) with 132 density in independant pixels => div is printed 61mm or 2.36inch on the screen
Iphone 11 (2019) with 163 density in independant pixels => div is printed 50mm or 2inch on the screen
So technically, density independant pixel can be approximated to 160dip on every devices
And the corresponding approximation of density in real pixel : The bucket density value. Let's call it ~dpi. Can be retrieve with the pixelRatio
~dpi = pixelRatio * 160