diff options
author | Mitsuru Oshima <oshima@google.com> | 2009-07-14 10:41:13 -0700 |
---|---|---|
committer | Mitsuru Oshima <oshima@google.com> | 2009-07-14 11:11:17 -0700 |
commit | ddd12535f095d8d056716c3290faf50ec52a538a (patch) | |
tree | bf5da24c87529503059153abe3a913216336e3d6 /core/java/android/content/res | |
parent | 9181bc9ab75f97f11f2188237ba4a0f31569dfb5 (diff) | |
download | frameworks_base-ddd12535f095d8d056716c3290faf50ec52a538a.zip frameworks_base-ddd12535f095d8d056716c3290faf50ec52a538a.tar.gz frameworks_base-ddd12535f095d8d056716c3290faf50ec52a538a.tar.bz2 |
Return adjusted display for WindowManager.getDefaultDisplay()
Diffstat (limited to 'core/java/android/content/res')
-rw-r--r-- | core/java/android/content/res/Resources.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index 8de938d..a9aa1ee 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -34,6 +34,7 @@ import android.util.Log; import android.util.SparseArray; import android.util.TypedValue; import android.util.LongSparseArray; +import android.view.Display; import java.io.IOException; import java.io.InputStream; @@ -87,6 +88,7 @@ public class Resources { PluralRules mPluralRule; private final CompatibilityInfo mCompatibilityInfo; + private Display mDefaultDisplay; private static final LongSparseArray<Object> EMPTY_ARRAY = new LongSparseArray<Object>() { @Override @@ -1915,6 +1917,24 @@ 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; |