summaryrefslogtreecommitdiffstats
path: root/services/java/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com/android')
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java8
-rw-r--r--services/java/com/android/server/wm/AppWindowToken.java6
-rw-r--r--services/java/com/android/server/wm/WindowAnimator.java5
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java120
-rw-r--r--services/java/com/android/server/wm/WindowState.java56
-rw-r--r--services/java/com/android/server/wm/WindowStateAnimator.java163
6 files changed, 205 insertions, 153 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index bbaebd9..ab4012f 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -3587,11 +3587,9 @@ public final class ActivityManagerService extends ActivityManagerNative
// If uid is specified and the uid and process name match
// Or, the uid is not specified and the process name matches
} else if (((uid > 0 && uid != Process.SYSTEM_UID && app.info.uid == uid)
- && (app.processName.equals(packageName)
- || app.processName.startsWith(procNamePrefix)))
- || (uid < 0
- && (app.processName.equals(packageName)
- || app.processName.startsWith(procNamePrefix)))) {
+ || ((app.processName.equals(packageName)
+ || app.processName.startsWith(procNamePrefix))
+ && uid < 0))) {
if (app.setAdj >= minOomAdj) {
if (!doit) {
return true;
diff --git a/services/java/com/android/server/wm/AppWindowToken.java b/services/java/com/android/server/wm/AppWindowToken.java
index d1f1b44..3069b74 100644
--- a/services/java/com/android/server/wm/AppWindowToken.java
+++ b/services/java/com/android/server/wm/AppWindowToken.java
@@ -376,7 +376,8 @@ class AppWindowToken extends WindowToken {
int numDrawn = 0;
boolean nowGone = true;
- if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Update reported visibility: " + this);
+ if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG,
+ "Update reported visibility: " + this);
final int N = allAppWindows.size();
for (int i=0; i<N; i++) {
WindowState win = allAppWindows.get(i);
@@ -393,8 +394,7 @@ class AppWindowToken extends WindowToken {
if (!win.isDrawnLw()) {
Slog.v(WindowManagerService.TAG, "Not displayed: s=" + win.mWinAnimator.mSurface
+ " pv=" + win.mPolicyVisibility
- + " dp=" + win.mWinAnimator.mDrawPending
- + " cdp=" + win.mWinAnimator.mCommitDrawPending
+ + " mDrawState=" + win.mWinAnimator.mDrawState
+ " ah=" + win.mAttachedHidden
+ " th="
+ (win.mAppToken != null
diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java
index 26f4d0d..5a104b2 100644
--- a/services/java/com/android/server/wm/WindowAnimator.java
+++ b/services/java/com/android/server/wm/WindowAnimator.java
@@ -299,8 +299,7 @@ public class WindowAnimator {
if (!w.isDrawnLw()) {
Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurface
+ " pv=" + w.mPolicyVisibility
- + " dp=" + winAnimator.mDrawPending
- + " cdp=" + winAnimator.mCommitDrawPending
+ + " mDrawState=" + winAnimator.mDrawState
+ " ah=" + w.mAttachedHidden
+ " th=" + atoken.hiddenRequested
+ " a=" + winAnimator.mAnimating);
@@ -323,7 +322,7 @@ public class WindowAnimator {
atoken.startingDisplayed = true;
}
}
- } else if (w.mReadyToShow) {
+ } else if (winAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW) {
if (winAnimator.performShowLocked()) {
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index a2dfd91..afbc348 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -149,7 +149,7 @@ public class WindowManagerService extends IWindowManager.Stub
implements Watchdog.Monitor, WindowManagerPolicy.WindowManagerFuncs {
static final String TAG = "WindowManager";
static final boolean DEBUG = false;
- static final boolean DEBUG_ADD_REMOVE = false;
+ static final boolean DEBUG_ADD_REMOVE = true;
static final boolean DEBUG_FOCUS = false;
static final boolean DEBUG_ANIM = false;
static final boolean DEBUG_LAYOUT = false;
@@ -158,7 +158,7 @@ public class WindowManagerService extends IWindowManager.Stub
static final boolean DEBUG_INPUT = false;
static final boolean DEBUG_INPUT_METHOD = false;
static final boolean DEBUG_VISIBILITY = false;
- static final boolean DEBUG_WINDOW_MOVEMENT = false;
+ static final boolean DEBUG_WINDOW_MOVEMENT = true;
static final boolean DEBUG_TOKEN_MOVEMENT = false;
static final boolean DEBUG_ORIENTATION = false;
static final boolean DEBUG_APP_ORIENTATION = false;
@@ -1589,8 +1589,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
if (DEBUG_WALLPAPER) Slog.v(TAG, "Win " + w + ": readyfordisplay="
- + w.isReadyForDisplay() + " drawpending=" + w.mWinAnimator.mDrawPending
- + " commitdrawpending=" + w.mWinAnimator.mCommitDrawPending);
+ + w.isReadyForDisplay() + " mDrawState=" + w.mWinAnimator.mDrawState);
if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0 && w.isReadyForDisplay()
&& (mWallpaperTarget == w || w.isDrawnLw())) {
if (DEBUG_WALLPAPER) Slog.v(TAG,
@@ -1972,6 +1971,11 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
+ // TODO(cmautner): Move to WindowAnimator.
+ void setWallpaperOffset(final WindowStateAnimator winAnimator, final int left, final int top) {
+ mH.sendMessage(mH.obtainMessage(H.SET_WALLPAPER_OFFSET, left, top, winAnimator));
+ }
+
void updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) {
final int dw = mAppDisplayWidth;
final int dh = mAppDisplayHeight;
@@ -2010,10 +2014,8 @@ public class WindowManagerService extends IWindowManager.Stub
if (SHOW_TRANSACTIONS) logSurface(wallpaper,
"POS " + wallpaper.mShownFrame.left
+ ", " + wallpaper.mShownFrame.top, null);
- winAnimator.mSurfaceX = wallpaper.mShownFrame.left;
- winAnimator.mSurfaceY = wallpaper.mShownFrame.top;
- winAnimator.mSurface.setPosition(wallpaper.mShownFrame.left,
- wallpaper.mShownFrame.top);
+ setWallpaperOffset(winAnimator, (int) wallpaper.mShownFrame.left,
+ (int) wallpaper.mShownFrame.top);
} catch (RuntimeException e) {
Slog.w(TAG, "Error positioning surface of " + wallpaper
+ " pos=(" + wallpaper.mShownFrame.left
@@ -2314,7 +2316,7 @@ public class WindowManagerService extends IWindowManager.Stub
// to hold off on removing the window until the animation is done.
// If the display is frozen, just remove immediately, since the
// animation wouldn't be seen.
- if (win.mWinAnimator.mSurface != null && okToDisplay()) {
+ if (win.mHasSurface && okToDisplay()) {
// If we are not currently running the exit animation, we
// need to see about starting one.
wasVisible = win.isWinVisibleLw();
@@ -2458,8 +2460,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
static void logSurface(WindowState w, String msg, RuntimeException where) {
- String str = " SURFACE " + Integer.toHexString(w.hashCode())
- + ": " + msg + " / " + w.mAttrs.getTitle();
+ String str = " SURFACE " + msg + ": " + w;
if (where != null) {
Slog.i(TAG, str, where);
} else {
@@ -2475,26 +2476,20 @@ public class WindowManagerService extends IWindowManager.Stub
Slog.i(TAG, str);
}
}
-
+
+ // TODO(cmautner): Move to WindowStateAnimator.
+ void setTransparentRegionHint(final WindowStateAnimator winAnimator, final Region region) {
+ mH.sendMessage(mH.obtainMessage(H.SET_TRANSPARENT_REGION,
+ new Pair<WindowStateAnimator, Region>(winAnimator, region)));
+ }
+
void setTransparentRegionWindow(Session session, IWindow client, Region region) {
long origId = Binder.clearCallingIdentity();
try {
synchronized (mWindowMap) {
WindowState w = windowForClientLocked(session, client, false);
- WindowStateAnimator winAnimator = w.mWinAnimator;
- if ((w != null) && (winAnimator.mSurface != null)) {
- if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
- ">>> OPEN TRANSACTION setTransparentRegion");
- Surface.openTransaction();
- try {
- if (SHOW_TRANSACTIONS) logSurface(w,
- "transparentRegionHint=" + region, null);
- winAnimator.mSurface.setTransparentRegionHint(region);
- } finally {
- Surface.closeTransaction();
- if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
- "<<< CLOSE TRANSACTION setTransparentRegion");
- }
+ if ((w != null) && w.mHasSurface) {
+ setTransparentRegionHint(w.mWinAnimator, region);
}
}
} finally {
@@ -2617,11 +2612,12 @@ public class WindowManagerService extends IWindowManager.Stub
long origId = Binder.clearCallingIdentity();
synchronized(mWindowMap) {
+ // TODO(cmautner): synchronize on mAnimator or win.mWinAnimator.
WindowState win = windowForClientLocked(session, client, false);
- WindowStateAnimator winAnimator = win.mWinAnimator;
if (win == null) {
return 0;
}
+ WindowStateAnimator winAnimator = win.mWinAnimator;
if (win.mRequestedWidth != requestedWidth
|| win.mRequestedHeight != requestedHeight) {
win.mLayoutNeeded = true;
@@ -2702,6 +2698,7 @@ public class WindowManagerService extends IWindowManager.Stub
displayed = !win.isVisibleLw();
if (win.mExiting) {
winAnimator.cancelExitAnimationForNextAnimationLocked();
+ win.mExiting = false;
}
if (win.mDestroying) {
win.mDestroying = false;
@@ -2740,7 +2737,7 @@ public class WindowManagerService extends IWindowManager.Stub
surfaceChanged = true;
}
try {
- if (winAnimator.mSurface == null) {
+ if (!win.mHasSurface) {
surfaceChanged = true;
}
Surface surface = winAnimator.createSurfaceLocked();
@@ -3416,15 +3413,13 @@ public class WindowManagerService extends IWindowManager.Stub
}
public int getOrientationFromAppTokensLocked() {
- int pos = mAppTokens.size() - 1;
int curGroup = 0;
int lastOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
boolean findingBehind = false;
boolean haveGroup = false;
boolean lastFullscreen = false;
- while (pos >= 0) {
+ for (int pos = mAppTokens.size() - 1; pos >= 0; pos--) {
AppWindowToken wtoken = mAppTokens.get(pos);
- pos--;
if (DEBUG_APP_ORIENTATION) Slog.v(TAG, "Checking app orientation: " + wtoken);
@@ -4138,7 +4133,7 @@ public class WindowManagerService extends IWindowManager.Stub
WindowState w = wtoken.allAppWindows.get(i);
if (w.mAppFreezing) {
w.mAppFreezing = false;
- if (w.mWinAnimator.mSurface != null && !w.mOrientationChanging) {
+ if (w.mHasSurface && !w.mOrientationChanging) {
if (DEBUG_ORIENTATION) Slog.v(TAG, "set mOrientationChanging of " + w);
w.mOrientationChanging = true;
}
@@ -4726,7 +4721,7 @@ public class WindowManagerService extends IWindowManager.Stub
synchronized(mWindowMap) {
for (int i=mWindows.size()-1; i>=0; i--) {
WindowState w = mWindows.get(i);
- if (w.mWinAnimator.mSurface != null) {
+ if (w.mHasSurface) {
try {
w.mClient.closeSystemDialogs(reason);
} catch (RemoteException e) {
@@ -5198,7 +5193,7 @@ public class WindowManagerService extends IWindowManager.Stub
boolean including = false;
for (int i=mWindows.size()-1; i>=0; i--) {
WindowState ws = mWindows.get(i);
- if (ws.mWinAnimator.mSurface == null) {
+ if (!ws.mHasSurface) {
continue;
}
if (ws.mLayer >= aboveAppLayer) {
@@ -5512,7 +5507,7 @@ public class WindowManagerService extends IWindowManager.Stub
for (int i=mWindows.size()-1; i>=0; i--) {
WindowState w = mWindows.get(i);
- if (w.mWinAnimator.mSurface != null) {
+ if (w.mHasSurface) {
if (DEBUG_ORIENTATION) Slog.v(TAG, "Set mOrientationChanging of " + w);
w.mOrientationChanging = true;
}
@@ -6659,6 +6654,10 @@ public class WindowManagerService extends IWindowManager.Stub
public static final int WAITING_FOR_DRAWN_TIMEOUT = 24;
public static final int BULK_UPDATE_PARAMETERS = 25;
+ public static final int ANIMATOR_WHAT_OFFSET = 100000;
+ public static final int SET_TRANSPARENT_REGION = ANIMATOR_WHAT_OFFSET + 1;
+ public static final int SET_WALLPAPER_OFFSET = ANIMATOR_WHAT_OFFSET + 2;
+
private Session mLastReportedHold;
public H() {
@@ -7082,6 +7081,28 @@ public class WindowManagerService extends IWindowManager.Stub
requestTraversalLocked();
}
+ break;
+ }
+
+ // Animation messages. Move to Window{State}Animator
+ case SET_TRANSPARENT_REGION: {
+ // TODO(cmautner): Remove sync.
+ synchronized (mWindowMap) {
+ Pair<WindowStateAnimator, Region> pair =
+ (Pair<WindowStateAnimator, Region>) msg.obj;
+ final WindowStateAnimator winAnimator = pair.first;
+ winAnimator.setTransparentRegionHint(pair.second);
+ }
+ break;
+ }
+
+ case SET_WALLPAPER_OFFSET: {
+ // TODO(cmautner): Remove sync.
+ synchronized (mWindowMap) {
+ final WindowStateAnimator winAnimator = (WindowStateAnimator) msg.obj;
+ winAnimator.setWallpaperOffset(msg.arg1, msg.arg2);
+ }
+ break;
}
}
}
@@ -8027,7 +8048,7 @@ public class WindowManagerService extends IWindowManager.Stub
mAnimator.mForceHiding = false;
for (int i=mWindows.size()-1; i>=0; i--) {
WindowState w = mWindows.get(i);
- if (w.mWinAnimator.mSurface != null) {
+ if (w.mHasSurface) {
final WindowManager.LayoutParams attrs = w.mAttrs;
if (mPolicy.doesForceHide(w, attrs) && w.isVisibleLw()) {
if (DEBUG_FOCUS) Slog.i(TAG, "win=" + w + " force hides other windows");
@@ -8089,9 +8110,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (DEBUG_ORIENTATION) Slog.v(TAG,
"Orientation start waiting for draw in "
+ w + ", surface " + w.mWinAnimator.mSurface);
- winAnimator.mDrawPending = true;
- winAnimator.mCommitDrawPending = false;
- w.mReadyToShow = false;
+ winAnimator.mDrawState = WindowStateAnimator.DRAW_PENDING;
if (w.mAppToken != null) {
w.mAppToken.allDrawn = false;
}
@@ -8127,7 +8146,7 @@ public class WindowManagerService extends IWindowManager.Stub
final int attrFlags = attrs.flags;
final boolean canBeSeen = w.isDisplayedLw();
- if (w.mWinAnimator.mSurface != null) {
+ if (w.mHasSurface) {
if ((attrFlags&FLAG_KEEP_SCREEN_ON) != 0) {
mInnerFields.mHoldScreen = w.mSession;
}
@@ -8279,7 +8298,7 @@ public class WindowManagerService extends IWindowManager.Stub
mPolicy.beginAnimationLw(dw, dh);
for (i = mWindows.size() - 1; i >= 0; i--) {
WindowState w = mWindows.get(i);
- if (w.mWinAnimator.mSurface != null) {
+ if (w.mHasSurface) {
mPolicy.animatingWindowLw(w, w.mAttrs);
}
}
@@ -8397,7 +8416,7 @@ public class WindowManagerService extends IWindowManager.Stub
updateResizingWindows(w);
// Moved from updateWindowsAndWallpaperLocked().
- if (winAnimator.mSurface != null) {
+ if (w.mHasSurface) {
// Take care of the window being ready to display.
if (winAnimator.commitFinishDrawingLocked(currentTime)) {
if ((w.mAttrs.flags
@@ -8456,10 +8475,8 @@ public class WindowManagerService extends IWindowManager.Stub
stopFreezingDisplayLocked();
}
- i = mResizingWindows.size();
- if (i > 0) {
- do {
- i--;
+ if (!mResizingWindows.isEmpty()) {
+ for (i = mResizingWindows.size() - 1; i >= 0; i--) {
WindowState win = mResizingWindows.get(i);
final WindowStateAnimator winAnimator = win.mWinAnimator;
try {
@@ -8478,19 +8495,21 @@ public class WindowManagerService extends IWindowManager.Stub
+ Integer.toHexString(diff));
}
win.mConfiguration = mCurConfiguration;
- if (DEBUG_ORIENTATION && winAnimator.mDrawPending) Slog.i(
+ if (DEBUG_ORIENTATION &&
+ winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING) Slog.i(
TAG, "Resizing " + win + " WITH DRAW PENDING");
win.mClient.resized((int)winAnimator.mSurfaceW,
(int)winAnimator.mSurfaceH,
win.mLastContentInsets, win.mLastVisibleInsets,
- winAnimator.mDrawPending, configChanged ? win.mConfiguration : null);
+ winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING,
+ configChanged ? win.mConfiguration : null);
win.mContentInsetsChanged = false;
win.mVisibleInsetsChanged = false;
winAnimator.mSurfaceResized = false;
} catch (RemoteException e) {
win.mOrientationChanging = false;
}
- } while (i > 0);
+ }
mResizingWindows.clear();
}
@@ -8725,6 +8744,7 @@ public class WindowManagerService extends IWindowManager.Stub
wsa.mSurface.destroy();
wsa.mSurfaceShown = false;
wsa.mSurface = null;
+ ws.mHasSurface = false;
mForceRemoves.add(ws);
i--;
N--;
@@ -8737,6 +8757,7 @@ public class WindowManagerService extends IWindowManager.Stub
wsa.mSurface.destroy();
wsa.mSurfaceShown = false;
wsa.mSurface = null;
+ ws.mHasSurface = false;
leakedSurface = true;
}
}
@@ -8775,6 +8796,7 @@ public class WindowManagerService extends IWindowManager.Stub
surface.destroy();
winAnimator.mSurfaceShown = false;
winAnimator.mSurface = null;
+ winAnimator.mWin.mHasSurface = false;
}
try {
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java
index 7f63429..b74aa61 100644
--- a/services/java/com/android/server/wm/WindowState.java
+++ b/services/java/com/android/server/wm/WindowState.java
@@ -83,7 +83,6 @@ final class WindowState implements WindowManagerPolicy.WindowState {
boolean mPolicyVisibilityAfterAnim = true;
boolean mAppFreezing;
boolean mAttachedHidden; // is our parent window hidden?
- boolean mLastHidden; // was this window last hidden?
boolean mWallpaperVisible; // for wallpaper, what was last vis report?
/**
@@ -206,15 +205,6 @@ final class WindowState implements WindowManagerPolicy.WindowState {
// when in that case until the layout is done.
boolean mLayoutNeeded;
- // This is set during the time after the window's drawing has been
- // committed, and before its surface is actually shown. It is used
- // to delay showing the surface until all windows in a token are ready
- // to be shown.
- boolean mReadyToShow;
-
- // Set when the window has been shown in the screen the first time.
- boolean mHasDrawn;
-
// Currently running an exit animation?
boolean mExiting;
@@ -246,6 +236,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
final WindowStateAnimator mWinAnimator;
+ boolean mHasSurface = false;
+
WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,
WindowState attachedWindow, int seq, WindowManager.LayoutParams a,
int viewVisibility) {
@@ -609,7 +601,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
*/
public boolean isVisibleLw() {
final AppWindowToken atoken = mAppToken;
- return mWinAnimator.mSurface != null && mPolicyVisibility && !mAttachedHidden
+ return mHasSurface && mPolicyVisibility && !mAttachedHidden
&& (atoken == null || !atoken.hiddenRequested)
&& !mExiting && !mDestroying;
}
@@ -630,7 +622,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
final AppWindowToken atoken = mAppToken;
final boolean animating = atoken != null
? (atoken.animation != null) : false;
- return mWinAnimator.mSurface != null && !mDestroying && !mExiting
+ return mHasSurface && !mDestroying && !mExiting
&& (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested)
&& ((!mAttachedHidden && mViewVisibility == View.VISIBLE
&& !mRootToken.hidden)
@@ -644,7 +636,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
*/
public boolean isWinVisibleLw() {
final AppWindowToken atoken = mAppToken;
- return mWinAnimator.mSurface != null && mPolicyVisibility && !mAttachedHidden
+ return mHasSurface && mPolicyVisibility && !mAttachedHidden
&& (atoken == null || !atoken.hiddenRequested || atoken.animating)
&& !mExiting && !mDestroying;
}
@@ -654,7 +646,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
* the associated app token, not the pending requested hidden state.
*/
boolean isVisibleNow() {
- return mWinAnimator.mSurface != null && mPolicyVisibility && !mAttachedHidden
+ return mHasSurface && mPolicyVisibility && !mAttachedHidden
&& !mRootToken.hidden && !mExiting && !mDestroying;
}
@@ -674,7 +666,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
*/
boolean isVisibleOrAdding() {
final AppWindowToken atoken = mAppToken;
- return ((mWinAnimator.mSurface != null && !mWinAnimator.mReportDestroySurface)
+ return ((mHasSurface && !mWinAnimator.mReportDestroySurface)
|| (!mRelayoutCalled && mViewVisibility == View.VISIBLE))
&& mPolicyVisibility && !mAttachedHidden
&& (atoken == null || !atoken.hiddenRequested)
@@ -687,15 +679,15 @@ final class WindowState implements WindowManagerPolicy.WindowState {
* being visible.
*/
boolean isOnScreen() {
+ if (!mHasSurface || !mPolicyVisibility || mDestroying) {
+ return false;
+ }
final AppWindowToken atoken = mAppToken;
if (atoken != null) {
- return mWinAnimator.mSurface != null && mPolicyVisibility && !mDestroying
- && ((!mAttachedHidden && !atoken.hiddenRequested)
+ return ((!mAttachedHidden && !atoken.hiddenRequested)
|| mWinAnimator.mAnimation != null || atoken.animation != null);
- } else {
- return mWinAnimator.mSurface != null && mPolicyVisibility && !mDestroying
- && (!mAttachedHidden || mWinAnimator.mAnimation != null);
}
+ return !mAttachedHidden || mWinAnimator.mAnimation != null;
}
/**
@@ -707,7 +699,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
return false;
}
- return mWinAnimator.mSurface != null && mPolicyVisibility && !mDestroying
+ return mHasSurface && mPolicyVisibility && !mDestroying
&& ((!mAttachedHidden && mViewVisibility == View.VISIBLE
&& !mRootToken.hidden)
|| mWinAnimator.mAnimation != null
@@ -741,8 +733,9 @@ final class WindowState implements WindowManagerPolicy.WindowState {
* complete UI in to.
*/
public boolean isDrawnLw() {
- return mWinAnimator.mSurface != null && !mDestroying
- && !mWinAnimator.mDrawPending && !mWinAnimator.mCommitDrawPending;
+ return mHasSurface && !mDestroying &&
+ (mWinAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW
+ || mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN);
}
/**
@@ -762,7 +755,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
* sense to call from performLayoutAndPlaceSurfacesLockedInner().)
*/
boolean shouldAnimateMove() {
- return mContentChanged && !mExiting && !mLastHidden && mService.okToDisplay()
+ return mContentChanged && !mExiting && !mWinAnimator.mLastHidden && mService.okToDisplay()
&& (mFrame.top != mLastFrame.top
|| mFrame.left != mLastFrame.left)
&& (mAttachedWindow == null || !mAttachedWindow.shouldAnimateMove());
@@ -835,10 +828,12 @@ final class WindowState implements WindowManagerPolicy.WindowState {
&& ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0);
}
+ @Override
public boolean hasDrawnLw() {
- return mHasDrawn;
+ return mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN;
}
+ @Override
public boolean showLw(boolean doAnimation) {
return showLw(doAnimation, true);
}
@@ -983,7 +978,6 @@ final class WindowState implements WindowManagerPolicy.WindowState {
}
pw.print(prefix); pw.print("mViewVisibility=0x");
pw.print(Integer.toHexString(mViewVisibility));
- pw.print(" mLastHidden="); pw.print(mLastHidden);
pw.print(" mHaveFrame="); pw.print(mHaveFrame);
pw.print(" mObscured="); pw.println(mObscured);
pw.print(prefix); pw.print("mSeq="); pw.print(mSeq);
@@ -1017,8 +1011,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
}
pw.print(prefix); pw.print("mConfiguration="); pw.println(mConfiguration);
}
- pw.print(prefix); pw.print("mShownFrame=");
- mShownFrame.printShortString(pw); pw.println();
+ pw.print(prefix); pw.print("mHasSurface="); pw.print(mHasSurface);
+ pw.print(" mShownFrame="); mShownFrame.printShortString(pw); pw.println();
if (dumpAll) {
pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw);
pw.print(" last="); mLastFrame.printShortString(pw);
@@ -1046,12 +1040,6 @@ final class WindowState implements WindowManagerPolicy.WindowState {
pw.println();
}
mWinAnimator.dump(pw, prefix, dumpAll);
- if (dumpAll) {
- pw.print(prefix); pw.print("mDrawPending="); pw.print(mWinAnimator.mDrawPending);
- pw.print(" mCommitDrawPending="); pw.print(mWinAnimator.mCommitDrawPending);
- pw.print(" mReadyToShow="); pw.print(mReadyToShow);
- pw.print(" mHasDrawn="); pw.println(mHasDrawn);
- }
if (mExiting || mRemoveOnExit || mDestroying || mRemoved) {
pw.print(prefix); pw.print("mExiting="); pw.print(mExiting);
pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit);
diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java
index e99340c..4979a4c 100644
--- a/services/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/java/com/android/server/wm/WindowStateAnimator.java
@@ -9,6 +9,7 @@ import android.content.Context;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
import android.graphics.Rect;
+import android.graphics.Region;
import android.os.RemoteException;
import android.util.Slog;
import android.view.Surface;
@@ -35,6 +36,7 @@ class WindowStateAnimator {
static final boolean SHOW_LIGHT_TRANSACTIONS = WindowManagerService.SHOW_LIGHT_TRANSACTIONS;
static final boolean SHOW_SURFACE_ALLOC = WindowManagerService.SHOW_SURFACE_ALLOC;
static final boolean localLOGV = WindowManagerService.localLOGV;
+ static final boolean DEBUG_ORIENTATION = WindowManagerService.DEBUG_ORIENTATION;
static final String TAG = "WindowStateAnimator";
@@ -98,14 +100,24 @@ class WindowStateAnimator {
// an enter animation.
boolean mEnterAnimationPending;
- // This is set after the Surface has been created but before the
- // window has been drawn. During this time the surface is hidden.
- boolean mDrawPending;
-
- // This is set after the window has finished drawing for the first
- // time but before its surface is shown. The surface will be
- // displayed when the next layout is run.
- boolean mCommitDrawPending;
+ /** This is set when there is no Surface */
+ static final int NO_SURFACE = 0;
+ /** This is set after the Surface has been created but before the window has been drawn. During
+ * this time the surface is hidden. */
+ static final int DRAW_PENDING = 1;
+ /** This is set after the window has finished drawing for the first time but before its surface
+ * is shown. The surface will be displayed when the next layout is run. */
+ static final int COMMIT_DRAW_PENDING = 2;
+ /** This is set during the time after the window's drawing has been committed, and before its
+ * surface is actually shown. It is used to delay showing the surface until all windows in a
+ * token are ready to be shown. */
+ static final int READY_TO_SHOW = 3;
+ /** Set when the window has been shown in the screen the first time. */
+ static final int HAS_DRAWN = 4;
+ int mDrawState;
+
+ /** Was this window last hidden? */
+ boolean mLastHidden;
public WindowStateAnimator(final WindowManagerService service, final WindowState win,
final WindowState attachedWindow) {
@@ -128,7 +140,7 @@ class WindowStateAnimator {
mAnimation.scaleCurrentDuration(mService.mWindowAnimationScale);
// Start out animation gone if window is gone, or visible if window is visible.
mTransformation.clear();
- mTransformation.setAlpha(mWin.mLastHidden ? 0 : 1);
+ mTransformation.setAlpha(mLastHidden ? 0 : 1);
mHasLocalTransformation = true;
}
@@ -158,13 +170,11 @@ class WindowStateAnimator {
}
void cancelExitAnimationForNextAnimationLocked() {
- if (!mWin.mExiting) return;
if (mAnimation != null) {
mAnimation.cancel();
mAnimation = null;
destroySurfaceLocked();
}
- mWin.mExiting = false;
}
private boolean stepAnimation(long currentTime) {
@@ -291,7 +301,7 @@ class WindowStateAnimator {
}
}
mTransformation.clear();
- if (mWin.mHasDrawn
+ if (mDrawState == HAS_DRAWN
&& mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
&& mWin.mAppToken != null
&& mWin.mAppToken.firstWindowDrawn
@@ -347,7 +357,7 @@ class WindowStateAnimator {
} catch (RuntimeException e) {
Slog.w(TAG, "Error hiding surface in " + this, e);
}
- mWin.mLastHidden = true;
+ mLastHidden = true;
}
mWin.mExiting = false;
if (mWin.mRemoveOnExit) {
@@ -357,11 +367,10 @@ class WindowStateAnimator {
}
boolean finishDrawingLocked() {
- if (mDrawPending) {
- if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) Slog.v(
+ if (mDrawState == DRAW_PENDING) {
+ if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION) Slog.v(
TAG, "finishDrawingLocked: " + this + " in " + mSurface);
- mCommitDrawPending = true;
- mDrawPending = false;
+ mDrawState = COMMIT_DRAW_PENDING;
return true;
}
return false;
@@ -370,11 +379,10 @@ class WindowStateAnimator {
// This must be called while inside a transaction.
boolean commitFinishDrawingLocked(long currentTime) {
//Slog.i(TAG, "commitFinishDrawingLocked: " + mSurface);
- if (!mCommitDrawPending) {
+ if (mDrawState != COMMIT_DRAW_PENDING) {
return false;
}
- mCommitDrawPending = false;
- mWin.mReadyToShow = true;
+ mDrawState = READY_TO_SHOW;
final boolean starting = mWin.mAttrs.type == TYPE_APPLICATION_STARTING;
final AppWindowToken atoken = mWin.mAppToken;
if (atoken == null || atoken.allDrawn || starting) {
@@ -387,11 +395,9 @@ class WindowStateAnimator {
if (mSurface == null) {
mReportDestroySurface = false;
mSurfacePendingDestroy = false;
- if (WindowManagerService.DEBUG_ORIENTATION) Slog.i(TAG,
+ if (DEBUG_ORIENTATION) Slog.i(TAG,
"createSurface " + this + ": DRAW NOW PENDING");
- mDrawPending = true;
- mCommitDrawPending = false;
- mWin.mReadyToShow = false;
+ mDrawState = DRAW_PENDING;
if (mWin.mAppToken != null) {
mWin.mAppToken.allDrawn = false;
}
@@ -443,6 +449,7 @@ class WindowStateAnimator {
mSession.mSurfaceSession, mSession.mPid,
attrs.getTitle().toString(),
0, w, h, format, flags);
+ mWin.mHasSurface = true;
if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) Slog.i(TAG,
" CREATE SURFACE "
+ mSurface + " IN SESSION "
@@ -452,11 +459,15 @@ class WindowStateAnimator {
+ Integer.toHexString(flags)
+ " / " + this);
} catch (Surface.OutOfResourcesException e) {
+ mWin.mHasSurface = false;
Slog.w(TAG, "OutOfResourcesException creating surface");
mService.reclaimSomeSurfaceMemoryLocked(this, "create", true);
+ mDrawState = NO_SURFACE;
return null;
} catch (Exception e) {
+ mWin.mHasSurface = false;
Slog.e(TAG, "Exception creating surface", e);
+ mDrawState = NO_SURFACE;
return null;
}
@@ -489,7 +500,7 @@ class WindowStateAnimator {
Slog.w(TAG, "Error creating surface in " + w, e);
mService.reclaimSomeSurfaceMemoryLocked(this, "create-init", true);
}
- mWin.mLastHidden = true;
+ mLastHidden = true;
} finally {
Surface.closeTransaction();
if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
@@ -506,10 +517,8 @@ class WindowStateAnimator {
mWin.mAppToken.startingDisplayed = false;
}
+ mDrawState = NO_SURFACE;
if (mSurface != null) {
- mDrawPending = false;
- mCommitDrawPending = false;
- mWin.mReadyToShow = false;
int i = mWin.mChildWindows.size();
while (i > 0) {
@@ -573,6 +582,7 @@ class WindowStateAnimator {
mSurfaceShown = false;
mSurface = null;
+ mWin.mHasSurface =false;
}
}
@@ -746,7 +756,7 @@ class WindowStateAnimator {
final WindowState w = mWin;
if (mSurface == null) {
if (w.mOrientationChanging) {
- if (WindowManagerService.DEBUG_ORIENTATION) {
+ if (DEBUG_ORIENTATION) {
Slog.v(TAG, "Orientation change skips hidden " + w);
}
w.mOrientationChanging = false;
@@ -819,9 +829,9 @@ class WindowStateAnimator {
}
if (w.mAttachedHidden || !w.isReadyForDisplay()) {
- if (!w.mLastHidden) {
+ if (!mLastHidden) {
//dump();
- w.mLastHidden = true;
+ mLastHidden = true;
if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
"HIDE (performLayout)", null);
if (mSurface != null) {
@@ -841,7 +851,7 @@ class WindowStateAnimator {
// new orientation.
if (w.mOrientationChanging) {
w.mOrientationChanging = false;
- if (WindowManagerService.DEBUG_ORIENTATION) Slog.v(TAG,
+ if (DEBUG_ORIENTATION) Slog.v(TAG,
"Orientation change skips hidden " + w);
}
} else if (mLastLayer != mAnimLayer
@@ -852,7 +862,7 @@ class WindowStateAnimator {
|| mLastDtDy != mDtDy
|| w.mLastHScale != w.mHScale
|| w.mLastVScale != w.mVScale
- || w.mLastHidden) {
+ || mLastHidden) {
displayed = true;
mLastAlpha = mShownAlpha;
mLastLayer = mAnimLayer;
@@ -877,6 +887,21 @@ class WindowStateAnimator {
mSurface.setMatrix(
mDsDx*w.mHScale, mDtDx*w.mVScale,
mDsDy*w.mHScale, mDtDy*w.mVScale);
+
+ if (mLastHidden && mDrawState == HAS_DRAWN) {
+ if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
+ "SHOW (performLayout)", null);
+ if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, "Showing " + w
+ + " during relayout");
+ if (showSurfaceRobustlyLocked()) {
+ mLastHidden = false;
+ } else {
+ w.mOrientationChanging = false;
+ }
+ }
+ if (mSurface != null) {
+ w.mToken.hasVisible = true;
+ }
} catch (RuntimeException e) {
Slog.w(TAG, "Error updating surface in " + w, e);
if (!recoveringMemory) {
@@ -884,23 +909,6 @@ class WindowStateAnimator {
}
}
}
-
- if (w.mLastHidden && w.isDrawnLw()
- && !w.mReadyToShow) {
- if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
- "SHOW (performLayout)", null);
- if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, "Showing " + w
- + " during relayout");
- if (showSurfaceRobustlyLocked()) {
- w.mHasDrawn = true;
- w.mLastHidden = false;
- } else {
- w.mOrientationChanging = false;
- }
- }
- if (mSurface != null) {
- w.mToken.hasVisible = true;
- }
} else {
displayed = true;
}
@@ -909,18 +917,45 @@ class WindowStateAnimator {
if (w.mOrientationChanging) {
if (!w.isDrawnLw()) {
mService.mInnerFields.mOrientationChangeComplete = false;
- if (WindowManagerService.DEBUG_ORIENTATION) Slog.v(TAG,
+ if (DEBUG_ORIENTATION) Slog.v(TAG,
"Orientation continue waiting for draw in " + w);
} else {
w.mOrientationChanging = false;
- if (WindowManagerService.DEBUG_ORIENTATION) Slog.v(TAG,
- "Orientation change complete in " + w);
+ if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change complete in " + w);
}
}
w.mToken.hasVisible = true;
}
}
+ void setTransparentRegionHint(final Region region) {
+ if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
+ ">>> OPEN TRANSACTION setTransparentRegion");
+ Surface.openTransaction();
+ try {
+ if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin,
+ "transparentRegionHint=" + region, null);
+ mSurface.setTransparentRegionHint(region);
+ } finally {
+ Surface.closeTransaction();
+ if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
+ "<<< CLOSE TRANSACTION setTransparentRegion");
+ }
+ }
+
+ void setWallpaperOffset(int left, int top) {
+ Surface.openTransaction();
+ try {
+ mSurfaceX = left;
+ mSurfaceY = top;
+ mSurface.setPosition(left, top);
+ } catch (RuntimeException e) {
+ Slog.w(TAG, "Error positioning surface of " + mWin
+ + " pos=(" + left + "," + top + ")", e);
+ }
+ Surface.closeTransaction();
+ }
+
// This must be called while inside a transaction.
boolean performShowLocked() {
if (DEBUG_VISIBILITY) {
@@ -930,12 +965,12 @@ class WindowStateAnimator {
e.fillInStackTrace();
}
Slog.v(TAG, "performShow on " + this
- + ": readyToShow=" + mWin.mReadyToShow + " readyForDisplay="
+ + ": mDrawState=" + mDrawState + " readyForDisplay="
+ mWin.isReadyForDisplay()
+ " starting=" + (mWin.mAttrs.type == TYPE_APPLICATION_STARTING), e);
}
- if (mWin.mReadyToShow && mWin.isReadyForDisplay()) {
- if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION)
+ if (mDrawState == READY_TO_SHOW && mWin.isReadyForDisplay()) {
+ if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION)
WindowManagerService.logSurface(mWin, "SHOW (performShowLocked)", null);
if (DEBUG_VISIBILITY) Slog.v(TAG, "Showing " + this
+ " during animation: policyVis=" + mWin.mPolicyVisibility
@@ -956,9 +991,8 @@ class WindowStateAnimator {
applyEnterAnimationLocked();
mLastAlpha = -1;
- mWin.mHasDrawn = true;
- mWin.mLastHidden = false;
- mWin.mReadyToShow = false;
+ mLastHidden = false;
+ mDrawState = HAS_DRAWN;
int i = mWin.mChildWindows.size();
while (i > 0) {
@@ -1051,6 +1085,7 @@ class WindowStateAnimator {
applyAnimationLocked(transit, true);
}
+ // TODO(cmautner): Move back to WindowState?
/**
* Choose the correct animation and set it to the passed WindowState.
* @param transit If WindowManagerPolicy.TRANSIT_PREVIEW_DONE and the app window has been drawn
@@ -1138,6 +1173,8 @@ class WindowStateAnimator {
if (mSurface != null) {
if (dumpAll) {
pw.print(prefix); pw.print("mSurface="); pw.println(mSurface);
+ pw.print(prefix); pw.print("mDrawState="); pw.print(mDrawState);
+ pw.print(" mLastHidden="); pw.println(mLastHidden);
}
pw.print(prefix); pw.print("Surface: shown="); pw.print(mSurfaceShown);
pw.print(" layer="); pw.print(mSurfaceLayer);
@@ -1169,4 +1206,12 @@ class WindowStateAnimator {
}
}
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer("WindowStateAnimator (");
+ sb.append(mWin.mLastTitle + "): ");
+ sb.append("mSurface " + mSurface);
+ sb.append(", mAnimation " + mAnimation);
+ return sb.toString();
+ }
}