| Index: ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
|
| diff --git a/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
|
| index da8e0262a1f9e202086b5d4095cc61b47555dd48..c6aa5cd0045a951bfbe82494f53425bb61a27757 100644
|
| --- a/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
|
| +++ b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
|
| @@ -17,6 +17,8 @@ import android.view.WindowManager;
|
| import org.chromium.base.CalledByNative;
|
| import org.chromium.base.JNINamespace;
|
|
|
| +import java.lang.ref.WeakReference;
|
| +
|
| /**
|
| * This class facilitates access to android information typically only
|
| * available using the Java SDK, including {@link Display} properties.
|
| @@ -26,15 +28,16 @@ import org.chromium.base.JNINamespace;
|
| */
|
| @JNINamespace("gfx")
|
| public class DeviceDisplayInfo {
|
| -
|
| - private final Context mAppContext;
|
| + private final WeakReference<Context> mContextRef;
|
| private final WindowManager mWinManager;
|
| + private final int mSmallestDIPWidth;
|
| private Point mTempPoint = new Point();
|
| private DisplayMetrics mTempMetrics = new DisplayMetrics();
|
|
|
| private DeviceDisplayInfo(Context context) {
|
| - mAppContext = context.getApplicationContext();
|
| - mWinManager = (WindowManager) mAppContext.getSystemService(Context.WINDOW_SERVICE);
|
| + mContextRef = new WeakReference<Context>(context);
|
| + mWinManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
| + mSmallestDIPWidth = context.getResources().getConfiguration().smallestScreenWidthDp;
|
| }
|
|
|
| /**
|
| @@ -153,8 +156,8 @@ public class DeviceDisplayInfo {
|
| * application will see, regardless of orientation.
|
| */
|
| @CalledByNative
|
| - private int getSmallestDIPWidth() {
|
| - return mAppContext.getResources().getConfiguration().smallestScreenWidthDp;
|
| + private int getSmallestDIPWidth() { // TODO(gsennton) can we remove this?
|
| + return mSmallestDIPWidth;
|
| }
|
|
|
| /**
|
| @@ -181,18 +184,6 @@ public class DeviceDisplayInfo {
|
| return 0;
|
| }
|
|
|
| - /**
|
| - * Inform the native implementation to update its cached representation of
|
| - * the DeviceDisplayInfo values.
|
| - */
|
| - public void updateNativeSharedDisplayInfo() {
|
| - nativeUpdateSharedDeviceDisplayInfo(
|
| - getDisplayHeight(), getDisplayWidth(),
|
| - getPhysicalDisplayHeight(), getPhysicalDisplayWidth(),
|
| - getBitsPerPixel(), getBitsPerComponent(),
|
| - getDIPScale(), getSmallestDIPWidth(), getRotationDegrees());
|
| - }
|
| -
|
| private Display getDisplay() {
|
| return mWinManager.getDefaultDisplay();
|
| }
|
| @@ -207,11 +198,4 @@ public class DeviceDisplayInfo {
|
| public static DeviceDisplayInfo create(Context context) {
|
| return new DeviceDisplayInfo(context);
|
| }
|
| -
|
| - private native void nativeUpdateSharedDeviceDisplayInfo(
|
| - int displayHeight, int displayWidth,
|
| - int physicalDisplayHeight, int physicalDisplayWidth,
|
| - int bitsPerPixel, int bitsPerComponent, double dipScale,
|
| - int smallestDIPWidth, int rotationDegrees);
|
| -
|
| }
|
|
|