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.InputApplicationHandle;
|
||||
import com.android.server.input.InputWindowHandle;
|
||||
import com.android.server.wm.WindowManagerService.AllWindowsIterator;
|
||||
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.graphics.Rect;
|
||||
@ -31,7 +30,6 @@ import android.view.InputChannel;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
|
||||
@ -249,45 +247,48 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
|
||||
}
|
||||
|
||||
// Add all windows on the default display.
|
||||
final AllWindowsIterator iterator = mService.new AllWindowsIterator(
|
||||
WindowManagerService.REVERSE_ITERATOR);
|
||||
while (iterator.hasNext()) {
|
||||
final WindowState child = iterator.next();
|
||||
final InputChannel inputChannel = child.mInputChannel;
|
||||
final InputWindowHandle inputWindowHandle = child.mInputWindowHandle;
|
||||
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);
|
||||
final int numDisplays = mService.mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final WindowList windows =
|
||||
mService.mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||
for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
|
||||
final WindowState child = windows.get(winNdx);
|
||||
final InputChannel inputChannel = child.mInputChannel;
|
||||
final InputWindowHandle inputWindowHandle = child.mInputWindowHandle;
|
||||
if (inputChannel == null || inputWindowHandle == null || child.mRemoved) {
|
||||
// Skip this window because it cannot possibly receive input.
|
||||
continue;
|
||||
}
|
||||
addedUniverse = true;
|
||||
}
|
||||
|
||||
if (child.mWinAnimator != universeBackground) {
|
||||
addInputWindowHandleLw(inputWindowHandle, child, flags, type,
|
||||
isVisible, hasFocus, hasWallpaper);
|
||||
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) {
|
||||
addInputWindowHandleLw(inputWindowHandle, child, flags, type,
|
||||
isVisible, hasFocus, hasWallpaper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@ import android.view.SurfaceControl;
|
||||
import android.view.WindowManagerPolicy;
|
||||
import android.view.animation.Animation;
|
||||
|
||||
import com.android.server.wm.WindowManagerService.DisplayContentsIterator;
|
||||
import com.android.server.wm.WindowManagerService.LayoutFields;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@ -627,9 +626,9 @@ public class WindowAnimator {
|
||||
}
|
||||
|
||||
boolean hasPendingLayoutChanges = false;
|
||||
DisplayContentsIterator iterator = mService.new DisplayContentsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
final DisplayContent displayContent = iterator.next();
|
||||
final int numDisplays = mService.mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx);
|
||||
final int pendingChanges = getPendingLayoutChanges(displayContent.getDisplayId());
|
||||
if ((pendingChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
|
||||
mBulkUpdateParams |= SET_WALLPAPER_ACTION_PENDING;
|
||||
|
@ -450,7 +450,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
String mLastANRState;
|
||||
|
||||
/** All DisplayDontents in the world, kept here */
|
||||
private SparseArray<DisplayContent> mDisplayContents = new SparseArray<DisplayContent>();
|
||||
SparseArray<DisplayContent> mDisplayContents = new SparseArray<DisplayContent>();
|
||||
|
||||
int mRotation = 0;
|
||||
int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
@ -4426,10 +4426,13 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
|
||||
void dumpWindowsLocked() {
|
||||
int i = 0;
|
||||
final AllWindowsIterator iterator = new AllWindowsIterator(REVERSE_ITERATOR);
|
||||
while (iterator.hasNext()) {
|
||||
final WindowState w = iterator.next();
|
||||
Slog.v(TAG, " #" + i++ + ": " + w);
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||
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 (DEBUG_REORDER) Slog.v(TAG, "Adding windows back in:");
|
||||
if (DEBUG_REORDER) dumpWindowsLocked();
|
||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
||||
while(iterator.hasNext()) {
|
||||
final DisplayContent displayContent = iterator.next();
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||
final WindowList windows = displayContent.getWindowList();
|
||||
final int pos = findWindowOffsetLocked(windows, index);
|
||||
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.
|
||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
final DisplayContent displayContent = iterator.next();
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||
final WindowList windows = displayContent.getWindowList();
|
||||
// Where to start adding?
|
||||
int pos = findWindowOffsetLocked(windows, tokenPos);
|
||||
@ -4846,13 +4849,17 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
@Override
|
||||
public void closeSystemDialogs(String reason) {
|
||||
synchronized(mWindowMap) {
|
||||
final AllWindowsIterator iterator = new AllWindowsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
final WindowState w = iterator.next();
|
||||
if (w.mHasSurface) {
|
||||
try {
|
||||
w.mClient.closeSystemDialogs(reason);
|
||||
} catch (RemoteException e) {
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||
final int numWindows = windows.size();
|
||||
for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
|
||||
final WindowState w = windows.get(winNdx);
|
||||
if (w.mHasSurface) {
|
||||
try {
|
||||
w.mClient.closeSystemDialogs(reason);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4985,9 +4992,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
mPolicy.setCurrentUserLw(newUserId);
|
||||
|
||||
// Hide windows that should not be seen by the new user.
|
||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
final WindowList windows = iterator.next().getWindowList();
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||
final WindowList windows = displayContent.getWindowList();
|
||||
for (int i = 0; i < windows.size(); i++) {
|
||||
final WindowState win = windows.get(i);
|
||||
if (win.isHiddenFromUserLocked()) {
|
||||
@ -5243,12 +5251,16 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
// the background..)
|
||||
if (on) {
|
||||
boolean isVisible = false;
|
||||
final AllWindowsIterator iterator = new AllWindowsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
final WindowState ws = iterator.next();
|
||||
if (ws.mSession.mPid == pid && ws.isVisibleLw()) {
|
||||
isVisible = true;
|
||||
break;
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||
final int numWindows = windows.size();
|
||||
for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
|
||||
final WindowState ws = windows.get(winNdx);
|
||||
if (ws.mSession.mPid == pid && ws.isVisibleLw()) {
|
||||
isVisible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isVisible) {
|
||||
@ -5998,9 +6010,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
WindowList windows = new WindowList();
|
||||
synchronized (mWindowMap) {
|
||||
//noinspection unchecked
|
||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
||||
while(iterator.hasNext()) {
|
||||
windows.addAll(iterator.next().getWindowList());
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||
windows.addAll(displayContent.getWindowList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -6228,11 +6241,15 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
|
||||
synchronized (mWindowMap) {
|
||||
final AllWindowsIterator iterator = new AllWindowsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
final WindowState w = iterator.next();
|
||||
if (System.identityHashCode(w) == hashCode) {
|
||||
return w;
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||
final int numWindows = windows.size();
|
||||
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.
|
||||
private void sendScreenStatusToClientsLocked() {
|
||||
final boolean on = mPowerManager.isScreenOn();
|
||||
final AllWindowsIterator iterator = new AllWindowsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
try {
|
||||
iterator.next().mClient.dispatchScreenState(on);
|
||||
} catch (RemoteException e) {
|
||||
// Ignored
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||
final int numWindows = windows.size();
|
||||
for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
|
||||
try {
|
||||
windows.get(winNdx).mClient.dispatchScreenState(on);
|
||||
} catch (RemoteException e) {
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7629,9 +7650,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
|
||||
final void rebuildAppWindowListLocked() {
|
||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
rebuildAppWindowListLocked(iterator.next());
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
rebuildAppWindowListLocked(mDisplayContents.valueAt(displayNdx));
|
||||
}
|
||||
}
|
||||
|
||||
@ -8594,9 +8615,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
boolean focusDisplayed = false;
|
||||
boolean updateAllDrawn = false;
|
||||
|
||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
final DisplayContent displayContent = iterator.next();
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||
WindowList windows = displayContent.getWindowList();
|
||||
DisplayInfo displayInfo = displayContent.getDisplayInfo();
|
||||
final int displayId = displayContent.getDisplayId();
|
||||
@ -9035,9 +9056,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
defaultDisplay.layoutNeeded = true;
|
||||
}
|
||||
|
||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
DisplayContent displayContent = iterator.next();
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||
if (displayContent.pendingLayoutChanges != 0) {
|
||||
displayContent.layoutNeeded = true;
|
||||
}
|
||||
@ -9224,9 +9245,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
|
||||
private boolean needsLayout() {
|
||||
DisplayContentsIterator iterator = new DisplayContentsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (iterator.next().layoutNeeded) {
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||
if (displayContent.layoutNeeded) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -9287,35 +9309,38 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
// window list to make sure we haven't left any dangling surfaces
|
||||
// around.
|
||||
|
||||
AllWindowsIterator iterator = new AllWindowsIterator();
|
||||
Slog.i(TAG, "Out of memory for surface! Looking for leaks...");
|
||||
while (iterator.hasNext()) {
|
||||
WindowState ws = iterator.next();
|
||||
WindowStateAnimator wsa = ws.mWinAnimator;
|
||||
if (wsa.mSurfaceControl != null) {
|
||||
if (!mSessions.contains(wsa.mSession)) {
|
||||
Slog.w(TAG, "LEAKED SURFACE (session doesn't exist): "
|
||||
+ ws + " surface=" + wsa.mSurfaceControl
|
||||
+ " token=" + ws.mToken
|
||||
+ " pid=" + ws.mSession.mPid
|
||||
+ " uid=" + ws.mSession.mUid);
|
||||
if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null);
|
||||
wsa.mSurfaceControl.destroy();
|
||||
wsa.mSurfaceShown = false;
|
||||
wsa.mSurfaceControl = null;
|
||||
ws.mHasSurface = false;
|
||||
mForceRemoves.add(ws);
|
||||
leakedSurface = true;
|
||||
} else if (ws.mAppToken != null && ws.mAppToken.clientHidden) {
|
||||
Slog.w(TAG, "LEAKED SURFACE (app token hidden): "
|
||||
+ ws + " surface=" + wsa.mSurfaceControl
|
||||
+ " token=" + ws.mAppToken);
|
||||
if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null);
|
||||
wsa.mSurfaceControl.destroy();
|
||||
wsa.mSurfaceShown = false;
|
||||
wsa.mSurfaceControl = null;
|
||||
ws.mHasSurface = false;
|
||||
leakedSurface = true;
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||
final int numWindows = windows.size();
|
||||
for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
|
||||
final WindowState ws = windows.get(winNdx);
|
||||
WindowStateAnimator wsa = ws.mWinAnimator;
|
||||
if (wsa.mSurfaceControl != null) {
|
||||
if (!mSessions.contains(wsa.mSession)) {
|
||||
Slog.w(TAG, "LEAKED SURFACE (session doesn't exist): "
|
||||
+ ws + " surface=" + wsa.mSurfaceControl
|
||||
+ " token=" + ws.mToken
|
||||
+ " pid=" + ws.mSession.mPid
|
||||
+ " uid=" + ws.mSession.mUid);
|
||||
if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null);
|
||||
wsa.mSurfaceControl.destroy();
|
||||
wsa.mSurfaceShown = false;
|
||||
wsa.mSurfaceControl = null;
|
||||
ws.mHasSurface = false;
|
||||
mForceRemoves.add(ws);
|
||||
leakedSurface = true;
|
||||
} else if (ws.mAppToken != null && ws.mAppToken.clientHidden) {
|
||||
Slog.w(TAG, "LEAKED SURFACE (app token hidden): "
|
||||
+ ws + " surface=" + wsa.mSurfaceControl
|
||||
+ " token=" + ws.mAppToken);
|
||||
if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null);
|
||||
wsa.mSurfaceControl.destroy();
|
||||
wsa.mSurfaceShown = false;
|
||||
wsa.mSurfaceControl = null;
|
||||
ws.mHasSurface = false;
|
||||
leakedSurface = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9323,27 +9348,30 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
if (!leakedSurface) {
|
||||
Slog.w(TAG, "No leaked surfaces; killing applicatons!");
|
||||
SparseIntArray pidCandidates = new SparseIntArray();
|
||||
iterator = new AllWindowsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
WindowState ws = iterator.next();
|
||||
if (mForceRemoves.contains(ws)) {
|
||||
continue;
|
||||
}
|
||||
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++) {
|
||||
pids[i] = pidCandidates.keyAt(i);
|
||||
}
|
||||
try {
|
||||
if (mActivityManager.killPids(pids, "Free memory", secure)) {
|
||||
killedApps = true;
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||
final int numWindows = windows.size();
|
||||
for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
|
||||
final WindowState ws = windows.get(winNdx);
|
||||
if (mForceRemoves.contains(ws)) {
|
||||
continue;
|
||||
}
|
||||
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++) {
|
||||
pids[i] = pidCandidates.keyAt(i);
|
||||
}
|
||||
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) {
|
||||
pw.println("WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)");
|
||||
if (mDisplayReady) {
|
||||
DisplayContentsIterator dCIterator = new DisplayContentsIterator();
|
||||
while (dCIterator.hasNext()) {
|
||||
dCIterator.next().dump(" ", pw);
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
mDisplayContents.valueAt(displayNdx).dump(" ", pw);
|
||||
}
|
||||
} else {
|
||||
pw.println(" NO DISPLAY");
|
||||
@ -9992,13 +10020,16 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
void dumpWindowsNoHeaderLocked(PrintWriter pw, boolean dumpAll,
|
||||
ArrayList<WindowState> windows) {
|
||||
int j = 0;
|
||||
final AllWindowsIterator iterator = new AllWindowsIterator(REVERSE_ITERATOR);
|
||||
while (iterator.hasNext()) {
|
||||
final WindowState w = iterator.next();
|
||||
if (windows == null || windows.contains(w)) {
|
||||
pw.print(" Window #"); pw.print(j++); pw.print(' ');
|
||||
pw.print(w); pw.println(":");
|
||||
w.dump(pw, " ", dumpAll || windows != null);
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final WindowList windowList = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||
for (int winNdx = windowList.size() - 1; winNdx >= 0; --winNdx) {
|
||||
final WindowState w = windowList.get(winNdx);
|
||||
if (windows == null || windows.contains(w)) {
|
||||
pw.print(" Window #"); pw.print(j++); pw.print(' ');
|
||||
pw.print(w); pw.println(":");
|
||||
w.dump(pw, " ", dumpAll || windows != null);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mInputMethodDialogs.size() > 0) {
|
||||
@ -10151,9 +10182,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
pw.print(" mDisplayEnabled="); pw.println(mDisplayEnabled);
|
||||
if (needsLayout()) {
|
||||
pw.print(" layoutNeeded on displays=");
|
||||
DisplayContentsIterator dcIterator = new DisplayContentsIterator();
|
||||
while (dcIterator.hasNext()) {
|
||||
final DisplayContent displayContent = dcIterator.next();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
|
||||
if (displayContent.layoutNeeded) {
|
||||
pw.print(displayContent.getDisplayId());
|
||||
}
|
||||
@ -10187,11 +10217,15 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
WindowList windows = new WindowList();
|
||||
if ("visible".equals(name)) {
|
||||
synchronized(mWindowMap) {
|
||||
final AllWindowsIterator iterator = new AllWindowsIterator(REVERSE_ITERATOR);
|
||||
while (iterator.hasNext()) {
|
||||
final WindowState w = iterator.next();
|
||||
if (w.mWinAnimator.mSurfaceShown) {
|
||||
windows.add(w);
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final WindowList windowList =
|
||||
mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||
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) {
|
||||
}
|
||||
synchronized(mWindowMap) {
|
||||
final AllWindowsIterator iterator = new AllWindowsIterator(REVERSE_ITERATOR);
|
||||
while (iterator.hasNext()) {
|
||||
final WindowState w = iterator.next();
|
||||
if (name != null) {
|
||||
if (w.mAttrs.getTitle().toString().contains(name)) {
|
||||
final int numDisplays = mDisplayContents.size();
|
||||
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||
final WindowList windowList = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||
for (int winNdx = windowList.size() - 1; winNdx >= 0; --winNdx) {
|
||||
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);
|
||||
}
|
||||
} else if (System.identityHashCode(w) == objectId) {
|
||||
windows.add(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10456,87 +10493,6 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
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.
|
||||
public DisplayContent getDefaultDisplayContentLocked() {
|
||||
return getDisplayContentLocked(Display.DEFAULT_DISPLAY);
|
||||
|
Reference in New Issue
Block a user