OSDN Git Service

Do not defer wm display logic when called from am.
authorBryce Lee <brycelee@google.com>
Mon, 20 Mar 2017 17:37:12 +0000 (10:37 -0700)
committerBryce Lee <brycelee@google.com>
Mon, 20 Mar 2017 17:37:12 +0000 (10:37 -0700)
Currently we process any remove/add/change logic from the activity
manager to the window manager through a handler message. This opens
the possibility of the activity manager requesting display state
from a window manager that is a step behind.

This change modifies the call behavior so that these changes are done
synchronously between the two managers.

Change-Id: Icd19f37c62bfb7aad10fab2e1b21e41ac75052b5
Fixes: 35741135
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test CtsServicesHostTestCases android.server.cts.ActivityManagerDisplayTests#testCreateMultipleVirtualDisplaysH

services/core/java/com/android/server/am/ActivityStackSupervisor.java
services/core/java/com/android/server/wm/WindowManagerService.java

index 217515b..6e75e34 100644 (file)
@@ -399,6 +399,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
     /** Mapping from (ActivityStack/TaskStack).mStackId to their current state */
     SparseArray<ActivityContainer> mActivityContainers = new SparseArray<>();
 
+    // TODO: There should be an ActivityDisplayController coordinating am/wm interaction.
     /** Mapping from displayId to display current state */
     private final SparseArray<ActivityDisplay> mActivityDisplays = new SparseArray<>();
 
@@ -3719,11 +3720,9 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
                 }
                 mActivityDisplays.put(displayId, activityDisplay);
                 calculateDefaultMinimalSizeOfResizeableTasks(activityDisplay);
+                mWindowManager.onDisplayAdded(displayId);
             }
         }
-        if (newDisplay) {
-            mWindowManager.onDisplayAdded(displayId);
-        }
     }
 
     /** Check if display with specified id is added to the list. */
@@ -3762,9 +3761,9 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
                     }
                 }
                 mActivityDisplays.remove(displayId);
+                mWindowManager.onDisplayRemoved(displayId);
             }
         }
-        mWindowManager.onDisplayRemoved(displayId);
     }
 
     private void handleDisplayChanged(int displayId) {
@@ -3773,8 +3772,8 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
             if (activityDisplay != null) {
                 // TODO: Update the bounds.
             }
+            mWindowManager.onDisplayChanged(displayId);
         }
-        mWindowManager.onDisplayChanged(displayId);
     }
 
     private StackInfo getStackInfoLocked(ActivityStack stack) {
@@ -4734,7 +4733,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
 
             init(mVirtualDisplay.getDisplay());
 
-            mWindowManager.handleDisplayAdded(mDisplayId);
+            mWindowManager.onDisplayAdded(mDisplayId);
         }
 
         void setSurface(Surface surface) {
index 7539cd4..5edb82c 100644 (file)
@@ -4634,10 +4634,6 @@ public class WindowManagerService extends IWindowManager.Stub
         public static final int SHOW_STRICT_MODE_VIOLATION = 25;
         public static final int DO_ANIMATION_CALLBACK = 26;
 
-        public static final int DO_DISPLAY_ADDED = 27;
-        public static final int DO_DISPLAY_REMOVED = 28;
-        public static final int DO_DISPLAY_CHANGED = 29;
-
         public static final int CLIENT_FREEZE_TIMEOUT = 30;
         public static final int TAP_OUTSIDE_TASK = 31;
         public static final int NOTIFY_ACTIVITY_DRAWN = 32;
@@ -4981,22 +4977,6 @@ public class WindowManagerService extends IWindowManager.Stub
                     break;
                 }
 
-                case DO_DISPLAY_ADDED:
-                    handleDisplayAdded(msg.arg1);
-                    break;
-
-                case DO_DISPLAY_REMOVED:
-                    synchronized (mWindowMap) {
-                        handleDisplayRemovedLocked(msg.arg1);
-                    }
-                    break;
-
-                case DO_DISPLAY_CHANGED:
-                    synchronized (mWindowMap) {
-                        handleDisplayChangedLocked(msg.arg1);
-                    }
-                    break;
-
                 case TAP_OUTSIDE_TASK: {
                     handleTapOutsideTask((DisplayContent)msg.obj, msg.arg1, msg.arg2);
                 }
@@ -6710,10 +6690,6 @@ public class WindowManagerService extends IWindowManager.Stub
     }
 
     public void onDisplayAdded(int displayId) {
-        mH.sendMessage(mH.obtainMessage(H.DO_DISPLAY_ADDED, displayId, 0));
-    }
-
-    public void handleDisplayAdded(int displayId) {
         synchronized (mWindowMap) {
             final Display display = mDisplayManager.getDisplay(displayId);
             if (display != null) {
@@ -6725,28 +6701,24 @@ public class WindowManagerService extends IWindowManager.Stub
     }
 
     public void onDisplayRemoved(int displayId) {
-        mH.sendMessage(mH.obtainMessage(H.DO_DISPLAY_REMOVED, displayId, 0));
-    }
-
-    private void handleDisplayRemovedLocked(int displayId) {
-        final DisplayContent displayContent = mRoot.getDisplayContentOrCreate(displayId);
-        if (displayContent != null) {
-            displayContent.removeIfPossible();
+        synchronized (mWindowMap) {
+            final DisplayContent displayContent = mRoot.getDisplayContentOrCreate(displayId);
+            if (displayContent != null) {
+                displayContent.removeIfPossible();
+            }
+            mAnimator.removeDisplayLocked(displayId);
+            mWindowPlacerLocked.requestTraversal();
         }
-        mAnimator.removeDisplayLocked(displayId);
-        mWindowPlacerLocked.requestTraversal();
     }
 
     public void onDisplayChanged(int displayId) {
-        mH.sendMessage(mH.obtainMessage(H.DO_DISPLAY_CHANGED, displayId, 0));
-    }
-
-    private void handleDisplayChangedLocked(int displayId) {
-        final DisplayContent displayContent = mRoot.getDisplayContentOrCreate(displayId);
-        if (displayContent != null) {
-            displayContent.updateDisplayInfo();
+        synchronized (mWindowMap) {
+            final DisplayContent displayContent = mRoot.getDisplayContentOrCreate(displayId);
+            if (displayContent != null) {
+                displayContent.updateDisplayInfo();
+            }
+            mWindowPlacerLocked.requestTraversal();
         }
-        mWindowPlacerLocked.requestTraversal();
     }
 
     @Override