Merge "Reject unsorted cmap entries. DO NOT MERGE am: 891e1569fa  -s ours" into lmp-mr1-dev am: abc4ac75da am: 33f42da9a9  -s ours am: a02dccd656 am: e4d2aeec0e am: 0fb4dfadd6 am: 5bc8e2aad7  -s ours am: 85f8b08e86 am: c741c242b6 am: 3c3c4a9c3c am: 5b013a6193 am: fa5c0e9773  -s ours
am: d6d6828f16

Change-Id: Ifb8649cb07baf52fd59f5ae6d630622c34a5891e
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..e875a17
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,11 @@
+cc_library_headers {
+    name: "libminikin_headers",
+    host_supported: true,
+    export_include_dirs: ["include"],
+}
+
+subdirs = [
+    "app",
+    "libs/minikin",
+    "tests",
+]
diff --git a/app/Android.bp b/app/Android.bp
new file mode 100644
index 0000000..e8085c1
--- /dev/null
+++ b/app/Android.bp
@@ -0,0 +1,30 @@
+// Copyright (C) 2015 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.
+
+// see how_to_run.txt for instructions on running these tests
+
+cc_binary_host {
+    name: "hyphtool",
+
+    static_libs: ["libminikin"],
+
+    // Shared libraries which are dependencies of minikin; these are not automatically
+    // pulled in by the build system (and thus sadly must be repeated).
+    shared_libs: [
+        "liblog",
+        "libicuuc",
+    ],
+
+    srcs: ["HyphTool.cpp"],
+}
diff --git a/app/Android.mk b/app/Android.mk
deleted file mode 100644
index 23305b7..0000000
--- a/app/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2015 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.
-
-# see how_to_run.txt for instructions on running these tests
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := hyphtool
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_STATIC_LIBRARIES := libminikin_host
-
-# Shared libraries which are dependencies of minikin; these are not automatically
-# pulled in by the build system (and thus sadly must be repeated).
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libicuuc
-
-LOCAL_SRC_FILES += \
-    HyphTool.cpp
-
-include $(BUILD_HOST_EXECUTABLE)
diff --git a/libs/minikin/Android.bp b/libs/minikin/Android.bp
new file mode 100644
index 0000000..c0fbbea
--- /dev/null
+++ b/libs/minikin/Android.bp
@@ -0,0 +1,87 @@
+// Copyright (C) 2013 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.
+
+cc_library_headers {
+    name: "libminikin-headers-for-tests",
+    export_include_dirs: ["."],
+    shared_libs: ["libharfbuzz_ng"],
+    export_shared_lib_headers: ["libharfbuzz_ng"],
+}
+
+cc_library {
+    name: "libminikin",
+    host_supported: true,
+    srcs: [
+        "Hyphenator.cpp",
+    ],
+    target: {
+        android: {
+            srcs: [
+                "CmapCoverage.cpp",
+                "Emoji.cpp",
+                "FontCollection.cpp",
+                "FontFamily.cpp",
+                "FontLanguage.cpp",
+                "FontLanguageListCache.cpp",
+                "FontUtils.cpp",
+                "GraphemeBreak.cpp",
+                "HbFontCache.cpp",
+                "Layout.cpp",
+                "LayoutUtils.cpp",
+                "LineBreaker.cpp",
+                "Measurement.cpp",
+                "MinikinInternal.cpp",
+                "MinikinFont.cpp",
+                "SparseBitSet.cpp",
+                "WordBreaker.cpp",
+            ],
+            shared_libs: [
+                "libharfbuzz_ng",
+                "libft2",
+                "libz",
+                "libutils",
+            ],
+            // TODO: clean up Minikin so it doesn't need the freetype include
+            export_shared_lib_headers: ["libft2"],
+
+            sanitize: {
+                misc_undefined: [
+                    "signed-integer-overflow",
+                    // b/26432628.
+                    //"unsigned-integer-overflow",
+                ],
+            },
+        },
+    },
+    cppflags: [
+        "-Werror",
+        "-Wall",
+        "-Wextra",
+    ],
+    product_variables: {
+        debuggable: {
+            // Enable race detection on eng and userdebug build.
+            cppflags: ["-DENABLE_RACE_DETECTION"],
+        },
+    },
+    shared_libs: [
+        "liblog",
+        "libicuuc",
+    ],
+    header_libs: ["libminikin_headers"],
+    export_header_lib_headers: ["libminikin_headers"],
+    export_shared_lib_headers: ["libicuuc"],
+
+    clang: true,
+}
diff --git a/libs/minikin/Android.mk b/libs/minikin/Android.mk
deleted file mode 100644
index bb6234a..0000000
--- a/libs/minikin/Android.mk
+++ /dev/null
@@ -1,102 +0,0 @@
-# Copyright (C) 2013 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-include $(CLEAR_VARS)
-minikin_src_files := \
-    CmapCoverage.cpp \
-    Emoji.cpp \
-    FontCollection.cpp \
-    FontFamily.cpp \
-    FontLanguage.cpp \
-    FontLanguageListCache.cpp \
-    FontUtils.cpp \
-    GraphemeBreak.cpp \
-    HbFontCache.cpp \
-    Hyphenator.cpp \
-    Layout.cpp \
-    LayoutUtils.cpp \
-    LineBreaker.cpp \
-    Measurement.cpp \
-    MinikinInternal.cpp \
-    MinikinFont.cpp \
-    SparseBitSet.cpp \
-    WordBreaker.cpp
-
-minikin_c_includes := \
-    external/harfbuzz_ng/src \
-    frameworks/minikin/include \
-    $(intermediates)
-
-minikin_shared_libraries := \
-    libharfbuzz_ng \
-    libft2 \
-    liblog \
-    libz \
-    libicuuc \
-    libutils
-
-ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
-# Enable race detection on eng and userdebug build.
-enable_race_detection := -DENABLE_RACE_DETECTION
-else
-enable_race_detection :=
-endif
-
-LOCAL_MODULE := libminikin
-LOCAL_EXPORT_C_INCLUDE_DIRS := frameworks/minikin/include
-LOCAL_SRC_FILES := $(minikin_src_files)
-LOCAL_C_INCLUDES := $(minikin_c_includes)
-LOCAL_CPPFLAGS += -Werror -Wall -Wextra $(enable_race_detection)
-LOCAL_SHARED_LIBRARIES := $(minikin_shared_libraries)
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-# b/26432628.
-#LOCAL_SANITIZE += unsigned-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libminikin
-LOCAL_MODULE_TAGS := optional
-LOCAL_EXPORT_C_INCLUDE_DIRS := frameworks/minikin/include
-LOCAL_SRC_FILES := $(minikin_src_files)
-LOCAL_C_INCLUDES := $(minikin_c_includes)
-LOCAL_CPPFLAGS += -Werror -Wall -Wextra $(enable_race_detection)
-LOCAL_SHARED_LIBRARIES := $(minikin_shared_libraries)
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-# b/26432628.
-#LOCAL_SANITIZE += unsigned-integer-overflow
-
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-
-# Reduced library (currently just hyphenation) for host
-
-LOCAL_MODULE := libminikin_host
-LOCAL_MODULE_TAGS := optional
-LOCAL_EXPORT_C_INCLUDE_DIRS := frameworks/minikin/include
-LOCAL_C_INCLUDES := $(minikin_c_includes)
-LOCAL_CPPFLAGS += -Werror -Wall -Wextra $(enable_race_detection)
-LOCAL_SHARED_LIBRARIES := liblog libicuuc
-
-LOCAL_SRC_FILES := Hyphenator.cpp
-
-include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/libs/minikin/LineBreaker.cpp b/libs/minikin/LineBreaker.cpp
index e75c7bf..d247644 100644
--- a/libs/minikin/LineBreaker.cpp
+++ b/libs/minikin/LineBreaker.cpp
@@ -400,7 +400,6 @@
     size_t active = 0;
     size_t nCand = mCandidates.size();
     float width = mLineWidths.getLineWidth(0);
-    float shortLineFactor = mJustified ? 0.75f : 0.5f;
     float maxShrink = mJustified ? SHRINKABILITY * getSpaceWidth() : 0.0f;
 
     // "i" iterates through candidates for the end of the line.
@@ -447,9 +446,6 @@
             } else if (atEnd && mStrategy != kBreakStrategy_Balanced) {
                 // increase penalty for hyphen on last line
                 additionalPenalty = LAST_LINE_PENALTY_MULTIPLIER * mCandidates[j].penalty;
-                // Penalize very short (< 1 - shortLineFactor of total width) lines.
-                float underfill = delta - shortLineFactor * width;
-                widthScore = underfill > 0 ? underfill * underfill : 0;
             } else {
                 widthScore = delta * delta;
                 if (delta < 0) {
diff --git a/tests/Android.bp b/tests/Android.bp
new file mode 100644
index 0000000..ddc5012
--- /dev/null
+++ b/tests/Android.bp
@@ -0,0 +1,33 @@
+filegroup {
+    name: "minikin-test-data",
+    srcs: [
+        "data/Bold.ttf",
+        "data/BoldItalic.ttf",
+        "data/ColorEmojiFont.ttf",
+        "data/ColorTextMixedEmojiFont.ttf",
+        "data/Emoji.ttf",
+        "data/Italic.ttf",
+        "data/Ja.ttf",
+        "data/Ko.ttf",
+        "data/MultiAxis.ttf",
+        "data/NoCmapFormat14.ttf",
+        "data/NoGlyphFont.ttf",
+        "data/Regular.ttf",
+        "data/TextEmojiFont.ttf",
+        "data/UnicodeBMPOnly.ttf",
+        "data/UnicodeBMPOnly2.ttf",
+        "data/UnicodeUCS4.ttf",
+        "data/VariationSelectorTest-Regular.ttf",
+        "data/ZhHans.ttf",
+        "data/ZhHant.ttf",
+        "data/emoji.xml",
+        "data/itemize.xml",
+    ],
+}
+
+subdirs = [
+    "perftests",
+    "stresstest",
+    "unittest",
+    "util",
+]
diff --git a/tests/perftests/Android.bp b/tests/perftests/Android.bp
new file mode 100644
index 0000000..f8847ac
--- /dev/null
+++ b/tests/perftests/Android.bp
@@ -0,0 +1,49 @@
+//
+// 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.
+//
+
+cc_benchmark {
+    name: "minikin_perftests",
+    test_suites: ["device-tests"],
+    cppflags: [
+        "-Werror",
+        "-Wall",
+        "-Wextra",
+    ],
+    srcs: [
+        "FontCollection.cpp",
+        "FontFamily.cpp",
+        "FontLanguage.cpp",
+        "GraphemeBreak.cpp",
+        "Hyphenator.cpp",
+        "WordBreaker.cpp",
+        "main.cpp",
+    ],
+
+    header_libs: ["libminikin-headers-for-tests"],
+
+    static_libs: [
+        "libminikin-tests-util",
+        "libminikin",
+        "libxml2",
+    ],
+
+    shared_libs: [
+        "libharfbuzz_ng",
+        "libicuuc",
+        "liblog",
+        "libskia",
+    ],
+}
diff --git a/tests/perftests/Android.mk b/tests/perftests/Android.mk
deleted file mode 100644
index c60123a..0000000
--- a/tests/perftests/Android.mk
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-perftest_src_files := \
-  ../util/FileUtils.cpp \
-  ../util/FontTestUtils.cpp \
-  ../util/MinikinFontForTest.cpp \
-  ../util/UnicodeUtils.cpp \
-  FontCollection.cpp \
-  FontFamily.cpp \
-  FontLanguage.cpp \
-  GraphemeBreak.cpp \
-  Hyphenator.cpp \
-  WordBreaker.cpp \
-  main.cpp
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := minikin_perftests
-LOCAL_CPPFLAGS := -Werror -Wall -Wextra
-LOCAL_SRC_FILES := $(perftest_src_files)
-LOCAL_STATIC_LIBRARIES := \
-  libminikin \
-  libxml2
-
-LOCAL_SHARED_LIBRARIES := \
-  libharfbuzz_ng \
-  libicuuc \
-  liblog \
-  libskia
-
-LOCAL_C_INCLUDES := \
-  $(LOCAL_PATH)/../ \
-  $(LOCAL_PATH)/../../libs/minikin \
-  external/harfbuzz_ng/src \
-  external/libxml2/include
-
-include $(BUILD_NATIVE_BENCHMARK)
diff --git a/tests/perftests/AndroidTest.xml b/tests/perftests/AndroidTest.xml
new file mode 100644
index 0000000..dcbdcf1
--- /dev/null
+++ b/tests/perftests/AndroidTest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+<configuration description="Config for minikin_perftests">
+    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+        <option name="cleanup" value="true" />
+        <option name="push" value="minikin_perftests->/data/benchmarktest/minikin_perftests" />
+    </target_preparer>
+    <option name="test-suite-tag" value="apct" />
+    <test class="com.android.tradefed.testtype.GoogleBenchmarkTest" >
+        <option name="native-benchmark-device-path" value="/data/benchmarktest" />
+        <option name="benchmark-module-name" value="minikin_perftests" />
+    </test>
+</configuration>
diff --git a/tests/perftests/FontCollection.cpp b/tests/perftests/FontCollection.cpp
index fd95cf1..d0fdc6e 100644
--- a/tests/perftests/FontCollection.cpp
+++ b/tests/perftests/FontCollection.cpp
@@ -18,8 +18,8 @@
 #include <memory>
 
 #include <minikin/FontCollection.h>
-#include <util/FontTestUtils.h>
-#include <util/UnicodeUtils.h>
+#include <FontTestUtils.h>
+#include <UnicodeUtils.h>
 #include <MinikinInternal.h>
 
 namespace minikin {
@@ -78,7 +78,7 @@
             getFontCollection(SYSTEM_FONT_PATH, SYSTEM_FONT_XML));
 
     size_t testIndex = state.range(0);
-    state.SetLabel("Itemize: " + ITEMIZE_TEST_CASES[testIndex].labelText);
+    state.SetLabel(("Itemize: " + ITEMIZE_TEST_CASES[testIndex].labelText).c_str());
 
     uint16_t buffer[64];
     size_t utf16_length = 0;
diff --git a/tests/perftests/GraphemeBreak.cpp b/tests/perftests/GraphemeBreak.cpp
index 6d6cf5b..830586f 100644
--- a/tests/perftests/GraphemeBreak.cpp
+++ b/tests/perftests/GraphemeBreak.cpp
@@ -18,7 +18,7 @@
 #include <cutils/log.h>
 
 #include "minikin/GraphemeBreak.h"
-#include "util/UnicodeUtils.h"
+#include "UnicodeUtils.h"
 
 namespace minikin {
 
diff --git a/tests/perftests/Hyphenator.cpp b/tests/perftests/Hyphenator.cpp
index 2107e05..ae62498 100644
--- a/tests/perftests/Hyphenator.cpp
+++ b/tests/perftests/Hyphenator.cpp
@@ -16,8 +16,8 @@
 #include <benchmark/benchmark.h>
 
 #include <minikin/Hyphenator.h>
-#include <util/FileUtils.h>
-#include <util/UnicodeUtils.h>
+#include <FileUtils.h>
+#include <UnicodeUtils.h>
 
 namespace minikin {
 
diff --git a/tests/perftests/WordBreaker.cpp b/tests/perftests/WordBreaker.cpp
index 6758cf9..f9ef214 100644
--- a/tests/perftests/WordBreaker.cpp
+++ b/tests/perftests/WordBreaker.cpp
@@ -16,7 +16,7 @@
 #include <benchmark/benchmark.h>
 
 #include "minikin/WordBreaker.h"
-#include "util/UnicodeUtils.h"
+#include "UnicodeUtils.h"
 
 namespace minikin {
 
diff --git a/tests/stresstest/Android.bp b/tests/stresstest/Android.bp
new file mode 100644
index 0000000..d91007a
--- /dev/null
+++ b/tests/stresstest/Android.bp
@@ -0,0 +1,50 @@
+// Copyright (C) 2017 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.
+
+// see how_to_run.txt for instructions on running these tests
+
+cc_test {
+    name: "minikin_stress_tests",
+
+    header_libs: ["libminikin-headers-for-tests"],
+
+    static_libs: [
+        "libminikin-tests-util",
+        "libminikin",
+        "libxml2",
+    ],
+
+    // Shared libraries which are dependencies of minikin; these are not automatically
+    // pulled in by the build system (and thus sadly must be repeated).
+    shared_libs: [
+        "libskia",
+        "libft2",
+        "libharfbuzz_ng",
+        "libicuuc",
+        "liblog",
+        "libutils",
+        "libz",
+    ],
+
+    srcs: [
+	"FontFamilyTest.cpp",
+        "MultithreadTest.cpp",
+    ],
+
+    cppflags: [
+        "-Werror",
+        "-Wall",
+        "-Wextra",
+    ],
+}
diff --git a/tests/stresstest/Android.mk b/tests/stresstest/Android.mk
deleted file mode 100644
index b655a74..0000000
--- a/tests/stresstest/Android.mk
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright (C) 2017 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.
-
-# see how_to_run.txt for instructions on running these tests
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_TEST_DATA := $(foreach f,$(LOCAL_TEST_DATA),frameworks/minikin/tests:$(f))
-
-LOCAL_MODULE := minikin_stress_tests
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE_CLASS := NATIVE_TESTS
-
-LOCAL_STATIC_LIBRARIES := libminikin
-
-# Shared libraries which are dependencies of minikin; these are not automatically
-# pulled in by the build system (and thus sadly must be repeated).
-
-LOCAL_SHARED_LIBRARIES := \
-    libskia \
-    libft2 \
-    libharfbuzz_ng \
-    libicuuc \
-    liblog \
-    libutils \
-    libz
-
-LOCAL_STATIC_LIBRARIES += \
-    libxml2
-
-LOCAL_SRC_FILES += \
-    ../util/FontTestUtils.cpp \
-    ../util/MinikinFontForTest.cpp \
-    FontFamilyTest.cpp \
-    MultithreadTest.cpp \
-
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/../../libs/minikin/ \
-    $(LOCAL_PATH)/../util \
-    external/libxml2/include \
-
-LOCAL_CPPFLAGS += -Werror -Wall -Wextra
-
-include $(BUILD_NATIVE_TEST)
diff --git a/tests/unittest/Android.bp b/tests/unittest/Android.bp
new file mode 100644
index 0000000..2353d4c
--- /dev/null
+++ b/tests/unittest/Android.bp
@@ -0,0 +1,74 @@
+// Copyright (C) 2015 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.
+
+// see how_to_run.txt for instructions on running these tests
+
+cc_test {
+    name: "minikin_tests",
+    test_suites: ["device-tests"],
+    data: [":minikin-test-data"],
+
+    header_libs: ["libminikin-headers-for-tests"],
+
+    static_libs: [
+        "libminikin-tests-util",
+        "libminikin",
+        "libxml2",
+    ],
+
+    // Shared libraries which are dependencies of minikin; these are not automatically
+    // pulled in by the build system (and thus sadly must be repeated).
+    shared_libs: [
+        "libskia",
+        "libft2",
+        "libharfbuzz_ng",
+        "libicuuc",
+        "liblog",
+        "libutils",
+        "libz",
+    ],
+
+    srcs: [
+        "CmapCoverageTest.cpp",
+        "EmojiTest.cpp",
+        "FontCollectionTest.cpp",
+        "FontCollectionItemizeTest.cpp",
+        "FontFamilyTest.cpp",
+        "FontLanguageListCacheTest.cpp",
+        "HbFontCacheTest.cpp",
+        "HyphenatorTest.cpp",
+        "GraphemeBreakTests.cpp",
+        "LayoutTest.cpp",
+        "LayoutUtilsTest.cpp",
+        "MeasurementTests.cpp",
+        "SparseBitSetTest.cpp",
+        "UnicodeUtilsTest.cpp",
+        "WordBreakerTests.cpp",
+    ],
+
+    cppflags: [
+        "-Werror",
+        "-Wall",
+        "-Wextra",
+    ],
+
+    multilib: {
+        lib32: {
+            cppflags: ["-DkTestFontDir=\"/data/nativetest/minikin_tests/data/\""],
+        },
+        lib64: {
+            cppflags: ["-DkTestFontDir=\"/data/nativetest64/minikin_tests/data/\""],
+        },
+    },
+}
diff --git a/tests/unittest/Android.mk b/tests/unittest/Android.mk
deleted file mode 100644
index b817c46..0000000
--- a/tests/unittest/Android.mk
+++ /dev/null
@@ -1,100 +0,0 @@
-# Copyright (C) 2015 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.
-
-# see how_to_run.txt for instructions on running these tests
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_TEST_DATA := \
-    data/Bold.ttf \
-    data/BoldItalic.ttf \
-    data/ColorEmojiFont.ttf \
-    data/ColorTextMixedEmojiFont.ttf \
-    data/Emoji.ttf \
-    data/Italic.ttf \
-    data/Ja.ttf \
-    data/Ko.ttf \
-    data/MultiAxis.ttf \
-    data/NoCmapFormat14.ttf \
-    data/NoGlyphFont.ttf \
-    data/Regular.ttf \
-    data/TextEmojiFont.ttf \
-    data/UnicodeBMPOnly.ttf \
-    data/UnicodeBMPOnly2.ttf \
-    data/UnicodeUCS4.ttf \
-    data/VariationSelectorTest-Regular.ttf \
-    data/ZhHans.ttf \
-    data/ZhHant.ttf \
-    data/emoji.xml \
-    data/itemize.xml \
-
-LOCAL_TEST_DATA := $(foreach f,$(LOCAL_TEST_DATA),frameworks/minikin/tests:$(f))
-
-LOCAL_MODULE := minikin_tests
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE_CLASS := NATIVE_TESTS
-
-LOCAL_STATIC_LIBRARIES := libminikin
-
-# Shared libraries which are dependencies of minikin; these are not automatically
-# pulled in by the build system (and thus sadly must be repeated).
-
-LOCAL_SHARED_LIBRARIES := \
-    libskia \
-    libft2 \
-    libharfbuzz_ng \
-    libicuuc \
-    liblog \
-    libutils \
-    libz
-
-LOCAL_STATIC_LIBRARIES += \
-    libxml2
-
-LOCAL_SRC_FILES += \
-    ../util/FileUtils.cpp \
-    ../util/FontTestUtils.cpp \
-    ../util/MinikinFontForTest.cpp \
-    ../util/UnicodeUtils.cpp \
-    CmapCoverageTest.cpp \
-    EmojiTest.cpp \
-    FontCollectionTest.cpp \
-    FontCollectionItemizeTest.cpp \
-    FontFamilyTest.cpp \
-    FontLanguageListCacheTest.cpp \
-    HbFontCacheTest.cpp \
-    HyphenatorTest.cpp \
-    GraphemeBreakTests.cpp \
-    LayoutTest.cpp \
-    LayoutUtilsTest.cpp \
-    MeasurementTests.cpp \
-    SparseBitSetTest.cpp \
-    UnicodeUtilsTest.cpp \
-    WordBreakerTests.cpp
-
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/../../libs/minikin/ \
-    $(LOCAL_PATH)/../util \
-    external/harfbuzz_ng/src \
-    external/libxml2/include \
-    external/skia/src/core
-
-LOCAL_CPPFLAGS += -Werror -Wall -Wextra
-
-LOCAL_CPPFLAGS_32 += -DkTestFontDir="\"/data/nativetest/minikin_tests/data/\""
-LOCAL_CPPFLAGS_64 += -DkTestFontDir="\"/data/nativetest64/minikin_tests/data/\""
-
-include $(BUILD_NATIVE_TEST)
diff --git a/tests/unittest/AndroidTest.xml b/tests/unittest/AndroidTest.xml
new file mode 100644
index 0000000..a073101
--- /dev/null
+++ b/tests/unittest/AndroidTest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+<configuration description="Config for minikin_tests">
+    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+        <option name="cleanup" value="true" />
+        <option name="push" value="minikin_tests->/data/local/tmp/minikin_tests" />
+    </target_preparer>
+    <option name="test-suite-tag" value="apct" />
+    <test class="com.android.tradefed.testtype.GTest" >
+        <option name="native-test-device-path" value="/data/local/tmp" />
+        <option name="module-name" value="minikin_tests" />
+    </test>
+</configuration>
\ No newline at end of file
diff --git a/tests/util/Android.bp b/tests/util/Android.bp
new file mode 100644
index 0000000..50a2cd7
--- /dev/null
+++ b/tests/util/Android.bp
@@ -0,0 +1,13 @@
+cc_library_static {
+    name: "libminikin-tests-util",
+    srcs: [
+        "FileUtils.cpp",
+        "FontTestUtils.cpp",
+        "MinikinFontForTest.cpp",
+        "UnicodeUtils.cpp",
+    ],
+    export_include_dirs: ["."],
+    shared_libs: ["libxml2"],
+    static_libs: ["libminikin"],
+    header_libs: ["libminikin-headers-for-tests"],
+}
diff --git a/tools/mk_hyb_file.py b/tools/mk_hyb_file.py
index a9b8932..545e9b7 100755
--- a/tools/mk_hyb_file.py
+++ b/tools/mk_hyb_file.py
@@ -35,6 +35,10 @@
 
 VERBOSE = False
 
+# U+00DF is LATIN SMALL LETTER SHARP S
+# U+1E9E is LATIN CAPITAL LETTER SHARP S
+SHARP_S_TO_DOUBLE = u'\u00dfSS'
+SHARP_S_TO_CAPITAL = u'\u00df\u1e9e'
 
 if sys.version_info[0] >= 3:
     def unichr(x):
@@ -283,8 +287,12 @@
         for i, l in enumerate(f):
             l = l.strip()
             if len(l) > 2:
-                # lowercase maps to multi-character uppercase sequence, ignore uppercase for now
-                l = l[:1]
+                if l == SHARP_S_TO_DOUBLE:
+                    # replace with lowercasing from capital letter sharp s
+                    l = SHARP_S_TO_CAPITAL
+                else:
+                    # lowercase maps to multi-character uppercase sequence, ignore uppercase for now
+                    l = l[:1]
             else:
                 assert len(l) == 2, 'expected 2 chars in chr'
             for c in l:
@@ -419,6 +427,9 @@
     file_lines = [l.strip() for l in io.open(fn, encoding='UTF-8')]
     line_set = set(lines)
     file_set = set(file_lines)
+    if SHARP_S_TO_DOUBLE in file_set:
+        # ignore difference of double capital letter s and capital letter sharp s
+        file_set.symmetric_difference_update([SHARP_S_TO_DOUBLE, SHARP_S_TO_CAPITAL])
     if line_set == file_set:
         return True
     for line in line_set - file_set: