split Surface in two classes: SurfaceControl and Surface

SurfaceControl is the window manager side; it can
control the attributes of a surface but cannot push buffers
to it. Surface on the other hand is the application (producer)
side and is used to push buffers to the surface.

Change-Id: Ib6754c968924e87e8dd02a2073c7a447f729f4dd
diff --git a/services/java/com/android/server/wm/BlackFrame.java b/services/java/com/android/server/wm/BlackFrame.java
index 5b77b20..a197840 100644
--- a/services/java/com/android/server/wm/BlackFrame.java
+++ b/services/java/com/android/server/wm/BlackFrame.java
@@ -23,6 +23,7 @@
 import android.graphics.Rect;
 import android.util.Slog;
 import android.view.Surface;
+import android.view.SurfaceControl;
 import android.view.SurfaceSession;
 
 /**
@@ -33,7 +34,7 @@
         final int left;
         final int top;
         final int layer;
-        final Surface surface;
+        final SurfaceControl surface;
 
         BlackSurface(SurfaceSession session, int layer, int l, int t, int r, int b, int layerStack)
                 throws Surface.OutOfResourcesException {
@@ -42,13 +43,17 @@
             this.layer = layer;
             int w = r-l;
             int h = b-t;
-            if (WindowManagerService.DEBUG_SURFACE_TRACE) {
-                surface = new WindowStateAnimator.SurfaceTrace(session, "BlackSurface("
-                        + l + ", " + t + ")",
-                        w, h, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM | Surface.HIDDEN);
-            } else {
-                surface = new Surface(session, "BlackSurface",
-                        w, h, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM | Surface.HIDDEN);
+            try {
+                if (WindowManagerService.DEBUG_SURFACE_TRACE) {
+                    surface = new WindowStateAnimator.SurfaceTrace(session, "BlackSurface("
+                            + l + ", " + t + ")",
+                            w, h, PixelFormat.OPAQUE, SurfaceControl.FX_SURFACE_DIM | SurfaceControl.HIDDEN);
+                } else {
+                    surface = new SurfaceControl(session, "BlackSurface",
+                            w, h, PixelFormat.OPAQUE, SurfaceControl.FX_SURFACE_DIM | SurfaceControl.HIDDEN);
+                }
+            } catch (SurfaceControl.OutOfResourcesException e) {
+                throw new Surface.OutOfResourcesException(e.getMessage());
             }
             surface.setAlpha(1);
             surface.setLayerStack(layerStack);