shims: add libshim_sensorndkbridge from exynos9820-common

Change-Id: I9f964211782f3f9945d5791ddf19a2b83626cc49
diff --git a/shim/Android.mk b/shim/Android.mk
new file mode 100644
index 0000000..9253d91
--- /dev/null
+++ b/shim/Android.mk
@@ -0,0 +1,19 @@
+#
+# Copyright (C) 2020 The LineageOS 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/shim/sensorsndkbridge/ASensorManager.cpp b/shim/sensorsndkbridge/ASensorManager.cpp
new file mode 100644
index 0000000..0d059e6
--- /dev/null
+++ b/shim/sensorsndkbridge/ASensorManager.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2020 LineageOS 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 <ALooper.h>
+
+#define LOG_TAG "libshim_sensorndkbridge"
+#include <android-base/logging.h>
+
+using android::Mutex;
+
+static Mutex gLock;
+
+extern "C" ALooper *ALooper_forCamera() {
+    LOG(VERBOSE) << "ALooper_forCamera";
+    ALooper *sLooper = NULL;
+
+    Mutex::Autolock autoLock(gLock);
+    sLooper = new ALooper;
+
+    return sLooper;
+}
+
+extern "C" int ALooper_release_forCamera(ALooper *sLooper) {
+    if (sLooper != nullptr) {
+        Mutex::Autolock autoLock(gLock);
+        delete sLooper;
+    }
+
+    return 0;
+}
+
+extern "C" int ALooper_pollOnce_camera(ALooper *sLooper,
+                                       int timeoutMillis,
+                                       int* outFd,
+                                       int* outEvents,
+                                       void** outData) {
+    int res = sLooper->pollOnce(timeoutMillis, outFd, outEvents, outData);
+    LOG(VERBOSE) << "ALooper_pollOnce_camera => " << res;
+    return res;
+}
diff --git a/shim/sensorsndkbridge/Android.mk b/shim/sensorsndkbridge/Android.mk
new file mode 100644
index 0000000..bf598b4
--- /dev/null
+++ b/shim/sensorsndkbridge/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2020 LineageOS 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.
+
+LOCAL_PATH := $(call my-dir)
+
+### SENSORNDKBRIDGE
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := ASensorManager.cpp
+LOCAL_SHARED_LIBRARIES := \
+    libbase \
+    libsensorndkbridge
+LOCAL_MODULE := libshim_sensorndkbridge
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_VENDOR_MODULE := true
+
+LOCAL_C_INCLUDES += system/core/base/include
+LOCAL_C_INCLUDES += system/core/libutils/include
+LOCAL_C_INCLUDES += frameworks/hardware/interfaces/sensorservice/libsensorndkbridge
+
+include $(BUILD_SHARED_LIBRARY)