Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java

Issue 11886074: Use correct favicon scale factor on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split DeviceTelephonyInfo from DeviceDisplayInfo; added SCALE_FACTOR_150P and 300P. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
diff --git a/content/public/android/java/src/org/chromium/content/common/DeviceInfo.java b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
similarity index 71%
rename from content/public/android/java/src/org/chromium/content/common/DeviceInfo.java
rename to ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
index ff7b2a648c92976242220bd6828f2f9ad362b751..61fc018dd4eede138c8a72cd2b983ca911744382 100644
--- a/content/public/android/java/src/org/chromium/content/common/DeviceInfo.java
+++ b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.chromium.content.common;
+package org.chromium.ui.gfx;
import android.content.Context;
import android.graphics.PixelFormat;
@@ -12,35 +12,44 @@ import android.view.Display;
import android.view.WindowManager;
import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
/**
* This class facilitates access to android information typically only
* available using the Java SDK, including {@link Display} properties.
*
* Currently the information consists of very raw display information (height, width, DPI scale)
- * regarding the main display, and also the current telephony region.
+ * regarding the main display.
*/
-public class DeviceInfo {
+@JNINamespace("gfx")
+public class DeviceDisplayInfo {
private WindowManager mWinManager;
- private TelephonyManager mTelManager;
- private DeviceInfo(Context context) {
+ private DeviceDisplayInfo(Context context) {
Context appContext = context.getApplicationContext();
mWinManager = (WindowManager) appContext.getSystemService(Context.WINDOW_SERVICE);
- mTelManager = (TelephonyManager) appContext.getSystemService(Context.TELEPHONY_SERVICE);
}
+ /**
+ * @return Display height in physical pixels.
+ */
@CalledByNative
- public int getHeight() {
+ public int getDisplayHeight() {
return getMetrics().heightPixels;
}
+ /**
+ * @return Display width in physical pixels.
+ */
@CalledByNative
- public int getWidth() {
+ public int getDisplayWidth() {
return getMetrics().widthPixels;
}
+ /**
+ * @return Bits per pixel.
+ */
@CalledByNative
public int getBitsPerPixel() {
PixelFormat info = new PixelFormat();
@@ -48,6 +57,9 @@ public class DeviceInfo {
return info.bitsPerPixel;
}
+ /**
+ * @return Bits per component.
+ */
@CalledByNative
public int getBitsPerComponent() {
int format = getDisplay().getPixelFormat();
@@ -81,11 +93,18 @@ public class DeviceInfo {
}
}
+ /**
+ * @return A scaling factor for the Density Independent Pixel unit.
+ * 1.0 is 160dpi, 0.75 is 120dpi, 2.0 is 320dpi.
+ */
@CalledByNative
- public double getDPIScale() {
+ public double getDIPScale() {
return getMetrics().density;
}
+ /**
+ * @return Display refresh rate in frames per second.
+ */
@CalledByNative
public double getRefreshRate() {
double result = getDisplay().getRefreshRate();
@@ -93,11 +112,6 @@ public class DeviceInfo {
return (result >= 61 || result < 30) ? 0 : result;
}
- @CalledByNative
- public String getNetworkCountryIso() {
- return mTelManager.getNetworkCountryIso();
- }
-
private Display getDisplay() {
return mWinManager.getDefaultDisplay();
}
@@ -108,8 +122,13 @@ public class DeviceInfo {
return metrics;
}
+ /**
+ * Creates DeviceDisplayInfo for a given Context.
+ * @param context A context to use.
+ * @return DeviceDisplayInfo associated with a given Context.
+ */
@CalledByNative
- public static DeviceInfo create(Context context) {
- return new DeviceInfo(context);
+ public static DeviceDisplayInfo create(Context context) {
+ return new DeviceDisplayInfo(context);
}
}

Powered by Google App Engine
This is Rietveld 408576698