Merge "Revert "Revert "Update protobuf library from 2.3 to 2.6."""
diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c
index e3042eb..81cdd12 100644
--- a/cmds/dumpstate/utils.c
+++ b/cmds/dumpstate/utils.c
@@ -360,7 +360,7 @@
         }
 
         if (timeout_seconds && elapsed / NANOS_PER_SEC > timeout_seconds) {
-            printf("*** %s: Timed out after %ds (killing pid %d)\n", command, (int) elapsed, pid);
+            printf("*** %s: Timed out after %.3fs (killing pid %d)\n", command, (float) elapsed / NANOS_PER_SEC, pid);
             kill(pid, SIGTERM);
             return -1;
         }
diff --git a/libs/binder/tests/binderDriverInterfaceTest.cpp b/libs/binder/tests/binderDriverInterfaceTest.cpp
index acb7d49..315f349 100644
--- a/libs/binder/tests/binderDriverInterfaceTest.cpp
+++ b/libs/binder/tests/binderDriverInterfaceTest.cpp
@@ -58,7 +58,7 @@
                 BC_ENTER_LOOPER,
             };
             struct binder_write_read bwr = binder_write_read();
-            bwr.write_buffer = (intptr_t)bc;
+            bwr.write_buffer = (uintptr_t)bc;
             bwr.write_size = sizeof(bc);
             ret = ioctl(m_binderFd, BINDER_WRITE_READ, &bwr);
             EXPECT_EQ(0, ret);
@@ -111,10 +111,10 @@
             uint32_t br[32];
             struct binder_write_read bwr = binder_write_read();
             SCOPED_TRACE("TestReadEmpty");
-            bwr.read_buffer = (intptr_t)br;
+            bwr.read_buffer = (uintptr_t)br;
             bwr.read_size = sizeof(br);
             binderTestIoctlErr1(BINDER_WRITE_READ, &bwr, EAGAIN);
-            EXPECT_EQ(0, bwr.read_consumed);
+            EXPECT_EQ(0u, bwr.read_consumed);
             for (i = 0; i * sizeof(uint32_t) < bwr.read_consumed; i++) {
                 SCOPED_TRACE(testing::Message() << "i = " << i);
                 EXPECT_EQ(BR_NOOP, br[i]);
@@ -206,7 +206,7 @@
         0,
     };
     struct binder_write_read bwr = binder_write_read();
-    bwr.write_buffer = (intptr_t)bc;
+    bwr.write_buffer = (uintptr_t)bc;
     bwr.write_size = sizeof(bc);
     binderTestIoctl(BINDER_WRITE_READ, &bwr);
     EXPECT_EQ(sizeof(bc), bwr.write_consumed);
@@ -241,9 +241,9 @@
     } __attribute__((packed)) br;
     struct binder_write_read bwr = binder_write_read();
 
-    bwr.write_buffer = (intptr_t)&bc1;
+    bwr.write_buffer = (uintptr_t)&bc1;
     bwr.write_size = sizeof(bc1);
-    bwr.read_buffer = (intptr_t)&br;
+    bwr.read_buffer = (uintptr_t)&br;
     bwr.read_size = sizeof(br);
 
     {
@@ -264,12 +264,12 @@
     if (bwr.read_consumed > offsetof(typeof(br), cmd2))
         EXPECT_EQ(BR_REPLY, br.cmd2);
     if (bwr.read_consumed >= offsetof(typeof(br), pad)) {
-        EXPECT_EQ(0, br.arg2.target.ptr);
-        EXPECT_EQ(0, br.arg2.cookie);
-        EXPECT_EQ(0, br.arg2.code);
-        EXPECT_EQ(0, br.arg2.flags);
-        EXPECT_EQ(0, br.arg2.data_size);
-        EXPECT_EQ(0, br.arg2.offsets_size);
+        EXPECT_EQ(0u, br.arg2.target.ptr);
+        EXPECT_EQ(0u, br.arg2.cookie);
+        EXPECT_EQ(0u, br.arg2.code);
+        EXPECT_EQ(0u, br.arg2.flags);
+        EXPECT_EQ(0u, br.arg2.data_size);
+        EXPECT_EQ(0u, br.arg2.offsets_size);
 
         SCOPED_TRACE("3rd WriteRead");
 
@@ -283,7 +283,7 @@
             .arg1 = br.arg2.data.ptr.buffer,
         };
 
-        bwr.write_buffer = (intptr_t)&bc2;
+        bwr.write_buffer = (uintptr_t)&bc2;
         bwr.write_size = sizeof(bc2);
         bwr.write_consumed = 0;
         bwr.read_size = 0;
@@ -329,9 +329,9 @@
     } __attribute__((packed)) br;
     struct binder_write_read bwr = binder_write_read();
 
-    bwr.write_buffer = (intptr_t)&bc;
+    bwr.write_buffer = (uintptr_t)&bc;
     bwr.write_size = sizeof(bc);
-    bwr.read_buffer = (intptr_t)&br;
+    bwr.read_buffer = (uintptr_t)&br;
     bwr.read_size = sizeof(br);
 
     binderTestIoctl(BINDER_WRITE_READ, &bwr);
diff --git a/opengl/libagl/Android.mk b/opengl/libagl/Android.mk
index 64320cf..4b08749 100644
--- a/opengl/libagl/Android.mk
+++ b/opengl/libagl/Android.mk
@@ -31,7 +31,9 @@
 LOCAL_SRC_FILES_arm += fixed_asm.S iterators.S
 LOCAL_CFLAGS_arm += -fstrict-aliasing
 
+ifndef ARCH_MIPS_REV6
 LOCAL_SRC_FILES_mips += arch-mips/fixed_asm.S
+endif
 LOCAL_CFLAGS_mips += -fstrict-aliasing
 # The graphics code can generate division by zero
 LOCAL_CFLAGS_mips += -mno-check-zero-division
diff --git a/opengl/libagl/fp.cpp b/opengl/libagl/fp.cpp
index aea4449..a7a4f7b 100644
--- a/opengl/libagl/fp.cpp
+++ b/opengl/libagl/fp.cpp
@@ -19,7 +19,7 @@
 
 // ----------------------------------------------------------------------------
 
-#if !defined(__arm__) && !defined(__mips__)
+#if !(defined(__arm__) || (defined(__mips__) && !defined(__LP64__) && __mips_isa_rev < 6))
 GGLfixed gglFloatToFixed(float v) {   
     return GGLfixed(floorf(v * 65536.0f + 0.5f));
 }
diff --git a/opengl/libagl/matrix.h b/opengl/libagl/matrix.h
index 5bd717a..cafc119 100644
--- a/opengl/libagl/matrix.h
+++ b/opengl/libagl/matrix.h
@@ -74,7 +74,7 @@
         ); 
     return r;
 
-#elif defined(__mips__)
+#elif defined(__mips__) && !defined(__LP64__) && __mips_isa_rev < 6
 
     GLfixed res;
     int32_t t1,t2,t3;
@@ -160,7 +160,7 @@
         ); 
     return r;
     
-#elif defined(__mips__)
+#elif defined(__mips__)  && !defined(__LP64__) && __mips_isa_rev < 6
 
     GLfixed res;
     int32_t t1,t2;
diff --git a/services/inputflinger/Android.mk b/services/inputflinger/Android.mk
index 85edbe5..1af59a3 100644
--- a/services/inputflinger/Android.mk
+++ b/services/inputflinger/Android.mk
@@ -31,16 +31,13 @@
     libinput \
     liblog \
     libutils \
-	libui \
-	libhardware_legacy
+    libui \
+    libhardware_legacy
 
 
 # TODO: Move inputflinger to its own process and mark it hidden
 #LOCAL_CFLAGS += -fvisibility=hidden
 
-LOCAL_C_INCLUDES := \
-    external/openssl/include \
-
 LOCAL_CFLAGS += -Wno-unused-parameter
 
 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp
index 7a77c30..93ce010 100644
--- a/services/inputflinger/EventHub.cpp
+++ b/services/inputflinger/EventHub.cpp
@@ -858,7 +858,6 @@
                                     int(iev.time.tv_sec), int(iev.time.tv_usec));
                         }
 
-#ifdef HAVE_POSIX_CLOCKS
                         // Use the time specified in the event instead of the current time
                         // so that downstream code can get more accurate estimates of
                         // event dispatch latency from the time the event is enqueued onto
@@ -909,9 +908,6 @@
                                         event->when, time, now);
                             }
                         }
-#else
-                        event->when = now;
-#endif
                         event->deviceId = deviceId;
                         event->type = iev.type;
                         event->code = iev.code;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 8daf0f9..6a5a39e 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2359,18 +2359,15 @@
         result.appendFormat("Permission Denial: "
                 "can't dump SurfaceFlinger from pid=%d, uid=%d\n", pid, uid);
     } else {
-        // Try to get the main lock, but don't insist if we can't
+        // Try to get the main lock, but give up after one second
         // (this would indicate SF is stuck, but we want to be able to
         // print something in dumpsys).
-        int retry = 3;
-        while (mStateLock.tryLock()<0 && --retry>=0) {
-            usleep(1000000);
-        }
-        const bool locked(retry >= 0);
+        status_t err = mStateLock.timedLock(s2ns(1));
+        bool locked = (err == NO_ERROR);
         if (!locked) {
-            result.append(
-                    "SurfaceFlinger appears to be unresponsive, "
-                    "dumping anyways (no locks held)\n");
+            result.appendFormat(
+                    "SurfaceFlinger appears to be unresponsive (%s [%d]), "
+                    "dumping anyways (no locks held)\n", strerror(-err), err);
         }
 
         bool dumpAll = true;