summaryrefslogtreecommitdiffstats
path: root/core/java/android/content/res
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-05-24 18:11:57 -0700
committerDianne Hackborn <hackbod@google.com>2011-05-24 18:13:25 -0700
commit5be8de3420ba4c9d816b98e29bdec11715f6b626 (patch)
tree90fd1fb8717bc2aa2afee394d846c4b331cbd17a /core/java/android/content/res
parentef89cc14957ab631346564801841190346632ac9 (diff)
downloadframeworks_base-5be8de3420ba4c9d816b98e29bdec11715f6b626.zip
frameworks_base-5be8de3420ba4c9d816b98e29bdec11715f6b626.tar.gz
frameworks_base-5be8de3420ba4c9d816b98e29bdec11715f6b626.tar.bz2
More compatibility mode improvements.
We now correctly adjust display metrics, fixing for example issues seen in Barcode Scanner. In addition the decision about when to use compatibility mode has a bug fixed where certain apps would not go out of compatibility mode even though they should be able to. Change-Id: I5971206323df0f11ce653d1c790c700f457f0582
Diffstat (limited to 'core/java/android/content/res')
-rw-r--r--core/java/android/content/res/CompatibilityInfo.java19
-rw-r--r--core/java/android/content/res/Configuration.java5
-rwxr-xr-xcore/java/android/content/res/Resources.java28
3 files changed, 23 insertions, 29 deletions
diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java
index 8bcb005..854d410 100644
--- a/core/java/android/content/res/CompatibilityInfo.java
+++ b/core/java/android/content/res/CompatibilityInfo.java
@@ -125,14 +125,16 @@ public class CompatibilityInfo implements Parcelable {
if ((appInfo.flags & ApplicationInfo.FLAG_SUPPORTS_XLARGE_SCREENS) != 0) {
compatFlags |= XLARGE_SCREENS | EXPANDABLE;
}
- if (!forceCompat) {
+ if ((appInfo.flags & ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS) != 0) {
+ compatFlags |= EXPANDABLE;
+ }
+
+ if (forceCompat) {
// If we are forcing compatibility mode, then ignore an app that
// just says it is resizable for screens. We'll only have it fill
// the screen if it explicitly says it supports the screen size we
// are running in.
- if ((appInfo.flags & ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS) != 0) {
- compatFlags |= EXPANDABLE;
- }
+ compatFlags &= ~EXPANDABLE;
}
boolean supportsScreen = false;
@@ -155,12 +157,10 @@ public class CompatibilityInfo implements Parcelable {
break;
}
- if ((screenLayout&Configuration.SCREENLAYOUT_COMPAT_NEEDED) == 0) {
+ if ((screenLayout&Configuration.SCREENLAYOUT_COMPAT_NEEDED) != 0) {
if ((compatFlags&EXPANDABLE) != 0) {
supportsScreen = true;
- }
- if ((compatFlags&EXPANDABLE) == 0 &&
- (appInfo.flags & ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS) == 0) {
+ } else if ((appInfo.flags & ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS) == 0) {
compatFlags |= ALWAYS_COMPAT;
}
}
@@ -382,6 +382,9 @@ public class CompatibilityInfo implements Parcelable {
// This is a larger screen device and the app is not
// compatible with large screens, so diddle it.
CompatibilityInfo.updateCompatibleScreenFrame(inoutDm, null, inoutDm);
+ } else {
+ inoutDm.widthPixels = inoutDm.realWidthPixels;
+ inoutDm.heightPixels = inoutDm.realHeightPixels;
}
if (isScalingRequired()) {
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 51a7115..d476997 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -316,10 +316,11 @@ public final class Configuration implements Parcelable, Comparable<Configuration
StringBuilder sb = new StringBuilder(128);
sb.append("{");
sb.append(fontScale);
- sb.append("x imsi=");
+ sb.append(" ");
sb.append(mcc);
- sb.append("/");
+ sb.append("mcc");
sb.append(mnc);
+ sb.append("mnc");
if (locale != null) {
sb.append(" ");
sb.append(locale);
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index a072e94..e63e7eb 100755
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -115,7 +115,6 @@ public class Resources {
private NativePluralRules mPluralRule;
private CompatibilityInfo mCompatibilityInfo;
- private Display mDefaultDisplay;
private static final LongSparseArray<Object> EMPTY_ARRAY = new LongSparseArray<Object>(0) {
@Override
@@ -1426,6 +1425,15 @@ 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.
mCompatibilityInfo.applyToDisplayMetrics(mMetrics);
}
mMetrics.scaledDensity = mMetrics.density * mConfiguration.fontScale;
@@ -2121,24 +2129,6 @@ public class Resources {
+ Integer.toHexString(id));
}
- /**
- * Returns the display adjusted for the Resources' metrics.
- * @hide
- */
- public Display getDefaultDisplay(Display defaultDisplay) {
- if (mDefaultDisplay == null) {
- if (!mCompatibilityInfo.isScalingRequired() && mCompatibilityInfo.supportsScreen()) {
- // the app supports the display. just use the default one.
- mDefaultDisplay = defaultDisplay;
- } else {
- // display needs adjustment.
- mDefaultDisplay = Display.createMetricsBasedDisplay(
- defaultDisplay.getDisplayId(), mMetrics);
- }
- }
- return mDefaultDisplay;
- }
-
private TypedArray getCachedStyledAttributes(int len) {
synchronized (mTmpValue) {
TypedArray attrs = mCachedStyledAttributes;