Remove code for seamlessly rotating SurfaceView's.

No longer required :D

Bug: 36230754
Bug: 36727915
Test: Rotate camera in different modes.
Change-Id: I7708d61646a36bc0c35cfa91d441296eb49eff9a
(cherry picked from commit 897215d76ae2e7cbca63a505113f5d90ef892d81)
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index 519c1e2..1cb563f 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -451,10 +451,6 @@
         return nativeGetHandle(mNativeObject);
     }
 
-    public boolean getTransformToDisplayInverse() {
-        return nativeGetTransformToDisplayInverse(mNativeObject);
-    }
-
     /** flag the transaction as an animation */
     public static void setAnimationTransaction() {
         nativeSetAnimationTransaction();
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 6fbf49b..e2443bb 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -735,16 +735,6 @@
     return javaObjectForIBinder(env, ctrl->getHandle());
 }
 
-static jboolean nativeGetTransformToDisplayInverse(JNIEnv* env, jclass clazz, jlong nativeObject) {
-    bool out = false;
-    auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
-    status_t status = ctrl->getTransformToDisplayInverse(&out);
-    if (status != NO_ERROR) {
-        return false;
-    }
-    return out;
-}
-
 static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject tokenObject) {
     sp<IBinder> token(ibinderForJavaObject(env, tokenObject));
     if (token == NULL) return NULL;
@@ -854,8 +844,6 @@
             (void*)nativeSetOverrideScalingMode },
     {"nativeGetHandle", "(J)Landroid/os/IBinder;",
             (void*)nativeGetHandle },
-    {"nativeGetTransformToDisplayInverse", "(J)Z",
-     (void*)nativeGetTransformToDisplayInverse },
     {"nativeScreenshotToBuffer",
      "(Landroid/os/IBinder;Landroid/graphics/Rect;IIIIZZI)Landroid/graphics/GraphicBuffer;",
      (void*)nativeScreenshotToBuffer },
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index aa85574..ae413e5 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -894,9 +894,10 @@
         final int lastOrientation = mLastOrientation;
         final boolean oldAltOrientation = mAltOrientation;
         int rotation = mService.mPolicy.rotationForOrientationLw(lastOrientation, oldRotation);
-        final boolean rotateSeamlessly;
+        final boolean rotateSeamlessly = mService.mPolicy.shouldRotateSeamlessly(oldRotation,
+                rotation);
 
-        if (mService.mPolicy.shouldRotateSeamlessly(oldRotation, rotation)) {
+        if (rotateSeamlessly) {
             final WindowState seamlessRotated = getWindow((w) -> w.mSeamlesslyRotated);
             if (seamlessRotated != null) {
                 // We can't rotate (seamlessly or not) while waiting for the last seamless rotation
@@ -905,27 +906,6 @@
                 // window-removal.
                 return false;
             }
-
-            final WindowState cantSeamlesslyRotate = getWindow((w) ->
-                    w.isChildWindow() && w.isVisibleNow()
-                            && !w.mWinAnimator.mSurfaceController.getTransformToDisplayInverse());
-            if (cantSeamlesslyRotate != null) {
-                // In what can only be called an unfortunate workaround we require seamlessly
-                // rotated child windows to have the TRANSFORM_TO_DISPLAY_INVERSE flag. Due to
-                // limitations in the client API, there is no way for the client to set this flag in
-                // a race free fashion. If we seamlessly rotate a window which does not have this
-                // flag, but then gains it, we will get an incorrect visual result
-                // (rotated viewfinder). This means if we want to support seamlessly rotating
-                // windows which could gain this flag, we can't rotate windows without it. This
-                // limits seamless rotation in N to camera framework users, windows without
-                // children, and native code. This is unfortunate but having the camera work is our
-                // primary goal.
-                rotateSeamlessly = false;
-            } else {
-                rotateSeamlessly = true;
-            }
-        } else {
-            rotateSeamlessly = false;
         }
 
         // TODO: Implement forced rotation changes.
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 826fb45..88e0354 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -1926,57 +1926,26 @@
         DisplayContent.createRotationMatrix(deltaRotation, x, y, displayWidth, displayHeight,
                 transform);
 
-        // We have two cases:
-        //  1. Windows with NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY:
-        //     These windows never change buffer size when rotating. Rather the window manager
-        //     just updates the scaling factors to fit in the new coordinate system,
-        //     and SurfaceFlinger takes care of updating the buffer contents. So in this case
-        //     we just need we just need to update the scaling factors and things are seamless
-        //     already.
-        //  2. Other windows:
-        //     In this case, we need to apply a rotation matrix to the window. For example
-        //     if we have a portrait window and rotate to landscape, the window is still portrait
-        //     and now extends off the bottom of the screen (and only halfway across). Essentially we
-        //     apply a transform to display the current buffer at it's old position
-        //     (in the new coordinate space). We then freeze layer updates until the resize
-        //     occurs, at which point we undo, them.
-        if (w.isChildWindow() && mSurfaceController.getTransformToDisplayInverse()) {
-            frameRect.set(x, y, x + width, y + height);
-            transform.mapRect(frameRect);
+        // We just need to apply a rotation matrix to the window. For example
+        // if we have a portrait window and rotate to landscape, the window is still portrait
+        // and now extends off the bottom of the screen (and only halfway across). Essentially we
+        // apply a transform to display the current buffer at it's old position
+        // (in the new coordinate space). We then freeze layer updates until the resize
+        // occurs, at which point we undo, them.
+        mService.markForSeamlessRotation(w, true);
+        transform.getValues(mService.mTmpFloats);
 
-            final Rect parentWindowFrame = w.getParentWindow().mFrame;
-            w.mAttrs.x = (int) frameRect.left - parentWindowFrame.left;
-            w.mAttrs.y = (int) frameRect.top - parentWindowFrame.top;
-            w.mAttrs.width = (int) Math.ceil(frameRect.width());
-            w.mAttrs.height = (int) Math.ceil(frameRect.height());
-
-            w.setWindowScale(w.mRequestedWidth, w.mRequestedHeight);
-
-            w.applyGravityAndUpdateFrame(w.mContainingFrame, w.mDisplayFrame);
-            computeShownFrameLocked();
-            setSurfaceBoundariesLocked(false);
-
-            // The stack bounds will not yet be rotated at this point so setSurfaceBoundaries locked
-            // will crop us incorrectly. Overwrite the crop, exposing the full surface. By the next
-            // transaction this will be corrected.
-            cropRect.set(0, 0, w.mRequestedWidth, w.mRequestedWidth + w.mRequestedHeight);
-            mSurfaceController.setCropInTransaction(cropRect, false);
-        } else {
-            mService.markForSeamlessRotation(w, true);
-            transform.getValues(mService.mTmpFloats);
-
-            float DsDx = mService.mTmpFloats[Matrix.MSCALE_X];
-            float DtDx = mService.mTmpFloats[Matrix.MSKEW_Y];
-            float DtDy = mService.mTmpFloats[Matrix.MSKEW_X];
-            float DsDy = mService.mTmpFloats[Matrix.MSCALE_Y];
-            float nx = mService.mTmpFloats[Matrix.MTRANS_X];
-            float ny = mService.mTmpFloats[Matrix.MTRANS_Y];
-            mSurfaceController.setPositionInTransaction(nx, ny, false);
-            mSurfaceController.setMatrixInTransaction(DsDx * w.mHScale,
-                    DtDx * w.mVScale,
-                    DtDy * w.mHScale,
-                    DsDy * w.mVScale, false);
-        }
+        float DsDx = mService.mTmpFloats[Matrix.MSCALE_X];
+        float DtDx = mService.mTmpFloats[Matrix.MSKEW_Y];
+        float DtDy = mService.mTmpFloats[Matrix.MSKEW_X];
+        float DsDy = mService.mTmpFloats[Matrix.MSCALE_Y];
+        float nx = mService.mTmpFloats[Matrix.MTRANS_X];
+        float ny = mService.mTmpFloats[Matrix.MTRANS_Y];
+        mSurfaceController.setPositionInTransaction(nx, ny, false);
+        mSurfaceController.setMatrixInTransaction(DsDx * w.mHScale,
+                DtDx * w.mVScale,
+                DtDy * w.mHScale,
+                DsDy * w.mVScale, false);
     }
 
     void enableSurfaceTrace(FileDescriptor fd) {
diff --git a/services/core/java/com/android/server/wm/WindowSurfaceController.java b/services/core/java/com/android/server/wm/WindowSurfaceController.java
index b08bb70..d244bda 100644
--- a/services/core/java/com/android/server/wm/WindowSurfaceController.java
+++ b/services/core/java/com/android/server/wm/WindowSurfaceController.java
@@ -509,10 +509,6 @@
         return mSurfaceControl.getHandle();
     }
 
-    boolean getTransformToDisplayInverse() {
-        return mSurfaceControl.getTransformToDisplayInverse();
-    }
-
     void getSurface(Surface outSurface) {
         outSurface.copyFrom(mSurfaceControl);
     }