Merge "Merge "Merge "Revert "Revert "Make AndroidRuntime only start the debugger for zygote forked apps.""" am: 3b50dc3d34 am: 98568f57ad" into oc-mr1-dev-plus-aosp am: e8626dee42"
diff --git a/core/java/android/app/WindowConfiguration.java b/core/java/android/app/WindowConfiguration.java
index 085fc79..46566e7 100644
--- a/core/java/android/app/WindowConfiguration.java
+++ b/core/java/android/app/WindowConfiguration.java
@@ -146,6 +146,9 @@
     })
     public @interface WindowConfig {}
 
+    /** @hide */
+    public static final int PINNED_WINDOWING_MODE_ELEVATION_IN_DIP = 5;
+
     public WindowConfiguration() {
         unset();
     }
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index 95bc352..eadefc9 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -86,6 +86,7 @@
 import android.widget.FrameLayout;
 import android.widget.PopupWindow;
 
+import static android.app.WindowConfiguration.PINNED_WINDOWING_MODE_ELEVATION_IN_DIP;
 import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
 import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
 import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
@@ -2216,7 +2217,7 @@
             elevation = dipToPx(elevation);
             mElevationAdjustedForStack = true;
         } else if (windowingMode == WINDOWING_MODE_PINNED) {
-            elevation = dipToPx(DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP);
+            elevation = dipToPx(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP);
             mElevationAdjustedForStack = true;
         } else {
             mElevationAdjustedForStack = false;
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index ae5341b..a0d1480 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -21,6 +21,7 @@
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
+import static android.app.WindowConfiguration.PINNED_WINDOWING_MODE_ELEVATION_IN_DIP;
 import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
 import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
 import static android.content.res.Configuration.DENSITY_DPI_UNDEFINED;
@@ -53,6 +54,7 @@
 import android.graphics.Rect;
 import android.graphics.Region;
 import android.os.RemoteException;
+import android.util.DisplayMetrics;
 import android.util.EventLog;
 import android.util.Slog;
 import android.util.SparseArray;
@@ -741,14 +743,32 @@
         scheduleAnimation();
     }
 
+    /**
+     * Calculate an amount by which to expand the stack bounds in each direction.
+     * Used to make room for shadows in the pinned windowing mode.
+     */
+    int getStackOutset() {
+        if (inPinnedWindowingMode()) {
+            final DisplayMetrics displayMetrics = getDisplayContent().getDisplayMetrics();
+            return mService.dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP,
+                    displayMetrics);
+        }
+        return 0;
+    }
+
     private void updateSurfaceSize(SurfaceControl.Transaction transaction) {
         if (mSurfaceControl == null) {
             return;
         }
 
         final Rect stackBounds = getBounds();
-        final int width = stackBounds.width();
-        final int height = stackBounds.height();
+        int width = stackBounds.width();
+        int height = stackBounds.height();
+
+        final int outset = getStackOutset();
+        width += 2*outset;
+        height += 2*outset;
+
         if (width == mLastSurfaceSize.x && height == mLastSurfaceSize.y) {
             return;
         }
@@ -1749,4 +1769,12 @@
         mDimmer.stopDim(getPendingTransaction());
         scheduleAnimation();
     }
+
+    @Override
+    void getRelativePosition(Point outPos) {
+        super.getRelativePosition(outPos);
+        final int outset = getStackOutset();
+        outPos.x -= outset;
+        outPos.y -= outset;
+    }
 }
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 53a8d82..36e3612 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -4576,6 +4576,17 @@
             outPoint.offset(-parentBounds.left, -parentBounds.top);
         }
 
+        TaskStack stack = getStack();
+
+        // If we have stack outsets, that means the top-left
+        // will be outset, and we need to inset ourselves
+        // to account for it. If we actually have shadows we will
+        // then un-inset ourselves by the surfaceInsets.
+        if (stack != null) {
+            final int outset = stack.getStackOutset();
+            outPoint.offset(outset, outset);
+        }
+
         // Expand for surface insets. See WindowState.expandForSurfaceInsets.
         outPoint.offset(-mAttrs.surfaceInsets.left, -mAttrs.surfaceInsets.top);
     }
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 1cfa956..5c9cfbb 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -99,7 +99,6 @@
     // Unchanging local convenience fields.
     final WindowManagerService mService;
     final WindowState mWin;
-    private final WindowStateAnimator mParentWinAnimator;
     final WindowAnimator mAnimator;
     final Session mSession;
     final WindowManagerPolicy mPolicy;
@@ -135,8 +134,6 @@
     float mAlpha = 0;
     float mLastAlpha = 0;
 
-    boolean mHasClipRect;
-    Rect mClipRect = new Rect();
     Rect mTmpClipRect = new Rect();
     Rect mTmpFinalClipRect = new Rect();
     Rect mLastClipRect = new Rect();
@@ -150,7 +147,6 @@
      * system decorations.
      */
     private final Rect mSystemDecorRect = new Rect();
-    private final Rect mLastSystemDecorRect = new Rect();
 
     float mDsDx=1, mDtDx=0, mDsDy=0, mDtDy=1;
     private float mLastDsDx=1, mLastDtDx=0, mLastDsDy=0, mLastDtDy=1;
@@ -224,7 +220,6 @@
         mContext = service.mContext;
 
         mWin = win;
-        mParentWinAnimator = !win.isChildWindow() ? null : win.getParentWindow().mWinAnimator;
         mSession = win.mSession;
         mAttrType = win.mAttrs.type;
         mIsWallpaper = win.mIsWallpaper;
@@ -455,9 +450,6 @@
         }
 
         // We may abort, so initialize to defaults.
-        mLastSystemDecorRect.set(0, 0, 0, 0);
-        mHasClipRect = false;
-        mClipRect.set(0, 0, 0, 0);
         mLastClipRect.set(0, 0, 0, 0);
 
         // Set up surface control with initial size.
@@ -649,14 +641,12 @@
     }
 
     void computeShownFrameLocked() {
-
         final int displayId = mWin.getDisplayId();
         final ScreenRotationAnimation screenRotationAnimation =
                 mAnimator.getScreenRotationAnimationLocked(displayId);
         final boolean screenAnimation =
                 screenRotationAnimation != null && screenRotationAnimation.isAnimating();
 
-        mHasClipRect = false;
         if (screenAnimation) {
             // cache often used attributes locally
             final Rect frame = mWin.mFrame;
@@ -796,9 +786,9 @@
 
         // We use the clip rect as provided by the tranformation for non-fullscreen windows to
         // avoid premature clipping with the system decor rect.
-        clipRect.set((mHasClipRect && !fullscreen) ? mClipRect : mSystemDecorRect);
+        clipRect.set(mSystemDecorRect);
         if (DEBUG_WINDOW_CROP) Slog.d(TAG, "win=" + w + " Initial clip rect: " + clipRect
-                + " mHasClipRect=" + mHasClipRect + " fullscreen=" + fullscreen);
+                + " fullscreen=" + fullscreen);
 
         if (isFreeformResizing && !w.isChildWindow()) {
             // For freeform resizing non child windows, we are using the big surface positioned
@@ -808,12 +798,6 @@
 
         w.expandForSurfaceInsets(clipRect);
 
-        if (mHasClipRect && fullscreen) {
-            // We intersect the clip rect specified by the transformation with the expanded system
-            // decor rect to prevent artifacts from drawing during animation if the transformation
-            // clip rect extends outside the system decor rect.
-            clipRect.intersect(mClipRect);
-        }
         // The clip rect was generated assuming (0,0) as the window origin,
         // so we need to translate to match the actual surface coordinates.
         clipRect.offset(w.mAttrs.surfaceInsets.left, w.mAttrs.surfaceInsets.top);
@@ -1378,8 +1362,6 @@
             pw.print(prefix); pw.print("mDrawState="); pw.print(drawStateToString());
             pw.print(prefix); pw.print(" mLastHidden="); pw.println(mLastHidden);
             pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw);
-            pw.print(" last="); mLastSystemDecorRect.printShortString(pw);
-            pw.print(" mHasClipRect="); pw.print(mHasClipRect);
             pw.print(" mLastClipRect="); mLastClipRect.printShortString(pw);
 
             if (!mLastFinalClipRect.isEmpty()) {