Merge "Reset and reuse Iterators and don't new() one."
This commit is contained in:
committed by
Android (Google) Code Review
commit
22ee9aad83
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.server.wm;
|
package com.android.server.wm;
|
||||||
|
|
||||||
|
import static com.android.server.wm.WindowManagerService.FORWARD_ITERATOR;
|
||||||
|
import static com.android.server.wm.WindowManagerService.REVERSE_ITERATOR;
|
||||||
|
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.DisplayInfo;
|
import android.view.DisplayInfo;
|
||||||
@@ -88,6 +91,8 @@ class DisplayContent {
|
|||||||
ArrayList<TaskList> mTaskLists = new ArrayList<TaskList>();
|
ArrayList<TaskList> mTaskLists = new ArrayList<TaskList>();
|
||||||
SparseArray<TaskList> mTaskIdToTaskList = new SparseArray<TaskList>();
|
SparseArray<TaskList> mTaskIdToTaskList = new SparseArray<TaskList>();
|
||||||
|
|
||||||
|
private final AppTokenIterator mTmpAppIterator = new AppTokenIterator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param display May not be null.
|
* @param display May not be null.
|
||||||
*/
|
*/
|
||||||
@@ -169,6 +174,18 @@ class DisplayContent {
|
|||||||
wtoken.groupId = newTaskId;
|
wtoken.groupId = newTaskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the utility iterator so we don't have to construct new iterators every time we
|
||||||
|
* iterate.
|
||||||
|
* NOTE: Do not ever nest this call or you will have a bad time!
|
||||||
|
* @param reverse Direction of iterator.
|
||||||
|
* @return The utility iterator.
|
||||||
|
*/
|
||||||
|
AppTokenIterator getTmpAppIterator(boolean reverse) {
|
||||||
|
mTmpAppIterator.reset(reverse);
|
||||||
|
return mTmpAppIterator;
|
||||||
|
}
|
||||||
|
|
||||||
class TaskListsIterator implements Iterator<TaskList> {
|
class TaskListsIterator implements Iterator<TaskList> {
|
||||||
private int mCur;
|
private int mCur;
|
||||||
private boolean mReverse;
|
private boolean mReverse;
|
||||||
@@ -178,9 +195,12 @@ class DisplayContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TaskListsIterator(boolean reverse) {
|
TaskListsIterator(boolean reverse) {
|
||||||
|
reset(reverse);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset(boolean reverse) {
|
||||||
mReverse = reverse;
|
mReverse = reverse;
|
||||||
int numTaskLists = mTaskLists.size();
|
mCur = reverse ? mTaskLists.size() - 1 : 0;
|
||||||
mCur = reverse ? numTaskLists - 1 : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -208,18 +228,22 @@ class DisplayContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AppTokenIterator implements Iterator<AppWindowToken> {
|
class AppTokenIterator implements Iterator<AppWindowToken> {
|
||||||
final TaskListsIterator mIterator;
|
final TaskListsIterator mIterator = new TaskListsIterator();
|
||||||
final boolean mReverse;
|
boolean mReverse;
|
||||||
int mCur;
|
int mCur;
|
||||||
TaskList mTaskList;
|
TaskList mTaskList;
|
||||||
|
|
||||||
public AppTokenIterator() {
|
public AppTokenIterator() {
|
||||||
this(false);
|
this(FORWARD_ITERATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppTokenIterator(boolean reverse) {
|
public AppTokenIterator(boolean reverse) {
|
||||||
|
reset(reverse);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset(boolean reverse) {
|
||||||
mReverse = reverse;
|
mReverse = reverse;
|
||||||
mIterator = new TaskListsIterator(reverse);
|
mIterator.reset(reverse);
|
||||||
getNextTaskList();
|
getNextTaskList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +316,7 @@ class DisplayContent {
|
|||||||
pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight);
|
pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight);
|
||||||
pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth);
|
pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth);
|
||||||
pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight);
|
pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight);
|
||||||
AppTokenIterator iterator = new AppTokenIterator(true);
|
AppTokenIterator iterator = getTmpAppIterator(REVERSE_ITERATOR);
|
||||||
int ndx = iterator.size() - 1;
|
int ndx = iterator.size() - 1;
|
||||||
if (ndx >= 0) {
|
if (ndx >= 0) {
|
||||||
pw.println();
|
pw.println();
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import static com.android.server.wm.WindowManagerService.LayoutFields.SET_WALLPA
|
|||||||
import static com.android.server.wm.WindowManagerService.LayoutFields.SET_FORCE_HIDING_CHANGED;
|
import static com.android.server.wm.WindowManagerService.LayoutFields.SET_FORCE_HIDING_CHANGED;
|
||||||
import static com.android.server.wm.WindowManagerService.LayoutFields.SET_ORIENTATION_CHANGE_COMPLETE;
|
import static com.android.server.wm.WindowManagerService.LayoutFields.SET_ORIENTATION_CHANGE_COMPLETE;
|
||||||
import static com.android.server.wm.WindowManagerService.LayoutFields.SET_WALLPAPER_ACTION_PENDING;
|
import static com.android.server.wm.WindowManagerService.LayoutFields.SET_WALLPAPER_ACTION_PENDING;
|
||||||
|
import static com.android.server.wm.WindowManagerService.FORWARD_ITERATOR;
|
||||||
|
import static com.android.server.wm.WindowManagerService.REVERSE_ITERATOR;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Debug;
|
import android.os.Debug;
|
||||||
@@ -176,7 +178,7 @@ public class WindowAnimator {
|
|||||||
private void updateAppWindowsLocked(int displayId) {
|
private void updateAppWindowsLocked(int displayId) {
|
||||||
int i;
|
int i;
|
||||||
final DisplayContent displayContent = mService.getDisplayContentLocked(displayId);
|
final DisplayContent displayContent = mService.getDisplayContentLocked(displayId);
|
||||||
AppTokenIterator iterator = displayContent.new AppTokenIterator();
|
AppTokenIterator iterator = displayContent.getTmpAppIterator(FORWARD_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
final AppWindowAnimator appAnimator = iterator.next().mAppAnimator;
|
final AppWindowAnimator appAnimator = iterator.next().mAppAnimator;
|
||||||
final boolean wasAnimating = appAnimator.animation != null
|
final boolean wasAnimating = appAnimator.animation != null
|
||||||
@@ -459,8 +461,8 @@ public class WindowAnimator {
|
|||||||
private void testTokenMayBeDrawnLocked(int displayId) {
|
private void testTokenMayBeDrawnLocked(int displayId) {
|
||||||
// See if any windows have been drawn, so they (and others
|
// See if any windows have been drawn, so they (and others
|
||||||
// associated with them) can now be shown.
|
// associated with them) can now be shown.
|
||||||
AppTokenIterator iterator = mService.getDisplayContentLocked(displayId).new
|
AppTokenIterator iterator =
|
||||||
AppTokenIterator();
|
mService.getDisplayContentLocked(displayId).getTmpAppIterator(FORWARD_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
AppWindowToken wtoken = iterator.next();
|
AppWindowToken wtoken = iterator.next();
|
||||||
AppWindowAnimator appAnimator = wtoken.mAppAnimator;
|
AppWindowAnimator appAnimator = wtoken.mAppAnimator;
|
||||||
|
|||||||
@@ -208,6 +208,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
static final boolean PROFILE_ORIENTATION = false;
|
static final boolean PROFILE_ORIENTATION = false;
|
||||||
static final boolean localLOGV = DEBUG;
|
static final boolean localLOGV = DEBUG;
|
||||||
|
|
||||||
|
final static boolean REVERSE_ITERATOR = true;
|
||||||
|
final static boolean FORWARD_ITERATOR = false;
|
||||||
|
|
||||||
/** How much to multiply the policy's type layer, to reserve room
|
/** How much to multiply the policy's type layer, to reserve room
|
||||||
* for multiple windows of the same type and Z-ordering adjustment
|
* for multiple windows of the same type and Z-ordering adjustment
|
||||||
* with TYPE_LAYER_OFFSET. */
|
* with TYPE_LAYER_OFFSET. */
|
||||||
@@ -422,6 +425,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
private SparseArray<DisplayContent> mTaskIdToDisplayContents =
|
private SparseArray<DisplayContent> mTaskIdToDisplayContents =
|
||||||
new SparseArray<DisplayContent>();
|
new SparseArray<DisplayContent>();
|
||||||
|
|
||||||
|
private final AllWindowsIterator mTmpWindowsIterator = new AllWindowsIterator();
|
||||||
|
|
||||||
int mRotation = 0;
|
int mRotation = 0;
|
||||||
int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||||
boolean mAltOrientation = false;
|
boolean mAltOrientation = false;
|
||||||
@@ -939,8 +944,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
// Figure out where the window should go, based on the
|
// Figure out where the window should go, based on the
|
||||||
// order of applications.
|
// order of applications.
|
||||||
WindowState pos = null;
|
WindowState pos = null;
|
||||||
AppTokenIterator iterator =
|
AppTokenIterator iterator = displayContent.getTmpAppIterator(REVERSE_ITERATOR);
|
||||||
displayContent.new AppTokenIterator(true /*reverse*/);
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
AppWindowToken t = iterator.next();
|
AppWindowToken t = iterator.next();
|
||||||
if (t == token) {
|
if (t == token) {
|
||||||
@@ -2453,9 +2457,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
public void updateAppOpsState() {
|
public void updateAppOpsState() {
|
||||||
synchronized(mWindowMap) {
|
synchronized(mWindowMap) {
|
||||||
AllWindowsIterator iterator = new AllWindowsIterator();
|
mTmpWindowsIterator.reset(FORWARD_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (mTmpWindowsIterator.hasNext()) {
|
||||||
final WindowState win = iterator.next();
|
final WindowState win = mTmpWindowsIterator.next();
|
||||||
if (win.mAppOp != AppOpsManager.OP_NONE) {
|
if (win.mAppOp != AppOpsManager.OP_NONE) {
|
||||||
final int mode = mAppOps.checkOpNoThrow(win.mAppOp, win.getOwningUid(),
|
final int mode = mAppOps.checkOpNoThrow(win.mAppOp, win.getOwningUid(),
|
||||||
win.getOwningPackage());
|
win.getOwningPackage());
|
||||||
@@ -3101,54 +3105,56 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
|
|
||||||
public void validateAppTokens(List<TaskGroup> tasks) {
|
public void validateAppTokens(List<TaskGroup> tasks) {
|
||||||
int t = tasks.size() - 1;
|
synchronized (mWindowMap) {
|
||||||
if (t < 0) {
|
int t = tasks.size() - 1;
|
||||||
Slog.w(TAG, "validateAppTokens: empty task list");
|
if (t < 0) {
|
||||||
return;
|
Slog.w(TAG, "validateAppTokens: empty task list");
|
||||||
}
|
|
||||||
|
|
||||||
TaskGroup task = tasks.get(0);
|
|
||||||
int taskId = task.taskId;
|
|
||||||
DisplayContent displayContent = mTaskIdToDisplayContents.get(taskId);
|
|
||||||
if (displayContent == null) {
|
|
||||||
Slog.w(TAG, "validateAppTokens: no Display for taskId=" + taskId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AppTokenIterator iterator = displayContent.new AppTokenIterator(true);
|
|
||||||
for ( ; t >= 0; --t) {
|
|
||||||
task = tasks.get(t);
|
|
||||||
List<IApplicationToken> tokens = task.tokens;
|
|
||||||
int v = task.tokens.size() - 1;
|
|
||||||
|
|
||||||
DisplayContent lastDisplayContent = displayContent;
|
|
||||||
displayContent = mTaskIdToDisplayContents.get(taskId);
|
|
||||||
if (displayContent != lastDisplayContent) {
|
|
||||||
Slog.w(TAG, "validateAppTokens: displayContent changed in TaskGroup list!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (v >= 0 && iterator.hasNext()) {
|
TaskGroup task = tasks.get(0);
|
||||||
AppWindowToken atoken = iterator.next();
|
int taskId = task.taskId;
|
||||||
if (atoken.removed) {
|
DisplayContent displayContent = mTaskIdToDisplayContents.get(taskId);
|
||||||
continue;
|
if (displayContent == null) {
|
||||||
}
|
Slog.w(TAG, "validateAppTokens: no Display for taskId=" + taskId);
|
||||||
if (tokens.get(v) != atoken.token) {
|
return;
|
||||||
Slog.w(TAG, "Tokens out of sync: external is " + tokens.get(v)
|
|
||||||
+ " @ " + v + ", internal is " + atoken.token);
|
|
||||||
}
|
|
||||||
v--;
|
|
||||||
}
|
}
|
||||||
while (v >= 0) {
|
|
||||||
Slog.w(TAG, "External token not found: " + tokens.get(v) + " @ " + v);
|
|
||||||
v--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
AppTokenIterator iterator = displayContent.getTmpAppIterator(REVERSE_ITERATOR);
|
||||||
AppWindowToken atoken = iterator.next();
|
for ( ; t >= 0; --t) {
|
||||||
if (!atoken.removed) {
|
task = tasks.get(t);
|
||||||
Slog.w(TAG, "Invalid internal atoken: " + atoken.token);
|
List<IApplicationToken> tokens = task.tokens;
|
||||||
|
int v = task.tokens.size() - 1;
|
||||||
|
|
||||||
|
DisplayContent lastDisplayContent = displayContent;
|
||||||
|
displayContent = mTaskIdToDisplayContents.get(taskId);
|
||||||
|
if (displayContent != lastDisplayContent) {
|
||||||
|
Slog.w(TAG, "validateAppTokens: displayContent changed in TaskGroup list!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (v >= 0 && iterator.hasNext()) {
|
||||||
|
AppWindowToken atoken = iterator.next();
|
||||||
|
if (atoken.removed) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (tokens.get(v) != atoken.token) {
|
||||||
|
Slog.w(TAG, "Tokens out of sync: external is " + tokens.get(v)
|
||||||
|
+ " @ " + v + ", internal is " + atoken.token);
|
||||||
|
}
|
||||||
|
v--;
|
||||||
|
}
|
||||||
|
while (v >= 0) {
|
||||||
|
Slog.w(TAG, "External token not found: " + tokens.get(v) + " @ " + v);
|
||||||
|
v--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
AppWindowToken atoken = iterator.next();
|
||||||
|
if (!atoken.removed) {
|
||||||
|
Slog.w(TAG, "Invalid internal atoken: " + atoken.token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3380,7 +3386,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
boolean lastFullscreen = false;
|
boolean lastFullscreen = false;
|
||||||
// TODO: Multi window.
|
// TODO: Multi window.
|
||||||
DisplayContent displayContent = getDefaultDisplayContentLocked();
|
DisplayContent displayContent = getDefaultDisplayContentLocked();
|
||||||
AppTokenIterator iterator = displayContent.new AppTokenIterator(true);
|
AppTokenIterator iterator = displayContent.getTmpAppIterator(REVERSE_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
AppWindowToken atoken = iterator.next();
|
AppWindowToken atoken = iterator.next();
|
||||||
|
|
||||||
@@ -4362,7 +4368,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
DisplayContent displayContent = iterator.next();
|
DisplayContent displayContent = iterator.next();
|
||||||
Slog.v(TAG, " Display " + displayContent.getDisplayId());
|
Slog.v(TAG, " Display " + displayContent.getDisplayId());
|
||||||
AppTokenIterator appIterator = displayContent.new AppTokenIterator(true);
|
AppTokenIterator appIterator = displayContent.getTmpAppIterator(REVERSE_ITERATOR);
|
||||||
int i = appIterator.size();
|
int i = appIterator.size();
|
||||||
while (appIterator.hasNext()) {
|
while (appIterator.hasNext()) {
|
||||||
Slog.v(TAG, " #" + --i + ": " + appIterator.next().token);
|
Slog.v(TAG, " #" + --i + ": " + appIterator.next().token);
|
||||||
@@ -4372,9 +4378,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
void dumpWindowsLocked() {
|
void dumpWindowsLocked() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
final AllWindowsIterator iterator = new AllWindowsIterator(REVERSE_ITERATOR);
|
mTmpWindowsIterator.reset(REVERSE_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (mTmpWindowsIterator.hasNext()) {
|
||||||
final WindowState w = iterator.next();
|
final WindowState w = mTmpWindowsIterator.next();
|
||||||
Slog.v(TAG, " #" + i++ + ": " + w);
|
Slog.v(TAG, " #" + i++ + ": " + w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4389,7 +4395,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
final WindowList windows = displayContent.getWindowList();
|
final WindowList windows = displayContent.getWindowList();
|
||||||
final int NW = windows.size();
|
final int NW = windows.size();
|
||||||
|
|
||||||
AppTokenIterator iterator = displayContent.new AppTokenIterator(true);
|
AppTokenIterator iterator = displayContent.getTmpAppIterator(REVERSE_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
if (iterator.next() == target) {
|
if (iterator.next() == target) {
|
||||||
break;
|
break;
|
||||||
@@ -4692,9 +4698,9 @@ 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();
|
mTmpWindowsIterator.reset(FORWARD_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (mTmpWindowsIterator.hasNext()) {
|
||||||
final WindowState w = iterator.next();
|
final WindowState w = mTmpWindowsIterator.next();
|
||||||
if (w.mHasSurface) {
|
if (w.mHasSurface) {
|
||||||
try {
|
try {
|
||||||
w.mClient.closeSystemDialogs(reason);
|
w.mClient.closeSystemDialogs(reason);
|
||||||
@@ -5088,9 +5094,9 @@ 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();
|
mTmpWindowsIterator.reset(FORWARD_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (mTmpWindowsIterator.hasNext()) {
|
||||||
final WindowState ws = iterator.next();
|
final WindowState ws = mTmpWindowsIterator.next();
|
||||||
if (ws.mSession.mPid == pid && ws.isVisibleLw()) {
|
if (ws.mSession.mPid == pid && ws.isVisibleLw()) {
|
||||||
isVisible = true;
|
isVisible = true;
|
||||||
break;
|
break;
|
||||||
@@ -5966,9 +5972,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mWindowMap) {
|
synchronized (mWindowMap) {
|
||||||
final AllWindowsIterator iterator = new AllWindowsIterator();
|
mTmpWindowsIterator.reset(FORWARD_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (mTmpWindowsIterator.hasNext()) {
|
||||||
final WindowState w = iterator.next();
|
final WindowState w = mTmpWindowsIterator.next();
|
||||||
if (System.identityHashCode(w) == hashCode) {
|
if (System.identityHashCode(w) == hashCode) {
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
@@ -6517,10 +6523,10 @@ 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();
|
mTmpWindowsIterator.reset(FORWARD_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (mTmpWindowsIterator.hasNext()) {
|
||||||
try {
|
try {
|
||||||
iterator.next().mClient.dispatchScreenState(on);
|
mTmpWindowsIterator.next().mClient.dispatchScreenState(on);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// Ignored
|
// Ignored
|
||||||
}
|
}
|
||||||
@@ -6861,7 +6867,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
synchronized (mWindowMap) {
|
synchronized (mWindowMap) {
|
||||||
Slog.w(TAG, "App freeze timeout expired.");
|
Slog.w(TAG, "App freeze timeout expired.");
|
||||||
DisplayContent displayContent = getDefaultDisplayContentLocked();
|
DisplayContent displayContent = getDefaultDisplayContentLocked();
|
||||||
AppTokenIterator iterator = displayContent.new AppTokenIterator(true);
|
AppTokenIterator iterator =
|
||||||
|
displayContent.getTmpAppIterator(REVERSE_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
AppWindowToken tok = iterator.next();
|
AppWindowToken tok = iterator.next();
|
||||||
if (tok.mAppAnimator.freezingScreen) {
|
if (tok.mAppAnimator.freezingScreen) {
|
||||||
@@ -7324,7 +7331,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
// And add in the still active app tokens in Z order.
|
// And add in the still active app tokens in Z order.
|
||||||
AppTokenIterator iterator = displayContent.new AppTokenIterator();
|
AppTokenIterator iterator = displayContent.getTmpAppIterator(FORWARD_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
i = reAddAppWindowsLocked(displayContent, i, iterator.next());
|
i = reAddAppWindowsLocked(displayContent, i, iterator.next());
|
||||||
}
|
}
|
||||||
@@ -7997,7 +8004,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
mAppTransition.setIdle();
|
mAppTransition.setIdle();
|
||||||
// Restore window app tokens to the ActivityManager views
|
// Restore window app tokens to the ActivityManager views
|
||||||
final DisplayContent displayContent = getDefaultDisplayContentLocked();
|
final DisplayContent displayContent = getDefaultDisplayContentLocked();
|
||||||
AppTokenIterator iterator = displayContent.new AppTokenIterator();
|
AppTokenIterator iterator = displayContent.getTmpAppIterator(FORWARD_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
iterator.next().sendingToBottom = false;
|
iterator.next().sendingToBottom = false;
|
||||||
}
|
}
|
||||||
@@ -8157,7 +8164,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
private void updateAllDrawnLocked(DisplayContent displayContent) {
|
private void updateAllDrawnLocked(DisplayContent displayContent) {
|
||||||
// See if any windows have been drawn, so they (and others
|
// See if any windows have been drawn, so they (and others
|
||||||
// associated with them) can now be shown.
|
// associated with them) can now be shown.
|
||||||
AppTokenIterator iterator = displayContent.new AppTokenIterator();
|
AppTokenIterator iterator = displayContent.getTmpAppIterator(FORWARD_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
AppWindowToken wtoken = iterator.next();
|
AppWindowToken wtoken = iterator.next();
|
||||||
if (!wtoken.allDrawn) {
|
if (!wtoken.allDrawn) {
|
||||||
@@ -8924,10 +8931,10 @@ 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();
|
mTmpWindowsIterator.reset(FORWARD_ITERATOR);
|
||||||
Slog.i(TAG, "Out of memory for surface! Looking for leaks...");
|
Slog.i(TAG, "Out of memory for surface! Looking for leaks...");
|
||||||
while (iterator.hasNext()) {
|
while (mTmpWindowsIterator.hasNext()) {
|
||||||
WindowState ws = iterator.next();
|
WindowState ws = mTmpWindowsIterator.next();
|
||||||
WindowStateAnimator wsa = ws.mWinAnimator;
|
WindowStateAnimator wsa = ws.mWinAnimator;
|
||||||
if (wsa.mSurface != null) {
|
if (wsa.mSurface != null) {
|
||||||
if (!mSessions.contains(wsa.mSession)) {
|
if (!mSessions.contains(wsa.mSession)) {
|
||||||
@@ -8960,9 +8967,9 @@ 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();
|
mTmpWindowsIterator.reset(FORWARD_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (mTmpWindowsIterator.hasNext()) {
|
||||||
WindowState ws = iterator.next();
|
WindowState ws = mTmpWindowsIterator.next();
|
||||||
if (mForceRemoves.contains(ws)) {
|
if (mForceRemoves.contains(ws)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -9088,7 +9095,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private WindowState findFocusedWindowLocked(DisplayContent displayContent) {
|
private WindowState findFocusedWindowLocked(DisplayContent displayContent) {
|
||||||
AppTokenIterator iterator = displayContent.new AppTokenIterator(true);
|
AppTokenIterator iterator = displayContent.getTmpAppIterator(REVERSE_ITERATOR);
|
||||||
WindowToken nextApp = iterator.hasNext() ? iterator.next() : null;
|
WindowToken nextApp = iterator.hasNext() ? iterator.next() : null;
|
||||||
|
|
||||||
final WindowList windows = displayContent.getWindowList();
|
final WindowList windows = displayContent.getWindowList();
|
||||||
@@ -9552,9 +9559,9 @@ 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);
|
mTmpWindowsIterator.reset(REVERSE_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (mTmpWindowsIterator.hasNext()) {
|
||||||
final WindowState w = iterator.next();
|
final WindowState w = mTmpWindowsIterator.next();
|
||||||
if (windows == null || windows.contains(w)) {
|
if (windows == null || windows.contains(w)) {
|
||||||
pw.print(" Window #"); pw.print(j++); pw.print(' ');
|
pw.print(" Window #"); pw.print(j++); pw.print(' ');
|
||||||
pw.print(w); pw.println(":");
|
pw.print(w); pw.println(":");
|
||||||
@@ -9749,9 +9756,9 @@ 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);
|
mTmpWindowsIterator.reset(REVERSE_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (mTmpWindowsIterator.hasNext()) {
|
||||||
final WindowState w = iterator.next();
|
final WindowState w = mTmpWindowsIterator.next();
|
||||||
if (w.mWinAnimator.mSurfaceShown) {
|
if (w.mWinAnimator.mSurfaceShown) {
|
||||||
windows.add(w);
|
windows.add(w);
|
||||||
}
|
}
|
||||||
@@ -9766,9 +9773,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
}
|
}
|
||||||
synchronized(mWindowMap) {
|
synchronized(mWindowMap) {
|
||||||
final AllWindowsIterator iterator = new AllWindowsIterator(REVERSE_ITERATOR);
|
mTmpWindowsIterator.reset(REVERSE_ITERATOR);
|
||||||
while (iterator.hasNext()) {
|
while (mTmpWindowsIterator.hasNext()) {
|
||||||
final WindowState w = iterator.next();
|
final WindowState w = mTmpWindowsIterator.next();
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
if (w.mAttrs.getTitle().toString().contains(name)) {
|
if (w.mAttrs.getTitle().toString().contains(name)) {
|
||||||
windows.add(w);
|
windows.add(w);
|
||||||
@@ -9995,6 +10002,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
class DisplayContentsIterator implements Iterator<DisplayContent> {
|
class DisplayContentsIterator implements Iterator<DisplayContent> {
|
||||||
private int cur;
|
private int cur;
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
cur = 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return cur < mDisplayContents.size();
|
return cur < mDisplayContents.size();
|
||||||
@@ -10014,7 +10025,6 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final static boolean REVERSE_ITERATOR = true;
|
|
||||||
class AllWindowsIterator implements Iterator<WindowState> {
|
class AllWindowsIterator implements Iterator<WindowState> {
|
||||||
private DisplayContent mDisplayContent;
|
private DisplayContent mDisplayContent;
|
||||||
private DisplayContentsIterator mDisplayContentsIterator;
|
private DisplayContentsIterator mDisplayContentsIterator;
|
||||||
@@ -10023,19 +10033,33 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
private boolean mReverse;
|
private boolean mReverse;
|
||||||
|
|
||||||
AllWindowsIterator() {
|
AllWindowsIterator() {
|
||||||
mDisplayContentsIterator = new DisplayContentsIterator();
|
this(false);
|
||||||
mDisplayContent = mDisplayContentsIterator.next();
|
|
||||||
mWindowList = mDisplayContent.getWindowList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AllWindowsIterator(boolean reverse) {
|
AllWindowsIterator(boolean reverse) {
|
||||||
this();
|
mDisplayContentsIterator = new DisplayContentsIterator();
|
||||||
|
reset(reverse);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset(boolean reverse) {
|
||||||
mReverse = reverse;
|
mReverse = reverse;
|
||||||
mWindowListIndex = reverse ? mWindowList.size() - 1 : 0;
|
mDisplayContentsIterator.reset();
|
||||||
|
if (mDisplayContentsIterator.hasNext()) {
|
||||||
|
mDisplayContent = mDisplayContentsIterator.next();
|
||||||
|
mWindowList = mDisplayContent.getWindowList();
|
||||||
|
mWindowListIndex = reverse ? mWindowList.size() - 1 : 0;
|
||||||
|
} else {
|
||||||
|
mDisplayContent = null;
|
||||||
|
mWindowList = null;
|
||||||
|
mWindowListIndex = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
|
if (mDisplayContent == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (mReverse) {
|
if (mReverse) {
|
||||||
return mWindowListIndex >= 0;
|
return mWindowListIndex >= 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user