diff options
| author | Dianne Hackborn <hackbod@google.com> | 2011-06-23 11:58:50 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2011-06-23 12:00:54 -0700 |
| commit | 2b31d53161789358de57fd396716a6503855c5da (patch) | |
| tree | 5c83f241eee1d124fa564457891465f2d8884a94 /core/java/android/content/res | |
| parent | 0f5d8441ef3ee88855df71b15d81f4c14f12d63d (diff) | |
| download | frameworks_base-2b31d53161789358de57fd396716a6503855c5da.zip frameworks_base-2b31d53161789358de57fd396716a6503855c5da.tar.gz frameworks_base-2b31d53161789358de57fd396716a6503855c5da.tar.bz2 | |
Fix issue #4770360: older app compatibility mode is really tiny on ICS phones
We were applying the density compat mode scaling multiple times to
display metrics, causing bad values.
Change-Id: Iafafd9a5e94b9d774cd2715bf968e91602a1bd82
Diffstat (limited to 'core/java/android/content/res')
| -rw-r--r-- | core/java/android/content/res/CompatibilityInfo.java | 20 | ||||
| -rwxr-xr-x | core/java/android/content/res/Resources.java | 23 |
2 files changed, 21 insertions, 22 deletions
diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java index acf2f2f..1c9285e 100644 --- a/core/java/android/content/res/CompatibilityInfo.java +++ b/core/java/android/content/res/CompatibilityInfo.java @@ -432,17 +432,17 @@ public class CompatibilityInfo implements Parcelable { // compatible with large screens, so diddle it. CompatibilityInfo.computeCompatibleScaling(inoutDm, inoutDm); } else { - inoutDm.widthPixels = inoutDm.unscaledWidthPixels; - inoutDm.heightPixels = inoutDm.unscaledHeightPixels; + inoutDm.widthPixels = inoutDm.noncompatWidthPixels; + inoutDm.heightPixels = inoutDm.noncompatHeightPixels; } if (isScalingRequired()) { float invertedRatio = applicationInvertedScale; - inoutDm.density *= invertedRatio; + inoutDm.density = inoutDm.noncompatDensity * invertedRatio; inoutDm.densityDpi = (int)((inoutDm.density*DisplayMetrics.DENSITY_DEFAULT)+.5f); - inoutDm.scaledDensity *= invertedRatio; - inoutDm.xdpi *= invertedRatio; - inoutDm.ydpi *= invertedRatio; + inoutDm.scaledDensity = inoutDm.noncompatScaledDensity * invertedRatio; + inoutDm.xdpi = inoutDm.noncompatXdpi * invertedRatio; + inoutDm.ydpi = inoutDm.noncompatYdpi * invertedRatio; inoutDm.widthPixels = (int) (inoutDm.widthPixels * invertedRatio + 0.5f); inoutDm.heightPixels = (int) (inoutDm.heightPixels * invertedRatio + 0.5f); } @@ -471,8 +471,8 @@ public class CompatibilityInfo implements Parcelable { * @return Returns the scaling factor for the window. */ public static float computeCompatibleScaling(DisplayMetrics dm, DisplayMetrics outDm) { - final int width = dm.unscaledWidthPixels; - final int height = dm.unscaledHeightPixels; + final int width = dm.noncompatWidthPixels; + final int height = dm.noncompatHeightPixels; int shortSize, longSize; if (width < height) { shortSize = width; @@ -532,7 +532,9 @@ public class CompatibilityInfo implements Parcelable { sb.append(applicationDensity); sb.append("dpi"); if (isScalingRequired()) { - sb.append(" scaling"); + sb.append(" "); + sb.append(applicationScale); + sb.append("x"); } if (!supportsScreen()) { sb.append(" resizing"); diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index bd8b1a4..324c9fd 100755 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -1416,23 +1416,19 @@ public class Resources { } if (metrics != null) { mMetrics.setTo(metrics); - // NOTE: We should re-arrange this code to create a Display - // with the CompatibilityInfo that is used everywhere we deal - // with the display in relation to this app, rather than - // doing the conversion here. This impl should be okay because - // we make sure to return a compatible display in the places - // where there are public APIs to retrieve the display... but - // it would be cleaner and more maintainble to just be - // consistently dealing with a compatible display everywhere in - // the framework. - if (mCompatibilityInfo != null) { - mCompatibilityInfo.applyToDisplayMetrics(mMetrics); - } } + // NOTE: We should re-arrange this code to create a Display + // with the CompatibilityInfo that is used everywhere we deal + // with the display in relation to this app, rather than + // doing the conversion here. This impl should be okay because + // we make sure to return a compatible display in the places + // where there are public APIs to retrieve the display... but + // it would be cleaner and more maintainble to just be + // consistently dealing with a compatible display everywhere in + // the framework. if (mCompatibilityInfo != null) { mCompatibilityInfo.applyToDisplayMetrics(mMetrics); } - mMetrics.scaledDensity = mMetrics.density * mConfiguration.fontScale; int configChanges = 0xfffffff; if (config != null) { mTmpConfig.setTo(config); @@ -1448,6 +1444,7 @@ public class Resources { if (mConfiguration.locale == null) { mConfiguration.locale = Locale.getDefault(); } + mMetrics.scaledDensity = mMetrics.density * mConfiguration.fontScale; String locale = null; if (mConfiguration.locale != null) { |
