Merge "Add SyncState class for calendar provider."
diff --git a/include/ui/CameraParameters.h b/include/ui/CameraParameters.h
index 9e4e140..a5ea133 100644
--- a/include/ui/CameraParameters.h
+++ b/include/ui/CameraParameters.h
@@ -109,9 +109,10 @@
     // The height (in pixels) of EXIF thumbnail in Jpeg picture.
     // Example value: "384". Read/write.
     static const char KEY_JPEG_THUMBNAIL_HEIGHT[];
-    // Supported EXIF thumbnail sizes (width x height).
-    // Example value: "512x384,320x240". Read only.
-    static const char KEY_SUPPORTED_THUMBNAIL_SIZES[];
+    // Supported EXIF thumbnail sizes (width x height). 0x0 means not thumbnail
+    // in EXIF.
+    // Example value: "512x384,320x240,0x0". Read only.
+    static const char KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[];
     // The quality of the EXIF thumbnail in Jpeg picture. The range is 1 to 100,
     // with 100 being the best.
     // Example value: "90". Read/write.
diff --git a/include/ui/ISurface.h b/include/ui/ISurface.h
index b37a8ac..c7f181c 100644
--- a/include/ui/ISurface.h
+++ b/include/ui/ISurface.h
@@ -55,8 +55,11 @@
     class BufferHeap {
     public:
         enum {
-            /* rotate source image 90 degrees */
+            /* rotate source image */
+            ROT_0     = 0,
             ROT_90    = HAL_TRANSFORM_ROT_90,
+            ROT_180   = HAL_TRANSFORM_ROT_180,
+            ROT_270   = HAL_TRANSFORM_ROT_270,
         };
         BufferHeap();
         
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index 17db6f4..4d7bef8 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -444,12 +444,21 @@
         glLoadIdentity();
 
         // the texture's source is rotated
-        if (texture.transform == HAL_TRANSFORM_ROT_90) {
-            // TODO: handle the other orientations
-            glTranslatef(0, 1, 0);
-            glRotatef(-90, 0, 0, 1);
+        switch (texture.transform) {
+            case HAL_TRANSFORM_ROT_90:
+                glTranslatef(0, 1, 0);
+                glRotatef(-90, 0, 0, 1);
+                break;
+            case HAL_TRANSFORM_ROT_180:
+                glTranslatef(1, 1, 0);
+                glRotatef(-180, 0, 0, 1);
+                break;
+            case HAL_TRANSFORM_ROT_270:
+                glTranslatef(1, 0, 0);
+                glRotatef(-270, 0, 0, 1);
+                break;
         }
-        
+
         if (texture.NPOTAdjust) {
             glScalef(texture.wScale, texture.hScale, 1.0f);
         }
diff --git a/libs/ui/CameraParameters.cpp b/libs/ui/CameraParameters.cpp
index 8f1749d..2e0409b 100644
--- a/libs/ui/CameraParameters.cpp
+++ b/libs/ui/CameraParameters.cpp
@@ -36,7 +36,7 @@
 const char CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS[] = "picture-format-values";
 const char CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH[] = "jpeg-thumbnail-width";
 const char CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT[] = "jpeg-thumbnail-height";
-const char CameraParameters::KEY_SUPPORTED_THUMBNAIL_SIZES[] = "jpeg-thumbnail-size-values";
+const char CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[] = "jpeg-thumbnail-size-values";
 const char CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY[] = "jpeg-thumbnail-quality";
 const char CameraParameters::KEY_JPEG_QUALITY[] = "jpeg-quality";
 const char CameraParameters::KEY_ROTATION[] = "rotation";
diff --git a/libs/ui/Surface.cpp b/libs/ui/Surface.cpp
index 24ae27f..c7be05b 100644
--- a/libs/ui/Surface.cpp
+++ b/libs/ui/Surface.cpp
@@ -607,13 +607,21 @@
 status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn, bool blocking) 
 {
     if (mApiLock.tryLock() != NO_ERROR) {
-        LOGE("calling Surface::lock() from different threads!");
+        LOGE("calling Surface::lock from different threads!");
         CallStack stack;
         stack.update();
         stack.dump("Surface::lock called from different threads");
         return WOULD_BLOCK;
     }
+
+    /* Here we're holding mApiLock */
     
+    if (mLockedBuffer != 0) {
+        LOGE("Surface::lock failed, already locked");
+        mApiLock.unlock();
+        return INVALID_OPERATION;
+    }
+
     // we're intending to do software rendering from this point
     setUsage(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
 
@@ -682,8 +690,8 @@
 status_t Surface::unlockAndPost() 
 {
     if (mLockedBuffer == 0) {
-        LOGE("unlockAndPost failed, no locked buffer");
-        return BAD_VALUE;
+        LOGE("Surface::unlockAndPost failed, no locked buffer");
+        return INVALID_OPERATION;
     }
 
     status_t err = mLockedBuffer->unlock();