Remove iterators (DO NOT MERGE)
Remove DisplayContentsIterator and AllWindowsIterator. These were cute but they take up valuable resources. Iterate over ArrayList members in their place. Change-Id: Ie0c537608532cfb36f34d976cc6eacd21bad98cd
This commit is contained in:
@ -19,7 +19,6 @@ package com.android.server.wm;
|
|||||||
import com.android.server.input.InputManagerService;
|
import com.android.server.input.InputManagerService;
|
||||||
import com.android.server.input.InputApplicationHandle;
|
import com.android.server.input.InputApplicationHandle;
|
||||||
import com.android.server.input.InputWindowHandle;
|
import com.android.server.input.InputWindowHandle;
|
||||||
import com.android.server.wm.WindowManagerService.AllWindowsIterator;
|
|
||||||
|
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManagerNative;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
@ -31,7 +30,6 @@ import android.view.InputChannel;
|
|||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
|
final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
|
||||||
@ -249,45 +247,48 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add all windows on the default display.
|
// Add all windows on the default display.
|
||||||
final AllWindowsIterator iterator = mService.new AllWindowsIterator(
|
final int numDisplays = mService.mDisplayContents.size();
|
||||||
WindowManagerService.REVERSE_ITERATOR);
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
while (iterator.hasNext()) {
|
final WindowList windows =
|
||||||
final WindowState child = iterator.next();
|
mService.mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||||
final InputChannel inputChannel = child.mInputChannel;
|
for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
|
||||||
final InputWindowHandle inputWindowHandle = child.mInputWindowHandle;
|
final WindowState child = windows.get(winNdx);
|
||||||
if (inputChannel == null || inputWindowHandle == null || child.mRemoved) {
|
final InputChannel inputChannel = child.mInputChannel;
|
||||||
// Skip this window because it cannot possibly receive input.
|
final InputWindowHandle inputWindowHandle = child.mInputWindowHandle;
|
||||||
continue;
|
if (inputChannel == null || inputWindowHandle == null || child.mRemoved) {
|
||||||
}
|
// Skip this window because it cannot possibly receive input.
|
||||||
|
continue;
|
||||||
final int flags = child.mAttrs.flags;
|
|
||||||
final int type = child.mAttrs.type;
|
|
||||||
|
|
||||||
final boolean hasFocus = (child == mInputFocus);
|
|
||||||
final boolean isVisible = child.isVisibleLw();
|
|
||||||
final boolean hasWallpaper = (child == mService.mWallpaperTarget)
|
|
||||||
&& (type != WindowManager.LayoutParams.TYPE_KEYGUARD);
|
|
||||||
final boolean onDefaultDisplay = (child.getDisplayId() == Display.DEFAULT_DISPLAY);
|
|
||||||
|
|
||||||
// If there's a drag in progress and 'child' is a potential drop target,
|
|
||||||
// make sure it's been told about the drag
|
|
||||||
if (inDrag && isVisible && onDefaultDisplay) {
|
|
||||||
mService.mDragState.sendDragStartedIfNeededLw(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (universeBackground != null && !addedUniverse
|
|
||||||
&& child.mBaseLayer < aboveUniverseLayer && onDefaultDisplay) {
|
|
||||||
final WindowState u = universeBackground.mWin;
|
|
||||||
if (u.mInputChannel != null && u.mInputWindowHandle != null) {
|
|
||||||
addInputWindowHandleLw(u.mInputWindowHandle, u, u.mAttrs.flags,
|
|
||||||
u.mAttrs.type, true, u == mInputFocus, false);
|
|
||||||
}
|
}
|
||||||
addedUniverse = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (child.mWinAnimator != universeBackground) {
|
final int flags = child.mAttrs.flags;
|
||||||
addInputWindowHandleLw(inputWindowHandle, child, flags, type,
|
final int type = child.mAttrs.type;
|
||||||
isVisible, hasFocus, hasWallpaper);
|
|
||||||
|
final boolean hasFocus = (child == mInputFocus);
|
||||||
|
final boolean isVisible = child.isVisibleLw();
|
||||||
|
final boolean hasWallpaper = (child == mService.mWallpaperTarget)
|
||||||
|
&& (type != WindowManager.LayoutParams.TYPE_KEYGUARD);
|
||||||
|
final boolean onDefaultDisplay = (child.getDisplayId() == Display.DEFAULT_DISPLAY);
|
||||||
|
|
||||||
|
// If there's a drag in progress and 'child' is a potential drop target,
|
||||||
|
// make sure it's been told about the drag
|
||||||
|
if (inDrag && isVisible && onDefaultDisplay) {
|
||||||
|
mService.mDragState.sendDragStartedIfNeededLw(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (universeBackground != null && !addedUniverse
|
||||||
|
&& child.mBaseLayer < aboveUniverseLayer && onDefaultDisplay) {
|
||||||
|
final WindowState u = universeBackground.mWin;
|
||||||
|
if (u.mInputChannel != null && u.mInputWindowHandle != null) {
|
||||||
|
addInputWindowHandleLw(u.mInputWindowHandle, u, u.mAttrs.flags,
|
||||||
|
u.mAttrs.type, true, u == mInputFocus, false);
|
||||||
|
}
|
||||||
|
addedUniverse = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (child.mWinAnimator != universeBackground) {
|
||||||
|
addInputWindowHandleLw(inputWindowHandle, child, flags, type,
|
||||||
|
isVisible, hasFocus, hasWallpaper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import android.view.SurfaceControl;
|
|||||||
import android.view.WindowManagerPolicy;
|
import android.view.WindowManagerPolicy;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
|
|
||||||
import com.android.server.wm.WindowManagerService.DisplayContentsIterator;
|
|
||||||
import com.android.server.wm.WindowManagerService.LayoutFields;
|
import com.android.server.wm.WindowManagerService.LayoutFields;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@ -627,9 +626,9 @@ public class WindowAnimator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean hasPendingLayoutChanges = false;
|
boolean hasPendingLayoutChanges = false;
|
||||||
DisplayContentsIterator iterator = mService.new DisplayContentsIterator();
|
final int numDisplays = mService.mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
final DisplayContent displayContent = iterator.next();
|
final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx);
|
||||||
final int pendingChanges = getPendingLayoutChanges(displayContent.getDisplayId());
|
final int pendingChanges = getPendingLayoutChanges(displayContent.getDisplayId());
|
||||||
if ((pendingChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
|
if ((pendingChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
|
||||||
mBulkUpdateParams |= SET_WALLPAPER_ACTION_PENDING;
|
mBulkUpdateParams |= SET_WALLPAPER_ACTION_PENDING;
|
||||||
|
@ -450,7 +450,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
String mLastANRState;
|
String mLastANRState;
|
||||||
|
|
||||||
/** All DisplayDontents in the world, kept here */
|
/** All DisplayDontents in the world, kept here */
|
||||||
private SparseArray<DisplayContent> mDisplayContents = new SparseArray<DisplayContent>();
|
SparseArray<DisplayContent> mDisplayContents = new SparseArray<DisplayContent>();
|
||||||
|
|
||||||
int mRotation = 0;
|
int mRotation = 0;
|
||||||
int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||||
@ -4426,10 +4426,13 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
void dumpWindowsLocked() {
|
void dumpWindowsLocked() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
final AllWindowsIterator iterator = new AllWindowsIterator(REVERSE_ITERATOR);
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
final WindowState w = iterator.next();
|
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||||
Slog.v(TAG, " #" + i++ + ": " + w);
|
for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
|
||||||
|
final WindowState w = windows.get(winNdx);
|
||||||
|
Slog.v(TAG, " #" + i++ + ": " + w);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4574,9 +4577,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
if (tmpRemoveAppWindowsLocked(wtoken)) {
|
if (tmpRemoveAppWindowsLocked(wtoken)) {
|
||||||
if (DEBUG_REORDER) Slog.v(TAG, "Adding windows back in:");
|
if (DEBUG_REORDER) Slog.v(TAG, "Adding windows back in:");
|
||||||
if (DEBUG_REORDER) dumpWindowsLocked();
|
if (DEBUG_REORDER) dumpWindowsLocked();
|
||||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while(iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
final DisplayContent displayContent = iterator.next();
|
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||||
final WindowList windows = displayContent.getWindowList();
|
final WindowList windows = displayContent.getWindowList();
|
||||||
final int pos = findWindowOffsetLocked(windows, index);
|
final int pos = findWindowOffsetLocked(windows, index);
|
||||||
final int newPos = reAddAppWindowsLocked(displayContent, pos, wtoken);
|
final int newPos = reAddAppWindowsLocked(displayContent, pos, wtoken);
|
||||||
@ -4628,9 +4631,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
// And now add them back at the correct place.
|
// And now add them back at the correct place.
|
||||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
final DisplayContent displayContent = iterator.next();
|
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||||
final WindowList windows = displayContent.getWindowList();
|
final WindowList windows = displayContent.getWindowList();
|
||||||
// Where to start adding?
|
// Where to start adding?
|
||||||
int pos = findWindowOffsetLocked(windows, tokenPos);
|
int pos = findWindowOffsetLocked(windows, tokenPos);
|
||||||
@ -4846,13 +4849,17 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
@Override
|
@Override
|
||||||
public void closeSystemDialogs(String reason) {
|
public void closeSystemDialogs(String reason) {
|
||||||
synchronized(mWindowMap) {
|
synchronized(mWindowMap) {
|
||||||
final AllWindowsIterator iterator = new AllWindowsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
final WindowState w = iterator.next();
|
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||||
if (w.mHasSurface) {
|
final int numWindows = windows.size();
|
||||||
try {
|
for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
|
||||||
w.mClient.closeSystemDialogs(reason);
|
final WindowState w = windows.get(winNdx);
|
||||||
} catch (RemoteException e) {
|
if (w.mHasSurface) {
|
||||||
|
try {
|
||||||
|
w.mClient.closeSystemDialogs(reason);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4985,9 +4992,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
mPolicy.setCurrentUserLw(newUserId);
|
mPolicy.setCurrentUserLw(newUserId);
|
||||||
|
|
||||||
// Hide windows that should not be seen by the new user.
|
// Hide windows that should not be seen by the new user.
|
||||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
final WindowList windows = iterator.next().getWindowList();
|
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||||
|
final WindowList windows = displayContent.getWindowList();
|
||||||
for (int i = 0; i < windows.size(); i++) {
|
for (int i = 0; i < windows.size(); i++) {
|
||||||
final WindowState win = windows.get(i);
|
final WindowState win = windows.get(i);
|
||||||
if (win.isHiddenFromUserLocked()) {
|
if (win.isHiddenFromUserLocked()) {
|
||||||
@ -5243,12 +5251,16 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
// the background..)
|
// the background..)
|
||||||
if (on) {
|
if (on) {
|
||||||
boolean isVisible = false;
|
boolean isVisible = false;
|
||||||
final AllWindowsIterator iterator = new AllWindowsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
final WindowState ws = iterator.next();
|
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||||
if (ws.mSession.mPid == pid && ws.isVisibleLw()) {
|
final int numWindows = windows.size();
|
||||||
isVisible = true;
|
for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
|
||||||
break;
|
final WindowState ws = windows.get(winNdx);
|
||||||
|
if (ws.mSession.mPid == pid && ws.isVisibleLw()) {
|
||||||
|
isVisible = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isVisible) {
|
if (!isVisible) {
|
||||||
@ -5998,9 +6010,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
WindowList windows = new WindowList();
|
WindowList windows = new WindowList();
|
||||||
synchronized (mWindowMap) {
|
synchronized (mWindowMap) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while(iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
windows.addAll(iterator.next().getWindowList());
|
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||||
|
windows.addAll(displayContent.getWindowList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6228,11 +6241,15 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mWindowMap) {
|
synchronized (mWindowMap) {
|
||||||
final AllWindowsIterator iterator = new AllWindowsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
final WindowState w = iterator.next();
|
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||||
if (System.identityHashCode(w) == hashCode) {
|
final int numWindows = windows.size();
|
||||||
return w;
|
for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
|
||||||
|
final WindowState w = windows.get(winNdx);
|
||||||
|
if (System.identityHashCode(w) == hashCode) {
|
||||||
|
return w;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6780,12 +6797,16 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
// TODO(multidisplay): Call isScreenOn for each display.
|
// TODO(multidisplay): Call isScreenOn for each display.
|
||||||
private void sendScreenStatusToClientsLocked() {
|
private void sendScreenStatusToClientsLocked() {
|
||||||
final boolean on = mPowerManager.isScreenOn();
|
final boolean on = mPowerManager.isScreenOn();
|
||||||
final AllWindowsIterator iterator = new AllWindowsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
try {
|
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||||
iterator.next().mClient.dispatchScreenState(on);
|
final int numWindows = windows.size();
|
||||||
} catch (RemoteException e) {
|
for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
|
||||||
// Ignored
|
try {
|
||||||
|
windows.get(winNdx).mClient.dispatchScreenState(on);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7629,9 +7650,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
final void rebuildAppWindowListLocked() {
|
final void rebuildAppWindowListLocked() {
|
||||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
rebuildAppWindowListLocked(iterator.next());
|
rebuildAppWindowListLocked(mDisplayContents.valueAt(displayNdx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8594,9 +8615,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
boolean focusDisplayed = false;
|
boolean focusDisplayed = false;
|
||||||
boolean updateAllDrawn = false;
|
boolean updateAllDrawn = false;
|
||||||
|
|
||||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
final DisplayContent displayContent = iterator.next();
|
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||||
WindowList windows = displayContent.getWindowList();
|
WindowList windows = displayContent.getWindowList();
|
||||||
DisplayInfo displayInfo = displayContent.getDisplayInfo();
|
DisplayInfo displayInfo = displayContent.getDisplayInfo();
|
||||||
final int displayId = displayContent.getDisplayId();
|
final int displayId = displayContent.getDisplayId();
|
||||||
@ -9035,9 +9056,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
defaultDisplay.layoutNeeded = true;
|
defaultDisplay.layoutNeeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
DisplayContent displayContent = iterator.next();
|
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||||
if (displayContent.pendingLayoutChanges != 0) {
|
if (displayContent.pendingLayoutChanges != 0) {
|
||||||
displayContent.layoutNeeded = true;
|
displayContent.layoutNeeded = true;
|
||||||
}
|
}
|
||||||
@ -9224,9 +9245,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean needsLayout() {
|
private boolean needsLayout() {
|
||||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
if (iterator.next().layoutNeeded) {
|
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||||
|
if (displayContent.layoutNeeded) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9287,35 +9309,38 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
// window list to make sure we haven't left any dangling surfaces
|
// window list to make sure we haven't left any dangling surfaces
|
||||||
// around.
|
// around.
|
||||||
|
|
||||||
AllWindowsIterator iterator = new AllWindowsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
Slog.i(TAG, "Out of memory for surface! Looking for leaks...");
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
while (iterator.hasNext()) {
|
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||||
WindowState ws = iterator.next();
|
final int numWindows = windows.size();
|
||||||
WindowStateAnimator wsa = ws.mWinAnimator;
|
for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
|
||||||
if (wsa.mSurfaceControl != null) {
|
final WindowState ws = windows.get(winNdx);
|
||||||
if (!mSessions.contains(wsa.mSession)) {
|
WindowStateAnimator wsa = ws.mWinAnimator;
|
||||||
Slog.w(TAG, "LEAKED SURFACE (session doesn't exist): "
|
if (wsa.mSurfaceControl != null) {
|
||||||
+ ws + " surface=" + wsa.mSurfaceControl
|
if (!mSessions.contains(wsa.mSession)) {
|
||||||
+ " token=" + ws.mToken
|
Slog.w(TAG, "LEAKED SURFACE (session doesn't exist): "
|
||||||
+ " pid=" + ws.mSession.mPid
|
+ ws + " surface=" + wsa.mSurfaceControl
|
||||||
+ " uid=" + ws.mSession.mUid);
|
+ " token=" + ws.mToken
|
||||||
if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null);
|
+ " pid=" + ws.mSession.mPid
|
||||||
wsa.mSurfaceControl.destroy();
|
+ " uid=" + ws.mSession.mUid);
|
||||||
wsa.mSurfaceShown = false;
|
if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null);
|
||||||
wsa.mSurfaceControl = null;
|
wsa.mSurfaceControl.destroy();
|
||||||
ws.mHasSurface = false;
|
wsa.mSurfaceShown = false;
|
||||||
mForceRemoves.add(ws);
|
wsa.mSurfaceControl = null;
|
||||||
leakedSurface = true;
|
ws.mHasSurface = false;
|
||||||
} else if (ws.mAppToken != null && ws.mAppToken.clientHidden) {
|
mForceRemoves.add(ws);
|
||||||
Slog.w(TAG, "LEAKED SURFACE (app token hidden): "
|
leakedSurface = true;
|
||||||
+ ws + " surface=" + wsa.mSurfaceControl
|
} else if (ws.mAppToken != null && ws.mAppToken.clientHidden) {
|
||||||
+ " token=" + ws.mAppToken);
|
Slog.w(TAG, "LEAKED SURFACE (app token hidden): "
|
||||||
if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null);
|
+ ws + " surface=" + wsa.mSurfaceControl
|
||||||
wsa.mSurfaceControl.destroy();
|
+ " token=" + ws.mAppToken);
|
||||||
wsa.mSurfaceShown = false;
|
if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null);
|
||||||
wsa.mSurfaceControl = null;
|
wsa.mSurfaceControl.destroy();
|
||||||
ws.mHasSurface = false;
|
wsa.mSurfaceShown = false;
|
||||||
leakedSurface = true;
|
wsa.mSurfaceControl = null;
|
||||||
|
ws.mHasSurface = false;
|
||||||
|
leakedSurface = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9323,27 +9348,30 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
if (!leakedSurface) {
|
if (!leakedSurface) {
|
||||||
Slog.w(TAG, "No leaked surfaces; killing applicatons!");
|
Slog.w(TAG, "No leaked surfaces; killing applicatons!");
|
||||||
SparseIntArray pidCandidates = new SparseIntArray();
|
SparseIntArray pidCandidates = new SparseIntArray();
|
||||||
iterator = new AllWindowsIterator();
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
while (iterator.hasNext()) {
|
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||||
WindowState ws = iterator.next();
|
final int numWindows = windows.size();
|
||||||
if (mForceRemoves.contains(ws)) {
|
for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
|
||||||
continue;
|
final WindowState ws = windows.get(winNdx);
|
||||||
}
|
if (mForceRemoves.contains(ws)) {
|
||||||
WindowStateAnimator wsa = ws.mWinAnimator;
|
continue;
|
||||||
if (wsa.mSurfaceControl != null) {
|
}
|
||||||
pidCandidates.append(wsa.mSession.mPid, wsa.mSession.mPid);
|
WindowStateAnimator wsa = ws.mWinAnimator;
|
||||||
}
|
if (wsa.mSurfaceControl != null) {
|
||||||
}
|
pidCandidates.append(wsa.mSession.mPid, wsa.mSession.mPid);
|
||||||
if (pidCandidates.size() > 0) {
|
}
|
||||||
int[] pids = new int[pidCandidates.size()];
|
}
|
||||||
for (int i=0; i<pids.length; i++) {
|
if (pidCandidates.size() > 0) {
|
||||||
pids[i] = pidCandidates.keyAt(i);
|
int[] pids = new int[pidCandidates.size()];
|
||||||
}
|
for (int i=0; i<pids.length; i++) {
|
||||||
try {
|
pids[i] = pidCandidates.keyAt(i);
|
||||||
if (mActivityManager.killPids(pids, "Free memory", secure)) {
|
}
|
||||||
killedApps = true;
|
try {
|
||||||
|
if (mActivityManager.killPids(pids, "Free memory", secure)) {
|
||||||
|
killedApps = true;
|
||||||
|
}
|
||||||
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9974,9 +10002,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
void dumpDisplayContentsLocked(PrintWriter pw, boolean dumpAll) {
|
void dumpDisplayContentsLocked(PrintWriter pw, boolean dumpAll) {
|
||||||
pw.println("WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)");
|
pw.println("WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)");
|
||||||
if (mDisplayReady) {
|
if (mDisplayReady) {
|
||||||
DisplayContentsIterator dCIterator = new DisplayContentsIterator();
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (dCIterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
dCIterator.next().dump(" ", pw);
|
mDisplayContents.valueAt(displayNdx).dump(" ", pw);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pw.println(" NO DISPLAY");
|
pw.println(" NO DISPLAY");
|
||||||
@ -9992,13 +10020,16 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
void dumpWindowsNoHeaderLocked(PrintWriter pw, boolean dumpAll,
|
void dumpWindowsNoHeaderLocked(PrintWriter pw, boolean dumpAll,
|
||||||
ArrayList<WindowState> windows) {
|
ArrayList<WindowState> windows) {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
final AllWindowsIterator iterator = new AllWindowsIterator(REVERSE_ITERATOR);
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
final WindowState w = iterator.next();
|
final WindowList windowList = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||||
if (windows == null || windows.contains(w)) {
|
for (int winNdx = windowList.size() - 1; winNdx >= 0; --winNdx) {
|
||||||
pw.print(" Window #"); pw.print(j++); pw.print(' ');
|
final WindowState w = windowList.get(winNdx);
|
||||||
pw.print(w); pw.println(":");
|
if (windows == null || windows.contains(w)) {
|
||||||
w.dump(pw, " ", dumpAll || windows != null);
|
pw.print(" Window #"); pw.print(j++); pw.print(' ');
|
||||||
|
pw.print(w); pw.println(":");
|
||||||
|
w.dump(pw, " ", dumpAll || windows != null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mInputMethodDialogs.size() > 0) {
|
if (mInputMethodDialogs.size() > 0) {
|
||||||
@ -10151,9 +10182,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
pw.print(" mDisplayEnabled="); pw.println(mDisplayEnabled);
|
pw.print(" mDisplayEnabled="); pw.println(mDisplayEnabled);
|
||||||
if (needsLayout()) {
|
if (needsLayout()) {
|
||||||
pw.print(" layoutNeeded on displays=");
|
pw.print(" layoutNeeded on displays=");
|
||||||
DisplayContentsIterator dcIterator = new DisplayContentsIterator();
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
while (dcIterator.hasNext()) {
|
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||||
final DisplayContent displayContent = dcIterator.next();
|
|
||||||
if (displayContent.layoutNeeded) {
|
if (displayContent.layoutNeeded) {
|
||||||
pw.print(displayContent.getDisplayId());
|
pw.print(displayContent.getDisplayId());
|
||||||
}
|
}
|
||||||
@ -10187,11 +10217,15 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
WindowList windows = new WindowList();
|
WindowList windows = new WindowList();
|
||||||
if ("visible".equals(name)) {
|
if ("visible".equals(name)) {
|
||||||
synchronized(mWindowMap) {
|
synchronized(mWindowMap) {
|
||||||
final AllWindowsIterator iterator = new AllWindowsIterator(REVERSE_ITERATOR);
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
final WindowState w = iterator.next();
|
final WindowList windowList =
|
||||||
if (w.mWinAnimator.mSurfaceShown) {
|
mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||||
windows.add(w);
|
for (int winNdx = windowList.size() - 1; winNdx >= 0; --winNdx) {
|
||||||
|
final WindowState w = windowList.get(winNdx);
|
||||||
|
if (w.mWinAnimator.mSurfaceShown) {
|
||||||
|
windows.add(w);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10204,15 +10238,18 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
}
|
}
|
||||||
synchronized(mWindowMap) {
|
synchronized(mWindowMap) {
|
||||||
final AllWindowsIterator iterator = new AllWindowsIterator(REVERSE_ITERATOR);
|
final int numDisplays = mDisplayContents.size();
|
||||||
while (iterator.hasNext()) {
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
final WindowState w = iterator.next();
|
final WindowList windowList = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||||
if (name != null) {
|
for (int winNdx = windowList.size() - 1; winNdx >= 0; --winNdx) {
|
||||||
if (w.mAttrs.getTitle().toString().contains(name)) {
|
final WindowState w = windowList.get(winNdx);
|
||||||
|
if (name != null) {
|
||||||
|
if (w.mAttrs.getTitle().toString().contains(name)) {
|
||||||
|
windows.add(w);
|
||||||
|
}
|
||||||
|
} else if (System.identityHashCode(w) == objectId) {
|
||||||
windows.add(w);
|
windows.add(w);
|
||||||
}
|
}
|
||||||
} else if (System.identityHashCode(w) == objectId) {
|
|
||||||
windows.add(w);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10456,87 +10493,6 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
return displayContent;
|
return displayContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DisplayContentsIterator implements Iterator<DisplayContent> {
|
|
||||||
private int cur;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
return cur < mDisplayContents.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DisplayContent next() {
|
|
||||||
if (hasNext()) {
|
|
||||||
return mDisplayContents.valueAt(cur++);
|
|
||||||
}
|
|
||||||
throw new NoSuchElementException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove() {
|
|
||||||
throw new IllegalArgumentException("AllDisplayContentIterator.remove not implemented");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final static boolean REVERSE_ITERATOR = true;
|
|
||||||
class AllWindowsIterator implements Iterator<WindowState> {
|
|
||||||
private DisplayContent mDisplayContent;
|
|
||||||
private DisplayContentsIterator mDisplayContentsIterator;
|
|
||||||
private WindowList mWindowList;
|
|
||||||
private int mWindowListIndex;
|
|
||||||
private boolean mReverse;
|
|
||||||
|
|
||||||
AllWindowsIterator() {
|
|
||||||
mDisplayContentsIterator = new DisplayContentsIterator();
|
|
||||||
mDisplayContent = mDisplayContentsIterator.next();
|
|
||||||
mWindowList = mDisplayContent.getWindowList();
|
|
||||||
}
|
|
||||||
|
|
||||||
AllWindowsIterator(boolean reverse) {
|
|
||||||
this();
|
|
||||||
mReverse = reverse;
|
|
||||||
mWindowListIndex = reverse ? mWindowList.size() - 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
if (mReverse) {
|
|
||||||
return mWindowListIndex >= 0;
|
|
||||||
}
|
|
||||||
return mWindowListIndex < mWindowList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WindowState next() {
|
|
||||||
if (hasNext()) {
|
|
||||||
WindowState win = mWindowList.get(mWindowListIndex);
|
|
||||||
if (mReverse) {
|
|
||||||
mWindowListIndex--;
|
|
||||||
if (mWindowListIndex < 0 && mDisplayContentsIterator.hasNext()) {
|
|
||||||
mDisplayContent = mDisplayContentsIterator.next();
|
|
||||||
mWindowList = mDisplayContent.getWindowList();
|
|
||||||
mWindowListIndex = mWindowList.size() - 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mWindowListIndex++;
|
|
||||||
if (mWindowListIndex >= mWindowList.size()
|
|
||||||
&& mDisplayContentsIterator.hasNext()) {
|
|
||||||
mDisplayContent = mDisplayContentsIterator.next();
|
|
||||||
mWindowList = mDisplayContent.getWindowList();
|
|
||||||
mWindowListIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return win;
|
|
||||||
}
|
|
||||||
throw new NoSuchElementException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove() {
|
|
||||||
throw new IllegalArgumentException("AllWindowsIterator.remove not implemented");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// There is an inherent assumption that this will never return null.
|
// There is an inherent assumption that this will never return null.
|
||||||
public DisplayContent getDefaultDisplayContentLocked() {
|
public DisplayContent getDefaultDisplayContentLocked() {
|
||||||
return getDisplayContentLocked(Display.DEFAULT_DISPLAY);
|
return getDisplayContentLocked(Display.DEFAULT_DISPLAY);
|
||||||
|
Reference in New Issue
Block a user