| 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 088c9c2476e7f2781572be7a56e1482965716dd3..ad9ce732c80fb1cd4dc36227b22ad619c3a360f8 100644
|
| --- a/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
|
| +++ b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
|
| @@ -5,6 +5,8 @@
|
| package org.chromium.ui.gfx;
|
|
|
| import android.content.Context;
|
| +import android.content.ComponentCallbacks;
|
| +import android.content.res.Configuration;
|
| import android.graphics.PixelFormat;
|
| import android.os.Build;
|
| import android.util.DisplayMetrics;
|
| @@ -21,7 +23,6 @@ import org.chromium.base.JNINamespace;
|
| * Currently the information consists of very raw display information (height, width, DPI scale)
|
| * regarding the main display.
|
| */
|
| -@JNINamespace("gfx")
|
| public class DeviceDisplayInfo {
|
|
|
|
|
| @@ -115,6 +116,25 @@ public class DeviceDisplayInfo {
|
| return getMetrics().density;
|
| }
|
|
|
| + private void registerListener() {
|
| + mAppContext.registerComponentCallbacks(
|
| + new ComponentCallbacks() {
|
| + @Override
|
| + public void onConfigurationChanged(Configuration configuration) {
|
| + updateNativeSharedDisplayInfo();
|
| + }
|
| +
|
| + @Override
|
| + public void onLowMemory() {
|
| + }
|
| + });
|
| + }
|
| +
|
| + private void updateNativeSharedDisplayInfo() {
|
| + nativeUpdateSharedDeviceDisplayInfo(getDisplayHeight(), getDisplayWidth(),
|
| + getBitsPerPixel(), getBitsPerComponent(), getDIPScale());
|
| + }
|
| +
|
| private Display getDisplay() {
|
| return mWinManager.getDefaultDisplay();
|
| }
|
| @@ -128,8 +148,19 @@ public class DeviceDisplayInfo {
|
| * @param context A context to use.
|
| * @return DeviceDisplayInfo associated with a given Context.
|
| */
|
| - @CalledByNative
|
| public static DeviceDisplayInfo create(Context context) {
|
| return new DeviceDisplayInfo(context);
|
| }
|
| +
|
| + @CalledByNative
|
| + private static DeviceDisplayInfo createWithListener(Context context) {
|
| + DeviceDisplayInfo deviceDisplayInfo = new DeviceDisplayInfo(context);
|
| + deviceDisplayInfo.registerListener();
|
| + return deviceDisplayInfo;
|
| + }
|
| +
|
| + private native void nativeUpdateSharedDeviceDisplayInfo(int displayHeight,
|
| + int displayWidth, int bitsPerPixel,
|
| + int bitsPerComponent, double dipScale);
|
| +
|
| }
|
|
|