Closed Bug 605024 Opened 10 years ago Closed 10 years ago

GetDPI on Android should be precise

Categories

(Core :: Widget: Android, defect)

All
Android
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: pavlov, Assigned: mbrubeck)

References

Details

Attachments

(1 file)

+++ This bug was initially created as a clone of Bug #602322 +++

nsIWidget::GetDPI should use xdpi to be precise rather than densityDpi

http://developer.android.com/reference/android/util/DisplayMetrics.html#xdpi
Summary: Implement GetDPI on Android → GetDPI on Android should be precise
In practice, xdpi is not actually more precide than densityDpi.  In the current implementation they are always set to the same value:
http://www.google.com/codesearch/p?hl=en#uX1GffpyOZk/core/java/android/util/DisplayMetrics.java&q=DisplayMetrics.java&l=118

Both properties reflect the "ro.sf.lcd_density" property, which is set at build time by the device maker and is not based on querying the actual display hardware:
http://www.google.com/codesearch?q=ro.sf.lcd_density%3D
tracking-fennec: 2.0b2+ → ---
(In reply to comment #1)
> In practice, xdpi is not actually more precide than densityDpi.  In the current
> implementation they are always set to the same value

On closer look, I think I was wrong about this.  The "getMetrics" method in android.view.Display does set xdpi/ydpi to more precise values.
tracking-fennec: --- → ?
Attached patch patchSplinter Review
Assignee: nobody → mbrubeck
Status: NEW → ASSIGNED
Attachment #491319 - Flags: review?(blassey.bugs)
We've seen reports that xdpi is not implemented correctly on some devices:
http://osdir.com/ml/Android-Developers/2010-01/msg03576.html
http://efreedom.com/Question/1-2656330/Anyone-Used-Xdpi-Ydpi-Gotten-Correct-Results

Need more testing before we land this.  We'll try to get data from our QA and internal testers.
Attachment #491319 - Flags: review?(blassey.bugs)
Attachment #491319 - Flags: review?(blassey.bugs)
Attachment #491319 - Flags: review?(blassey.bugs)
Matt, as I suggested on irc, please put together a test app to grab dpi values and ask people to test it on their devices so we can get some useful data here
Here's a test application.  If you run this on your Android device and press the "send email" button, it will submit the data to me: http://limpet.net/dpi.apk
Based on this submission, there are still devices in the wild with inaccurate values for xdpi:

density=1.5
densityDpi=240
xdpi=144.0
ydpi=144.0
manufacturer=motorola
brand=verizon
model=DROIDX
device=cdma_shadow
product=shadow_vzw
display=VZW

We could develop a whitelist or blacklist of hardware models.  Or we could assume xdpi is broken if it is not "close" to densityDpi...
tracking-fennec: ? → 2.0+
The Samsung Galaxy Tab has the opposite problem from the Droid X.  In this case, xdpi is accurate and densityDpi is not:

density=1.5
densityDpi=240
xdpi=168.89351
ydpi=169.33333
manufacturer=samsung
brand=verizon
model=SCH-I800
device=SCH-I800
product=SCH-I800
display=FROYO.DJ11

This means we can't assume densityDpi is more accurate when they differ, as I suggested in comment 7.  Also, if we use xdpi on this device then we will be inconsistent with other Android applications (which are scaled based on densityDpi).
Removing blocking on this; we can't make GetDPI precise if devices don't reliably report a precise DPI.

For the primary case where we intend to use GetDPI (bug 590817, to adjust our UI dimensions), using densityDPI is more appropriate anyway, since it allows vendors to make devices designed for different viewing distances.
tracking-fennec: 2.0+ → ---
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.