See here and here.
The gist is that on Android devices specifically, the values returned from Screen.dpi are often off because Android doesn't have the same info available (or in the presumed format) for Unity to crunch. So Unity forces the function Screen.dpi to call densityDpi instead. This method returns constant DPI densities provided by the manufacturer. They may be off by a little or a lot.
That second forum post link is provided by a Unity developer (back in 2013) and they offer a potential workaround function you can use instead of Screen.dpi (though it is not guaranteed). They also list phones where there WERE issues and phones were there were NOT issues. Unfortunately, it being 7 years later now, you will be swinging in the dark a little.
All this being said, the DPI of your phone should be publicly available via a simple Google search. When you find it, just multiply the density by the screen width to get the number of pixels horizontally, and multiply the density by the screen height to get the number of pixels vertically. The manufacturer will likely have more accurate screen size calculations than you can do with a ruler on their website.
This is an official developer guide on the Android website. Check out the content under "Device Compatibility", which includes multiple articles on screen sizes.