Remove libbase/liblog export headers from libfmq

Using libfmq shouldn't require dependency to libbase/liblog.
Moving the dependency to source file.

Test: pass
Test: camera works with fmq

Bug: 33241851
Change-Id: Iaafc4c4854839e4f454f482c4bc81f98d7976f4f
Merged-In: Iaafc4c4854839e4f454f482c4bc81f98d7976f4f
diff --git a/Android.bp b/Android.bp
index 216ee56..4636f2b 100644
--- a/Android.bp
+++ b/Android.bp
@@ -15,6 +15,7 @@
 cc_library_shared {
     name: "libfmq",
     shared_libs: [
+        "libbase",
         "liblog",
         "libcutils",
         "libutils",
@@ -22,13 +23,13 @@
     export_shared_lib_headers: [
         "libcutils",
         "libutils",
-        "liblog"
     ],
     export_include_dirs: ["include"],
     local_include_dirs: ["include"],
     clang: true,
     srcs: [
         "EventFlag.cpp",
+        "FmqInternal.cpp",
     ],
     cflags: [
         "-Wall",
diff --git a/FmqInternal.cpp b/FmqInternal.cpp
new file mode 100644
index 0000000..6b95def
--- /dev/null
+++ b/FmqInternal.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#define LOG_TAG "FMQ"
+#include <android-base/logging.h>
+
+namespace android {
+namespace hardware {
+namespace details {
+
+void check(bool exp) {
+    CHECK(exp);
+}
+
+void logError(const std::string &message) {
+    LOG(ERROR) << message;
+}
+
+}  // namespace details
+}  // namespace hardware
+}  // namespace android
diff --git a/include/fmq/MessageQueue.h b/include/fmq/MessageQueue.h
index 6f315b2..e80348d 100644
--- a/include/fmq/MessageQueue.h
+++ b/include/fmq/MessageQueue.h
@@ -17,7 +17,6 @@
 #ifndef HIDL_MQ_H
 #define HIDL_MQ_H
 
-#include <android-base/logging.h>
 #include <atomic>
 #include <cutils/ashmem.h>
 #include <fmq/EventFlag.h>
@@ -30,6 +29,11 @@
 namespace android {
 namespace hardware {
 
+namespace details {
+void check(bool exp);
+void logError(const std::string &message);
+}  // namespace details
+
 template <typename T, MQFlavor flavor>
 struct MessageQueue {
     typedef MQDescriptor<T, flavor> Descriptor;
@@ -593,11 +597,11 @@
         mReadPtr = new (std::nothrow) std::atomic<uint64_t>;
     }
 
-    CHECK(mReadPtr != nullptr);
+    details::check(mReadPtr != nullptr);
 
     mWritePtr =
             reinterpret_cast<std::atomic<uint64_t>*>(mapGrantorDescr(Descriptor::WRITEPTRPOS));
-    CHECK(mWritePtr != nullptr);
+    details::check(mWritePtr != nullptr);
 
     if (resetPointers) {
         mReadPtr->store(0, std::memory_order_release);
@@ -608,7 +612,7 @@
     }
 
     mRing = reinterpret_cast<uint8_t*>(mapGrantorDescr(Descriptor::DATAPTRPOS));
-    CHECK(mRing != nullptr);
+    details::check(mRing != nullptr);
 
     mEvFlagWord = static_cast<std::atomic<uint32_t>*>(mapGrantorDescr(Descriptor::EVFLAGWORDPOS));
     if (mEvFlagWord != nullptr) {
@@ -804,7 +808,7 @@
                                        true /* retry on spurious wake */);
 
         if (status != android::TIMED_OUT && status != android::NO_ERROR) {
-            ALOGE("Unexpected error code from EventFlag Wait write %d", status);
+            details::logError("Unexpected error code from EventFlag Wait status " + std::to_string(status));
             break;
         }
 
@@ -919,7 +923,7 @@
                                        true /* retry on spurious wake */);
 
         if (status != android::TIMED_OUT && status != android::NO_ERROR) {
-            ALOGE("Unexpected error code from EventFlag Wait status %d", status);
+            details::logError("Unexpected error code from EventFlag Wait status " + std::to_string(status));
             break;
         }