summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWale Ogunwale <ogunwale@google.com>2014-11-10 12:12:27 -0800
committerWale Ogunwale <ogunwale@google.com>2014-11-10 15:32:59 -0800
commit98e70d0908eaf259ac21fc75b252be3c25d788c3 (patch)
treec3240c8ba73056489755b8a849c53b90054d5ca6
parente2e649f5371857e0df41356512c6e06663ba8577 (diff)
downloadframeworks_base-98e70d0908eaf259ac21fc75b252be3c25d788c3.zip
frameworks_base-98e70d0908eaf259ac21fc75b252be3c25d788c3.tar.gz
frameworks_base-98e70d0908eaf259ac21fc75b252be3c25d788c3.tar.bz2
Fixed index out of bounds issue when removing windows.
Child windows are also removed when WMS.removeWindowInnerLocked() is called to removed a window. This causes the number of windows to decrement by more than 1 which causes an out of bounds exception in AppWindowToken.removeAllWindows() which was expecting a decrement of 1. Changed code to only continue looping if the size of the Windows array is still greater than 0. Bug: 18202119 Change-Id: I6124717272c552ec98e89cbacaadcd964fdba02e
-rw-r--r--services/core/java/com/android/server/wm/AppWindowToken.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index b2575e6..1086eb2 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -252,11 +252,17 @@ class AppWindowToken extends WindowToken {
return false;
}
+ @Override
void removeAllWindows() {
- for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) {
- WindowState win = allAppWindows.get(winNdx);
- if (WindowManagerService.DEBUG_WINDOW_MOVEMENT) Slog.w(WindowManagerService.TAG,
- "removeAllWindows: removing win=" + win);
+ int winNdx;
+ while ((winNdx = allAppWindows.size()) > 0) {
+ WindowState win = allAppWindows.get(winNdx - 1);
+ if (WindowManagerService.DEBUG_WINDOW_MOVEMENT) {
+ Slog.w(WindowManagerService.TAG, "removeAllWindows: removing win=" + win);
+ }
+
+ // {@link WindowManagerService.removeWindowLocked} may remove multiple entries from
+ // {@link #allAppWindows} if the window to be removed has child windows.
win.mService.removeWindowLocked(win.mSession, win);
}
}