Add PRESENT_FENCE_IS_NOT_RELIABLE

Test: adb shell /data/nativetest/libgui_test/libgui_test
  --gtest_filter=*GetFrameTimestamps*
Bug: 36730849, 36887025

Change-Id: Ide992e4dda7840f7982237943256ea3019eda434
diff --git a/graphics/composer/2.1/IComposer.hal b/graphics/composer/2.1/IComposer.hal
index b3ac761..e2aa5cd 100644
--- a/graphics/composer/2.1/IComposer.hal
+++ b/graphics/composer/2.1/IComposer.hal
@@ -44,6 +44,12 @@
          * applying the color transform during its composition step.
          */
         SKIP_CLIENT_COLOR_TRANSFORM = 2,
+
+        /**
+         * Specifies that the present fence must not be used as an accurate
+         * representation of the actual present time of a frame.
+         */
+        PRESENT_FENCE_IS_NOT_RELIABLE = 3,
     };
 
     /**
diff --git a/graphics/composer/2.1/default/Hwc.cpp b/graphics/composer/2.1/default/Hwc.cpp
index 1497065..8ca0eb3 100644
--- a/graphics/composer/2.1/default/Hwc.cpp
+++ b/graphics/composer/2.1/default/Hwc.cpp
@@ -65,6 +65,12 @@
     }
 
     initCapabilities();
+    if (majorVersion >= 2 &&
+        hasCapability(Capability::PRESENT_FENCE_IS_NOT_RELIABLE)) {
+        ALOGE("Present fence must be reliable from HWC2 on.");
+        abort();
+    }
+
     initDispatch();
 }