summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2014-03-27 13:19:29 -0700
committerCraig Mautner <cmautner@google.com>2014-03-27 13:19:29 -0700
commitd3849f54158bf1a370b9462b30ee36c15e7b02ea (patch)
treef4adfe219bbcd2744c3e3a477254c6fd4d7f60d0
parent79e6578b6c7e8352f86942b99de4513133a1acdb (diff)
downloadframeworks_base-d3849f54158bf1a370b9462b30ee36c15e7b02ea.zip
frameworks_base-d3849f54158bf1a370b9462b30ee36c15e7b02ea.tar.gz
frameworks_base-d3849f54158bf1a370b9462b30ee36c15e7b02ea.tar.bz2
Check return values for null.
When a Display has been removed there is a delay until all of its windows have been removed. Therefore there is a possibility that WindowState.getDisplayContent() returns null. Guard against that possibility. Fixes bug 13616765. Change-Id: Ia2074d293b0e1bd4ca2cd14aeb4a2cc09ed9f41e
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java14
-rw-r--r--services/core/java/com/android/server/wm/WindowStateAnimator.java12
2 files changed, 22 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 3b11c4e..332097b 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -917,6 +917,10 @@ public class WindowManagerService extends IWindowManager.Stub
final IWindow client = win.mClient;
final WindowToken token = win.mToken;
final DisplayContent displayContent = win.getDisplayContent();
+ if (displayContent == null) {
+ // It doesn't matter this display is going away.
+ return 0;
+ }
final WindowList windows = win.getWindowList();
final int N = windows.size();
@@ -1094,6 +1098,9 @@ public class WindowManagerService extends IWindowManager.Stub
private void addAttachedWindowToListLocked(final WindowState win, boolean addToToken) {
final WindowToken token = win.mToken;
final DisplayContent displayContent = win.getDisplayContent();
+ if (displayContent == null) {
+ return;
+ }
final WindowState attached = win.mAttachedWindow;
WindowList tokenWindowList = getTokenWindowsOnDisplay(token, displayContent);
@@ -2251,6 +2258,11 @@ public class WindowManagerService extends IWindowManager.Stub
return WindowManagerGlobal.ADD_APP_EXITING;
}
+ if (win.getDisplayContent() == null) {
+ Slog.w(TAG, "Adding window to Display that has been removed.");
+ return WindowManagerGlobal.ADD_INVALID_DISPLAY;
+ }
+
mPolicy.adjustWindowParamsLw(win.mAttrs);
win.setShowToOwnerOnlyLocked(mPolicy.checkShowToOwnerOnly(attrs));
@@ -2744,7 +2756,7 @@ public class WindowManagerService extends IWindowManager.Stub
return;
}
- final DisplayInfo displayInfo = window.getDisplayContent().getDisplayInfo();
+ final DisplayInfo displayInfo = displayContent.getDisplayInfo();
final RectF dispRect = new RectF(0, 0,
displayInfo.logicalWidth, displayInfo.logicalHeight);
matrix.mapRect(dispRect);
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 93f6d22..1ff0afb 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -171,9 +171,15 @@ class WindowStateAnimator {
mAnimator = service.mAnimator;
mPolicy = service.mPolicy;
mContext = service.mContext;
- final DisplayInfo displayInfo = win.getDisplayContent().getDisplayInfo();
- mAnimDw = displayInfo.appWidth;
- mAnimDh = displayInfo.appHeight;
+ final DisplayContent displayContent = win.getDisplayContent();
+ if (displayContent != null) {
+ final DisplayInfo displayInfo = displayContent.getDisplayInfo();
+ mAnimDw = displayInfo.appWidth;
+ mAnimDh = displayInfo.appHeight;
+ } else {
+ Slog.w(TAG, "WindowStateAnimator ctor: Display has been removed");
+ // This is checked on return and dealt with.
+ }
mWin = win;
mAttachedWinAnimator = win.mAttachedWindow == null