OSDN Git Service

Update decor LayoutParams when window is already added.
authorBryce Lee <brycelee@google.com>
Fri, 7 Apr 2017 17:27:19 +0000 (10:27 -0700)
committerBryce Lee <brycelee@google.com>
Fri, 7 Apr 2017 22:11:12 +0000 (15:11 -0700)
These values can change for themes that are dependent on the size,
such as the DialogWhenLarge theme. In this case, different layouts
are loaded that could depend on updated LayoutParams.

This CL identifies the case when the layoutparams change and informs
the activity.

Change-Id: Icde8d94cc089ca0c02a15120a860533ef540c850
Fixes: 31643268
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test CtsServicesHostTestCases android.server.cts.ActivityManagerAppConfigurationTests#testDialogWhenLargeSplitSmall

core/java/android/app/ActivityThread.java

index 7299d6b..182982a 100644 (file)
@@ -3727,9 +3727,17 @@ public final class ActivityThread {
                         impl.notifyChildRebuilt();
                     }
                 }
-                if (a.mVisibleFromClient && !a.mWindowAdded) {
-                    a.mWindowAdded = true;
-                    wm.addView(decor, l);
+                if (a.mVisibleFromClient) {
+                    if (!a.mWindowAdded) {
+                        a.mWindowAdded = true;
+                        wm.addView(decor, l);
+                    } else {
+                        // The activity will get a callback for this {@link LayoutParams} change
+                        // earlier. However, at that time the decor will not be set (this is set
+                        // in this method), so no action will be taken. This call ensures the
+                        // callback occurs with the decor set.
+                        a.onWindowAttributesChanged(l);
+                    }
                 }
 
             // If the window has already been added, but during resume
@@ -3769,6 +3777,7 @@ public final class ActivityThread {
                         wm.updateViewLayout(decor, l);
                     }
                 }
+
                 r.activity.mVisibleFromServer = true;
                 mNumVisibleActivities++;
                 if (r.activity.mVisibleFromClient) {