Show build config in dumpsys SurfaceFlinger

This adds a line to the "dumpsys SurfaceFlinger" output that shows
build-time configuration values.

Example:
 Build configuration: [sf HAS_CONTEXT_PRIORITY] [libui] \
  [libgui USE_FENCE_SYNC]

Bug 7206633

Change-Id: Ibe1856b459d34a4be6ee83a4ebfd2807e6cc68a0
diff --git a/include/gui/GuiConfig.h b/include/gui/GuiConfig.h
new file mode 100644
index 0000000..b020ed9
--- /dev/null
+++ b/include/gui/GuiConfig.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_GUI_CONFIG_H
+#define ANDROID_GUI_CONFIG_H
+
+#include <utils/String8.h>
+
+namespace android {
+
+// Append the libgui configuration details to configStr.
+void appendGuiConfigString(String8& configStr);
+
+}; // namespace android
+
+#endif /*ANDROID_GUI_CONFIG_H*/
diff --git a/include/ui/UiConfig.h b/include/ui/UiConfig.h
new file mode 100644
index 0000000..fcf8ed5
--- /dev/null
+++ b/include/ui/UiConfig.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_UI_CONFIG_H
+#define ANDROID_UI_CONFIG_H
+
+#include <utils/String8.h>
+
+namespace android {
+
+// Append the libui configuration details to configStr.
+void appendUiConfigString(String8& configStr);
+
+}; // namespace android
+
+#endif /*ANDROID_UI_CONFIG_H*/
diff --git a/libs/gui/Android.mk b/libs/gui/Android.mk
index 282c25a..923845c 100644
--- a/libs/gui/Android.mk
+++ b/libs/gui/Android.mk
@@ -24,7 +24,8 @@
 	SurfaceComposerClient.cpp \
 	DummyConsumer.cpp \
 	CpuConsumer.cpp \
-	BufferItemConsumer.cpp
+	BufferItemConsumer.cpp \
+	GuiConfig.cpp
 
 LOCAL_SHARED_LIBRARIES := \
 	libbinder \
diff --git a/libs/gui/GuiConfig.cpp b/libs/gui/GuiConfig.cpp
new file mode 100644
index 0000000..0744e4f
--- /dev/null
+++ b/libs/gui/GuiConfig.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gui/GuiConfig.h>
+
+namespace android {
+
+void appendGuiConfigString(String8& configStr)
+{
+    static const char* config =
+            " [libgui"
+#ifdef USE_FENCE_SYNC
+            " USE_FENCE_SYNC"
+#endif
+#ifdef USE_NATIVE_FENCE_SYNC
+            " USE_NATIVE_FENCE_SYNC"
+#endif
+#ifdef ALLOW_DEQUEUE_CURRENT_BUFFER
+            " ALLOW_DEQUEUE_CURRENT_BUFFER"
+#endif
+            "]";
+    configStr.append(config);
+}
+
+}; // namespace android
diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk
index 80c28a1..0d2e44c 100644
--- a/libs/ui/Android.mk
+++ b/libs/ui/Android.mk
@@ -23,7 +23,8 @@
 	GraphicBufferMapper.cpp \
 	PixelFormat.cpp \
 	Rect.cpp \
-	Region.cpp
+	Region.cpp \
+	UiConfig.cpp
 
 LOCAL_SHARED_LIBRARIES := \
 	libcutils \
diff --git a/libs/ui/UiConfig.cpp b/libs/ui/UiConfig.cpp
new file mode 100644
index 0000000..8b2130e
--- /dev/null
+++ b/libs/ui/UiConfig.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ui/UiConfig.h>
+
+namespace android {
+
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+
+void appendUiConfigString(String8& configStr)
+{
+    static const char* config =
+            " [libui"
+#ifdef FRAMEBUFFER_FORCE_FORMAT
+            " FRAMEBUFFER_FORCE_FORMAT=" TOSTRING(FRAMEBUFFER_FORCE_FORMAT)
+#endif
+            "]";
+    configStr.append(config);
+}
+
+
+}; // namespace android
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index bc7552d..6bd300d 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -37,11 +37,13 @@
 
 #include <gui/BitTube.h>
 #include <gui/BufferQueue.h>
+#include <gui/GuiConfig.h>
 #include <gui/IDisplayEventConnection.h>
 #include <gui/SurfaceTextureClient.h>
 
 #include <ui/GraphicBufferAllocator.h>
 #include <ui/PixelFormat.h>
+#include <ui/UiConfig.h>
 
 #include <utils/misc.h>
 #include <utils/String8.h>
@@ -2045,6 +2047,26 @@
     }
 }
 
+/*static*/ void SurfaceFlinger::appendSfConfigString(String8& result)
+{
+    static const char* config =
+            " [sf"
+#ifdef NO_RGBX_8888
+            " NO_RGBX_8888"
+#endif
+#ifdef HAS_CONTEXT_PRIORITY
+            " HAS_CONTEXT_PRIORITY"
+#endif
+#ifdef NEVER_DEFAULT_TO_ASYNC_MODE
+            " NEVER_DEFAULT_TO_ASYNC_MODE"
+#endif
+#ifdef TARGET_DISABLE_TRIPLE_BUFFERING
+            " TARGET_DISABLE_TRIPLE_BUFFERING"
+#endif
+            "]";
+    result.append(config);
+}
+
 void SurfaceFlinger::dumpAllLocked(
         String8& result, char* buffer, size_t SIZE) const
 {
@@ -2056,6 +2078,15 @@
     nsecs_t inTransactionDuration = (inTransaction) ? now-inTransaction : 0;
 
     /*
+     * Dump library configuration.
+     */
+    result.append("Build configuration:");
+    appendSfConfigString(result);
+    appendUiConfigString(result);
+    appendGuiConfigString(result);
+    result.append("\n");
+
+    /*
      * Dump the visible layer list
      */
     const LayerVector& currentLayers = mCurrentState.layersSortedByZ;
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index c9877b2..0a019ce 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -382,6 +382,7 @@
         String8& result, char* buffer, size_t SIZE) const;
     void dumpAllLocked(String8& result, char* buffer, size_t SIZE) const;
     bool startDdmConnection();
+    static void appendSfConfigString(String8& result);
 
     /* ------------------------------------------------------------------------
      * Attributes