Merge "Change WindowState.mShownFrame to WindowState.mShownPosition."
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index aaf6052..d20c729 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -22,6 +22,7 @@
import android.content.pm.ActivityInfo;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
+import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
@@ -38,7 +39,7 @@
* instance of it is created by the window manager when it starts up, and allows
* customization of window layering, special window types, key dispatching, and
* layout.
- *
+ *
* <p>Because this provides deep interaction with the system window manager,
* specific methods on this interface can be called from a variety of contexts
* with various restrictions on what they can do. These are encoded through
@@ -47,9 +48,9 @@
* is attached to a method, then it is not called with any locks and may be
* called from the main window manager thread or another thread calling into
* the window manager.
- *
+ *
* <p>The current suffixes are:
- *
+ *
* <dl>
* <dt> Ti <dd> Called from the input thread. This is the thread that
* collects pending input events and dispatches them to the appropriate window.
@@ -71,7 +72,7 @@
* acquired by the window manager while it holds the window lock, so this is
* even more restrictive than <var>Lw</var>.
* </dl>
- *
+ *
* @hide
*/
public interface WindowManagerPolicy {
@@ -138,7 +139,7 @@
* Perform standard frame computation. The result can be obtained with
* getFrame() if so desired. Must be called with the window manager
* lock held.
- *
+ *
* @param parentFrame The frame of the parent container this window
* is in, used for computing its basic position.
* @param displayFrame The frame of the overall display in which this
@@ -168,18 +169,18 @@
/**
* Retrieve the current frame of the window that has been assigned by
* the window manager. Must be called with the window manager lock held.
- *
+ *
* @return Rect The rectangle holding the window frame.
*/
public Rect getFrameLw();
/**
- * Retrieve the current frame of the window that is actually shown.
+ * Retrieve the current position of the window that is actually shown.
* Must be called with the window manager lock held.
- *
- * @return Rect The rectangle holding the shown window frame.
+ *
+ * @return Point The point holding the shown window position.
*/
- public RectF getShownFrameLw();
+ public Point getShownPositionLw();
/**
* Retrieve the frame of the display that this window was last
@@ -206,7 +207,7 @@
* account for screen decorations such as a status bar or soft
* keyboard. Must be called with the
* window manager lock held.
- *
+ *
* @return Rect The rectangle holding the content frame.
*/
public Rect getContentFrameLw();
@@ -218,7 +219,7 @@
* content frame to account for transient UI elements blocking it
* such as an input method's candidates UI. Must be called with the
* window manager lock held.
- *
+ *
* @return Rect The rectangle holding the visible frame.
*/
public Rect getVisibleFrameLw();
@@ -229,12 +230,12 @@
* layout of other windows.
*/
public boolean getGivenInsetsPendingLw();
-
+
/**
* Retrieve the insets given by this window's client for the content
* area of windows behind it. Must be called with the
* window manager lock held.
- *
+ *
* @return Rect The left, top, right, and bottom insets, relative
* to the window's frame, of the actual contents.
*/
@@ -244,7 +245,7 @@
* Retrieve the insets given by this window's client for the visible
* area of windows behind it. Must be called with the
* window manager lock held.
- *
+ *
* @return Rect The left, top, right, and bottom insets, relative
* to the window's frame, of the actual visible area.
*/
@@ -252,7 +253,7 @@
/**
* Retrieve the current LayoutParams of the window.
- *
+ *
* @return WindowManager.LayoutParams The window's internal LayoutParams
* instance.
*/
@@ -298,12 +299,12 @@
public boolean isVoiceInteraction();
/**
- * Return true if, at any point, the application token associated with
- * this window has actually displayed any windows. This is most useful
- * with the "starting up" window to determine if any windows were
- * displayed when it is closed.
- *
- * @return Returns true if one or more windows have been displayed,
+ * Return true if, at any point, the application token associated with
+ * this window has actually displayed any windows. This is most useful
+ * with the "starting up" window to determine if any windows were
+ * displayed when it is closed.
+ *
+ * @return Returns true if one or more windows have been displayed,
* else false.
*/
public boolean hasAppShownWindows();
@@ -314,17 +315,17 @@
* that will remove the surface.
*/
boolean isVisibleLw();
-
+
/**
* Like {@link #isVisibleLw}, but also counts a window that is currently
* "hidden" behind the keyguard as visible. This allows us to apply
* things like window flags that impact the keyguard.
*/
boolean isVisibleOrBehindKeyguardLw();
-
+
/**
- * Is this window currently visible to the user on-screen? It is
- * displayed either if it is visible or it is currently running an
+ * Is this window currently visible to the user on-screen? It is
+ * displayed either if it is visible or it is currently running an
* animation before no longer being visible. Must be called with the
* window manager lock held.
*/
@@ -350,7 +351,7 @@
boolean isDrawnLw();
/**
- * Returns true if this window has been shown on screen at some time in
+ * Returns true if this window has been shown on screen at some time in
* the past. Must be called with the window manager lock held.
*/
public boolean hasDrawnLw();
@@ -362,7 +363,7 @@
* Returns true if {@link #showLw} was last called for the window.
*/
public boolean hideLw(boolean doAnimation);
-
+
/**
* Can be called to undo the effect of {@link #hideLw}, allowing a
* window to be shown as long as the window manager and client would
@@ -479,7 +480,7 @@
// NOTE: screen off reasons are in order of significance, with more
// important ones lower than less important ones.
-
+
/** Screen turned off because of a device admin */
public final int OFF_BECAUSE_OF_ADMIN = 1;
/** Screen turned off because of power button */
@@ -498,10 +499,10 @@
/** When not otherwise specified by the activity's screenOrientation, rotation is set by
* the user. */
public final int USER_ROTATION_LOCKED = 1;
-
+
/**
* Perform initialization of the policy.
- *
+ *
* @param context The system context we are running in.
*/
public void init(Context context, IWindowManager windowManager,
@@ -526,11 +527,11 @@
/**
* Check permissions when adding a window.
- *
+ *
* @param attrs The window's LayoutParams.
* @param outAppOp First element will be filled with the app op corresponding to
* this window, or OP_NONE.
- *
+ *
* @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed;
* else an error code, usually
* {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add.
@@ -551,21 +552,21 @@
* Sanitize the layout parameters coming from a client. Allows the policy
* to do things like ensure that windows of a specific type can't take
* input focus.
- *
+ *
* @param attrs The window layout parameters to be modified. These values
* are modified in-place.
*/
public void adjustWindowParamsLw(WindowManager.LayoutParams attrs);
-
+
/**
* After the window manager has computed the current configuration based
* on its knowledge of the display and input devices, it gives the policy
* a chance to adjust the information contained in it. If you want to
* leave it as-is, simply do nothing.
- *
+ *
* <p>This method may be called by any thread in the window manager, but
* no internal locks in the window manager will be held.
- *
+ *
* @param config The Configuration being computed, for you to change as
* desired.
* @param keyboardPresence Flags that indicate whether internal or external
@@ -575,13 +576,13 @@
*/
public void adjustConfigurationLw(Configuration config, int keyboardPresence,
int navigationPresence);
-
+
/**
* Assign a window type to a layer. Allows you to control how different
* kinds of windows are ordered on-screen.
- *
+ *
* @param type The type of window being assigned.
- *
+ *
* @return int An arbitrary integer used to order windows, with lower
* numbers below higher ones.
*/
@@ -591,9 +592,9 @@
* Return how to Z-order sub-windows in relation to the window they are
* attached to. Return positive to have them ordered in front, negative for
* behind.
- *
+ *
* @param type The sub-window type code.
- *
+ *
* @return int Layer in relation to the attached window, where positive is
* above and negative is below.
*/
@@ -669,19 +670,19 @@
* manager (using the normal window manager APIs) that will be shown until
* the application displays its own window. This is called without the
* window manager locked so that you can call back into it.
- *
+ *
* @param appToken Token of the application being started.
- * @param packageName The name of the application package being started.
+ * @param packageName The name of the application package being started.
* @param theme Resource defining the application's overall visual theme.
* @param nonLocalizedLabel The default title label of the application if
* no data is found in the resource.
* @param labelRes The resource ID the application would like to use as its name.
* @param icon The resource ID the application would like to use as its icon.
* @param windowFlags Window layout flags.
- *
+ *
* @return Optionally you can return the View that was used to create the
* window, for easy removal in removeStartingWindow.
- *
+ *
* @see #removeStartingWindow
*/
public View addStartingWindow(IBinder appToken, String packageName,
@@ -694,15 +695,15 @@
* that application. You should at this point remove the window from the
* window manager. This is called without the window manager locked so
* that you can call back into it.
- *
+ *
* <p>Note: due to the nature of these functions not being called with the
* window manager locked, you must be prepared for this function to be
* called multiple times and/or an initial time with a null View window
* even if you previously returned one.
- *
+ *
* @param appToken Token of the application that has started.
* @param window Window View that was returned by createStartingWindow.
- *
+ *
* @see #addStartingWindow
*/
public void removeStartingWindow(IBinder appToken, View window);
@@ -711,10 +712,10 @@
* Prepare for a window being added to the window manager. You can throw an
* exception here to prevent the window being added, or do whatever setup
* you need to keep track of the window.
- *
+ *
* @param win The window being added.
- * @param attrs The window's LayoutParams.
- *
+ * @param attrs The window's LayoutParams.
+ *
* @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed, else an
* error code to abort the add.
*/
@@ -724,7 +725,7 @@
/**
* Called when a window is being removed from a window manager. Must not
* throw an exception -- clean up as much as possible.
- *
+ *
* @param win The window being removed.
*/
public void removeWindowLw(WindowState win);
@@ -733,12 +734,12 @@
* Control the animation to run when a window's state changes. Return a
* non-0 number to force the animation to a specific resource ID, or 0
* to use the default animation.
- *
+ *
* @param win The window that is changing.
* @param transit What is happening to the window: {@link #TRANSIT_ENTER},
* {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
* {@link #TRANSIT_HIDE}.
- *
+ *
* @return Resource ID of the actual animation to use, or 0 for none.
*/
public int selectAnimationLw(WindowState win, int transit);
@@ -747,8 +748,8 @@
* Determine the animation to run for a rotation transition based on the
* top fullscreen windows {@link WindowManager.LayoutParams#rotationAnimation}
* and whether it is currently fullscreen and frontmost.
- *
- * @param anim The exiting animation resource id is stored in anim[0], the
+ *
+ * @param anim The exiting animation resource id is stored in anim[0], the
* entering animation resource id is stored in anim[1].
*/
public void selectRotationAnimationLw(int anim[]);
@@ -814,7 +815,7 @@
* <p>Allows you to define
* behavior for keys that can not be overridden by applications.
* This method is called from the input thread, with no locks held.
- *
+ *
* @param win The window that currently has focus. This is where the key
* event will normally go.
* @param event The key event.
@@ -832,7 +833,7 @@
*
* <p>Allows you to define default global behavior for keys that were not handled
* by applications. This method is called from the input thread, with no locks held.
- *
+ *
* @param win The window that currently has focus. This is where the key
* event will normally go.
* @param event The key event.
@@ -844,7 +845,7 @@
/**
* Called when layout of the windows is about to start.
- *
+ *
* @param isDefaultDisplay true if window is on {@link Display#DEFAULT_DISPLAY}.
* @param displayWidth The current full width of the screen.
* @param displayHeight The current full height of the screen.
@@ -872,7 +873,7 @@
* Called for each window attached to the window manager as layout is
* proceeding. The implementation of this function must take care of
* setting the window's frame, either here or in finishLayout().
- *
+ *
* @param win The window being positioned.
* @param attached For sub-windows, the window it is attached to; this
* window will already have had layoutWindow() called on it
@@ -880,7 +881,7 @@
*/
public void layoutWindowLw(WindowState win, WindowState attached);
-
+
/**
* Return the insets for the areas covered by system windows. These values
* are computed on the most recent layout, so they are not guaranteed to
@@ -912,10 +913,10 @@
static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
/** Need to recompute animations */
static final int FINISH_LAYOUT_REDO_ANIM = 0x0008;
-
+
/**
* Called following layout of all windows before each window has policy applied.
- *
+ *
* @param displayWidth The current full width of the screen.
* @param displayHeight The current full height of the screen.
*/
@@ -936,7 +937,7 @@
* to each window. If in this function you do
* something that may have modified the animation state of another window,
* be sure to return non-zero in order to perform another pass through layout.
- *
+ *
* @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
* {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
* or {@link #FINISH_LAYOUT_REDO_ANIM}.
@@ -1150,7 +1151,7 @@
* the system should go into safe mode.
*/
public void setSafeMode(boolean safeMode);
-
+
/**
* Called when the system is mostly done booting.
*/
@@ -1184,14 +1185,14 @@
* this point the display is active.
*/
public void enableScreenAfterBoot();
-
+
public void setCurrentOrientationLw(@ActivityInfo.ScreenOrientation int newOrientation);
-
+
/**
* Call from application to perform haptic feedback on its window.
*/
public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
-
+
/**
* Called when we have started keeping the screen on because a window
* requesting this has become visible.
@@ -1205,21 +1206,21 @@
public void keepScreenOnStoppedLw();
/**
- * Gets the current user rotation mode.
+ * Gets the current user rotation mode.
*
* @return The rotation mode.
*
* @see WindowManagerPolicy#USER_ROTATION_LOCKED
- * @see WindowManagerPolicy#USER_ROTATION_FREE
+ * @see WindowManagerPolicy#USER_ROTATION_FREE
*/
@UserRotationMode
public int getUserRotationMode();
/**
- * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
+ * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
*
* @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or
- * {@link WindowManagerPolicy#USER_ROTATION_FREE}.
+ * {@link WindowManagerPolicy#USER_ROTATION_FREE}.
* @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
* {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
*/
diff --git a/graphics/java/android/graphics/Point.java b/graphics/java/android/graphics/Point.java
index e0d8ccc..3bd17fa 100644
--- a/graphics/java/android/graphics/Point.java
+++ b/graphics/java/android/graphics/Point.java
@@ -19,6 +19,8 @@
import android.os.Parcel;
import android.os.Parcelable;
+import java.io.PrintWriter;
+
/**
* Point holds two integer coordinates
@@ -95,6 +97,11 @@
return "Point(" + x + ", " + y + ")";
}
+ /** @hide */
+ public void printShortString(PrintWriter pw) {
+ pw.println("["); pw.print(x); pw.print(","); pw.print(y); pw.print("]");
+ }
+
/**
* Parcelable interface methods
*/
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 16add37..e354029 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -4614,7 +4614,8 @@
final int fl = PolicyControl.getWindowFlags(null, lp);
if (localLOGV) {
Slog.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw()
- + " shown frame: " + mTopFullscreenOpaqueWindowState.getShownFrameLw());
+ + " shown position: "
+ + mTopFullscreenOpaqueWindowState.getShownPositionLw());
Slog.d(TAG, "attr: " + mTopFullscreenOpaqueWindowState.getAttrs()
+ " lp.flags=0x" + Integer.toHexString(fl));
}
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java
index 66ae9ef..d713751 100644
--- a/services/core/java/com/android/server/wm/AccessibilityController.java
+++ b/services/core/java/com/android/server/wm/AccessibilityController.java
@@ -206,8 +206,8 @@
sTempFloats[Matrix.MSKEW_Y] = windowState.mWinAnimator.mDtDx;
sTempFloats[Matrix.MSKEW_X] = windowState.mWinAnimator.mDsDy;
sTempFloats[Matrix.MSCALE_Y] = windowState.mWinAnimator.mDtDy;
- sTempFloats[Matrix.MTRANS_X] = windowState.mShownFrame.left;
- sTempFloats[Matrix.MTRANS_Y] = windowState.mShownFrame.top;
+ sTempFloats[Matrix.MTRANS_X] = windowState.mShownPosition.x;
+ sTempFloats[Matrix.MTRANS_Y] = windowState.mShownPosition.y;
sTempFloats[Matrix.MPERSP_0] = 0;
sTempFloats[Matrix.MPERSP_1] = 0;
sTempFloats[Matrix.MPERSP_2] = 1;
diff --git a/services/core/java/com/android/server/wm/WallpaperController.java b/services/core/java/com/android/server/wm/WallpaperController.java
index 1a946b2..7f2f2cd 100644
--- a/services/core/java/com/android/server/wm/WallpaperController.java
+++ b/services/core/java/com/android/server/wm/WallpaperController.java
@@ -419,7 +419,7 @@
winAnimator.computeShownFrameLocked();
// No need to lay out the windows - we can just set the wallpaper position
// directly.
- winAnimator.setWallpaperOffset(wallpaper.mShownFrame);
+ winAnimator.setWallpaperOffset(wallpaper.mShownPosition);
// We only want to be synchronous with one wallpaper.
sync = false;
}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 383ad8c..e72d35c 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -29,15 +29,14 @@
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static com.android.server.wm.WindowManagerService.DEBUG_CONFIGURATION;
-import static com.android.server.wm.WindowManagerService.DEBUG_DIM_LAYER;
import static com.android.server.wm.WindowManagerService.DEBUG_LAYOUT;
import static com.android.server.wm.WindowManagerService.DEBUG_ORIENTATION;
import static com.android.server.wm.WindowManagerService.DEBUG_POWER;
import static com.android.server.wm.WindowManagerService.DEBUG_RESIZE;
import static com.android.server.wm.WindowManagerService.DEBUG_VISIBILITY;
-import android.app.ActivityManager;
import android.app.AppOpsManager;
+import android.graphics.Point;
import android.os.PowerManager;
import android.os.RemoteCallbackList;
import android.os.SystemClock;
@@ -159,11 +158,10 @@
private boolean mConfigHasChanged;
/**
- * Actual frame shown on-screen (may be modified by animation). These
- * are in the screen's coordinate space (WITH the compatibility scale
- * applied).
+ * Actual position of the surface shown on-screen (may be modified by animation). These are
+ * in the screen's coordinate space (WITH the compatibility scale applied).
*/
- final RectF mShownFrame = new RectF();
+ final Point mShownPosition = new Point();
/**
* Insets that determine the actually visible area. These are in the application's
@@ -787,8 +785,8 @@
}
@Override
- public RectF getShownFrameLw() {
- return mShownFrame;
+ public Point getShownPositionLw() {
+ return mShownPosition;
}
@Override
@@ -1822,7 +1820,7 @@
}
}
pw.print(prefix); pw.print("mHasSurface="); pw.print(mHasSurface);
- pw.print(" mShownFrame="); mShownFrame.printShortString(pw);
+ pw.print(" mShownPosition="); mShownPosition.printShortString(pw);
pw.print(" isReadyForDisplay()="); pw.println(isReadyForDisplay());
if (dumpAll) {
pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw);
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 2733933..3c897fa 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -1192,7 +1192,7 @@
float y = tmpFloats[Matrix.MTRANS_Y];
int w = frame.width();
int h = frame.height();
- mWin.mShownFrame.set(x, y, x+w, y+h);
+ mWin.mShownPosition.set((int) x, (int) y);
// Now set the alpha... but because our current hardware
// can't do alpha transformation on a non-opaque surface,
@@ -1287,13 +1287,13 @@
float y = tmpFloats[Matrix.MTRANS_Y];
int w = frame.width();
int h = frame.height();
- mWin.mShownFrame.set(x, y, x + w, y + h);
+ mWin.mShownPosition.set((int) x, (int) y);
mShownAlpha = mAlpha;
} else {
- mWin.mShownFrame.set(mWin.mFrame);
+ mWin.mShownPosition.set(mWin.mFrame.left, mWin.mFrame.top);
if (mWin.mXOffset != 0 || mWin.mYOffset != 0) {
- mWin.mShownFrame.offset(mWin.mXOffset, mWin.mYOffset);
+ mWin.mShownPosition.offset(mWin.mXOffset, mWin.mYOffset);
}
mShownAlpha = mAlpha;
mHaveMatrix = false;
@@ -1458,8 +1458,8 @@
void setSurfaceBoundariesLocked(final boolean recoveringMemory) {
final WindowState w = mWin;
- float left = w.mShownFrame.left;
- float top = w.mShownFrame.top;
+ float left = w.mShownPosition.x;
+ float top = w.mShownPosition.y;
int width;
int height;
@@ -1701,10 +1701,10 @@
}
}
- void setWallpaperOffset(RectF shownFrame) {
+ void setWallpaperOffset(Point shownPosition) {
final LayoutParams attrs = mWin.getAttrs();
- final int left = ((int) shownFrame.left) - attrs.surfaceInsets.left;
- final int top = ((int) shownFrame.top) - attrs.surfaceInsets.top;
+ final int left = shownPosition.x - attrs.surfaceInsets.left;
+ final int top = shownPosition.y - attrs.surfaceInsets.top;
if (mSurfaceX != left || mSurfaceY != top) {
if (mAnimating) {
// If this window (or its app token) is animating, then the position
diff --git a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
index 112646a..247562f 100644
--- a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
+++ b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
@@ -717,7 +717,8 @@
/*
* Updates the shown frame before we set up the surface. This is needed because
* the resizing could change the top-left position (in addition to size) of the
- * window. setSurfaceBoundariesLocked uses mShownFrame to position the surface.
+ * window. setSurfaceBoundariesLocked uses mShownPosition to position the
+ * surface.
*/
winAnimator.computeShownFrameLocked();
winAnimator.setSurfaceBoundariesLocked(recoveringMemory);