resolved conflicts for merge of f7adbe10 to master
Change-Id: I898a5e53b180adaee2337c0c0b9896c799d056e7
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 0e5ff42..b82ec01 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -331,7 +331,7 @@
/**
* Z-ordered (bottom-most first) list of all Window objects.
*/
- final ArrayList mWindows = new ArrayList();
+ final ArrayList<WindowState> mWindows = new ArrayList<WindowState>();
/**
* Windows that are being resized. Used so we can tell the client about
@@ -629,7 +629,7 @@
"KEEP_SCREEN_ON_FLAG");
mHoldingScreenWakeLock.setReferenceCounted(false);
- mInputManager = new InputManager(context, this, pmc, mPowerManager);
+ mInputManager = new InputManager(context, this);
PolicyThread thr = new PolicyThread(mPolicy, this, context, pm);
thr.start();
@@ -664,7 +664,7 @@
}
}
- private void placeWindowAfter(Object pos, WindowState window) {
+ private void placeWindowAfter(WindowState pos, WindowState window) {
final int i = mWindows.indexOf(pos);
if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v(
TAG, "Adding window " + window + " at "
@@ -673,7 +673,7 @@
mWindowsChanged = true;
}
- private void placeWindowBefore(Object pos, WindowState window) {
+ private void placeWindowBefore(WindowState pos, WindowState window) {
final int i = mWindows.indexOf(pos);
if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v(
TAG, "Adding window " + window + " at "
@@ -686,13 +686,13 @@
//win. used for z ordering the windows in mWindows
private int findIdxBasedOnAppTokens(WindowState win) {
//use a local variable to cache mWindows
- ArrayList localmWindows = mWindows;
+ ArrayList<WindowState> localmWindows = mWindows;
int jmax = localmWindows.size();
if(jmax == 0) {
return -1;
}
for(int j = (jmax-1); j >= 0; j--) {
- WindowState wentry = (WindowState)localmWindows.get(j);
+ WindowState wentry = localmWindows.get(j);
if(wentry.mAppToken == win.mAppToken) {
return j;
}
@@ -703,7 +703,7 @@
private void addWindowToListInOrderLocked(WindowState win, boolean addToToken) {
final IWindow client = win.mClient;
final WindowToken token = win.mToken;
- final ArrayList localmWindows = mWindows;
+ final ArrayList<WindowState> localmWindows = mWindows;
final int N = localmWindows.size();
final WindowState attached = win.mAttachedWindow;
@@ -748,7 +748,7 @@
// Figure out where the window should go, based on the
// order of applications.
final int NA = mAppTokens.size();
- Object pos = null;
+ WindowState pos = null;
for (i=NA-1; i>=0; i--) {
AppWindowToken t = mAppTokens.get(i);
if (t == token) {
@@ -768,8 +768,7 @@
// we need to look some more.
if (pos != null) {
// Move behind any windows attached to this one.
- WindowToken atoken =
- mTokenMap.get(((WindowState)pos).mClient.asBinder());
+ WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
if (atoken != null) {
final int NC = atoken.windows.size();
if (NC > 0) {
@@ -795,8 +794,7 @@
if (pos != null) {
// Move in front of any windows attached to this
// one.
- WindowToken atoken =
- mTokenMap.get(((WindowState)pos).mClient.asBinder());
+ WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
if (atoken != null) {
final int NC = atoken.windows.size();
if (NC > 0) {
@@ -811,7 +809,7 @@
// Just search for the start of this layer.
final int myLayer = win.mBaseLayer;
for (i=0; i<N; i++) {
- WindowState w = (WindowState)localmWindows.get(i);
+ WindowState w = localmWindows.get(i);
if (w.mBaseLayer > myLayer) {
break;
}
@@ -828,7 +826,7 @@
// Figure out where window should go, based on layer.
final int myLayer = win.mBaseLayer;
for (i=N-1; i>=0; i--) {
- if (((WindowState)localmWindows.get(i)).mBaseLayer <= myLayer) {
+ if (localmWindows.get(i).mBaseLayer <= myLayer) {
i++;
break;
}
@@ -911,13 +909,13 @@
}
int findDesiredInputMethodWindowIndexLocked(boolean willMove) {
- final ArrayList localmWindows = mWindows;
+ final ArrayList<WindowState> localmWindows = mWindows;
final int N = localmWindows.size();
WindowState w = null;
int i = N;
while (i > 0) {
i--;
- w = (WindowState)localmWindows.get(i);
+ w = localmWindows.get(i);
//Slog.i(TAG, "Checking window @" + i + " " + w + " fl=0x"
// + Integer.toHexString(w.mAttrs.flags));
@@ -932,7 +930,7 @@
if (!willMove
&& w.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
&& i > 0) {
- WindowState wb = (WindowState)localmWindows.get(i-1);
+ WindowState wb = localmWindows.get(i-1);
if (wb.mAppToken == w.mAppToken && canBeImeTarget(wb)) {
i--;
w = wb;
@@ -962,7 +960,7 @@
int pos = 0;
pos = localmWindows.indexOf(curTarget);
while (pos >= 0) {
- WindowState win = (WindowState)localmWindows.get(pos);
+ WindowState win = localmWindows.get(pos);
if (win.mAppToken != token) {
break;
}
@@ -1067,7 +1065,7 @@
int wi = imw.mChildWindows.size();
while (wi > 0) {
wi--;
- WindowState cw = (WindowState)imw.mChildWindows.get(wi);
+ WindowState cw = imw.mChildWindows.get(wi);
cw.mAnimLayer = cw.mLayer + adj;
if (DEBUG_LAYERS) Slog.v(TAG, "IM win " + cw
+ " anim layer: " + cw.mAnimLayer);
@@ -1093,7 +1091,7 @@
int NC = win.mChildWindows.size();
while (NC > 0) {
NC--;
- WindowState cw = (WindowState)win.mChildWindows.get(NC);
+ WindowState cw = win.mChildWindows.get(NC);
int cpos = mWindows.indexOf(cw);
if (cpos >= 0) {
if (cpos < interestingPos) interestingPos--;
@@ -1145,7 +1143,7 @@
if (pos >= 0) {
final AppWindowToken targetAppToken = mInputMethodTarget.mAppToken;
if (pos < mWindows.size()) {
- WindowState wp = (WindowState)mWindows.get(pos);
+ WindowState wp = mWindows.get(pos);
if (wp == mInputMethodWindow) {
pos++;
}
@@ -1189,14 +1187,14 @@
// located here, and contiguous.
final int N = mWindows.size();
WindowState firstImWin = imPos < N
- ? (WindowState)mWindows.get(imPos) : null;
+ ? mWindows.get(imPos) : null;
// Figure out the actual input method window that should be
// at the bottom of their stack.
WindowState baseImWin = imWin != null
? imWin : mInputMethodDialogs.get(0);
if (baseImWin.mChildWindows.size() > 0) {
- WindowState cw = (WindowState)baseImWin.mChildWindows.get(0);
+ WindowState cw = baseImWin.mChildWindows.get(0);
if (cw.mSubLayer < 0) baseImWin = cw;
}
@@ -1205,7 +1203,7 @@
// First find the top IM window.
int pos = imPos+1;
while (pos < N) {
- if (!((WindowState)mWindows.get(pos)).mIsImWindow) {
+ if (!(mWindows.get(pos)).mIsImWindow) {
break;
}
pos++;
@@ -1213,7 +1211,7 @@
pos++;
// Now there should be no more input method windows above.
while (pos < N) {
- if (((WindowState)mWindows.get(pos)).mIsImWindow) {
+ if ((mWindows.get(pos)).mIsImWindow) {
break;
}
pos++;
@@ -1301,7 +1299,7 @@
// First find top-most window that has asked to be on top of the
// wallpaper; all wallpapers go behind it.
- final ArrayList localmWindows = mWindows;
+ final ArrayList<WindowState> localmWindows = mWindows;
int N = localmWindows.size();
WindowState w = null;
WindowState foundW = null;
@@ -1311,7 +1309,7 @@
int i = N;
while (i > 0) {
i--;
- w = (WindowState)localmWindows.get(i);
+ w = localmWindows.get(i);
if ((w.mAttrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER)) {
if (topCurW == null) {
topCurW = w;
@@ -1482,7 +1480,7 @@
// AND any starting window associated with it, AND below the
// maximum layer the policy allows for wallpapers.
while (foundI > 0) {
- WindowState wb = (WindowState)localmWindows.get(foundI-1);
+ WindowState wb = localmWindows.get(foundI-1);
if (wb.mBaseLayer < maxLayer &&
wb.mAttachedWindow != foundW &&
(wb.mAttrs.type != TYPE_APPLICATION_STARTING ||
@@ -1506,7 +1504,7 @@
} else {
// Okay i is the position immediately above the wallpaper. Look at
// what is below it for later.
- foundW = foundI > 0 ? (WindowState)localmWindows.get(foundI-1) : null;
+ foundW = foundI > 0 ? localmWindows.get(foundI-1) : null;
}
if (visible) {
@@ -1565,7 +1563,7 @@
if (wallpaper == foundW) {
foundI--;
foundW = foundI > 0
- ? (WindowState)localmWindows.get(foundI-1) : null;
+ ? localmWindows.get(foundI-1) : null;
continue;
}
@@ -2402,6 +2400,8 @@
outSurface.release();
}
} catch (Exception e) {
+ mInputMonitor.updateInputWindowsLw();
+
Slog.w(TAG, "Exception thrown when creating surface for client "
+ client + " (" + win.mAttrs.getTitle() + ")",
e);
@@ -2448,7 +2448,6 @@
applyAnimationLocked(win, transit, false)) {
focusMayChange = true;
win.mExiting = true;
- mInputMonitor.windowIsBecomingInvisibleLw(win);
} else if (win.isAnimating()) {
// Currently in a hide animation... turn this into
// an exit.
@@ -2543,6 +2542,8 @@
TAG, "Relayout of " + win + ": focusMayChange=" + focusMayChange);
inTouchMode = mInTouchMode;
+
+ mInputMonitor.updateInputWindowsLw();
}
if (configChanged) {
@@ -2998,7 +2999,7 @@
public int getOrientationFromWindowsLocked() {
int pos = mWindows.size() - 1;
while (pos >= 0) {
- WindowState wtoken = (WindowState) mWindows.get(pos);
+ WindowState wtoken = mWindows.get(pos);
pos--;
if (wtoken.mAppToken != null) {
// We hit an application window. so the orientation will be determined by the
@@ -3552,7 +3553,6 @@
applyAnimationLocked(win,
WindowManagerPolicy.TRANSIT_EXIT, false);
}
- mInputMonitor.windowIsBecomingInvisibleLw(win);
changed = true;
}
}
@@ -3580,6 +3580,8 @@
if (performLayout) {
updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES);
performLayoutAndPlaceSurfacesLocked();
+ } else {
+ mInputMonitor.updateInputWindowsLw();
}
}
}
@@ -3867,7 +3869,7 @@
int j = win.mChildWindows.size();
while (j > 0) {
j--;
- WindowState cwin = (WindowState)win.mChildWindows.get(j);
+ WindowState cwin = win.mChildWindows.get(j);
if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG,
"Tmp removing child window " + cwin);
mWindows.remove(cwin);
@@ -3895,7 +3897,7 @@
int i = NW;
while (i > 0) {
i--;
- WindowState win = (WindowState)mWindows.get(i);
+ WindowState win = mWindows.get(i);
if (win.getAppToken() != null) {
return i+1;
}
@@ -3921,7 +3923,7 @@
int j = win.mChildWindows.size();
while (j > 0) {
j--;
- WindowState cwin = (WindowState)win.mChildWindows.get(j);
+ WindowState cwin = win.mChildWindows.get(j);
if (cwin.mSubLayer >= 0) {
for (int pos=NW-1; pos>=0; pos--) {
if (mWindows.get(pos) == cwin) {
@@ -3949,7 +3951,7 @@
final int NCW = win.mChildWindows.size();
boolean added = false;
for (int j=0; j<NCW; j++) {
- WindowState cwin = (WindowState)win.mChildWindows.get(j);
+ WindowState cwin = win.mChildWindows.get(j);
if (!added && cwin.mSubLayer >= 0) {
if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Re-adding child window at "
+ index + ": " + cwin);
@@ -4233,7 +4235,7 @@
public void closeSystemDialogs(String reason) {
synchronized(mWindowMap) {
for (int i=mWindows.size()-1; i>=0; i--) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.mSurface != null) {
try {
w.mClient.closeSystemDialogs(reason);
@@ -4417,7 +4419,7 @@
// have been drawn.
final int N = mWindows.size();
for (int i=0; i<N; i++) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.isVisibleLw() && !w.mObscured && !w.isDrawnLw()) {
return;
}
@@ -4529,7 +4531,7 @@
Surface.setOrientation(0, rotation, animFlags);
}
for (int i=mWindows.size()-1; i>=0; i--) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.mSurface != null) {
w.mOrientationChanging = true;
}
@@ -4685,11 +4687,10 @@
boolean result = true;
- Object[] windows;
+ WindowState[] windows;
synchronized (mWindowMap) {
- windows = new Object[mWindows.size()];
//noinspection unchecked
- windows = mWindows.toArray(windows);
+ windows = mWindows.toArray(new WindowState[mWindows.size()]);
}
BufferedWriter out = null;
@@ -4701,7 +4702,7 @@
final int count = windows.length;
for (int i = 0; i < count; i++) {
- final WindowState w = (WindowState) windows[i];
+ final WindowState w = windows[i];
out.write(Integer.toHexString(System.identityHashCode(w)));
out.write(' ');
out.append(w.mAttrs.getTitle());
@@ -4854,11 +4855,11 @@
}
synchronized (mWindowMap) {
- final ArrayList windows = mWindows;
+ final ArrayList<WindowState> windows = mWindows;
final int count = windows.size();
for (int i = 0; i < count; i++) {
- WindowState w = (WindowState) windows.get(i);
+ WindowState w = windows.get(i);
if (System.identityHashCode(w) == hashCode) {
return w;
}
@@ -5092,7 +5093,7 @@
private WindowState getWindowStateForInputChannelLocked(InputChannel inputChannel) {
int windowCount = mWindows.size();
for (int i = 0; i < windowCount; i++) {
- WindowState windowState = (WindowState) mWindows.get(i);
+ WindowState windowState = mWindows.get(i);
if (windowState.mInputChannel == inputChannel) {
return windowState;
}
@@ -5108,10 +5109,10 @@
// As an optimization, we could try to prune the list of windows but this turns
// out to be difficult because only the native code knows for sure which window
// currently has touch focus.
- final ArrayList windows = mWindows;
+ final ArrayList<WindowState> windows = mWindows;
final int N = windows.size();
for (int i = N - 1; i >= 0; i--) {
- final WindowState child = (WindowState) windows.get(i);
+ final WindowState child = windows.get(i);
if (child.mInputChannel == null || child.mRemoved) {
// Skip this window because it cannot possibly receive input.
continue;
@@ -5256,17 +5257,6 @@
}
}
- public void windowIsBecomingInvisibleLw(WindowState window) {
- // The window is becoming invisible. Preempt input dispatch in progress
- // so that the next window below can receive focus.
- if (window == mInputFocus) {
- mInputFocus = null;
- preemptInputDispatchLw();
- }
-
- updateInputWindowsLw();
- }
-
/* Tells the dispatcher to stop waiting for its current synchronous event targets.
* Essentially, just makes those dispatches asynchronous so a new dispatch cycle
* can begin.
@@ -5777,7 +5767,7 @@
final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams();
final DeathRecipient mDeathRecipient;
final WindowState mAttachedWindow;
- final ArrayList mChildWindows = new ArrayList();
+ final ArrayList<WindowState> mChildWindows = new ArrayList<WindowState>();
final int mBaseLayer;
final int mSubLayer;
final boolean mLayoutAttached;
@@ -6333,10 +6323,8 @@
int i = mChildWindows.size();
while (i > 0) {
i--;
- WindowState c = (WindowState)mChildWindows.get(i);
+ WindowState c = mChildWindows.get(i);
c.mAttachedHidden = true;
-
- mInputMonitor.windowIsBecomingInvisibleLw(c);
}
if (mReportDestroySurface) {
@@ -6446,7 +6434,7 @@
int i = mChildWindows.size();
while (i > 0) {
i--;
- WindowState c = (WindowState)mChildWindows.get(i);
+ WindowState c = mChildWindows.get(i);
if (c.mAttachedHidden) {
c.mAttachedHidden = false;
if (c.mSurface != null) {
@@ -6619,7 +6607,7 @@
final int N = mChildWindows.size();
for (int i=0; i<N; i++) {
- ((WindowState)mChildWindows.get(i)).finishExit();
+ mChildWindows.get(i).finishExit();
}
if (!mExiting) {
@@ -6644,10 +6632,6 @@
Slog.w(TAG, "Error hiding surface in " + this, e);
}
mLastHidden = true;
-
- for (int i=0; i<N; i++) {
- mInputMonitor.windowIsBecomingInvisibleLw((WindowState)mChildWindows.get(i));
- }
}
mExiting = false;
if (mRemoveOnExit) {
@@ -7550,7 +7534,7 @@
final int N = windows.size();
for (int i=0; i<N; i++) {
- ((WindowState)windows.get(i)).finishExit();
+ windows.get(i).finishExit();
}
updateReportedVisibilityLocked();
@@ -7976,7 +7960,7 @@
int i = mWindows.size();
while (i > 0) {
i--;
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.mOrientationChanging) {
w.mOrientationChanging = false;
Slog.w(TAG, "Force clearing orientation change: " + w);
@@ -8115,7 +8099,7 @@
int idx = findDesiredInputMethodWindowIndexLocked(false);
WindowState imFocus;
if (idx > 0) {
- imFocus = (WindowState)mWindows.get(idx-1);
+ imFocus = mWindows.get(idx-1);
if (imFocus != null) {
if (imFocus.mSession.mClient != null &&
imFocus.mSession.mClient.asBinder() == client.asBinder()) {
@@ -8173,9 +8157,9 @@
// First remove all existing app windows.
i=0;
while (i < NW) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.mAppToken != null) {
- WindowState win = (WindowState)mWindows.remove(i);
+ WindowState win = mWindows.remove(i);
mWindowsChanged = true;
if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG,
"Rebuild removing window: " + win);
@@ -8223,7 +8207,7 @@
int i;
for (i=0; i<N; i++) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.mBaseLayer == curBaseLayer || w.mIsImWindow
|| (i > 0 && w.mIsWallpaper)) {
curLayer += WINDOW_LAYER_MULTIPLIER;
@@ -8348,7 +8332,7 @@
// to another window).
int topAttached = -1;
for (i = N-1; i >= 0; i--) {
- WindowState win = (WindowState) mWindows.get(i);
+ WindowState win = mWindows.get(i);
// Don't do layout of a window if it is not visible, or
// soon won't be visible, to avoid wasting time and funky
@@ -8397,7 +8381,7 @@
// XXX does not deal with windows that are attached to windows
// that are themselves attached.
for (i = topAttached; i >= 0; i--) {
- WindowState win = (WindowState) mWindows.get(i);
+ WindowState win = mWindows.get(i);
// If this view is GONE, then skip it -- keep the current
// frame, and let the caller know so they can ignore it
@@ -8549,7 +8533,7 @@
final int N = mWindows.size();
for (i=N-1; i>=0; i--) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
final WindowManager.LayoutParams attrs = w.mAttrs;
@@ -8982,7 +8966,7 @@
// Clear them out.
forceHiding = false;
for (i=N-1; i>=0; i--) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
if (w.mSurface != null) {
final WindowManager.LayoutParams attrs = w.mAttrs;
if (mPolicy.doesForceHide(w, attrs) && w.isVisibleLw()) {
@@ -9032,6 +9016,7 @@
if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "*** ANIM STEP: changes=0x"
+ Integer.toHexString(changes));
+ mInputMonitor.updateInputWindowsLw();
} while (changes != 0);
// THIRD LOOP: Update the surfaces of all windows.
@@ -9048,7 +9033,7 @@
final int N = mWindows.size();
for (i=N-1; i>=0; i--) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
boolean displayed = false;
final WindowManager.LayoutParams attrs = w.mAttrs;
@@ -9222,7 +9207,6 @@
Slog.w(TAG, "Exception hiding surface in " + w);
}
}
- mInputMonitor.windowIsBecomingInvisibleLw(w);
}
// If we are waiting for this window to handle an
// orientation change, well, it is hidden, so
@@ -9482,6 +9466,8 @@
Slog.e(TAG, "Unhandled exception in Window Manager", e);
}
+ mInputMonitor.updateInputWindowsLw();
+
Surface.closeTransaction();
if (DEBUG_ORIENTATION && mDisplayFrozen) Slog.v(TAG,
@@ -9606,6 +9592,9 @@
} else if (animating) {
requestAnimationLocked(currentTime+(1000/60)-SystemClock.uptimeMillis());
}
+
+ mInputMonitor.updateInputWindowsLw();
+
setHoldScreenLocked(holdScreen != null);
if (screenBrightness < 0 || screenBrightness > 1.0f) {
mPowerManager.setScreenBrightnessOverride(-1);
@@ -9708,7 +9697,7 @@
boolean leakedSurface = false;
Slog.i(TAG, "Out of memory for surface! Looking for leaks...");
for (int i=0; i<N; i++) {
- WindowState ws = (WindowState)mWindows.get(i);
+ WindowState ws = mWindows.get(i);
if (ws.mSurface != null) {
if (!mSessions.contains(ws.mSession)) {
Slog.w(TAG, "LEAKED SURFACE (session doesn't exist): "
@@ -9740,7 +9729,7 @@
Slog.w(TAG, "No leaked surfaces; killing applicatons!");
SparseIntArray pidCandidates = new SparseIntArray();
for (int i=0; i<N; i++) {
- WindowState ws = (WindowState)mWindows.get(i);
+ WindowState ws = mWindows.get(i);
if (ws.mSurface != null) {
pidCandidates.append(ws.mSession.mPid, ws.mSession.mPid);
}
@@ -9832,7 +9821,7 @@
? mAppTokens.get(nextAppIndex) : null;
while (i >= 0) {
- win = (WindowState)mWindows.get(i);
+ win = mWindows.get(i);
if (localLOGV || DEBUG_FOCUS) Slog.v(
TAG, "Looking for focus: " + i
@@ -9976,14 +9965,13 @@
return;
}
- pw.println("Input Dispatcher State:");
mInputManager.dump(pw);
pw.println(" ");
synchronized(mWindowMap) {
pw.println("Current Window Manager state:");
for (int i=mWindows.size()-1; i>=0; i--) {
- WindowState w = (WindowState)mWindows.get(i);
+ WindowState w = mWindows.get(i);
pw.print(" Window #"); pw.print(i); pw.print(' ');
pw.print(w); pw.println(":");
w.dump(pw, " ");