diff options
20 files changed, 346 insertions, 89 deletions
diff --git a/api/current.txt b/api/current.txt index 0f5c98a..3492960 100644 --- a/api/current.txt +++ b/api/current.txt @@ -7941,29 +7941,37 @@ package android.graphics { ctor public PixelXorXfermode(int); } - public class Point { + public class Point implements android.os.Parcelable { ctor public Point(); ctor public Point(int, int); ctor public Point(android.graphics.Point); + method public int describeContents(); method public final boolean equals(int, int); method public final void negate(); method public final void offset(int, int); + method public void readFromParcel(android.os.Parcel); method public void set(int, int); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator CREATOR; field public int x; field public int y; } - public class PointF { + public class PointF implements android.os.Parcelable { ctor public PointF(); ctor public PointF(float, float); ctor public PointF(android.graphics.Point); + method public int describeContents(); method public final boolean equals(float, float); method public final float length(); method public static float length(float, float); method public final void negate(); method public final void offset(float, float); + method public void readFromParcel(android.os.Parcel); method public final void set(float, float); method public final void set(android.graphics.PointF); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator CREATOR; field public float x; field public float y; } @@ -19895,13 +19903,15 @@ package android.view { public class Display { method public int getDisplayId(); - method public int getHeight(); + method public deprecated int getHeight(); method public void getMetrics(android.util.DisplayMetrics); method public deprecated int getOrientation(); method public int getPixelFormat(); + method public void getRectSize(android.graphics.Rect); method public float getRefreshRate(); method public int getRotation(); - method public int getWidth(); + method public void getSize(android.graphics.Point); + method public deprecated int getWidth(); field public static final int DEFAULT_DISPLAY = 0; // 0x0 } diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 389d4856..f5849c2 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -818,18 +818,6 @@ public class Activity extends ContextThemeWrapper return mWindow != null ? mWindow.getCurrentFocus() : null; } - @Override - public int getWallpaperDesiredMinimumWidth() { - int width = super.getWallpaperDesiredMinimumWidth(); - return width <= 0 ? getWindowManager().getDefaultDisplay().getWidth() : width; - } - - @Override - public int getWallpaperDesiredMinimumHeight() { - int height = super.getWallpaperDesiredMinimumHeight(); - return height <= 0 ? getWindowManager().getDefaultDisplay().getHeight() : height; - } - /** * Called when the activity is starting. This is where most initialization * should go: calling {@link #setContentView(int)} to inflate the diff --git a/core/java/android/app/backup/WallpaperBackupHelper.java b/core/java/android/app/backup/WallpaperBackupHelper.java index 55368d6..0c034cf 100644 --- a/core/java/android/app/backup/WallpaperBackupHelper.java +++ b/core/java/android/app/backup/WallpaperBackupHelper.java @@ -19,6 +19,7 @@ package android.app.backup; import android.app.WallpaperManager; import android.content.Context; import android.graphics.BitmapFactory; +import android.graphics.Point; import android.os.ParcelFileDescriptor; import android.util.Slog; import android.view.Display; @@ -70,8 +71,10 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu if (mDesiredMinWidth <= 0 || mDesiredMinHeight <= 0) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display d = wm.getDefaultDisplay(); - mDesiredMinWidth = d.getWidth(); - mDesiredMinHeight = d.getHeight(); + Point size = new Point(); + d.getSize(size); + mDesiredMinWidth = size.x; + mDesiredMinHeight = size.y; } if (DEBUG) { diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index 126f409..980239b 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -16,10 +16,15 @@ package android.view; +import android.graphics.Point; +import android.graphics.Rect; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.os.SystemClock; import android.util.DisplayMetrics; +import android.util.Slog; -public class Display -{ +public class Display { /** * Specify the default Display */ @@ -35,10 +40,10 @@ public class Display Display(int display) { // initalize the statics when this class is first instansiated. This is // done here instead of in the static block because Zygote - synchronized (mStaticInit) { - if (!mInitialized) { + synchronized (sStaticInit) { + if (!sInitialized) { nativeClassInit(); - mInitialized = true; + sInitialized = true; } } mDisplay = display; @@ -60,29 +65,92 @@ public class Display native static int getDisplayCount(); /** - * Returns the raw width of the display, in pixels. Note that this + * 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. */ - native public int getWidth(); + public void getSize(Point outSize) { + try { + IWindowManager wm = getWindowManager(); + if (wm != null) { + wm.getDisplaySize(outSize); + } else { + // This is just for boot-strapping, initializing the + // system process before the window manager is up. + outSize.y = getRealHeight(); + } + } catch (RemoteException e) { + Slog.w("Display", "Unable to get display size", e); + } + } /** - * Returns the raw height 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. + * This is just easier for some parts of the framework. */ - native public int getHeight(); + public void getRectSize(Rect outSize) { + synchronized (mTmpPoint) { + getSize(mTmpPoint); + outSize.set(0, 0, mTmpPoint.x, mTmpPoint.y); + } + } - /** @hide special for when we are faking the screen size. */ + /** + * Return the maximum screen size dimension that will happen. This is + * mostly for wallpapers. + * @hide + */ + public int getMaximumSizeDimension() { + try { + IWindowManager wm = getWindowManager(); + return wm.getMaximumSizeDimension(); + } catch (RemoteException e) { + Slog.w("Display", "Unable to get display maximum size dimension", e); + return 0; + } + } + + /** + * @deprecated Use {@link #getSize(Point)} instead. + */ + @Deprecated + public int getWidth() { + synchronized (mTmpPoint) { + long now = SystemClock.uptimeMillis(); + if (now > (mLastGetTime+20)) { + getSize(mTmpPoint); + mLastGetTime = now; + } + return mTmpPoint.x; + } + } + + /** + * @deprecated Use {@link #getSize(Point)} instead. + */ + @Deprecated + public int getHeight() { + synchronized (mTmpPoint) { + long now = SystemClock.uptimeMillis(); + if (now > (mLastGetTime+20)) { + getSize(mTmpPoint); + mLastGetTime = now; + } + return mTmpPoint.y; + } + } + + /** @hide Returns the actual screen size, not including any decor. */ native public int getRealWidth(); - /** @hide special for when we are faking the screen size. */ + /** @hide Returns the actual screen size, not including any decor. */ native public int getRealHeight(); + + /** @hide special for when we are faking the screen size. */ + native public int getRawWidth(); + /** @hide special for when we are faking the screen size. */ + native public int getRawHeight(); /** * Returns the rotation of the screen from its "natural" orientation. @@ -141,6 +209,16 @@ public class Display outMetrics.ydpi = mDpiY; } + static IWindowManager getWindowManager() { + synchronized (sStaticInit) { + if (sWindowManager == null) { + sWindowManager = IWindowManager.Stub.asInterface( + ServiceManager.getService("window")); + } + return sWindowManager; + } + } + /* * We use a class initializer to allow the native code to cache some * field offsets. @@ -157,8 +235,12 @@ public class Display private float mDpiX; private float mDpiY; - private static final Object mStaticInit = new Object(); - private static boolean mInitialized = false; + private final Point mTmpPoint = new Point(); + private float mLastGetTime; + + private static final Object sStaticInit = new Object(); + private static boolean sInitialized = false; + private static IWindowManager sWindowManager; /** * Returns a display object which uses the metric's width/height instead. diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index dd8242a..0be02a6 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -21,6 +21,7 @@ import com.android.internal.view.IInputMethodClient; import android.content.res.Configuration; import android.graphics.Bitmap; +import android.graphics.Point; import android.view.IApplicationToken; import android.view.IOnKeyguardExitResult; import android.view.IRotationWatcher; @@ -52,6 +53,9 @@ interface IWindowManager in IInputContext inputContext); boolean inputMethodClientHasFocus(IInputMethodClient client); + void getDisplaySize(out Point size); + int getMaximumSizeDimension(); + // 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/InputDevice.java b/core/java/android/view/InputDevice.java index 98d4eb9..8cb68f9 100755 --- a/core/java/android/view/InputDevice.java +++ b/core/java/android/view/InputDevice.java @@ -290,7 +290,7 @@ public final class InputDevice implements Parcelable { * @return The input device or null if not found. */ public static InputDevice getDevice(int id) { - IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window")); + IWindowManager wm = Display.getWindowManager(); try { return wm.getInputDevice(id); } catch (RemoteException ex) { @@ -304,7 +304,7 @@ public final class InputDevice implements Parcelable { * @return The input device ids. */ public static int[] getDeviceIds() { - IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window")); + IWindowManager wm = Display.getWindowManager(); try { return wm.getInputDeviceIds(); } catch (RemoteException ex) { diff --git a/core/java/android/view/KeyCharacterMap.java b/core/java/android/view/KeyCharacterMap.java index 3ff7fcd..885a75f 100644 --- a/core/java/android/view/KeyCharacterMap.java +++ b/core/java/android/view/KeyCharacterMap.java @@ -527,7 +527,7 @@ public class KeyCharacterMap { */ public static boolean[] deviceHasKeys(int[] keyCodes) { boolean[] ret = new boolean[keyCodes.length]; - IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window")); + IWindowManager wm = Display.getWindowManager(); try { wm.hasKeys(keyCodes, ret); } catch (RemoteException e) { diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index fe8af19..4a62892 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -4992,7 +4992,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility return; } Display d = WindowManagerImpl.getDefault().getDefaultDisplay(); - outRect.set(0, 0, d.getWidth(), d.getHeight()); + d.getRectSize(outRect); } /** diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java index 1a6bae7..4104b07 100644 --- a/core/java/android/view/ViewRoot.java +++ b/core/java/android/view/ViewRoot.java @@ -263,9 +263,8 @@ public final class ViewRoot extends Handler implements ViewParent, if (!mInitialized) { try { InputMethodManager imm = InputMethodManager.getInstance(mainLooper); - sWindowSession = IWindowManager.Stub.asInterface( - ServiceManager.getService("window")) - .openSession(imm.getClient(), imm.getInputContext()); + sWindowSession = Display.getWindowManager().openSession( + imm.getClient(), imm.getInputContext()); mInitialized = true; } catch (RemoteException e) { } diff --git a/core/jni/android_view_Display.cpp b/core/jni/android_view_Display.cpp index 8feeb9a..97f9fc3 100644 --- a/core/jni/android_view_Display.cpp +++ b/core/jni/android_view_Display.cpp @@ -92,14 +92,14 @@ static jint android_view_Display_getHeight( return h == gOldSize ? gNewSize : h; } -static jint android_view_Display_getRealWidth( +static jint android_view_Display_getRawWidth( JNIEnv* env, jobject clazz) { DisplayID dpy = env->GetIntField(clazz, offsets.display); return SurfaceComposerClient::getDisplayWidth(dpy); } -static jint android_view_Display_getRealHeight( +static jint android_view_Display_getRawHeight( JNIEnv* env, jobject clazz) { DisplayID dpy = env->GetIntField(clazz, offsets.display); @@ -132,14 +132,14 @@ static JNINativeMethod gMethods[] = { (void*)android_view_Display_getDisplayCount }, { "init", "(I)V", (void*)android_view_Display_init }, - { "getWidth", "()I", - (void*)android_view_Display_getWidth }, - { "getHeight", "()I", - (void*)android_view_Display_getHeight }, { "getRealWidth", "()I", - (void*)android_view_Display_getRealWidth }, + (void*)android_view_Display_getWidth }, { "getRealHeight", "()I", - (void*)android_view_Display_getRealHeight }, + (void*)android_view_Display_getHeight }, + { "getRawWidth", "()I", + (void*)android_view_Display_getRawWidth }, + { "getRawHeight", "()I", + (void*)android_view_Display_getRawHeight }, { "getOrientation", "()I", (void*)android_view_Display_getOrientation } }; diff --git a/graphics/java/android/graphics/Point.aidl b/graphics/java/android/graphics/Point.aidl new file mode 100644 index 0000000..0e6b2b9 --- /dev/null +++ b/graphics/java/android/graphics/Point.aidl @@ -0,0 +1,18 @@ +/* Copyright 2011, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +package android.graphics; + +parcelable Point; diff --git a/graphics/java/android/graphics/Point.java b/graphics/java/android/graphics/Point.java index c351444..338e880 100644 --- a/graphics/java/android/graphics/Point.java +++ b/graphics/java/android/graphics/Point.java @@ -16,11 +16,14 @@ package android.graphics; +import android.os.Parcel; +import android.os.Parcelable; + /** * Point holds two integer coordinates */ -public class Point { +public class Point implements Parcelable { public int x; public int y; @@ -82,4 +85,52 @@ public class Point { @Override public String toString() { return "Point(" + x + ", " + y+ ")"; } + + /** + * Parcelable interface methods + */ + @Override + public int describeContents() { + return 0; + } + + /** + * Write this point to the specified parcel. To restore a point from + * a parcel, use readFromParcel() + * @param out The parcel to write the point's coordinates into + */ + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeInt(x); + out.writeInt(y); + } + + public static final Parcelable.Creator<Point> CREATOR = new Parcelable.Creator<Point>() { + /** + * Return a new point from the data in the specified parcel. + */ + public Point createFromParcel(Parcel in) { + Point r = new Point(); + r.readFromParcel(in); + return r; + } + + /** + * Return an array of rectangles of the specified size. + */ + public Point[] newArray(int size) { + return new Point[size]; + } + }; + + /** + * Set the point's coordinates from the data stored in the specified + * parcel. To write a point to a parcel, call writeToParcel(). + * + * @param in The parcel to read the point's coordinates from + */ + public void readFromParcel(Parcel in) { + x = in.readInt(); + y = in.readInt(); + } } diff --git a/graphics/java/android/graphics/PointF.aidl b/graphics/java/android/graphics/PointF.aidl new file mode 100644 index 0000000..ad72acd --- /dev/null +++ b/graphics/java/android/graphics/PointF.aidl @@ -0,0 +1,18 @@ +/* Copyright 2011, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +package android.graphics; + +parcelable PointF; diff --git a/graphics/java/android/graphics/PointF.java b/graphics/java/android/graphics/PointF.java index 0f045a1..e00271f 100644 --- a/graphics/java/android/graphics/PointF.java +++ b/graphics/java/android/graphics/PointF.java @@ -16,13 +16,15 @@ package android.graphics; +import android.os.Parcel; +import android.os.Parcelable; import android.util.FloatMath; /** * PointF holds two float coordinates */ -public class PointF { +public class PointF implements Parcelable { public float x; public float y; @@ -84,5 +86,52 @@ public class PointF { public static float length(float x, float y) { return FloatMath.sqrt(x * x + y * y); } -} + /** + * Parcelable interface methods + */ + @Override + public int describeContents() { + return 0; + } + + /** + * Write this point to the specified parcel. To restore a point from + * a parcel, use readFromParcel() + * @param out The parcel to write the point's coordinates into + */ + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeFloat(x); + out.writeFloat(y); + } + + public static final Parcelable.Creator<PointF> CREATOR = new Parcelable.Creator<PointF>() { + /** + * Return a new point from the data in the specified parcel. + */ + public PointF createFromParcel(Parcel in) { + PointF r = new PointF(); + r.readFromParcel(in); + return r; + } + + /** + * Return an array of rectangles of the specified size. + */ + public PointF[] newArray(int size) { + return new PointF[size]; + } + }; + + /** + * Set the point's coordinates from the data stored in the specified + * parcel. To write a point to a parcel, call writeToParcel(). + * + * @param in The parcel to read the point's coordinates from + */ + public void readFromParcel(Parcel in) { + x = in.readFloat(); + y = in.readFloat(); + } +} diff --git a/media/java/android/mtp/MtpDatabase.java b/media/java/android/mtp/MtpDatabase.java index b900671..c9e0f6f 100644 --- a/media/java/android/mtp/MtpDatabase.java +++ b/media/java/android/mtp/MtpDatabase.java @@ -616,8 +616,8 @@ public class MtpDatabase { // use screen size as max image size Display display = ((WindowManager)mContext.getSystemService( Context.WINDOW_SERVICE)).getDefaultDisplay(); - int width = display.getWidth(); - int height = display.getHeight(); + int width = display.getMaximumSizeDimension(); + int height = display.getMaximumSizeDimension(); String imageSize = Integer.toString(width) + "x" + Integer.toString(height); imageSize.getChars(0, imageSize.length(), outStringValue, 0); outStringValue[imageSize.length()] = 0; diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java index b1a6a9a..c129b97 100644 --- a/services/java/com/android/server/WallpaperManagerService.java +++ b/services/java/com/android/server/WallpaperManagerService.java @@ -49,6 +49,7 @@ import android.service.wallpaper.IWallpaperService; import android.service.wallpaper.WallpaperService; import android.util.Slog; import android.util.Xml; +import android.view.Display; import android.view.IWindowManager; import android.view.WindowManager; @@ -726,6 +727,17 @@ class WallpaperManagerService extends IWallpaperManager.Stub { mHeight = -1; mName = ""; } + + // We always want to have some reasonable width hint. + WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); + Display d = wm.getDefaultDisplay(); + int baseSize = d.getMaximumSizeDimension(); + if (mWidth < baseSize) { + mWidth = baseSize; + } + if (mHeight < baseSize) { + mHeight = baseSize; + } } // Called by SystemBackupAgent after files are restored to disk. diff --git a/services/java/com/android/server/wm/InputMonitor.java b/services/java/com/android/server/wm/InputMonitor.java index 45a78af..4f157fe 100644 --- a/services/java/com/android/server/wm/InputMonitor.java +++ b/services/java/com/android/server/wm/InputMonitor.java @@ -132,8 +132,8 @@ final class InputMonitor { // The drag window covers the entire display inputWindow.frameLeft = 0; inputWindow.frameTop = 0; - inputWindow.frameRight = mService.mDisplay.getWidth(); - inputWindow.frameBottom = mService.mDisplay.getHeight(); + inputWindow.frameRight = mService.mDisplay.getRealWidth(); + inputWindow.frameBottom = mService.mDisplay.getRealHeight(); // The drag window cannot receive new touches. inputWindow.touchableRegion.setEmpty(); diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index e2874f8..b2e78f1 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -64,6 +64,7 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.PixelFormat; +import android.graphics.Point; import android.graphics.Rect; import android.graphics.Region; import android.os.BatteryStats; @@ -392,6 +393,8 @@ public class WindowManagerService extends IWindowManager.Stub boolean mSystemBooted = false; int mInitialDisplayWidth = 0; int mInitialDisplayHeight = 0; + int mCurDisplayWidth = 0; + int mCurDisplayHeight = 0; int mRotation = 0; int mRequestedRotation = 0; int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; @@ -1419,8 +1422,8 @@ public class WindowManagerService extends IWindowManager.Stub int adjustWallpaperWindowsLocked() { int changed = 0; - final int dw = mDisplay.getWidth(); - final int dh = mDisplay.getHeight(); + final int dw = mCurDisplayWidth; + final int dh = mCurDisplayHeight; // First find top-most window that has asked to be on top of the // wallpaper; all wallpapers go behind it. @@ -1838,8 +1841,8 @@ public class WindowManagerService extends IWindowManager.Stub } boolean updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) { - final int dw = mDisplay.getWidth(); - final int dh = mDisplay.getHeight(); + final int dw = mCurDisplayWidth; + final int dh = mCurDisplayHeight; boolean changed = false; @@ -1879,8 +1882,8 @@ public class WindowManagerService extends IWindowManager.Stub void updateWallpaperVisibilityLocked() { final boolean visible = isWallpaperVisible(mWallpaperTarget); - final int dw = mDisplay.getWidth(); - final int dh = mDisplay.getHeight(); + final int dw = mCurDisplayWidth; + final int dh = mCurDisplayHeight; int curTokenIndex = mWallpaperTokens.size(); while (curTokenIndex > 0) { @@ -2682,8 +2685,7 @@ public class WindowManagerService extends IWindowManager.Stub configChanged = updateOrientationFromAppTokensLocked(false); performLayoutAndPlaceSurfacesLocked(); if (displayed && win.mIsWallpaper) { - updateWallpaperOffsetLocked(win, mDisplay.getWidth(), - mDisplay.getHeight(), false); + updateWallpaperOffsetLocked(win, mCurDisplayWidth, mCurDisplayHeight, false); } if (win.mAppToken != null) { win.mAppToken.updateReportedVisibilityLocked(); @@ -4757,8 +4759,8 @@ public class WindowManagerService extends IWindowManager.Stub synchronized(mWindowMap) { long ident = Binder.clearCallingIdentity(); - dw = mDisplay.getWidth(); - dh = mDisplay.getHeight(); + dw = mCurDisplayWidth; + dh = mCurDisplayHeight; int aboveAppLayer = mPolicy.windowTypeToLayerLw( WindowManager.LayoutParams.TYPE_APPLICATION) * TYPE_LAYER_MULTIPLIER @@ -5848,9 +5850,9 @@ public class WindowManagerService extends IWindowManager.Stub } WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); mDisplay = wm.getDefaultDisplay(); - mInitialDisplayWidth = mDisplay.getWidth(); - mInitialDisplayHeight = mDisplay.getHeight(); - mInputManager.setDisplaySize(0, mDisplay.getRealWidth(), mDisplay.getRealHeight()); + mInitialDisplayWidth = mCurDisplayWidth = mDisplay.getRealWidth(); + mInitialDisplayHeight = mCurDisplayHeight = mDisplay.getRealHeight(); + mInputManager.setDisplaySize(0, mDisplay.getRawWidth(), mDisplay.getRawHeight()); } try { @@ -6344,6 +6346,21 @@ public class WindowManagerService extends IWindowManager.Stub return false; } + public void getDisplaySize(Point size) { + synchronized(mWindowMap) { + size.x = mCurDisplayWidth; + size.y = mCurDisplayHeight; + } + } + + public int getMaximumSizeDimension() { + synchronized(mWindowMap) { + // Do this based on the raw screen size, until we are smarter. + return mInitialDisplayWidth > mInitialDisplayHeight + ? mInitialDisplayWidth : mInitialDisplayHeight; + } + } + // ------------------------------------------------------------- // Internals // ------------------------------------------------------------- @@ -6586,8 +6603,8 @@ public class WindowManagerService extends IWindowManager.Stub mLayoutNeeded = false; - final int dw = mDisplay.getWidth(); - final int dh = mDisplay.getHeight(); + final int dw = mCurDisplayWidth; + final int dh = mCurDisplayHeight; final int N = mWindows.size(); int i; @@ -6704,8 +6721,8 @@ public class WindowManagerService extends IWindowManager.Stub } final long currentTime = SystemClock.uptimeMillis(); - final int dw = mDisplay.getWidth(); - final int dh = mDisplay.getHeight(); + final int dw = mCurDisplayWidth = mDisplay.getRealWidth(); + final int dh = mCurDisplayHeight = mDisplay.getRealHeight(); int i; @@ -8726,8 +8743,13 @@ public class WindowManagerService extends IWindowManager.Stub pw.print(" mToBottomApps="); pw.println(mToBottomApps); } if (mDisplay != null) { - pw.print(" DisplayWidth="); pw.print(mDisplay.getWidth()); - pw.print(" DisplayHeight="); pw.println(mDisplay.getHeight()); + pw.print(" Display: init="); pw.print(mInitialDisplayWidth); pw.print("x"); + pw.print(mInitialDisplayHeight); pw.print(" cur="); + pw.print(mCurDisplayWidth); pw.print("x"); pw.print(mCurDisplayHeight); + pw.print(" real="); pw.print(mDisplay.getRealWidth()); + pw.print("x"); pw.print(mDisplay.getRealHeight()); + pw.print(" raw="); pw.print(mDisplay.getRawWidth()); + pw.print("x"); pw.println(mDisplay.getRawHeight()); } else { pw.println(" NO DISPLAY"); } diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java index f8ff5f8..c05186a 100644 --- a/services/java/com/android/server/wm/WindowState.java +++ b/services/java/com/android/server/wm/WindowState.java @@ -440,8 +440,8 @@ final class WindowState implements WindowManagerPolicy.WindowState { visibleInsets.bottom = frame.bottom-visible.bottom; if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) { - mService.updateWallpaperOffsetLocked(this, mService.mDisplay.getWidth(), - mService.mDisplay.getHeight(), false); + mService.updateWallpaperOffsetLocked(this, mService.mDisplay.getRealWidth(), + mService.mDisplay.getRealHeight(), false); } if (WindowManagerService.localLOGV) { diff --git a/test-runner/src/android/test/TouchUtils.java b/test-runner/src/android/test/TouchUtils.java index 69c6d2d..acbde0b 100644 --- a/test-runner/src/android/test/TouchUtils.java +++ b/test-runner/src/android/test/TouchUtils.java @@ -18,6 +18,7 @@ package android.test; import android.app.Activity; import android.app.Instrumentation; +import android.graphics.Point; import android.os.SystemClock; import android.view.Display; import android.view.Gravity; @@ -53,12 +54,12 @@ public class TouchUtils { */ public static void dragQuarterScreenDown(InstrumentationTestCase test, Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); - int screenHeight = display.getHeight(); - int screenWidth = display.getWidth(); + final Point size = new Point(); + display.getSize(size); - final float x = screenWidth / 2.0f; - final float fromY = screenHeight * 0.5f; - final float toY = screenHeight * 0.75f; + final float x = size.x / 2.0f; + final float fromY = size.y * 0.5f; + final float toY = size.y * 0.75f; drag(test, x, x, fromY, toY, 4); } @@ -83,12 +84,12 @@ public class TouchUtils { */ public static void dragQuarterScreenUp(InstrumentationTestCase test, Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); - int screenHeight = display.getHeight(); - int screenWidth = display.getWidth(); + final Point size = new Point(); + display.getSize(size); - final float x = screenWidth / 2.0f; - final float fromY = screenHeight * 0.5f; - final float toY = screenHeight * 0.25f; + final float x = size.x / 2.0f; + final float fromY = size.y * 0.5f; + final float toY = size.y * 0.25f; drag(test, x, x, fromY, toY, 4); } |