OSDN Git Service

[DO NOT MERGE] Fixed NPE when trying to animate a window without display
authorWale Ogunwale <ogunwale@google.com>
Thu, 2 Apr 2015 23:13:57 +0000 (16:13 -0700)
committerThe Android Automerger <android-build@google.com>
Tue, 7 Apr 2015 01:51:16 +0000 (18:51 -0700)
In some cases it is possible for the AppToken.allAppWindows list to
get out of sync with the list of windows known to WMS if the client
doesn't call Session.remove(Window). This can lead to an NPE when
the animation threads runs and the display for the window has been
removed.

Bug: 19972099
Change-Id: Ifdf9ff2364b96757bba0539394c4a682f64577c9

services/core/java/com/android/server/wm/WindowAnimator.java

index 64713d9..e833511 100644 (file)
@@ -824,12 +824,16 @@ public class WindowAnimator {
         if (displayId < 0) {
             return 0;
         }
-        return mService.getDisplayContentLocked(displayId).pendingLayoutChanges;
+        DisplayContent displayContent = mService.getDisplayContentLocked(displayId);
+        return (displayContent != null) ? displayContent.pendingLayoutChanges : 0;
     }
 
     void setPendingLayoutChanges(final int displayId, final int changes) {
         if (displayId >= 0) {
-            mService.getDisplayContentLocked(displayId).pendingLayoutChanges |= changes;
+            DisplayContent displayContent = mService.getDisplayContentLocked(displayId);
+            if (displayContent != null) {
+                displayContent.pendingLayoutChanges |= changes;
+            }
         }
     }