Merge branch 'donut' of ssh://android-git.corp.google.com:29418/platform/frameworks/base into donut

This commit is contained in:
The Android Open Source Project
2009-05-07 17:40:33 -07:00
2 changed files with 15 additions and 9 deletions

View File

@@ -316,18 +316,16 @@ public final class ActivityThread {
float appScale = -1.0f;
if (ai.supportsDensities != null) {
// TODO: precompute this in DisplayMetrics
float systemDensityDpi = metrics.density * DisplayMetrics.DEFAULT_DENSITY;
int minDiff = Integer.MAX_VALUE;
for (int density : ai.supportsDensities) {
int tmpDiff = (int) Math.abs(systemDensityDpi - density);
int tmpDiff = (int) Math.abs(DisplayMetrics.DEVICE_DENSITY - density);
if (tmpDiff == 0) {
appScale = 1.0f;
break;
}
// prefer higher density (appScale>1.0), unless that's only option.
if (tmpDiff < minDiff && appScale < 1.0f) {
appScale = systemDensityDpi / density;
appScale = DisplayMetrics.DEVICE_DENSITY / density;
minDiff = tmpDiff;
}
}
@@ -3482,6 +3480,8 @@ public final class ActivityThread {
}
mConfiguration.updateFrom(config);
DisplayMetrics dm = getDisplayMetricsLocked(true);
DisplayMetrics appDm = new DisplayMetrics();
appDm.setTo(dm);
// set it for java, this also affects newly created Resources
if (config.locale != null) {
@@ -3501,7 +3501,9 @@ public final class ActivityThread {
WeakReference<Resources> v = it.next();
Resources r = v.get();
if (r != null) {
r.updateConfiguration(config, dm);
// keep the original density based on application cale.
appDm.density = r.getDisplayMetrics().density;
r.updateConfiguration(config, appDm);
//Log.i(TAG, "Updated app resources " + v.getKey()
// + " " + r + ": " + r.getConfiguration());
} else {

View File

@@ -31,7 +31,11 @@ public class DisplayMetrics {
*/
public static final int DEFAULT_DENSITY = 160;
private static final int sLcdDensity = SystemProperties.getInt("ro.sf.lcd_density",
/**
* The device's density.
* @hide
*/
public static final int DEVICE_DENSITY = SystemProperties.getInt("ro.sf.lcd_density",
DEFAULT_DENSITY);
/**
@@ -90,9 +94,9 @@ public class DisplayMetrics {
public void setToDefaults() {
widthPixels = 0;
heightPixels = 0;
density = sLcdDensity / (float) DEFAULT_DENSITY;
density = DEVICE_DENSITY / (float) DEFAULT_DENSITY;
scaledDensity = density;
xdpi = sLcdDensity;
ydpi = sLcdDensity;
xdpi = DEVICE_DENSITY;
ydpi = DEVICE_DENSITY;
}
}