| Index: ui/android/java/src/org/chromium/ui/gfx/DeviceInfo.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/common/DeviceInfo.java b/ui/android/java/src/org/chromium/ui/gfx/DeviceInfo.java
|
| similarity index 77%
|
| rename from content/public/android/java/src/org/chromium/content/common/DeviceInfo.java
|
| rename to ui/android/java/src/org/chromium/ui/gfx/DeviceInfo.java
|
| index ff7b2a648c92976242220bd6828f2f9ad362b751..b1a6ffd9f14ea8ed0e9bdad5d6c9a01a55d8e44c 100644
|
| --- a/content/public/android/java/src/org/chromium/content/common/DeviceInfo.java
|
| +++ b/ui/android/java/src/org/chromium/ui/gfx/DeviceInfo.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,6 +12,7 @@ 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
|
| @@ -20,6 +21,7 @@ import org.chromium.base.CalledByNative;
|
| * Currently the information consists of very raw display information (height, width, DPI scale)
|
| * regarding the main display, and also the current telephony region.
|
| */
|
| +@JNINamespace("gfx")
|
| public class DeviceInfo {
|
|
|
| private WindowManager mWinManager;
|
| @@ -31,16 +33,25 @@ public class DeviceInfo {
|
| 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 +59,9 @@ public class DeviceInfo {
|
| return info.bitsPerPixel;
|
| }
|
|
|
| + /**
|
| + * @return Bits per component.
|
| + */
|
| @CalledByNative
|
| public int getBitsPerComponent() {
|
| int format = getDisplay().getPixelFormat();
|
| @@ -81,11 +95,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,6 +114,9 @@ public class DeviceInfo {
|
| return (result >= 61 || result < 30) ? 0 : result;
|
| }
|
|
|
| + /**
|
| + * @return The ISO country code equivalent of the current MCC.
|
| + */
|
| @CalledByNative
|
| public String getNetworkCountryIso() {
|
| return mTelManager.getNetworkCountryIso();
|
| @@ -108,6 +132,11 @@ public class DeviceInfo {
|
| return metrics;
|
| }
|
|
|
| + /**
|
| + * Creates DeviceInfo for a given Context.
|
| + * @param context A context to use.
|
| + * @return DeviceInfo associated with a given Context.
|
| + */
|
| @CalledByNative
|
| public static DeviceInfo create(Context context) {
|
| return new DeviceInfo(context);
|
|
|