Merge "vndk-def: Fix template"
diff --git a/python-packages/adb/device.py b/python-packages/adb/device.py
index aafd28d..e0da8f5 100644
--- a/python-packages/adb/device.py
+++ b/python-packages/adb/device.py
@@ -51,7 +51,8 @@
     with open(os.devnull, 'wb') as devnull:
         subprocess.check_call([adb_path, 'start-server'], stdout=devnull,
                               stderr=devnull)
-    out = split_lines(subprocess.check_output([adb_path, 'devices']))
+    out = split_lines(
+        subprocess.check_output([adb_path, 'devices']).decode('utf-8'))
 
     # The first line of `adb devices` just says "List of attached devices", so
     # skip that.
@@ -118,7 +119,7 @@
                               stderr=devnull)
     try:
         serial = subprocess.check_output(
-            [adb_path, flag, 'get-serialno']).strip()
+            [adb_path, flag, 'get-serialno']).decode('utf-8').strip()
     except subprocess.CalledProcessError:
         raise RuntimeError('adb unexpectedly returned nonzero')
     if serial == 'unknown':
@@ -233,6 +234,7 @@
 
     adb_path = adb_path if adb_path is not None else ['adb']
     version_output = subprocess.check_output(adb_path + ['version'])
+    version_output = version_output.decode('utf-8')
     pattern = r'^Android Debug Bridge version 1.0.(\d+)$'
     result = re.match(pattern, version_output.splitlines()[0])
     if not result:
@@ -273,8 +275,8 @@
     @property
     def linesep(self):
         if self._linesep is None:
-            self._linesep = subprocess.check_output(self.adb_cmd +
-                                                    ['shell', 'echo'])
+            self._linesep = subprocess.check_output(
+                self.adb_cmd + ['shell', 'echo']).decode('utf-8')
         return self._linesep
 
     @property
@@ -326,7 +328,7 @@
     def _simple_call(self, cmd):
         logging.info(' '.join(self.adb_cmd + cmd))
         return _subprocess_check_output(
-            self.adb_cmd + cmd, stderr=subprocess.STDOUT)
+            self.adb_cmd + cmd, stderr=subprocess.STDOUT).decode('utf-8')
 
     def shell(self, cmd):
         """Calls `adb shell`
@@ -361,6 +363,8 @@
         p = _subprocess_Popen(
             cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         stdout, stderr = p.communicate()
+        stdout = stdout.decode('utf-8')
+        stderr = stderr.decode('utf-8')
         if self.has_shell_protocol():
             exit_code = p.returncode
         else:
diff --git a/samples/SimpleJNI/jni/Android.mk b/samples/SimpleJNI/jni/Android.mk
index 1c2589f..dc6390f 100644
--- a/samples/SimpleJNI/jni/Android.mk
+++ b/samples/SimpleJNI/jni/Android.mk
@@ -31,18 +31,15 @@
     native.cpp
 
 # All of the shared libraries we link against.
-LOCAL_SHARED_LIBRARIES := \
-    liblog
+LOCAL_LDLIBS := -llog
 
 # No static libraries.
 LOCAL_STATIC_LIBRARIES :=
 
-# Also need the JNI headers.
-LOCAL_C_INCLUDES += \
-    $(JNI_H_INCLUDE)
-
 LOCAL_CFLAGS := -Wall -Werror
 
-LOCAL_CXX_STL := none
+LOCAL_NDK_STL_VARIANT := none
+
+LOCAL_SDK_VERSION := current
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/samples/SimpleJNI/jni/native.cpp b/samples/SimpleJNI/jni/native.cpp
index dd322c4..cb52233 100644
--- a/samples/SimpleJNI/jni/native.cpp
+++ b/samples/SimpleJNI/jni/native.cpp
@@ -15,12 +15,18 @@
  */
 
 #define LOG_TAG "simplejni native.cpp"
-#include <utils/Log.h>
+#include <android/log.h>
 
 #include <stdio.h>
 
 #include "jni.h"
 
+#define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
+#define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
+#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+#define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
+#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
+
 static jint
 add(JNIEnv* /*env*/, jobject /*thiz*/, jint a, jint b) {
 int result = a + b;
diff --git a/vndk/tools/header-checker/tests/integration/c_and_cpp/include/reproducability_c.h b/vndk/tools/header-checker/tests/integration/c_and_cpp/include/reproducability_c.h
new file mode 100644
index 0000000..987f2c4
--- /dev/null
+++ b/vndk/tools/header-checker/tests/integration/c_and_cpp/include/reproducability_c.h
@@ -0,0 +1,3 @@
+struct ShouldRepro {
+  int a;
+};
diff --git a/vndk/tools/header-checker/tests/integration/c_and_cpp/repro_map.txt b/vndk/tools/header-checker/tests/integration/c_and_cpp/repro_map.txt
new file mode 100644
index 0000000..f3d04c0
--- /dev/null
+++ b/vndk/tools/header-checker/tests/integration/c_and_cpp/repro_map.txt
@@ -0,0 +1,4 @@
+libreproducability {
+  global:
+    repro;
+};
diff --git a/vndk/tools/header-checker/tests/integration/c_and_cpp/reproducability.c b/vndk/tools/header-checker/tests/integration/c_and_cpp/reproducability.c
new file mode 100644
index 0000000..3578434
--- /dev/null
+++ b/vndk/tools/header-checker/tests/integration/c_and_cpp/reproducability.c
@@ -0,0 +1,6 @@
+#include <reproducability_c.h>
+
+int repro(struct ShouldRepro *s) {
+  return s->a;
+}
+
diff --git a/vndk/tools/header-checker/tests/integration/cpp/gold/golden_1.cpp b/vndk/tools/header-checker/tests/integration/cpp/gold/golden_1.cpp
index e98d21d..60a3113 100644
--- a/vndk/tools/header-checker/tests/integration/cpp/gold/golden_1.cpp
+++ b/vndk/tools/header-checker/tests/integration/cpp/gold/golden_1.cpp
@@ -1,4 +1,5 @@
 #include<abstract_class.h>
+#include<additional_odr.h>
 
 SuperSpeaker *SuperSpeaker::CreateSuperSpeaker(int id) {
   // :)
diff --git a/vndk/tools/header-checker/tests/integration/cpp/gold/include/additional_odr.h b/vndk/tools/header-checker/tests/integration/cpp/gold/include/additional_odr.h
new file mode 100644
index 0000000..adb1caa
--- /dev/null
+++ b/vndk/tools/header-checker/tests/integration/cpp/gold/include/additional_odr.h
@@ -0,0 +1,5 @@
+#ifdef TEST_ODR
+class LowVolumeSpeaker {
+  int a;
+};
+#endif
diff --git a/vndk/tools/header-checker/tests/module.py b/vndk/tools/header-checker/tests/module.py
index 056f12e..bb6c1ae 100755
--- a/vndk/tools/header-checker/tests/module.py
+++ b/vndk/tools/header-checker/tests/module.py
@@ -160,6 +160,18 @@
         api = 'current',
     ),
     Module(
+        name = 'libgolden_cpp_odr',
+        srcs = ['integration/cpp/gold/golden_1.cpp',
+                'integration/cpp/gold/high_volume_speaker.cpp',
+                'integration/cpp/gold/low_volume_speaker.cpp',
+                ],
+        version_script = 'integration/cpp/gold/map.txt',
+        export_include_dirs = ['integration/cpp/gold/include'],
+        cflags = ['-DTEST_ODR'],
+        arch = '',
+        api = 'current',
+    ),
+    Module(
         name = 'libgolden_cpp_add_function',
         srcs = ['integration/cpp/gold/golden_1.cpp',
                 'integration/cpp/gold/high_volume_speaker.cpp',
diff --git a/vndk/tools/header-checker/tests/test.py b/vndk/tools/header-checker/tests/test.py
index f6a7a1f..eeed47e 100755
--- a/vndk/tools/header-checker/tests/test.py
+++ b/vndk/tools/header-checker/tests/test.py
@@ -150,6 +150,11 @@
         self.prepare_and_run_abi_diff_all_archs(
             "libgolden_cpp", "libgolden_cpp_return_type_diff", 8)
 
+    def test_libgolden_cpp_add_odr(self):
+        self.prepare_and_run_abi_diff_all_archs(
+            "libgolden_cpp", "libgolden_cpp_odr", 0,
+            ['-check-all-apis', '-allow-unreferenced-changes'])
+
     def test_libgolden_cpp_add_function(self):
         self.prepare_and_run_abi_diff_all_archs(
             "libgolden_cpp", "libgolden_cpp_add_function", 4)