merge in jb-mr1-release history after reset to jb-mr1-dev
diff --git a/include/ui/Fence.h b/include/ui/Fence.h
index a8460c2..ff6cefe 100644
--- a/include/ui/Fence.h
+++ b/include/ui/Fence.h
@@ -60,14 +60,14 @@
     // before the fence signals then -ETIME is returned.  A timeout of
     // TIMEOUT_NEVER may be used to indicate that the call should wait
     // indefinitely for the fence to signal.
-    int wait(unsigned int timeout);
+    status_t wait(unsigned int timeout);
 
     // waitForever is a convenience function for waiting forever for a fence to
     // signal (just like wait(TIMEOUT_NEVER)), but issuing an error to the
     // system log and fence state to the kernel log if the wait lasts longer
     // than warningTimeout. The logname argument should be a string identifying
     // the caller and will be included in the log message.
-    int waitForever(unsigned int warningTimeout, const char* logname);
+    status_t waitForever(unsigned int warningTimeout, const char* logname);
 
     // TIMEOUT_NEVER may be passed to the wait method to indicate that it
     // should wait indefinitely for the fence to signal.
diff --git a/libs/ui/Fence.cpp b/libs/ui/Fence.cpp
index d2dbad2..d214b97 100644
--- a/libs/ui/Fence.cpp
+++ b/libs/ui/Fence.cpp
@@ -42,26 +42,27 @@
     }
 }
 
-int Fence::wait(unsigned int timeout) {
+status_t Fence::wait(unsigned int timeout) {
     ATRACE_CALL();
     if (mFenceFd == -1) {
         return NO_ERROR;
     }
-    return sync_wait(mFenceFd, timeout);
+    int err = sync_wait(mFenceFd, timeout);
+    return err < 0 ? -errno : status_t(NO_ERROR);
 }
 
-int Fence::waitForever(unsigned int warningTimeout, const char* logname) {
+status_t Fence::waitForever(unsigned int warningTimeout, const char* logname) {
     ATRACE_CALL();
     if (mFenceFd == -1) {
         return NO_ERROR;
     }
     int err = sync_wait(mFenceFd, warningTimeout);
-    if (err == -ETIME) {
+    if (err < 0 && errno == ETIME) {
         ALOGE("%s: fence %d didn't signal in %u ms", logname, mFenceFd,
                 warningTimeout);
         err = sync_wait(mFenceFd, TIMEOUT_NEVER);
     }
-    return err;
+    return err < 0 ? -errno : status_t(NO_ERROR);
 }
 
 sp<Fence> Fence::merge(const String8& name, const sp<Fence>& f1,
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index ff1af83..40631ee 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -233,7 +233,7 @@
         if (error == EGL_CONTEXT_LOST ||
                 mType == DisplayDevice::DISPLAY_PRIMARY) {
             LOG_ALWAYS_FATAL("eglSwapBuffers(%p, %p) failed with 0x%08x",
-                    mDisplay, mSurface, eglGetError());
+                    mDisplay, mSurface, error);
         }
     }
 }
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 8367417..17c67f9 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1212,12 +1212,6 @@
                                 state.viewport, state.frame);
                         hw->setDisplayName(state.displayName);
                         mDisplays.add(display, hw);
-                        if (hw->getDisplayType() < DisplayDevice::NUM_DISPLAY_TYPES) {
-                            // notify the system that this display is now up
-                            // (note onScreenAcquired() is safe to call from
-                            // here because we're in the main thread)
-                            onScreenAcquired(hw);
-                        }
                     }
                 }
             }