Add force default orientation.

Devices can be configured to remain in their default landscape or
portrait orientation by setting config_forceDefaultOrientation true
in overlay/.../values/config.xml.

Activities that desire to run in the non-default orientation are
supported by creating a logical display within the physical display.
Transitions to and from the activity perform a crossfade rather than
the normal rotation animation.

Also, improve SurfaceTrace debug output.

Fixes bug 9695710.

Change-Id: I053e136cd2b9ae200028595f245b6ada5927cfe9
diff --git a/services/java/com/android/server/wm/BlackFrame.java b/services/java/com/android/server/wm/BlackFrame.java
index 774b165..737d854 100644
--- a/services/java/com/android/server/wm/BlackFrame.java
+++ b/services/java/com/android/server/wm/BlackFrame.java
@@ -22,7 +22,6 @@
 import android.graphics.PixelFormat;
 import android.graphics.Rect;
 import android.util.Slog;
-import android.view.Surface;
 import android.view.SurfaceControl;
 import android.view.SurfaceSession;
 
@@ -62,6 +61,10 @@
                             "  BLACK " + surface + ": CREATE layer=" + layer);
         }
 
+        void setAlpha(float alpha) {
+            surface.setAlpha(alpha);
+        }
+
         void setMatrix(Matrix matrix) {
             mTmpMatrix.setTranslate(left, top);
             mTmpMatrix.postConcat(matrix);
@@ -93,6 +96,8 @@
     final float[] mTmpFloats = new float[9];
     final BlackSurface[] mBlackSurfaces = new BlackSurface[4];
 
+    final boolean mForceDefaultOrientation;
+
     public void printTo(String prefix, PrintWriter pw) {
         pw.print(prefix); pw.print("Outer: "); mOuterRect.printShortString(pw);
                 pw.print(" / Inner: "); mInnerRect.printShortString(pw);
@@ -106,10 +111,12 @@
         }
     }
 
-    public BlackFrame(SurfaceSession session, Rect outer, Rect inner,
-            int layer, final int layerStack) throws SurfaceControl.OutOfResourcesException {
+    public BlackFrame(SurfaceSession session, Rect outer, Rect inner, int layer, int layerStack,
+            boolean forceDefaultOrientation) throws SurfaceControl.OutOfResourcesException {
         boolean success = false;
 
+        mForceDefaultOrientation = forceDefaultOrientation;
+
         mOuterRect = new Rect(outer);
         mInnerRect = new Rect(inner);
         try {
@@ -162,6 +169,14 @@
         }
     }
 
+    public void setAlpha(float alpha) {
+        for (int i=0; i<mBlackSurfaces.length; i++) {
+            if (mBlackSurfaces[i] != null) {
+                mBlackSurfaces[i].setAlpha(alpha);
+            }
+        }
+    }
+
     public void setMatrix(Matrix matrix) {
         for (int i=0; i<mBlackSurfaces.length; i++) {
             if (mBlackSurfaces[i] != null) {