ndk: Add a test to check that prebuilt libraries work as expected.

Change-Id: I7c0683ac1ee50bb62cc0f7ac22e839f749ec1cdf
diff --git a/ndk/tests/prebuilt-library/jni/Android.mk b/ndk/tests/prebuilt-library/jni/Android.mk
new file mode 100644
index 0000000..88a7dd3
--- /dev/null
+++ b/ndk/tests/prebuilt-library/jni/Android.mk
@@ -0,0 +1,31 @@
+LOCAL_PATH := $(call my-dir)
+
+# Define BUILD_FOO=1 to rebuild libfoo.so from scratch, then
+# copy obj/local/armeabi/libfoo.so to jni/libfoo.so
+#
+ifneq ($(BUILD_FOO),)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := foo
+LOCAL_SRC_FILES := foo/foo.c
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/foo
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/foo
+include $(BUILD_SHARED_LIBRARY)
+
+else # not build libfoo.so, trying to use PREBUILT_SHARED_LIBRARY instead.
+
+# Note: the module is named foo-prebuilt, but the library is libfool.so !
+#
+include $(CLEAR_VARS)
+LOCAL_MODULE := foo-prebuilt
+LOCAL_SRC_FILES := $(LOCAL_PATH)/libfoo.so
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/foo
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := foo-user
+LOCAL_SRC_FILES := foo-user.c
+LOCAL_PREBUILTS := foo-prebuilt
+include $(BUILD_SHARED_LIBRARY)
+
+endif
diff --git a/ndk/tests/prebuilt-library/jni/foo-user.c b/ndk/tests/prebuilt-library/jni/foo-user.c
new file mode 100644
index 0000000..acc453e
--- /dev/null
+++ b/ndk/tests/prebuilt-library/jni/foo-user.c
@@ -0,0 +1,6 @@
+#include "foo.h"
+
+int main(void)
+{
+    return foo();
+}
diff --git a/ndk/tests/prebuilt-library/jni/foo/foo.c b/ndk/tests/prebuilt-library/jni/foo/foo.c
new file mode 100644
index 0000000..a4758ad
--- /dev/null
+++ b/ndk/tests/prebuilt-library/jni/foo/foo.c
@@ -0,0 +1,6 @@
+#include "foo.h"
+
+int foo(void)
+{
+    return 42;
+}
diff --git a/ndk/tests/prebuilt-library/jni/foo/foo.h b/ndk/tests/prebuilt-library/jni/foo/foo.h
new file mode 100644
index 0000000..5b5c8f2
--- /dev/null
+++ b/ndk/tests/prebuilt-library/jni/foo/foo.h
@@ -0,0 +1,6 @@
+#ifndef FOO_FOO_H
+#define FOO_FOO_H
+
+extern int  foo(void);
+
+#endif /* FOO_FOO_H */
diff --git a/ndk/tests/prebuilt-library/jni/libfoo.so b/ndk/tests/prebuilt-library/jni/libfoo.so
new file mode 100755
index 0000000..d5c7c37
--- /dev/null
+++ b/ndk/tests/prebuilt-library/jni/libfoo.so
Binary files differ