Avoid drawing the starting window twice

Logic in WindowState caused a delayed layout on the starting window,
which forced another layout/draw pass, which was unnecessary. Making
the resize call happen sooner means that that request gets lumped in
with a pending layout request, so there's only one resulting draw.

This saves not only the second drawing operation, but also the creation
of an extra buffer in SurfaceFlinger for that second draw request. This
buffer is temporary, but can be quite large on some devices and push
the system over the memory edge in extreme situations. It's difficult
to track this memory usage difference as the buffer resides at a very
low level in the system. But you can see in systrace that the second
allocation (and the second draw) is not happening after the fix.

Issue #17570761 Constrain starting window to only one buffer

Change-Id: I0e0fff7efdc812730706afccbfb020dea3f8d3e2
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 0baa2be..b4a7f04 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1373,7 +1373,8 @@
             final Rect stableInsets = mLastStableInsets;
             final boolean reportDraw = mWinAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING;
             final Configuration newConfig = configChanged ? mConfiguration : null;
-            if (mClient instanceof IWindow.Stub) {
+            if (mAttrs.type != WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
+                    && mClient instanceof IWindow.Stub) {
                 // To prevent deadlock simulate one-way call if win.mClient is a local object.
                 mService.mH.post(new Runnable() {
                     @Override