Fix a few issues with NATIVE_WINDOW_TRANSFORM_HINT

- fixed uninitialized variable
- set hint to indentity when transform is too complex
- make sure FrameBufferNativeWindow doesn't fail on needed perform commands

Bug: 4487161
Change-Id: I7cb2b0869b72404732eca7cb2d145ff669e2ed9b
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index 1dc6cd2..986fc7e 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -55,6 +55,9 @@
     mQueryWidth = 0;
     mQueryHeight = 0;
     mQueryFormat = 0;
+    mDefaultWidth = 0;
+    mDefaultHeight = 0;
+    mTransformHint = 0;
     mConnectedToCpu = false;
 }
 
diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp
index 412552e..0e8ae61 100644
--- a/libs/ui/FramebufferNativeWindow.cpp
+++ b/libs/ui/FramebufferNativeWindow.cpp
@@ -310,35 +310,21 @@
         int operation, ...)
 {
     switch (operation) {
-        case NATIVE_WINDOW_SET_USAGE:
-            // TODO: we should implement this
-            return NO_ERROR;
         case NATIVE_WINDOW_CONNECT:
-            // TODO: we should implement this
-            return NO_ERROR;
         case NATIVE_WINDOW_DISCONNECT:
-            // TODO: we should implement this
-            return NO_ERROR;
-        case NATIVE_WINDOW_LOCK:
-            return INVALID_OPERATION;
-        case NATIVE_WINDOW_UNLOCK_AND_POST:
-            return INVALID_OPERATION;
-        case NATIVE_WINDOW_SET_CROP:
-            return INVALID_OPERATION;
-        case NATIVE_WINDOW_SET_BUFFER_COUNT:
-            // TODO: we should implement this
-            return INVALID_OPERATION;
+        case NATIVE_WINDOW_SET_USAGE:
         case NATIVE_WINDOW_SET_BUFFERS_GEOMETRY:
-            return INVALID_OPERATION;
-        case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM:
-            return INVALID_OPERATION;
-        case NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP:
-            return INVALID_OPERATION;
         case NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS:
-            return INVALID_OPERATION;
         case NATIVE_WINDOW_SET_BUFFERS_FORMAT:
-            // TODO: we should implement this
+        case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM:
+            // TODO: we should implement these
             return NO_ERROR;
+
+        case NATIVE_WINDOW_LOCK:
+        case NATIVE_WINDOW_UNLOCK_AND_POST:
+        case NATIVE_WINDOW_SET_CROP:
+        case NATIVE_WINDOW_SET_BUFFER_COUNT:
+        case NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP:
         case NATIVE_WINDOW_SET_SCALING_MODE:
             return INVALID_OPERATION;
     }
diff --git a/services/surfaceflinger/SurfaceTextureLayer.cpp b/services/surfaceflinger/SurfaceTextureLayer.cpp
index 11f61cc..40659d4 100644
--- a/services/surfaceflinger/SurfaceTextureLayer.cpp
+++ b/services/surfaceflinger/SurfaceTextureLayer.cpp
@@ -60,6 +60,10 @@
 
     sp<Layer> layer(mLayer.promote());
     if (layer != NULL) {
+        uint32_t orientation = layer->getOrientation();
+        if (orientation & Transform::ROT_INVALID) {
+            orientation = 0;
+        }
         *outTransform = layer->getOrientation();
     }