Re-enable frame dropping for non-auto timestamps

This change adds an entire field to note whether the timestamp was
auto-generated by Surface or supplied by the application.

The value is used when deciding whether or not to drop frames based
on buffer presentation timestamps.  If a desired presentation time
was set explicitly, BufferQueue will use that value to decide if a
frame should be dropped.  If the timestamp was generated by Surface
at the time the buffer was queued, the timestamp is ignored.

Bug 10151804

Change-Id: Ibd571a7578351063b813cbdad2ddbeed70655ba5
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp
index 033c2a6..65007fa 100644
--- a/libs/gui/BufferQueue.cpp
+++ b/libs/gui/BufferQueue.cpp
@@ -475,10 +475,12 @@
     uint32_t transform;
     int scalingMode;
     int64_t timestamp;
+    bool isAutoTimestamp;
     bool async;
     sp<Fence> fence;
 
-    input.deflate(&timestamp, &crop, &scalingMode, &transform, &async, &fence);
+    input.deflate(&timestamp, &isAutoTimestamp, &crop, &scalingMode, &transform,
+            &async, &fence);
 
     if (fence == NULL) {
         ST_LOGE("queueBuffer: fence is NULL");
@@ -558,6 +560,7 @@
         item.mTransform = transform;
         item.mScalingMode = scalingMode;
         item.mTimestamp = timestamp;
+        item.mIsAutoTimestamp = isAutoTimestamp;
         item.mFrameNumber = mFrameCounter;
         item.mBuf = buf;
         item.mFence = fence;
@@ -860,7 +863,12 @@
         //
         // NOTE: code assumes monotonic time values from the system clock are
         // positive.
-        while (false && mQueue.size() > 1) {
+
+        // Start by checking to see if we can drop frames.  We skip this check
+        // if the timestamps are being auto-generated by Surface -- if the
+        // app isn't generating timestamps explicitly, they probably don't
+        // want frames to be discarded based on them.
+        while (mQueue.size() > 1 && !mQueue[0].mIsAutoTimestamp) {
             // If entry[1] is timely, drop entry[0] (and repeat).  We apply
             // an additional criteria here: we only drop the earlier buffer if
             // our desiredPresent falls within +/- 1 second of the expected