Merge "DO NOT MERGE. Integrate from master: Rework display size access." into honeycomb-mr2
This commit is contained in:
committed by
Android (Google) Code Review
commit
1e662c3294
138
api/current.xml
138
api/current.xml
@@ -84678,6 +84678,8 @@
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
<implements name="android.os.Parcelable">
|
||||
</implements>
|
||||
<constructor name="Point"
|
||||
type="android.graphics.Point"
|
||||
static="false"
|
||||
@@ -84708,6 +84710,17 @@
|
||||
<parameter name="src" type="android.graphics.Point">
|
||||
</parameter>
|
||||
</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"
|
||||
return="boolean"
|
||||
abstract="false"
|
||||
@@ -84749,6 +84762,19 @@
|
||||
<parameter name="dy" type="int">
|
||||
</parameter>
|
||||
</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"
|
||||
return="void"
|
||||
abstract="false"
|
||||
@@ -84764,6 +84790,31 @@
|
||||
<parameter name="y" type="int">
|
||||
</parameter>
|
||||
</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"
|
||||
type="int"
|
||||
transient="false"
|
||||
@@ -84793,6 +84844,8 @@
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
<implements name="android.os.Parcelable">
|
||||
</implements>
|
||||
<constructor name="PointF"
|
||||
type="android.graphics.PointF"
|
||||
static="false"
|
||||
@@ -84823,6 +84876,17 @@
|
||||
<parameter name="p" type="android.graphics.Point">
|
||||
</parameter>
|
||||
</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"
|
||||
return="boolean"
|
||||
abstract="false"
|
||||
@@ -84890,6 +84954,19 @@
|
||||
<parameter name="dy" type="float">
|
||||
</parameter>
|
||||
</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"
|
||||
return="void"
|
||||
abstract="false"
|
||||
@@ -84918,6 +84995,31 @@
|
||||
<parameter name="p" type="android.graphics.PointF">
|
||||
</parameter>
|
||||
</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"
|
||||
type="float"
|
||||
transient="false"
|
||||
@@ -209935,11 +210037,11 @@
|
||||
<method name="getHeight"
|
||||
return="int"
|
||||
abstract="false"
|
||||
native="true"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
deprecated="deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</method>
|
||||
@@ -209978,6 +210080,19 @@
|
||||
visibility="public"
|
||||
>
|
||||
</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"
|
||||
return="float"
|
||||
abstract="false"
|
||||
@@ -210000,16 +210115,29 @@
|
||||
visibility="public"
|
||||
>
|
||||
</method>
|
||||
<method name="getWidth"
|
||||
return="int"
|
||||
<method name="getSize"
|
||||
return="void"
|
||||
abstract="false"
|
||||
native="true"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
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>
|
||||
<field name="DEFAULT_DISPLAY"
|
||||
type="int"
|
||||
|
||||
@@ -819,18 +819,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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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. */
|
||||
native public int getRealWidth();
|
||||
native public int getRawWidth();
|
||||
/** @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.
|
||||
@@ -144,6 +212,16 @@ public class Display
|
||||
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
|
||||
* field offsets.
|
||||
@@ -160,8 +238,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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -4855,7 +4855,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -255,9 +255,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) {
|
||||
}
|
||||
|
||||
@@ -97,14 +97,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);
|
||||
@@ -137,14 +137,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 }
|
||||
};
|
||||
|
||||
18
graphics/java/android/graphics/Point.aidl
Normal file
18
graphics/java/android/graphics/Point.aidl
Normal 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;
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
18
graphics/java/android/graphics/PointF.aidl
Normal file
18
graphics/java/android/graphics/PointF.aidl
Normal 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;
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -63,6 +63,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;
|
||||
@@ -391,6 +392,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();
|
||||
@@ -4755,8 +4757,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
synchronized(mWindowMap) {
|
||||
long ident = Binder.clearCallingIdentity();
|
||||
|
||||
dw = mPolicy.getNonDecorDisplayWidth(mDisplay.getWidth());
|
||||
dh = mPolicy.getNonDecorDisplayHeight(mDisplay.getHeight());
|
||||
dw = mCurDisplayWidth;
|
||||
dh = mCurDisplayHeight;
|
||||
|
||||
int aboveAppLayer = mPolicy.windowTypeToLayerLw(
|
||||
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);
|
||||
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 {
|
||||
@@ -6345,6 +6347,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
|
||||
// -------------------------------------------------------------
|
||||
@@ -6587,8 +6604,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 innerDw = mPolicy.getNonDecorDisplayWidth(dw);
|
||||
final int innerDh = mPolicy.getNonDecorDisplayHeight(dh);
|
||||
@@ -6712,8 +6729,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();
|
||||
|
||||
final int innerDw = mPolicy.getNonDecorDisplayWidth(dw);
|
||||
final int innerDh = mPolicy.getNonDecorDisplayHeight(dh);
|
||||
@@ -8745,8 +8762,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");
|
||||
}
|
||||
|
||||
@@ -483,8 +483,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user