diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-05-26 11:39:22 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-05-26 11:39:22 -0700 |
commit | 7a09f72b8850ec22e4ca7fd50aba20ead7666f67 (patch) | |
tree | a634e3074cc07606449f2c1fe2699e49c6817983 /core/java | |
parent | 66fd9ab236b3df85a32792caec41a2cd83622e28 (diff) | |
parent | 81e56d535c853d73ff537357da5b935f51cb779d (diff) | |
download | frameworks_base-7a09f72b8850ec22e4ca7fd50aba20ead7666f67.zip frameworks_base-7a09f72b8850ec22e4ca7fd50aba20ead7666f67.tar.gz frameworks_base-7a09f72b8850ec22e4ca7fd50aba20ead7666f67.tar.bz2 |
Merge "Rework how we decide whether to use system or status bar." into honeycomb-mr2
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/app/ContextImpl.java | 3 | ||||
-rw-r--r-- | core/java/android/content/res/CompatibilityInfo.java | 8 | ||||
-rw-r--r-- | core/java/android/util/DisplayMetrics.java | 24 | ||||
-rw-r--r-- | core/java/android/view/Display.java | 44 | ||||
-rw-r--r-- | core/java/android/view/IWindowManager.aidl | 3 | ||||
-rw-r--r-- | core/java/android/view/WindowManagerPolicy.java | 6 |
6 files changed, 57 insertions, 31 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 51f1e3d..73170bb 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -425,9 +425,6 @@ class ContextImpl extends Context { registerService(WINDOW_SERVICE, new ServiceFetcher() { public Object getService(ContextImpl ctx) { - RuntimeException e = new RuntimeException("foo"); - e.fillInStackTrace(); - Log.i(TAG, "Getting window manager", e); CompatibilityInfo ci = ctx.mResources.getCompatibilityInfo(); return WindowManagerImpl.getDefault(ci); }}); diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java index dca53a8..8d725cd 100644 --- a/core/java/android/content/res/CompatibilityInfo.java +++ b/core/java/android/content/res/CompatibilityInfo.java @@ -392,8 +392,8 @@ public class CompatibilityInfo implements Parcelable { // compatible with large screens, so diddle it. CompatibilityInfo.updateCompatibleScreenFrame(inoutDm, null, inoutDm); } else { - inoutDm.widthPixels = inoutDm.realWidthPixels; - inoutDm.heightPixels = inoutDm.realHeightPixels; + inoutDm.widthPixels = inoutDm.unscaledWidthPixels; + inoutDm.heightPixels = inoutDm.unscaledHeightPixels; } if (isScalingRequired()) { @@ -429,8 +429,8 @@ public class CompatibilityInfo implements Parcelable { */ public static float updateCompatibleScreenFrame(DisplayMetrics dm, Rect outRect, DisplayMetrics outDm) { - final int width = dm.realWidthPixels; - final int height = dm.realHeightPixels; + final int width = dm.unscaledWidthPixels; + final int height = dm.unscaledHeightPixels; int shortSize, longSize; if (width < height) { shortSize = width; diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java index 8018ff9..60a4ef2 100644 --- a/core/java/android/util/DisplayMetrics.java +++ b/core/java/android/util/DisplayMetrics.java @@ -105,10 +105,18 @@ public class DisplayMetrics { */ public float ydpi; - /** @hide */ - public int realWidthPixels; - /** @hide */ - public int realHeightPixels; + /** + * The reported display width prior to any compatibility mode scaling + * being applied. + * @hide + */ + public int unscaledWidthPixels; + /** + * The reported display height prior to any compatibility mode scaling + * being applied. + * @hide + */ + public int unscaledHeightPixels; public DisplayMetrics() { } @@ -121,8 +129,8 @@ public class DisplayMetrics { scaledDensity = o.scaledDensity; xdpi = o.xdpi; ydpi = o.ydpi; - realWidthPixels = o.realWidthPixels; - realHeightPixels = o.realHeightPixels; + unscaledWidthPixels = o.unscaledWidthPixels; + unscaledHeightPixels = o.unscaledHeightPixels; } public void setToDefaults() { @@ -133,8 +141,8 @@ public class DisplayMetrics { scaledDensity = density; xdpi = DENSITY_DEVICE; ydpi = DENSITY_DEVICE; - realWidthPixels = 0; - realHeightPixels = 0; + unscaledWidthPixels = 0; + unscaledHeightPixels = 0; } @Override diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index b5d36d9..8032546 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -80,25 +80,37 @@ public class Display { * adjusted for you based on the current rotation of the display. */ public void getSize(Point outSize) { + getSizeInternal(outSize, true); + } + + /** + * Returns the raw size of the display, in pixels. Note that this + * should <em>not</em> generally be used for computing layouts, since + * a device will typically have screen decoration (such as a status bar) + * along the edges of the display that reduce the amount of application + * space available from the raw size returned here. This value is + * adjusted for you based on the current rotation of the display. + */ + private void getSizeInternal(Point outSize, boolean doCompat) { try { IWindowManager wm = getWindowManager(); if (wm != null) { wm.getDisplaySize(outSize); + if (doCompat && mCompatibilityInfo != null) { + synchronized (mTmpMetrics) { + mTmpMetrics.unscaledWidthPixels = outSize.x; + mTmpMetrics.unscaledHeightPixels = outSize.y; + mTmpMetrics.density = mDensity; + mCompatibilityInfo.applyToDisplayMetrics(mTmpMetrics); + outSize.x = mTmpMetrics.widthPixels; + outSize.y = mTmpMetrics.heightPixels; + } + } } else { // This is just for boot-strapping, initializing the // system process before the window manager is up. outSize.y = getRealHeight(); } - if (mCompatibilityInfo != null) { - synchronized (mTmpMetrics) { - mTmpMetrics.realWidthPixels = outSize.x; - mTmpMetrics.realHeightPixels = outSize.y; - mTmpMetrics.density = mDensity; - mCompatibilityInfo.applyToDisplayMetrics(mTmpMetrics); - outSize.x = mTmpMetrics.widthPixels; - outSize.y = mTmpMetrics.heightPixels; - } - } } catch (RemoteException e) { Slog.w("Display", "Unable to get display size", e); } @@ -109,7 +121,7 @@ public class Display { */ public void getRectSize(Rect outSize) { synchronized (mTmpPoint) { - getSize(mTmpPoint); + getSizeInternal(mTmpPoint, true); outSize.set(0, 0, mTmpPoint.x, mTmpPoint.y); } } @@ -137,7 +149,7 @@ public class Display { synchronized (mTmpPoint) { long now = SystemClock.uptimeMillis(); if (now > (mLastGetTime+20)) { - getSize(mTmpPoint); + getSizeInternal(mTmpPoint, true); mLastGetTime = now; } return mTmpPoint.x; @@ -152,7 +164,7 @@ public class Display { synchronized (mTmpPoint) { long now = SystemClock.uptimeMillis(); if (now > (mLastGetTime+20)) { - getSize(mTmpPoint); + getSizeInternal(mTmpPoint, true); mLastGetTime = now; } return mTmpPoint.y; @@ -218,7 +230,7 @@ public class Display { */ public void getMetrics(DisplayMetrics outMetrics) { synchronized (mTmpPoint) { - getSize(mTmpPoint); + getSizeInternal(mTmpPoint, false); outMetrics.widthPixels = mTmpPoint.x; outMetrics.heightPixels = mTmpPoint.y; } @@ -248,8 +260,8 @@ public class Display { outMetrics.xdpi = mDpiX; outMetrics.ydpi = mDpiY; - outMetrics.realWidthPixels = outMetrics.widthPixels; - outMetrics.realHeightPixels = outMetrics.heightPixels; + outMetrics.unscaledWidthPixels = outMetrics.widthPixels; + outMetrics.unscaledHeightPixels = outMetrics.heightPixels; } static IWindowManager getWindowManager() { diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index adafb59..bdf04ab 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -59,6 +59,9 @@ interface IWindowManager void setForcedDisplaySize(int longDimen, int shortDimen); void clearForcedDisplaySize(); + // Is device configured with a hideable status bar or a tablet system bar? + boolean canStatusBarHide(); + // These can only be called when injecting events to your own window, // or by holding the INJECT_EVENTS permission. These methods may block // until pending input events are finished being dispatched even when 'sync' is false. diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 086ed5a..beb23aa 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -464,6 +464,12 @@ public interface WindowManagerPolicy { public int getMaxWallpaperLayer(); /** + * Return true if the policy allows the status bar to hide. Otherwise, + * it is a tablet-style system bar. + */ + public boolean canStatusBarHide(); + + /** * Return the display width available after excluding any screen * decorations that can never be removed. That is, system bar or * button bar. |