* commit 'fa5e3b658f3f42eabec82c9f8e44d8a4cc565249': DO NOT MERGE. Fix density compat mode.
This commit is contained in:
@@ -432,17 +432,17 @@ public class CompatibilityInfo implements Parcelable {
|
|||||||
// compatible with large screens, so diddle it.
|
// compatible with large screens, so diddle it.
|
||||||
CompatibilityInfo.computeCompatibleScaling(inoutDm, inoutDm);
|
CompatibilityInfo.computeCompatibleScaling(inoutDm, inoutDm);
|
||||||
} else {
|
} else {
|
||||||
inoutDm.widthPixels = inoutDm.unscaledWidthPixels;
|
inoutDm.widthPixels = inoutDm.noncompatWidthPixels;
|
||||||
inoutDm.heightPixels = inoutDm.unscaledHeightPixels;
|
inoutDm.heightPixels = inoutDm.noncompatHeightPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isScalingRequired()) {
|
if (isScalingRequired()) {
|
||||||
float invertedRatio = applicationInvertedScale;
|
float invertedRatio = applicationInvertedScale;
|
||||||
inoutDm.density *= invertedRatio;
|
inoutDm.density = inoutDm.noncompatDensity * invertedRatio;
|
||||||
inoutDm.densityDpi = (int)((inoutDm.density*DisplayMetrics.DENSITY_DEFAULT)+.5f);
|
inoutDm.densityDpi = (int)((inoutDm.density*DisplayMetrics.DENSITY_DEFAULT)+.5f);
|
||||||
inoutDm.scaledDensity *= invertedRatio;
|
inoutDm.scaledDensity = inoutDm.noncompatScaledDensity * invertedRatio;
|
||||||
inoutDm.xdpi *= invertedRatio;
|
inoutDm.xdpi = inoutDm.noncompatXdpi * invertedRatio;
|
||||||
inoutDm.ydpi *= invertedRatio;
|
inoutDm.ydpi = inoutDm.noncompatYdpi * invertedRatio;
|
||||||
inoutDm.widthPixels = (int) (inoutDm.widthPixels * invertedRatio + 0.5f);
|
inoutDm.widthPixels = (int) (inoutDm.widthPixels * invertedRatio + 0.5f);
|
||||||
inoutDm.heightPixels = (int) (inoutDm.heightPixels * 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.
|
* @return Returns the scaling factor for the window.
|
||||||
*/
|
*/
|
||||||
public static float computeCompatibleScaling(DisplayMetrics dm, DisplayMetrics outDm) {
|
public static float computeCompatibleScaling(DisplayMetrics dm, DisplayMetrics outDm) {
|
||||||
final int width = dm.unscaledWidthPixels;
|
final int width = dm.noncompatWidthPixels;
|
||||||
final int height = dm.unscaledHeightPixels;
|
final int height = dm.noncompatHeightPixels;
|
||||||
int shortSize, longSize;
|
int shortSize, longSize;
|
||||||
if (width < height) {
|
if (width < height) {
|
||||||
shortSize = width;
|
shortSize = width;
|
||||||
@@ -532,7 +532,9 @@ public class CompatibilityInfo implements Parcelable {
|
|||||||
sb.append(applicationDensity);
|
sb.append(applicationDensity);
|
||||||
sb.append("dpi");
|
sb.append("dpi");
|
||||||
if (isScalingRequired()) {
|
if (isScalingRequired()) {
|
||||||
sb.append(" scaling");
|
sb.append(" ");
|
||||||
|
sb.append(applicationScale);
|
||||||
|
sb.append("x");
|
||||||
}
|
}
|
||||||
if (!supportsScreen()) {
|
if (!supportsScreen()) {
|
||||||
sb.append(" resizing");
|
sb.append(" resizing");
|
||||||
|
|||||||
@@ -1416,23 +1416,19 @@ public class Resources {
|
|||||||
}
|
}
|
||||||
if (metrics != null) {
|
if (metrics != null) {
|
||||||
mMetrics.setTo(metrics);
|
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) {
|
if (mCompatibilityInfo != null) {
|
||||||
mCompatibilityInfo.applyToDisplayMetrics(mMetrics);
|
mCompatibilityInfo.applyToDisplayMetrics(mMetrics);
|
||||||
}
|
}
|
||||||
mMetrics.scaledDensity = mMetrics.density * mConfiguration.fontScale;
|
|
||||||
int configChanges = 0xfffffff;
|
int configChanges = 0xfffffff;
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
mTmpConfig.setTo(config);
|
mTmpConfig.setTo(config);
|
||||||
@@ -1448,6 +1444,7 @@ public class Resources {
|
|||||||
if (mConfiguration.locale == null) {
|
if (mConfiguration.locale == null) {
|
||||||
mConfiguration.locale = Locale.getDefault();
|
mConfiguration.locale = Locale.getDefault();
|
||||||
}
|
}
|
||||||
|
mMetrics.scaledDensity = mMetrics.density * mConfiguration.fontScale;
|
||||||
|
|
||||||
String locale = null;
|
String locale = null;
|
||||||
if (mConfiguration.locale != null) {
|
if (mConfiguration.locale != null) {
|
||||||
|
|||||||
@@ -119,13 +119,37 @@ public class DisplayMetrics {
|
|||||||
* being applied.
|
* being applied.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public int unscaledWidthPixels;
|
public int noncompatWidthPixels;
|
||||||
/**
|
/**
|
||||||
* The reported display height prior to any compatibility mode scaling
|
* The reported display height prior to any compatibility mode scaling
|
||||||
* being applied.
|
* being applied.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public int unscaledHeightPixels;
|
public int noncompatHeightPixels;
|
||||||
|
/**
|
||||||
|
* The reported display density prior to any compatibility mode scaling
|
||||||
|
* being applied.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public float noncompatDensity;
|
||||||
|
/**
|
||||||
|
* The reported scaled density prior to any compatibility mode scaling
|
||||||
|
* being applied.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public float noncompatScaledDensity;
|
||||||
|
/**
|
||||||
|
* The reported display xdpi prior to any compatibility mode scaling
|
||||||
|
* being applied.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public float noncompatXdpi;
|
||||||
|
/**
|
||||||
|
* The reported display ydpi prior to any compatibility mode scaling
|
||||||
|
* being applied.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public float noncompatYdpi;
|
||||||
|
|
||||||
public DisplayMetrics() {
|
public DisplayMetrics() {
|
||||||
}
|
}
|
||||||
@@ -138,8 +162,12 @@ public class DisplayMetrics {
|
|||||||
scaledDensity = o.scaledDensity;
|
scaledDensity = o.scaledDensity;
|
||||||
xdpi = o.xdpi;
|
xdpi = o.xdpi;
|
||||||
ydpi = o.ydpi;
|
ydpi = o.ydpi;
|
||||||
unscaledWidthPixels = o.unscaledWidthPixels;
|
noncompatWidthPixels = o.noncompatWidthPixels;
|
||||||
unscaledHeightPixels = o.unscaledHeightPixels;
|
noncompatHeightPixels = o.noncompatHeightPixels;
|
||||||
|
noncompatDensity = o.noncompatDensity;
|
||||||
|
noncompatScaledDensity = o.noncompatScaledDensity;
|
||||||
|
noncompatXdpi = o.noncompatXdpi;
|
||||||
|
noncompatYdpi = o.noncompatYdpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setToDefaults() {
|
public void setToDefaults() {
|
||||||
@@ -150,8 +178,8 @@ public class DisplayMetrics {
|
|||||||
scaledDensity = density;
|
scaledDensity = density;
|
||||||
xdpi = DENSITY_DEVICE;
|
xdpi = DENSITY_DEVICE;
|
||||||
ydpi = DENSITY_DEVICE;
|
ydpi = DENSITY_DEVICE;
|
||||||
unscaledWidthPixels = 0;
|
noncompatWidthPixels = 0;
|
||||||
unscaledHeightPixels = 0;
|
noncompatHeightPixels = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ public class Display {
|
|||||||
CompatibilityInfo ci;
|
CompatibilityInfo ci;
|
||||||
if (doCompat && (ci=mCompatibilityInfo.getIfNeeded()) != null) {
|
if (doCompat && (ci=mCompatibilityInfo.getIfNeeded()) != null) {
|
||||||
synchronized (mTmpMetrics) {
|
synchronized (mTmpMetrics) {
|
||||||
mTmpMetrics.unscaledWidthPixels = outSize.x;
|
mTmpMetrics.noncompatWidthPixels = outSize.x;
|
||||||
mTmpMetrics.unscaledHeightPixels = outSize.y;
|
mTmpMetrics.noncompatHeightPixels = outSize.y;
|
||||||
mTmpMetrics.density = mDensity;
|
mTmpMetrics.density = mDensity;
|
||||||
ci.applyToDisplayMetrics(mTmpMetrics);
|
ci.applyToDisplayMetrics(mTmpMetrics);
|
||||||
outSize.x = mTmpMetrics.widthPixels;
|
outSize.x = mTmpMetrics.widthPixels;
|
||||||
@@ -268,14 +268,15 @@ public class Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void getNonSizeMetrics(DisplayMetrics outMetrics) {
|
private void getNonSizeMetrics(DisplayMetrics outMetrics) {
|
||||||
outMetrics.density = mDensity;
|
|
||||||
outMetrics.densityDpi = (int)((mDensity*DisplayMetrics.DENSITY_DEFAULT)+.5f);
|
outMetrics.densityDpi = (int)((mDensity*DisplayMetrics.DENSITY_DEFAULT)+.5f);
|
||||||
outMetrics.scaledDensity= outMetrics.density;
|
|
||||||
outMetrics.xdpi = mDpiX;
|
|
||||||
outMetrics.ydpi = mDpiY;
|
|
||||||
|
|
||||||
outMetrics.unscaledWidthPixels = outMetrics.widthPixels;
|
outMetrics.noncompatWidthPixels = outMetrics.widthPixels;
|
||||||
outMetrics.unscaledHeightPixels = outMetrics.heightPixels;
|
outMetrics.noncompatHeightPixels = outMetrics.heightPixels;
|
||||||
|
|
||||||
|
outMetrics.density = outMetrics.noncompatDensity = mDensity;
|
||||||
|
outMetrics.scaledDensity = outMetrics.noncompatScaledDensity = outMetrics.density;
|
||||||
|
outMetrics.xdpi = outMetrics.noncompatXdpi = mDpiX;
|
||||||
|
outMetrics.ydpi = outMetrics.noncompatYdpi = mDpiY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IWindowManager getWindowManager() {
|
static IWindowManager getWindowManager() {
|
||||||
|
|||||||
@@ -5552,10 +5552,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
private int reduceCompatConfigWidthSize(int curSize, int rotation, DisplayMetrics dm,
|
private int reduceCompatConfigWidthSize(int curSize, int rotation, DisplayMetrics dm,
|
||||||
int dw, int dh) {
|
int dw, int dh) {
|
||||||
dm.unscaledWidthPixels = mPolicy.getNonDecorDisplayWidth(rotation, dw);
|
dm.noncompatWidthPixels = mPolicy.getNonDecorDisplayWidth(rotation, dw);
|
||||||
dm.unscaledHeightPixels = mPolicy.getNonDecorDisplayHeight(rotation, dh);
|
dm.noncompatHeightPixels = mPolicy.getNonDecorDisplayHeight(rotation, dh);
|
||||||
float scale = CompatibilityInfo.computeCompatibleScaling(dm, null);
|
float scale = CompatibilityInfo.computeCompatibleScaling(dm, null);
|
||||||
int size = (int)(((dm.unscaledWidthPixels / scale) / dm.density) + .5f);
|
int size = (int)(((dm.noncompatWidthPixels / scale) / dm.density) + .5f);
|
||||||
if (curSize == 0 || size < curSize) {
|
if (curSize == 0 || size < curSize) {
|
||||||
curSize = size;
|
curSize = size;
|
||||||
}
|
}
|
||||||
@@ -5630,9 +5630,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
// Override display width and height with what we are computing,
|
// Override display width and height with what we are computing,
|
||||||
// to be sure they remain consistent.
|
// to be sure they remain consistent.
|
||||||
dm.widthPixels = dm.unscaledWidthPixels = mAppDisplayWidth
|
dm.widthPixels = dm.noncompatWidthPixels = mAppDisplayWidth
|
||||||
= mPolicy.getNonDecorDisplayWidth(mRotation, dw);
|
= mPolicy.getNonDecorDisplayWidth(mRotation, dw);
|
||||||
dm.heightPixels = dm.unscaledHeightPixels = mAppDisplayHeight
|
dm.heightPixels = dm.noncompatHeightPixels = mAppDisplayHeight
|
||||||
= mPolicy.getNonDecorDisplayHeight(mRotation, dh);
|
= mPolicy.getNonDecorDisplayHeight(mRotation, dh);
|
||||||
|
|
||||||
mCompatibleScreenScale = CompatibilityInfo.computeCompatibleScaling(dm,
|
mCompatibleScreenScale = CompatibilityInfo.computeCompatibleScaling(dm,
|
||||||
|
|||||||
Reference in New Issue
Block a user