Merge "Merge TQ1A.221205.012" into stage-aosp-master
diff --git a/Android.bp b/Android.bp
index f5aaf31..8988459 100644
--- a/Android.bp
+++ b/Android.bp
@@ -2,6 +2,16 @@
     default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
+cc_defaults {
+    name: "libminikin_defaults",
+    cflags: [
+        "-Wall",
+        "-Werror",
+        "-Wextra",
+        "-Wthread-safety",
+    ],
+}
+
 cc_library_headers {
     name: "libminikin_headers",
     host_supported: true,
diff --git a/app/Android.bp b/app/Android.bp
index 9d6c28a..939d58c 100644
--- a/app/Android.bp
+++ b/app/Android.bp
@@ -33,5 +33,5 @@
 
     srcs: ["HyphTool.cpp"],
 
-    cflags: ["-Wall", "-Werror"],
+    defaults: ["libminikin_defaults"],
 }
diff --git a/libs/minikin/Android.bp b/libs/minikin/Android.bp
index c0c4035..3c89688 100644
--- a/libs/minikin/Android.bp
+++ b/libs/minikin/Android.bp
@@ -56,10 +56,7 @@
         "SystemFonts.cpp",
         "WordBreaker.cpp",
     ],
-    cflags: [
-        "-Wall",
-        "-Werror",
-    ],
+    defaults: ["libminikin_defaults"],
     sanitize: {
         misc_undefined: [
             "signed-integer-overflow",
@@ -67,12 +64,6 @@
             "bounds",
         ],
     },
-    cppflags: [
-        "-Werror",
-        "-Wall",
-        "-Wextra",
-        "-Wthread-safety",
-    ],
     product_variables: {
         debuggable: {
             // Enable assertion on eng and userdebug build.
diff --git a/tests/perftests/Android.bp b/tests/perftests/Android.bp
index 19ed8eb..4eb47c9 100644
--- a/tests/perftests/Android.bp
+++ b/tests/perftests/Android.bp
@@ -21,11 +21,7 @@
 cc_benchmark {
     name: "minikin_perftests",
     test_suites: ["device-tests"],
-    cppflags: [
-        "-Werror",
-        "-Wall",
-        "-Wextra",
-    ],
+    defaults: ["libminikin_defaults"],
     srcs: [
         "FontCollection.cpp",
         "FontLanguage.cpp",
diff --git a/tests/stresstest/Android.bp b/tests/stresstest/Android.bp
index 784dc6a..cebefe5 100644
--- a/tests/stresstest/Android.bp
+++ b/tests/stresstest/Android.bp
@@ -47,9 +47,5 @@
         "MultithreadTest.cpp",
     ],
 
-    cflags: [
-        "-Werror",
-        "-Wall",
-        "-Wextra",
-    ],
+    defaults: ["libminikin_defaults"],
 }
diff --git a/tests/stresstest/MultithreadTest.cpp b/tests/stresstest/MultithreadTest.cpp
index 560b517..d32d0b4 100644
--- a/tests/stresstest/MultithreadTest.cpp
+++ b/tests/stresstest/MultithreadTest.cpp
@@ -21,17 +21,19 @@
 #include <random>
 #include <thread>
 
+#include <android-base/thread_annotations.h>
 #include <cutils/log.h>
 #include <gtest/gtest.h>
 
 #include "minikin/FontCollection.h"
 #include "minikin/Macros.h"
 #include "minikin/MinikinPaint.h"
-
 #include "FontTestUtils.h"
 #include "MinikinInternal.h"
 #include "PathUtils.h"
 
+using android::base::ScopedLockAssertion;
+
 namespace minikin {
 
 constexpr int LAYOUT_COUNT_PER_COLLECTION = 500;
@@ -63,7 +65,7 @@
     {
         // Wait until all threads are created.
         std::unique_lock<std::mutex> lock(gMutex);
-        gCv.wait(lock, [] { return gReady; });
+        gCv.wait(lock, []() EXCLUSIVE_LOCKS_REQUIRED(gMutex) { return gReady; });
     }
 
     std::mt19937 mt(tid);
@@ -90,7 +92,7 @@
     std::vector<std::thread> threads;
 
     {
-        std::unique_lock<std::mutex> lock(gMutex);
+        ScopedLockAssertion lock(gMutex);
         threads.reserve(NUM_THREADS);
         for (int i = 0; i < NUM_THREADS; ++i) {
             threads.emplace_back(&thread_main, i);
diff --git a/tests/unittest/Android.bp b/tests/unittest/Android.bp
index d36c52f..d73fa30 100644
--- a/tests/unittest/Android.bp
+++ b/tests/unittest/Android.bp
@@ -79,9 +79,5 @@
         "WordBreakerTests.cpp",
     ],
 
-    cflags: [
-        "-Werror",
-        "-Wall",
-        "-Wextra",
-    ],
+    defaults: ["libminikin_defaults"],
 }
diff --git a/tests/util/Android.bp b/tests/util/Android.bp
index 1d3d8cf..d8c153d 100644
--- a/tests/util/Android.bp
+++ b/tests/util/Android.bp
@@ -11,7 +11,7 @@
         "PathUtils.cpp",
         "UnicodeUtils.cpp",
     ],
-    cflags: ["-Wall", "-Werror"],
+    defaults: ["libminikin_defaults"],
     export_include_dirs: ["."],
     shared_libs: ["libxml2", "libft2"],
     static_libs: ["libminikin"],