From: L. David Baron Use a more accurate way of getting the display DPI on Android. (Bug 705278) diff --git a/embedding/android/GeckoAppShell.java b/embedding/android/GeckoAppShell.java --- a/embedding/android/GeckoAppShell.java +++ b/embedding/android/GeckoAppShell.java @@ -1014,17 +1014,19 @@ public class GeckoAppShell NotificationManager notificationManager = (NotificationManager) GeckoApp.mAppContext.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(notificationID); } public static int getDpi() { DisplayMetrics metrics = new DisplayMetrics(); GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics); - return metrics.densityDpi; + // densityDpi is quantized; xdpi and ydpi are accurate, so use + // their average. + return Math.round((metrics.xdpi + metrics.ydpi) / 2.0f) } public static void setFullScreen(boolean fullscreen) { GeckoApp.mFullscreen = fullscreen; // force a reconfiguration to hide/show the system bar GeckoApp.mAppContext.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); GeckoApp.mAppContext.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);