AI 143320: am: CL 143171 am: CL 142873 fix [1732012] Only show screen rotation animation when triggered by sensor
  Original author: mathias
  Merged from: //branches/cupcake/...
  Original author: android-build
  Merged from: //branches/donutburger/...

Automated import of CL 143320
diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp
index 8499b67..de64f55 100644
--- a/libs/surfaceflinger/SurfaceFlinger.cpp
+++ b/libs/surfaceflinger/SurfaceFlinger.cpp
@@ -655,6 +655,7 @@
 
             const int dpy = 0;
             const int orientation = mCurrentState.orientation;
+            const uint32_t type = mCurrentState.orientationType;
             GraphicPlane& plane(graphicPlane(dpy));
             plane.setOrientation(orientation);
 
@@ -673,8 +674,8 @@
 
             mVisibleRegionsDirty = true;
             mDirtyRegion.set(hw.bounds());
-
-            mOrientationAnimation->onOrientationChanged();
+            mFreezeDisplayTime = 0;
+            mOrientationAnimation->onOrientationChanged(type);
         }
 
         if (mCurrentState.freezeDisplay != mDrawingState.freezeDisplay) {
@@ -1201,7 +1202,8 @@
     return NO_ERROR;
 }
 
-int SurfaceFlinger::setOrientation(DisplayID dpy, int orientation)
+int SurfaceFlinger::setOrientation(DisplayID dpy, 
+        int orientation, uint32_t flags)
 {
     if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
         return BAD_VALUE;
@@ -1209,6 +1211,7 @@
     Mutex::Autolock _l(mStateLock);
     if (mCurrentState.orientation != orientation) {
         if (uint32_t(orientation)<=eOrientation270 || orientation==42) {
+            mCurrentState.orientationType = flags;
             mCurrentState.orientation = orientation;
             setTransactionFlags(eTransactionNeeded);
             mTransactionCV.wait(mStateLock);