am d90a2c4d: am 1e662c32: Merge "DO NOT MERGE. Integrate from master: Rework display size access." into honeycomb-mr2

* commit 'd90a2c4d4463085155444efb07eba2d6579b444a':
  DO NOT MERGE.  Integrate from master: Rework display size access.
This commit is contained in:
Dianne Hackborn
2011-05-16 13:01:38 -07:00
committed by Android Git Automerger
20 changed files with 465 additions and 90 deletions

View File

@@ -84678,6 +84678,8 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<implements name="android.os.Parcelable">
</implements>
<constructor name="Point" <constructor name="Point"
type="android.graphics.Point" type="android.graphics.Point"
static="false" static="false"
@@ -84708,6 +84710,17 @@
<parameter name="src" type="android.graphics.Point"> <parameter name="src" type="android.graphics.Point">
</parameter> </parameter>
</constructor> </constructor>
<method name="describeContents"
return="int"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="equals" <method name="equals"
return="boolean" return="boolean"
abstract="false" abstract="false"
@@ -84749,6 +84762,19 @@
<parameter name="dy" type="int"> <parameter name="dy" type="int">
</parameter> </parameter>
</method> </method>
<method name="readFromParcel"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="in" type="android.os.Parcel">
</parameter>
</method>
<method name="set" <method name="set"
return="void" return="void"
abstract="false" abstract="false"
@@ -84764,6 +84790,31 @@
<parameter name="y" type="int"> <parameter name="y" type="int">
</parameter> </parameter>
</method> </method>
<method name="writeToParcel"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="out" type="android.os.Parcel">
</parameter>
<parameter name="flags" type="int">
</parameter>
</method>
<field name="CREATOR"
type="android.os.Parcelable.Creator"
transient="false"
volatile="false"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="x" <field name="x"
type="int" type="int"
transient="false" transient="false"
@@ -84793,6 +84844,8 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<implements name="android.os.Parcelable">
</implements>
<constructor name="PointF" <constructor name="PointF"
type="android.graphics.PointF" type="android.graphics.PointF"
static="false" static="false"
@@ -84823,6 +84876,17 @@
<parameter name="p" type="android.graphics.Point"> <parameter name="p" type="android.graphics.Point">
</parameter> </parameter>
</constructor> </constructor>
<method name="describeContents"
return="int"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="equals" <method name="equals"
return="boolean" return="boolean"
abstract="false" abstract="false"
@@ -84890,6 +84954,19 @@
<parameter name="dy" type="float"> <parameter name="dy" type="float">
</parameter> </parameter>
</method> </method>
<method name="readFromParcel"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="in" type="android.os.Parcel">
</parameter>
</method>
<method name="set" <method name="set"
return="void" return="void"
abstract="false" abstract="false"
@@ -84918,6 +84995,31 @@
<parameter name="p" type="android.graphics.PointF"> <parameter name="p" type="android.graphics.PointF">
</parameter> </parameter>
</method> </method>
<method name="writeToParcel"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="out" type="android.os.Parcel">
</parameter>
<parameter name="flags" type="int">
</parameter>
</method>
<field name="CREATOR"
type="android.os.Parcelable.Creator"
transient="false"
volatile="false"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="x" <field name="x"
type="float" type="float"
transient="false" transient="false"
@@ -209935,11 +210037,11 @@
<method name="getHeight" <method name="getHeight"
return="int" return="int"
abstract="false" abstract="false"
native="true" native="false"
synchronized="false" synchronized="false"
static="false" static="false"
final="false" final="false"
deprecated="not deprecated" deprecated="deprecated"
visibility="public" visibility="public"
> >
</method> </method>
@@ -209978,6 +210080,19 @@
visibility="public" visibility="public"
> >
</method> </method>
<method name="getRectSize"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="outSize" type="android.graphics.Rect">
</parameter>
</method>
<method name="getRefreshRate" <method name="getRefreshRate"
return="float" return="float"
abstract="false" abstract="false"
@@ -210000,16 +210115,29 @@
visibility="public" visibility="public"
> >
</method> </method>
<method name="getWidth" <method name="getSize"
return="int" return="void"
abstract="false" abstract="false"
native="true" native="false"
synchronized="false" synchronized="false"
static="false" static="false"
final="false" final="false"
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="outSize" type="android.graphics.Point">
</parameter>
</method>
<method name="getWidth"
return="int"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="deprecated"
visibility="public"
>
</method> </method>
<field name="DEFAULT_DISPLAY" <field name="DEFAULT_DISPLAY"
type="int" type="int"

View File

@@ -819,18 +819,6 @@ public class Activity extends ContextThemeWrapper
return mWindow != null ? mWindow.getCurrentFocus() : null; 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 * Called when the activity is starting. This is where most initialization
* should go: calling {@link #setContentView(int)} to inflate the * should go: calling {@link #setContentView(int)} to inflate the

View File

@@ -19,6 +19,7 @@ package android.app.backup;
import android.app.WallpaperManager; import android.app.WallpaperManager;
import android.content.Context; import android.content.Context;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.util.Slog; import android.util.Slog;
import android.view.Display; import android.view.Display;
@@ -70,8 +71,10 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu
if (mDesiredMinWidth <= 0 || mDesiredMinHeight <= 0) { if (mDesiredMinWidth <= 0 || mDesiredMinHeight <= 0) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display d = wm.getDefaultDisplay(); Display d = wm.getDefaultDisplay();
mDesiredMinWidth = d.getWidth(); Point size = new Point();
mDesiredMinHeight = d.getHeight(); d.getSize(size);
mDesiredMinWidth = size.x;
mDesiredMinHeight = size.y;
} }
if (DEBUG) { if (DEBUG) {

View File

@@ -16,10 +16,15 @@
package android.view; 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.DisplayMetrics;
import android.util.Slog;
public class Display public class Display {
{
/** /**
* Specify the default Display * Specify the default Display
*/ */
@@ -35,10 +40,10 @@ public class Display
Display(int display) { Display(int display) {
// initalize the statics when this class is first instansiated. This is // initalize the statics when this class is first instansiated. This is
// done here instead of in the static block because Zygote // done here instead of in the static block because Zygote
synchronized (mStaticInit) { synchronized (sStaticInit) {
if (!mInitialized) { if (!sInitialized) {
nativeClassInit(); nativeClassInit();
mInitialized = true; sInitialized = true;
} }
} }
mDisplay = display; mDisplay = display;
@@ -60,29 +65,92 @@ public class Display
native static int getDisplayCount(); 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 * should <em>not</em> generally be used for computing layouts, since
* a device will typically have screen decoration (such as a status bar) * a device will typically have screen decoration (such as a status bar)
* along the edges of the display that reduce the amount of application * along the edges of the display that reduce the amount of application
* space available from the raw size returned here. This value is * space available from the raw size returned here. This value is
* adjusted for you based on the current rotation of the display. * 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 * This is just easier for some parts of the framework.
* 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 getHeight(); public void getRectSize(Rect outSize) {
synchronized (mTmpPoint) {
getSize(mTmpPoint);
outSize.set(0, 0, mTmpPoint.x, mTmpPoint.y);
}
}
/**
* 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 Returns the actual screen size, not including any decor. */
native public int getRealHeight();
/** @hide special for when we are faking the screen size. */ /** @hide special for when we are faking the screen size. */
native public int getRealWidth(); native public int getRawWidth();
/** @hide special for when we are faking the screen size. */ /** @hide special for when we are faking the screen size. */
native public int getRealHeight(); native public int getRawHeight();
/** /**
* Returns the rotation of the screen from its "natural" orientation. * Returns the rotation of the screen from its "natural" orientation.
@@ -144,6 +212,16 @@ public class Display
outMetrics.realHeightPixels = outMetrics.heightPixels; outMetrics.realHeightPixels = outMetrics.heightPixels;
} }
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 * We use a class initializer to allow the native code to cache some
* field offsets. * field offsets.
@@ -160,8 +238,12 @@ public class Display
private float mDpiX; private float mDpiX;
private float mDpiY; private float mDpiY;
private static final Object mStaticInit = new Object(); private final Point mTmpPoint = new Point();
private static boolean mInitialized = false; 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. * Returns a display object which uses the metric's width/height instead.

View File

@@ -21,6 +21,7 @@ import com.android.internal.view.IInputMethodClient;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Point;
import android.view.IApplicationToken; import android.view.IApplicationToken;
import android.view.IOnKeyguardExitResult; import android.view.IOnKeyguardExitResult;
import android.view.IRotationWatcher; import android.view.IRotationWatcher;
@@ -52,6 +53,9 @@ interface IWindowManager
in IInputContext inputContext); in IInputContext inputContext);
boolean inputMethodClientHasFocus(IInputMethodClient client); boolean inputMethodClientHasFocus(IInputMethodClient client);
void getDisplaySize(out Point size);
int getMaximumSizeDimension();
// 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.

View File

@@ -290,7 +290,7 @@ public final class InputDevice implements Parcelable {
* @return The input device or null if not found. * @return The input device or null if not found.
*/ */
public static InputDevice getDevice(int id) { public static InputDevice getDevice(int id) {
IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window")); IWindowManager wm = Display.getWindowManager();
try { try {
return wm.getInputDevice(id); return wm.getInputDevice(id);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -304,7 +304,7 @@ public final class InputDevice implements Parcelable {
* @return The input device ids. * @return The input device ids.
*/ */
public static int[] getDeviceIds() { public static int[] getDeviceIds() {
IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window")); IWindowManager wm = Display.getWindowManager();
try { try {
return wm.getInputDeviceIds(); return wm.getInputDeviceIds();
} catch (RemoteException ex) { } catch (RemoteException ex) {

View File

@@ -527,7 +527,7 @@ public class KeyCharacterMap {
*/ */
public static boolean[] deviceHasKeys(int[] keyCodes) { public static boolean[] deviceHasKeys(int[] keyCodes) {
boolean[] ret = new boolean[keyCodes.length]; boolean[] ret = new boolean[keyCodes.length];
IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window")); IWindowManager wm = Display.getWindowManager();
try { try {
wm.hasKeys(keyCodes, ret); wm.hasKeys(keyCodes, ret);
} catch (RemoteException e) { } catch (RemoteException e) {

View File

@@ -4855,7 +4855,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
return; return;
} }
Display d = WindowManagerImpl.getDefault().getDefaultDisplay(); Display d = WindowManagerImpl.getDefault().getDefaultDisplay();
outRect.set(0, 0, d.getWidth(), d.getHeight()); d.getRectSize(outRect);
} }
/** /**

View File

@@ -255,9 +255,8 @@ public final class ViewRoot extends Handler implements ViewParent,
if (!mInitialized) { if (!mInitialized) {
try { try {
InputMethodManager imm = InputMethodManager.getInstance(mainLooper); InputMethodManager imm = InputMethodManager.getInstance(mainLooper);
sWindowSession = IWindowManager.Stub.asInterface( sWindowSession = Display.getWindowManager().openSession(
ServiceManager.getService("window")) imm.getClient(), imm.getInputContext());
.openSession(imm.getClient(), imm.getInputContext());
mInitialized = true; mInitialized = true;
} catch (RemoteException e) { } catch (RemoteException e) {
} }

View File

@@ -97,14 +97,14 @@ static jint android_view_Display_getHeight(
return h == gOldSize ? gNewSize : h; return h == gOldSize ? gNewSize : h;
} }
static jint android_view_Display_getRealWidth( static jint android_view_Display_getRawWidth(
JNIEnv* env, jobject clazz) JNIEnv* env, jobject clazz)
{ {
DisplayID dpy = env->GetIntField(clazz, offsets.display); DisplayID dpy = env->GetIntField(clazz, offsets.display);
return SurfaceComposerClient::getDisplayWidth(dpy); return SurfaceComposerClient::getDisplayWidth(dpy);
} }
static jint android_view_Display_getRealHeight( static jint android_view_Display_getRawHeight(
JNIEnv* env, jobject clazz) JNIEnv* env, jobject clazz)
{ {
DisplayID dpy = env->GetIntField(clazz, offsets.display); DisplayID dpy = env->GetIntField(clazz, offsets.display);
@@ -137,14 +137,14 @@ static JNINativeMethod gMethods[] = {
(void*)android_view_Display_getDisplayCount }, (void*)android_view_Display_getDisplayCount },
{ "init", "(I)V", { "init", "(I)V",
(void*)android_view_Display_init }, (void*)android_view_Display_init },
{ "getWidth", "()I",
(void*)android_view_Display_getWidth },
{ "getHeight", "()I",
(void*)android_view_Display_getHeight },
{ "getRealWidth", "()I", { "getRealWidth", "()I",
(void*)android_view_Display_getRealWidth }, (void*)android_view_Display_getWidth },
{ "getRealHeight", "()I", { "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", { "getOrientation", "()I",
(void*)android_view_Display_getOrientation } (void*)android_view_Display_getOrientation }
}; };

View File

@@ -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;

View File

@@ -16,11 +16,14 @@
package android.graphics; package android.graphics;
import android.os.Parcel;
import android.os.Parcelable;
/** /**
* Point holds two integer coordinates * Point holds two integer coordinates
*/ */
public class Point { public class Point implements Parcelable {
public int x; public int x;
public int y; public int y;
@@ -82,4 +85,52 @@ public class Point {
@Override public String toString() { @Override public String toString() {
return "Point(" + x + ", " + y+ ")"; 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();
}
} }

View File

@@ -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;

View File

@@ -16,13 +16,15 @@
package android.graphics; package android.graphics;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.FloatMath; import android.util.FloatMath;
/** /**
* PointF holds two float coordinates * PointF holds two float coordinates
*/ */
public class PointF { public class PointF implements Parcelable {
public float x; public float x;
public float y; public float y;
@@ -84,5 +86,52 @@ public class PointF {
public static float length(float x, float y) { public static float length(float x, float y) {
return FloatMath.sqrt(x * x + y * 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();
}
}

View File

@@ -616,8 +616,8 @@ public class MtpDatabase {
// use screen size as max image size // use screen size as max image size
Display display = ((WindowManager)mContext.getSystemService( Display display = ((WindowManager)mContext.getSystemService(
Context.WINDOW_SERVICE)).getDefaultDisplay(); Context.WINDOW_SERVICE)).getDefaultDisplay();
int width = display.getWidth(); int width = display.getMaximumSizeDimension();
int height = display.getHeight(); int height = display.getMaximumSizeDimension();
String imageSize = Integer.toString(width) + "x" + Integer.toString(height); String imageSize = Integer.toString(width) + "x" + Integer.toString(height);
imageSize.getChars(0, imageSize.length(), outStringValue, 0); imageSize.getChars(0, imageSize.length(), outStringValue, 0);
outStringValue[imageSize.length()] = 0; outStringValue[imageSize.length()] = 0;

View File

@@ -49,6 +49,7 @@ import android.service.wallpaper.IWallpaperService;
import android.service.wallpaper.WallpaperService; import android.service.wallpaper.WallpaperService;
import android.util.Slog; import android.util.Slog;
import android.util.Xml; import android.util.Xml;
import android.view.Display;
import android.view.IWindowManager; import android.view.IWindowManager;
import android.view.WindowManager; import android.view.WindowManager;
@@ -726,6 +727,17 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
mHeight = -1; mHeight = -1;
mName = ""; 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. // Called by SystemBackupAgent after files are restored to disk.

View File

@@ -132,8 +132,8 @@ final class InputMonitor {
// The drag window covers the entire display // The drag window covers the entire display
inputWindow.frameLeft = 0; inputWindow.frameLeft = 0;
inputWindow.frameTop = 0; inputWindow.frameTop = 0;
inputWindow.frameRight = mService.mDisplay.getWidth(); inputWindow.frameRight = mService.mDisplay.getRealWidth();
inputWindow.frameBottom = mService.mDisplay.getHeight(); inputWindow.frameBottom = mService.mDisplay.getRealHeight();
// The drag window cannot receive new touches. // The drag window cannot receive new touches.
inputWindow.touchableRegion.setEmpty(); inputWindow.touchableRegion.setEmpty();

View File

@@ -63,6 +63,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Region; import android.graphics.Region;
import android.os.BatteryStats; import android.os.BatteryStats;
@@ -391,6 +392,8 @@ public class WindowManagerService extends IWindowManager.Stub
boolean mSystemBooted = false; boolean mSystemBooted = false;
int mInitialDisplayWidth = 0; int mInitialDisplayWidth = 0;
int mInitialDisplayHeight = 0; int mInitialDisplayHeight = 0;
int mCurDisplayWidth = 0;
int mCurDisplayHeight = 0;
int mRotation = 0; int mRotation = 0;
int mRequestedRotation = 0; int mRequestedRotation = 0;
int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
@@ -1419,8 +1422,8 @@ public class WindowManagerService extends IWindowManager.Stub
int adjustWallpaperWindowsLocked() { int adjustWallpaperWindowsLocked() {
int changed = 0; int changed = 0;
final int dw = mDisplay.getWidth(); final int dw = mCurDisplayWidth;
final int dh = mDisplay.getHeight(); final int dh = mCurDisplayHeight;
// First find top-most window that has asked to be on top of the // First find top-most window that has asked to be on top of the
// wallpaper; all wallpapers go behind it. // wallpaper; all wallpapers go behind it.
@@ -1838,8 +1841,8 @@ public class WindowManagerService extends IWindowManager.Stub
} }
boolean updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) { boolean updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) {
final int dw = mDisplay.getWidth(); final int dw = mCurDisplayWidth;
final int dh = mDisplay.getHeight(); final int dh = mCurDisplayHeight;
boolean changed = false; boolean changed = false;
@@ -1879,8 +1882,8 @@ public class WindowManagerService extends IWindowManager.Stub
void updateWallpaperVisibilityLocked() { void updateWallpaperVisibilityLocked() {
final boolean visible = isWallpaperVisible(mWallpaperTarget); final boolean visible = isWallpaperVisible(mWallpaperTarget);
final int dw = mDisplay.getWidth(); final int dw = mCurDisplayWidth;
final int dh = mDisplay.getHeight(); final int dh = mCurDisplayHeight;
int curTokenIndex = mWallpaperTokens.size(); int curTokenIndex = mWallpaperTokens.size();
while (curTokenIndex > 0) { while (curTokenIndex > 0) {
@@ -2682,8 +2685,7 @@ public class WindowManagerService extends IWindowManager.Stub
configChanged = updateOrientationFromAppTokensLocked(false); configChanged = updateOrientationFromAppTokensLocked(false);
performLayoutAndPlaceSurfacesLocked(); performLayoutAndPlaceSurfacesLocked();
if (displayed && win.mIsWallpaper) { if (displayed && win.mIsWallpaper) {
updateWallpaperOffsetLocked(win, mDisplay.getWidth(), updateWallpaperOffsetLocked(win, mCurDisplayWidth, mCurDisplayHeight, false);
mDisplay.getHeight(), false);
} }
if (win.mAppToken != null) { if (win.mAppToken != null) {
win.mAppToken.updateReportedVisibilityLocked(); win.mAppToken.updateReportedVisibilityLocked();
@@ -4755,8 +4757,8 @@ public class WindowManagerService extends IWindowManager.Stub
synchronized(mWindowMap) { synchronized(mWindowMap) {
long ident = Binder.clearCallingIdentity(); long ident = Binder.clearCallingIdentity();
dw = mPolicy.getNonDecorDisplayWidth(mDisplay.getWidth()); dw = mCurDisplayWidth;
dh = mPolicy.getNonDecorDisplayHeight(mDisplay.getHeight()); dh = mCurDisplayHeight;
int aboveAppLayer = mPolicy.windowTypeToLayerLw( int aboveAppLayer = mPolicy.windowTypeToLayerLw(
WindowManager.LayoutParams.TYPE_APPLICATION) * TYPE_LAYER_MULTIPLIER WindowManager.LayoutParams.TYPE_APPLICATION) * TYPE_LAYER_MULTIPLIER
@@ -5849,9 +5851,9 @@ public class WindowManagerService extends IWindowManager.Stub
} }
WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
mDisplay = wm.getDefaultDisplay(); mDisplay = wm.getDefaultDisplay();
mInitialDisplayWidth = mDisplay.getWidth(); mInitialDisplayWidth = mCurDisplayWidth = mDisplay.getRealWidth();
mInitialDisplayHeight = mDisplay.getHeight(); mInitialDisplayHeight = mCurDisplayHeight = mDisplay.getRealHeight();
mInputManager.setDisplaySize(0, mDisplay.getRealWidth(), mDisplay.getRealHeight()); mInputManager.setDisplaySize(0, mDisplay.getRawWidth(), mDisplay.getRawHeight());
} }
try { try {
@@ -6345,6 +6347,21 @@ public class WindowManagerService extends IWindowManager.Stub
return false; 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 // Internals
// ------------------------------------------------------------- // -------------------------------------------------------------
@@ -6587,8 +6604,8 @@ public class WindowManagerService extends IWindowManager.Stub
mLayoutNeeded = false; mLayoutNeeded = false;
final int dw = mDisplay.getWidth(); final int dw = mCurDisplayWidth;
final int dh = mDisplay.getHeight(); final int dh = mCurDisplayHeight;
final int innerDw = mPolicy.getNonDecorDisplayWidth(dw); final int innerDw = mPolicy.getNonDecorDisplayWidth(dw);
final int innerDh = mPolicy.getNonDecorDisplayHeight(dh); final int innerDh = mPolicy.getNonDecorDisplayHeight(dh);
@@ -6712,8 +6729,8 @@ public class WindowManagerService extends IWindowManager.Stub
} }
final long currentTime = SystemClock.uptimeMillis(); final long currentTime = SystemClock.uptimeMillis();
final int dw = mDisplay.getWidth(); final int dw = mCurDisplayWidth = mDisplay.getRealWidth();
final int dh = mDisplay.getHeight(); final int dh = mCurDisplayHeight = mDisplay.getRealHeight();
final int innerDw = mPolicy.getNonDecorDisplayWidth(dw); final int innerDw = mPolicy.getNonDecorDisplayWidth(dw);
final int innerDh = mPolicy.getNonDecorDisplayHeight(dh); final int innerDh = mPolicy.getNonDecorDisplayHeight(dh);
@@ -8745,8 +8762,13 @@ public class WindowManagerService extends IWindowManager.Stub
pw.print(" mToBottomApps="); pw.println(mToBottomApps); pw.print(" mToBottomApps="); pw.println(mToBottomApps);
} }
if (mDisplay != null) { if (mDisplay != null) {
pw.print(" DisplayWidth="); pw.print(mDisplay.getWidth()); pw.print(" Display: init="); pw.print(mInitialDisplayWidth); pw.print("x");
pw.print(" DisplayHeight="); pw.println(mDisplay.getHeight()); 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 { } else {
pw.println(" NO DISPLAY"); pw.println(" NO DISPLAY");
} }

View File

@@ -483,8 +483,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
} }
if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) { if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) {
mService.updateWallpaperOffsetLocked(this, mService.mDisplay.getWidth(), mService.updateWallpaperOffsetLocked(this, mService.mDisplay.getRealWidth(),
mService.mDisplay.getHeight(), false); mService.mDisplay.getRealHeight(), false);
} }
if (WindowManagerService.localLOGV) { if (WindowManagerService.localLOGV) {

View File

@@ -18,6 +18,7 @@ package android.test;
import android.app.Activity; import android.app.Activity;
import android.app.Instrumentation; import android.app.Instrumentation;
import android.graphics.Point;
import android.os.SystemClock; import android.os.SystemClock;
import android.view.Display; import android.view.Display;
import android.view.Gravity; import android.view.Gravity;
@@ -53,12 +54,12 @@ public class TouchUtils {
*/ */
public static void dragQuarterScreenDown(InstrumentationTestCase test, Activity activity) { public static void dragQuarterScreenDown(InstrumentationTestCase test, Activity activity) {
Display display = activity.getWindowManager().getDefaultDisplay(); Display display = activity.getWindowManager().getDefaultDisplay();
int screenHeight = display.getHeight(); final Point size = new Point();
int screenWidth = display.getWidth(); display.getSize(size);
final float x = screenWidth / 2.0f; final float x = size.x / 2.0f;
final float fromY = screenHeight * 0.5f; final float fromY = size.y * 0.5f;
final float toY = screenHeight * 0.75f; final float toY = size.y * 0.75f;
drag(test, x, x, fromY, toY, 4); drag(test, x, x, fromY, toY, 4);
} }
@@ -83,12 +84,12 @@ public class TouchUtils {
*/ */
public static void dragQuarterScreenUp(InstrumentationTestCase test, Activity activity) { public static void dragQuarterScreenUp(InstrumentationTestCase test, Activity activity) {
Display display = activity.getWindowManager().getDefaultDisplay(); Display display = activity.getWindowManager().getDefaultDisplay();
int screenHeight = display.getHeight(); final Point size = new Point();
int screenWidth = display.getWidth(); display.getSize(size);
final float x = screenWidth / 2.0f; final float x = size.x / 2.0f;
final float fromY = screenHeight * 0.5f; final float fromY = size.y * 0.5f;
final float toY = screenHeight * 0.25f; final float toY = size.y * 0.25f;
drag(test, x, x, fromY, toY, 4); drag(test, x, x, fromY, toY, 4);
} }