Loading core/java/android/app/ContextImpl.java +0 −3 Original line number Original line Diff line number Diff line Loading @@ -425,9 +425,6 @@ class ContextImpl extends Context { registerService(WINDOW_SERVICE, new ServiceFetcher() { registerService(WINDOW_SERVICE, new ServiceFetcher() { public Object getService(ContextImpl ctx) { public Object getService(ContextImpl ctx) { RuntimeException e = new RuntimeException("foo"); e.fillInStackTrace(); Log.i(TAG, "Getting window manager", e); CompatibilityInfo ci = ctx.mResources.getCompatibilityInfo(); CompatibilityInfo ci = ctx.mResources.getCompatibilityInfo(); return WindowManagerImpl.getDefault(ci); return WindowManagerImpl.getDefault(ci); }}); }}); Loading core/java/android/content/res/CompatibilityInfo.java +4 −4 Original line number Original line Diff line number Diff line Loading @@ -392,8 +392,8 @@ public class CompatibilityInfo implements Parcelable { // compatible with large screens, so diddle it. // compatible with large screens, so diddle it. CompatibilityInfo.updateCompatibleScreenFrame(inoutDm, null, inoutDm); CompatibilityInfo.updateCompatibleScreenFrame(inoutDm, null, inoutDm); } else { } else { inoutDm.widthPixels = inoutDm.realWidthPixels; inoutDm.widthPixels = inoutDm.unscaledWidthPixels; inoutDm.heightPixels = inoutDm.realHeightPixels; inoutDm.heightPixels = inoutDm.unscaledHeightPixels; } } if (isScalingRequired()) { if (isScalingRequired()) { Loading Loading @@ -429,8 +429,8 @@ public class CompatibilityInfo implements Parcelable { */ */ public static float updateCompatibleScreenFrame(DisplayMetrics dm, public static float updateCompatibleScreenFrame(DisplayMetrics dm, Rect outRect, DisplayMetrics outDm) { Rect outRect, DisplayMetrics outDm) { final int width = dm.realWidthPixels; final int width = dm.unscaledWidthPixels; final int height = dm.realHeightPixels; final int height = dm.unscaledHeightPixels; int shortSize, longSize; int shortSize, longSize; if (width < height) { if (width < height) { shortSize = width; shortSize = width; Loading core/java/android/util/DisplayMetrics.java +16 −8 Original line number Original line Diff line number Diff line Loading @@ -105,10 +105,18 @@ public class DisplayMetrics { */ */ public float ydpi; public float ydpi; /** @hide */ /** public int realWidthPixels; * The reported display width prior to any compatibility mode scaling /** @hide */ * being applied. public int realHeightPixels; * @hide */ public int unscaledWidthPixels; /** * The reported display height prior to any compatibility mode scaling * being applied. * @hide */ public int unscaledHeightPixels; public DisplayMetrics() { public DisplayMetrics() { } } Loading @@ -121,8 +129,8 @@ public class DisplayMetrics { scaledDensity = o.scaledDensity; scaledDensity = o.scaledDensity; xdpi = o.xdpi; xdpi = o.xdpi; ydpi = o.ydpi; ydpi = o.ydpi; realWidthPixels = o.realWidthPixels; unscaledWidthPixels = o.unscaledWidthPixels; realHeightPixels = o.realHeightPixels; unscaledHeightPixels = o.unscaledHeightPixels; } } public void setToDefaults() { public void setToDefaults() { Loading @@ -133,8 +141,8 @@ public class DisplayMetrics { scaledDensity = density; scaledDensity = density; xdpi = DENSITY_DEVICE; xdpi = DENSITY_DEVICE; ydpi = DENSITY_DEVICE; ydpi = DENSITY_DEVICE; realWidthPixels = 0; unscaledWidthPixels = 0; realHeightPixels = 0; unscaledHeightPixels = 0; } } @Override @Override Loading core/java/android/view/Display.java +28 −16 Original line number Original line Diff line number Diff line Loading @@ -80,25 +80,37 @@ public class Display { * adjusted for you based on the current rotation of the display. * adjusted for you based on the current rotation of the display. */ */ public void getSize(Point outSize) { 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 { try { IWindowManager wm = getWindowManager(); IWindowManager wm = getWindowManager(); if (wm != null) { if (wm != null) { wm.getDisplaySize(outSize); wm.getDisplaySize(outSize); } else { if (doCompat && mCompatibilityInfo != null) { // This is just for boot-strapping, initializing the // system process before the window manager is up. outSize.y = getRealHeight(); } if (mCompatibilityInfo != null) { synchronized (mTmpMetrics) { synchronized (mTmpMetrics) { mTmpMetrics.realWidthPixels = outSize.x; mTmpMetrics.unscaledWidthPixels = outSize.x; mTmpMetrics.realHeightPixels = outSize.y; mTmpMetrics.unscaledHeightPixels = outSize.y; mTmpMetrics.density = mDensity; mTmpMetrics.density = mDensity; mCompatibilityInfo.applyToDisplayMetrics(mTmpMetrics); mCompatibilityInfo.applyToDisplayMetrics(mTmpMetrics); outSize.x = mTmpMetrics.widthPixels; outSize.x = mTmpMetrics.widthPixels; outSize.y = mTmpMetrics.heightPixels; outSize.y = mTmpMetrics.heightPixels; } } } } } else { // This is just for boot-strapping, initializing the // system process before the window manager is up. outSize.y = getRealHeight(); } } catch (RemoteException e) { } catch (RemoteException e) { Slog.w("Display", "Unable to get display size", e); Slog.w("Display", "Unable to get display size", e); } } Loading @@ -109,7 +121,7 @@ public class Display { */ */ public void getRectSize(Rect outSize) { public void getRectSize(Rect outSize) { synchronized (mTmpPoint) { synchronized (mTmpPoint) { getSize(mTmpPoint); getSizeInternal(mTmpPoint, true); outSize.set(0, 0, mTmpPoint.x, mTmpPoint.y); outSize.set(0, 0, mTmpPoint.x, mTmpPoint.y); } } } } Loading Loading @@ -137,7 +149,7 @@ public class Display { synchronized (mTmpPoint) { synchronized (mTmpPoint) { long now = SystemClock.uptimeMillis(); long now = SystemClock.uptimeMillis(); if (now > (mLastGetTime+20)) { if (now > (mLastGetTime+20)) { getSize(mTmpPoint); getSizeInternal(mTmpPoint, true); mLastGetTime = now; mLastGetTime = now; } } return mTmpPoint.x; return mTmpPoint.x; Loading @@ -152,7 +164,7 @@ public class Display { synchronized (mTmpPoint) { synchronized (mTmpPoint) { long now = SystemClock.uptimeMillis(); long now = SystemClock.uptimeMillis(); if (now > (mLastGetTime+20)) { if (now > (mLastGetTime+20)) { getSize(mTmpPoint); getSizeInternal(mTmpPoint, true); mLastGetTime = now; mLastGetTime = now; } } return mTmpPoint.y; return mTmpPoint.y; Loading Loading @@ -218,7 +230,7 @@ public class Display { */ */ public void getMetrics(DisplayMetrics outMetrics) { public void getMetrics(DisplayMetrics outMetrics) { synchronized (mTmpPoint) { synchronized (mTmpPoint) { getSize(mTmpPoint); getSizeInternal(mTmpPoint, false); outMetrics.widthPixels = mTmpPoint.x; outMetrics.widthPixels = mTmpPoint.x; outMetrics.heightPixels = mTmpPoint.y; outMetrics.heightPixels = mTmpPoint.y; } } Loading Loading @@ -248,8 +260,8 @@ public class Display { outMetrics.xdpi = mDpiX; outMetrics.xdpi = mDpiX; outMetrics.ydpi = mDpiY; outMetrics.ydpi = mDpiY; outMetrics.realWidthPixels = outMetrics.widthPixels; outMetrics.unscaledWidthPixels = outMetrics.widthPixels; outMetrics.realHeightPixels = outMetrics.heightPixels; outMetrics.unscaledHeightPixels = outMetrics.heightPixels; } } static IWindowManager getWindowManager() { static IWindowManager getWindowManager() { Loading core/java/android/view/IWindowManager.aidl +3 −0 Original line number Original line Diff line number Diff line Loading @@ -59,6 +59,9 @@ interface IWindowManager void setForcedDisplaySize(int longDimen, int shortDimen); void setForcedDisplaySize(int longDimen, int shortDimen); void clearForcedDisplaySize(); 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, // These can only be called when injecting events to your own window, // or by holding the INJECT_EVENTS permission. These methods may block // or by holding the INJECT_EVENTS permission. These methods may block // until pending input events are finished being dispatched even when 'sync' is false. // until pending input events are finished being dispatched even when 'sync' is false. Loading Loading
core/java/android/app/ContextImpl.java +0 −3 Original line number Original line Diff line number Diff line Loading @@ -425,9 +425,6 @@ class ContextImpl extends Context { registerService(WINDOW_SERVICE, new ServiceFetcher() { registerService(WINDOW_SERVICE, new ServiceFetcher() { public Object getService(ContextImpl ctx) { public Object getService(ContextImpl ctx) { RuntimeException e = new RuntimeException("foo"); e.fillInStackTrace(); Log.i(TAG, "Getting window manager", e); CompatibilityInfo ci = ctx.mResources.getCompatibilityInfo(); CompatibilityInfo ci = ctx.mResources.getCompatibilityInfo(); return WindowManagerImpl.getDefault(ci); return WindowManagerImpl.getDefault(ci); }}); }}); Loading
core/java/android/content/res/CompatibilityInfo.java +4 −4 Original line number Original line Diff line number Diff line Loading @@ -392,8 +392,8 @@ public class CompatibilityInfo implements Parcelable { // compatible with large screens, so diddle it. // compatible with large screens, so diddle it. CompatibilityInfo.updateCompatibleScreenFrame(inoutDm, null, inoutDm); CompatibilityInfo.updateCompatibleScreenFrame(inoutDm, null, inoutDm); } else { } else { inoutDm.widthPixels = inoutDm.realWidthPixels; inoutDm.widthPixels = inoutDm.unscaledWidthPixels; inoutDm.heightPixels = inoutDm.realHeightPixels; inoutDm.heightPixels = inoutDm.unscaledHeightPixels; } } if (isScalingRequired()) { if (isScalingRequired()) { Loading Loading @@ -429,8 +429,8 @@ public class CompatibilityInfo implements Parcelable { */ */ public static float updateCompatibleScreenFrame(DisplayMetrics dm, public static float updateCompatibleScreenFrame(DisplayMetrics dm, Rect outRect, DisplayMetrics outDm) { Rect outRect, DisplayMetrics outDm) { final int width = dm.realWidthPixels; final int width = dm.unscaledWidthPixels; final int height = dm.realHeightPixels; final int height = dm.unscaledHeightPixels; int shortSize, longSize; int shortSize, longSize; if (width < height) { if (width < height) { shortSize = width; shortSize = width; Loading
core/java/android/util/DisplayMetrics.java +16 −8 Original line number Original line Diff line number Diff line Loading @@ -105,10 +105,18 @@ public class DisplayMetrics { */ */ public float ydpi; public float ydpi; /** @hide */ /** public int realWidthPixels; * The reported display width prior to any compatibility mode scaling /** @hide */ * being applied. public int realHeightPixels; * @hide */ public int unscaledWidthPixels; /** * The reported display height prior to any compatibility mode scaling * being applied. * @hide */ public int unscaledHeightPixels; public DisplayMetrics() { public DisplayMetrics() { } } Loading @@ -121,8 +129,8 @@ public class DisplayMetrics { scaledDensity = o.scaledDensity; scaledDensity = o.scaledDensity; xdpi = o.xdpi; xdpi = o.xdpi; ydpi = o.ydpi; ydpi = o.ydpi; realWidthPixels = o.realWidthPixels; unscaledWidthPixels = o.unscaledWidthPixels; realHeightPixels = o.realHeightPixels; unscaledHeightPixels = o.unscaledHeightPixels; } } public void setToDefaults() { public void setToDefaults() { Loading @@ -133,8 +141,8 @@ public class DisplayMetrics { scaledDensity = density; scaledDensity = density; xdpi = DENSITY_DEVICE; xdpi = DENSITY_DEVICE; ydpi = DENSITY_DEVICE; ydpi = DENSITY_DEVICE; realWidthPixels = 0; unscaledWidthPixels = 0; realHeightPixels = 0; unscaledHeightPixels = 0; } } @Override @Override Loading
core/java/android/view/Display.java +28 −16 Original line number Original line Diff line number Diff line Loading @@ -80,25 +80,37 @@ public class Display { * adjusted for you based on the current rotation of the display. * adjusted for you based on the current rotation of the display. */ */ public void getSize(Point outSize) { 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 { try { IWindowManager wm = getWindowManager(); IWindowManager wm = getWindowManager(); if (wm != null) { if (wm != null) { wm.getDisplaySize(outSize); wm.getDisplaySize(outSize); } else { if (doCompat && mCompatibilityInfo != null) { // This is just for boot-strapping, initializing the // system process before the window manager is up. outSize.y = getRealHeight(); } if (mCompatibilityInfo != null) { synchronized (mTmpMetrics) { synchronized (mTmpMetrics) { mTmpMetrics.realWidthPixels = outSize.x; mTmpMetrics.unscaledWidthPixels = outSize.x; mTmpMetrics.realHeightPixels = outSize.y; mTmpMetrics.unscaledHeightPixels = outSize.y; mTmpMetrics.density = mDensity; mTmpMetrics.density = mDensity; mCompatibilityInfo.applyToDisplayMetrics(mTmpMetrics); mCompatibilityInfo.applyToDisplayMetrics(mTmpMetrics); outSize.x = mTmpMetrics.widthPixels; outSize.x = mTmpMetrics.widthPixels; outSize.y = mTmpMetrics.heightPixels; outSize.y = mTmpMetrics.heightPixels; } } } } } else { // This is just for boot-strapping, initializing the // system process before the window manager is up. outSize.y = getRealHeight(); } } catch (RemoteException e) { } catch (RemoteException e) { Slog.w("Display", "Unable to get display size", e); Slog.w("Display", "Unable to get display size", e); } } Loading @@ -109,7 +121,7 @@ public class Display { */ */ public void getRectSize(Rect outSize) { public void getRectSize(Rect outSize) { synchronized (mTmpPoint) { synchronized (mTmpPoint) { getSize(mTmpPoint); getSizeInternal(mTmpPoint, true); outSize.set(0, 0, mTmpPoint.x, mTmpPoint.y); outSize.set(0, 0, mTmpPoint.x, mTmpPoint.y); } } } } Loading Loading @@ -137,7 +149,7 @@ public class Display { synchronized (mTmpPoint) { synchronized (mTmpPoint) { long now = SystemClock.uptimeMillis(); long now = SystemClock.uptimeMillis(); if (now > (mLastGetTime+20)) { if (now > (mLastGetTime+20)) { getSize(mTmpPoint); getSizeInternal(mTmpPoint, true); mLastGetTime = now; mLastGetTime = now; } } return mTmpPoint.x; return mTmpPoint.x; Loading @@ -152,7 +164,7 @@ public class Display { synchronized (mTmpPoint) { synchronized (mTmpPoint) { long now = SystemClock.uptimeMillis(); long now = SystemClock.uptimeMillis(); if (now > (mLastGetTime+20)) { if (now > (mLastGetTime+20)) { getSize(mTmpPoint); getSizeInternal(mTmpPoint, true); mLastGetTime = now; mLastGetTime = now; } } return mTmpPoint.y; return mTmpPoint.y; Loading Loading @@ -218,7 +230,7 @@ public class Display { */ */ public void getMetrics(DisplayMetrics outMetrics) { public void getMetrics(DisplayMetrics outMetrics) { synchronized (mTmpPoint) { synchronized (mTmpPoint) { getSize(mTmpPoint); getSizeInternal(mTmpPoint, false); outMetrics.widthPixels = mTmpPoint.x; outMetrics.widthPixels = mTmpPoint.x; outMetrics.heightPixels = mTmpPoint.y; outMetrics.heightPixels = mTmpPoint.y; } } Loading Loading @@ -248,8 +260,8 @@ public class Display { outMetrics.xdpi = mDpiX; outMetrics.xdpi = mDpiX; outMetrics.ydpi = mDpiY; outMetrics.ydpi = mDpiY; outMetrics.realWidthPixels = outMetrics.widthPixels; outMetrics.unscaledWidthPixels = outMetrics.widthPixels; outMetrics.realHeightPixels = outMetrics.heightPixels; outMetrics.unscaledHeightPixels = outMetrics.heightPixels; } } static IWindowManager getWindowManager() { static IWindowManager getWindowManager() { Loading
core/java/android/view/IWindowManager.aidl +3 −0 Original line number Original line Diff line number Diff line Loading @@ -59,6 +59,9 @@ interface IWindowManager void setForcedDisplaySize(int longDimen, int shortDimen); void setForcedDisplaySize(int longDimen, int shortDimen); void clearForcedDisplaySize(); 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, // These can only be called when injecting events to your own window, // or by holding the INJECT_EVENTS permission. These methods may block // or by holding the INJECT_EVENTS permission. These methods may block // until pending input events are finished being dispatched even when 'sync' is false. // until pending input events are finished being dispatched even when 'sync' is false. Loading