hwc: add some logging

We are seeing errors where a device's hwcVsyncThread is not present for some
reason.  The surface flinger has not crashed, so either the thread never got
created, or it exited withouth throwing an error.  This patch adds some more
verbose on-error logging to the HWC as an attempt to verify the theory that the
thread does not get created, or fails in pthread_create.  While we're at it, we
add the same logging at pthread_create() for hwcUeventThread, as well.

Also, replace the lseek()+read() with a pread() combo in the vsync thread.

Change-Id: I555d786a7d66ff4ef1dbfd95947a7d9341e56f11
related-to-bug: 7305728
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp
index ef43f62..a7f58ea 100644
--- a/libhwcomposer/hwc_uevents.cpp
+++ b/libhwcomposer/hwc_uevents.cpp
@@ -29,6 +29,8 @@
 
 namespace qhwc {
 
+#define HWC_UEVENT_THREAD_NAME "hwcUeventThread"
+
 const char* MSMFB_HDMI_NODE = "fb1";
 
 static void handle_uevent(hwc_context_t* ctx, const char* udata, int len)
@@ -67,7 +69,7 @@
     int len = 0;
     static char udata[PAGE_SIZE];
     hwc_context_t * ctx = reinterpret_cast<hwc_context_t *>(param);
-    char thread_name[64] = "hwcUeventThread";
+    char thread_name[64] = HWC_UEVENT_THREAD_NAME;
     prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0);
     setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);
     uevent_init();
@@ -83,7 +85,14 @@
 void init_uevent_thread(hwc_context_t* ctx)
 {
     pthread_t uevent_thread;
-    pthread_create(&uevent_thread, NULL, uevent_loop, (void*) ctx);
+    int ret;
+
+    ALOGI("Initializing UEVENT Thread");
+    ret = pthread_create(&uevent_thread, NULL, uevent_loop, (void*) ctx);
+    if (ret) {
+        ALOGE("%s: failed to create %s: %s", __FUNCTION__,
+            HWC_UEVENT_THREAD_NAME, strerror(ret));
+    }
 }
 
 }; //namespace