summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--minui/Android.mk10
-rw-r--r--minui/include/minui/minui.h3
-rw-r--r--minui/resources.cpp33
-rw-r--r--recovery.cpp2
-rw-r--r--res-hdpi/images/erasing_text.pngbin50184 -> 50680 bytes
-rw-r--r--res-hdpi/images/error_text.pngbin35856 -> 36036 bytes
-rw-r--r--res-hdpi/images/installing_security_text.pngbin113078 -> 113819 bytes
-rw-r--r--res-hdpi/images/installing_text.pngbin104002 -> 104768 bytes
-rw-r--r--res-hdpi/images/no_command_text.pngbin61417 -> 62037 bytes
-rw-r--r--res-mdpi/images/erasing_text.pngbin29660 -> 29898 bytes
-rw-r--r--res-mdpi/images/error_text.pngbin21123 -> 21147 bytes
-rw-r--r--res-mdpi/images/installing_security_text.pngbin69603 -> 70010 bytes
-rw-r--r--res-mdpi/images/installing_text.pngbin61281 -> 61701 bytes
-rw-r--r--res-mdpi/images/no_command_text.pngbin34366 -> 34683 bytes
-rw-r--r--res-xhdpi/images/erasing_text.pngbin73097 -> 73361 bytes
-rw-r--r--res-xhdpi/images/error_text.pngbin52180 -> 52019 bytes
-rw-r--r--res-xhdpi/images/installing_security_text.pngbin197146 -> 196871 bytes
-rw-r--r--res-xhdpi/images/installing_text.pngbin175660 -> 175570 bytes
-rw-r--r--res-xhdpi/images/no_command_text.pngbin86619 -> 86622 bytes
-rw-r--r--res-xxhdpi/images/erasing_text.pngbin121637 -> 121608 bytes
-rw-r--r--res-xxhdpi/images/error_text.pngbin84961 -> 84727 bytes
-rw-r--r--res-xxhdpi/images/installing_security_text.pngbin447228 -> 447158 bytes
-rw-r--r--res-xxhdpi/images/installing_text.pngbin416000 -> 415889 bytes
-rw-r--r--res-xxhdpi/images/no_command_text.pngbin243226 -> 243028 bytes
-rw-r--r--res-xxxhdpi/images/erasing_text.pngbin263646 -> 263768 bytes
-rw-r--r--res-xxxhdpi/images/error_text.pngbin178458 -> 176936 bytes
-rw-r--r--res-xxxhdpi/images/installing_security_text.pngbin610223 -> 610107 bytes
-rw-r--r--res-xxxhdpi/images/installing_text.pngbin567987 -> 567834 bytes
-rw-r--r--res-xxxhdpi/images/no_command_text.pngbin331473 -> 331159 bytes
-rw-r--r--tests/unit/locale_test.cpp21
30 files changed, 24 insertions, 45 deletions
diff --git a/minui/Android.mk b/minui/Android.mk
index 4dfc65f8a..281f64912 100644
--- a/minui/Android.mk
+++ b/minui/Android.mk
@@ -28,10 +28,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \
libdrm \
libsync_recovery
-LOCAL_STATIC_LIBRARIES := \
- libpng \
- libbase
-
+LOCAL_STATIC_LIBRARIES := libpng
LOCAL_CFLAGS := -Werror
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
@@ -64,10 +61,7 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libminui
LOCAL_WHOLE_STATIC_LIBRARIES += libminui
-LOCAL_SHARED_LIBRARIES := \
- libpng \
- libbase
-
+LOCAL_SHARED_LIBRARIES := libpng
LOCAL_CFLAGS := -Werror
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h
index 78dd4cb98..a1749dfe6 100644
--- a/minui/include/minui/minui.h
+++ b/minui/include/minui/minui.h
@@ -20,7 +20,6 @@
#include <sys/types.h>
#include <functional>
-#include <string>
//
// Graphics.
@@ -94,7 +93,7 @@ int ev_get_epollfd();
// Resources
//
-bool matches_locale(const std::string& prefix, const std::string& locale);
+bool matches_locale(const char* prefix, const char* locale);
// res_create_*_surface() functions return 0 if no error, else
// negative.
diff --git a/minui/resources.cpp b/minui/resources.cpp
index 86c731b02..c0f9c5c85 100644
--- a/minui/resources.cpp
+++ b/minui/resources.cpp
@@ -25,11 +25,8 @@
#include <sys/types.h>
#include <unistd.h>
-#include <regex>
-#include <string>
#include <vector>
-#include <android-base/strings.h>
#include <png.h>
#include "minui/minui.h"
@@ -374,26 +371,16 @@ int res_create_alpha_surface(const char* name, GRSurface** pSurface) {
// This function tests if a locale string stored in PNG (prefix) matches
// the locale string provided by the system (locale).
-bool matches_locale(const std::string& prefix, const std::string& locale) {
- // According to the BCP 47 format, A locale string may consists of:
- // language-{extlang}-{script}-{region}-{variant}
- // The locale headers in PNG mostly consist of language-{region} except for sr-Latn, and some
- // android's system locale can have the format language-{script}-{region}.
-
- // Return true if the whole string of prefix matches the top part of locale. Otherwise try to
- // match the locale string without the {script} section.
- // For instance, prefix == "en" matches locale == "en-US", prefix == "sr-Latn" matches locale
- // == "sr-Latn-BA", and prefix == "zh-CN" matches locale == "zh-Hans-CN".
- if (android::base::StartsWith(locale, prefix.c_str())) {
- return true;
- }
-
- size_t separator = prefix.find('-');
- if (separator == std::string::npos) {
- return false;
- }
- std::regex loc_regex(prefix.substr(0, separator) + "-[A-Za-z]*" + prefix.substr(separator));
- return std::regex_match(locale, loc_regex);
+bool matches_locale(const char* prefix, const char* locale) {
+ if (locale == nullptr) {
+ return false;
+ }
+
+ // Return true if the whole string of prefix matches the top part of
+ // locale. For instance, prefix == "en" matches locale == "en_US";
+ // and prefix == "zh_CN" matches locale == "zh_CN_#Hans".
+
+ return (strncmp(prefix, locale, strlen(prefix)) == 0);
}
int res_create_localized_alpha_surface(const char* name,
diff --git a/recovery.cpp b/recovery.cpp
index b24efa963..c2262161a 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -122,7 +122,7 @@ static const int BATTERY_READ_TIMEOUT_IN_SEC = 10;
static const int BATTERY_OK_PERCENTAGE = 20;
static const int BATTERY_WITH_CHARGER_OK_PERCENTAGE = 15;
static constexpr const char* RECOVERY_WIPE = "/etc/recovery.wipe";
-static constexpr const char* DEFAULT_LOCALE = "en-US";
+static constexpr const char* DEFAULT_LOCALE = "en_US";
static std::string locale;
static bool has_cache = false;
diff --git a/res-hdpi/images/erasing_text.png b/res-hdpi/images/erasing_text.png
index 0982544d2..684fc7c6c 100644
--- a/res-hdpi/images/erasing_text.png
+++ b/res-hdpi/images/erasing_text.png
Binary files differ
diff --git a/res-hdpi/images/error_text.png b/res-hdpi/images/error_text.png
index 3a06f6eb1..00c485d70 100644
--- a/res-hdpi/images/error_text.png
+++ b/res-hdpi/images/error_text.png
Binary files differ
diff --git a/res-hdpi/images/installing_security_text.png b/res-hdpi/images/installing_security_text.png
index b1acd2336..dadcfc32b 100644
--- a/res-hdpi/images/installing_security_text.png
+++ b/res-hdpi/images/installing_security_text.png
Binary files differ
diff --git a/res-hdpi/images/installing_text.png b/res-hdpi/images/installing_text.png
index f0f5d8b6c..abe73b4b9 100644
--- a/res-hdpi/images/installing_text.png
+++ b/res-hdpi/images/installing_text.png
Binary files differ
diff --git a/res-hdpi/images/no_command_text.png b/res-hdpi/images/no_command_text.png
index def503678..958e10613 100644
--- a/res-hdpi/images/no_command_text.png
+++ b/res-hdpi/images/no_command_text.png
Binary files differ
diff --git a/res-mdpi/images/erasing_text.png b/res-mdpi/images/erasing_text.png
index 82b4461ba..10e317829 100644
--- a/res-mdpi/images/erasing_text.png
+++ b/res-mdpi/images/erasing_text.png
Binary files differ
diff --git a/res-mdpi/images/error_text.png b/res-mdpi/images/error_text.png
index adb45131f..0022d10c1 100644
--- a/res-mdpi/images/error_text.png
+++ b/res-mdpi/images/error_text.png
Binary files differ
diff --git a/res-mdpi/images/installing_security_text.png b/res-mdpi/images/installing_security_text.png
index 54e556448..7a4cd414b 100644
--- a/res-mdpi/images/installing_security_text.png
+++ b/res-mdpi/images/installing_security_text.png
Binary files differ
diff --git a/res-mdpi/images/installing_text.png b/res-mdpi/images/installing_text.png
index d42331820..ee95e569c 100644
--- a/res-mdpi/images/installing_text.png
+++ b/res-mdpi/images/installing_text.png
Binary files differ
diff --git a/res-mdpi/images/no_command_text.png b/res-mdpi/images/no_command_text.png
index cd77ff457..af7660908 100644
--- a/res-mdpi/images/no_command_text.png
+++ b/res-mdpi/images/no_command_text.png
Binary files differ
diff --git a/res-xhdpi/images/erasing_text.png b/res-xhdpi/images/erasing_text.png
index 333edbe27..91cc35871 100644
--- a/res-xhdpi/images/erasing_text.png
+++ b/res-xhdpi/images/erasing_text.png
Binary files differ
diff --git a/res-xhdpi/images/error_text.png b/res-xhdpi/images/error_text.png
index e26258438..772b139e6 100644
--- a/res-xhdpi/images/error_text.png
+++ b/res-xhdpi/images/error_text.png
Binary files differ
diff --git a/res-xhdpi/images/installing_security_text.png b/res-xhdpi/images/installing_security_text.png
index e0f0f3ea7..a7113a04a 100644
--- a/res-xhdpi/images/installing_security_text.png
+++ b/res-xhdpi/images/installing_security_text.png
Binary files differ
diff --git a/res-xhdpi/images/installing_text.png b/res-xhdpi/images/installing_text.png
index a7e67f512..566eb0658 100644
--- a/res-xhdpi/images/installing_text.png
+++ b/res-xhdpi/images/installing_text.png
Binary files differ
diff --git a/res-xhdpi/images/no_command_text.png b/res-xhdpi/images/no_command_text.png
index 13aef7b71..b8da125cb 100644
--- a/res-xhdpi/images/no_command_text.png
+++ b/res-xhdpi/images/no_command_text.png
Binary files differ
diff --git a/res-xxhdpi/images/erasing_text.png b/res-xxhdpi/images/erasing_text.png
index 80e7c475e..86693f435 100644
--- a/res-xxhdpi/images/erasing_text.png
+++ b/res-xxhdpi/images/erasing_text.png
Binary files differ
diff --git a/res-xxhdpi/images/error_text.png b/res-xxhdpi/images/error_text.png
index 32a1965b8..9c4bcab95 100644
--- a/res-xxhdpi/images/error_text.png
+++ b/res-xxhdpi/images/error_text.png
Binary files differ
diff --git a/res-xxhdpi/images/installing_security_text.png b/res-xxhdpi/images/installing_security_text.png
index c53c9ac21..f5ec698f8 100644
--- a/res-xxhdpi/images/installing_security_text.png
+++ b/res-xxhdpi/images/installing_security_text.png
Binary files differ
diff --git a/res-xxhdpi/images/installing_text.png b/res-xxhdpi/images/installing_text.png
index 38b18d20d..100a5b303 100644
--- a/res-xxhdpi/images/installing_text.png
+++ b/res-xxhdpi/images/installing_text.png
Binary files differ
diff --git a/res-xxhdpi/images/no_command_text.png b/res-xxhdpi/images/no_command_text.png
index a0666d8dc..590030c8b 100644
--- a/res-xxhdpi/images/no_command_text.png
+++ b/res-xxhdpi/images/no_command_text.png
Binary files differ
diff --git a/res-xxxhdpi/images/erasing_text.png b/res-xxxhdpi/images/erasing_text.png
index 4f7b37b51..4cf5d76e8 100644
--- a/res-xxxhdpi/images/erasing_text.png
+++ b/res-xxxhdpi/images/erasing_text.png
Binary files differ
diff --git a/res-xxxhdpi/images/error_text.png b/res-xxxhdpi/images/error_text.png
index 052bf2142..8dd6f1236 100644
--- a/res-xxxhdpi/images/error_text.png
+++ b/res-xxxhdpi/images/error_text.png
Binary files differ
diff --git a/res-xxxhdpi/images/installing_security_text.png b/res-xxxhdpi/images/installing_security_text.png
index a9e739b17..fa06f3147 100644
--- a/res-xxxhdpi/images/installing_security_text.png
+++ b/res-xxxhdpi/images/installing_security_text.png
Binary files differ
diff --git a/res-xxxhdpi/images/installing_text.png b/res-xxxhdpi/images/installing_text.png
index 2d1948677..d0f930160 100644
--- a/res-xxxhdpi/images/installing_text.png
+++ b/res-xxxhdpi/images/installing_text.png
Binary files differ
diff --git a/res-xxxhdpi/images/no_command_text.png b/res-xxxhdpi/images/no_command_text.png
index ee0c23865..233aec468 100644
--- a/res-xxxhdpi/images/no_command_text.png
+++ b/res-xxxhdpi/images/no_command_text.png
Binary files differ
diff --git a/tests/unit/locale_test.cpp b/tests/unit/locale_test.cpp
index cdaba0e8b..f73235005 100644
--- a/tests/unit/locale_test.cpp
+++ b/tests/unit/locale_test.cpp
@@ -19,15 +19,14 @@
#include "minui/minui.h"
TEST(LocaleTest, Misc) {
- EXPECT_TRUE(matches_locale("zh-CN", "zh-Hans-CN"));
- EXPECT_TRUE(matches_locale("zh", "zh-Hans-CN"));
- EXPECT_FALSE(matches_locale("zh-HK", "zh-Hans-CN"));
- EXPECT_TRUE(matches_locale("en-GB", "en-GB"));
- EXPECT_TRUE(matches_locale("en", "en-GB"));
- EXPECT_FALSE(matches_locale("en-GB", "en"));
- EXPECT_FALSE(matches_locale("en-GB", "en-US"));
- EXPECT_FALSE(matches_locale("en-US", ""));
- // Empty locale prefix in the PNG file will match the input locale.
- EXPECT_TRUE(matches_locale("", "en-US"));
- EXPECT_TRUE(matches_locale("sr-Latn", "sr-Latn-BA"));
+ EXPECT_TRUE(matches_locale("zh_CN", "zh_CN_#Hans"));
+ EXPECT_TRUE(matches_locale("zh", "zh_CN_#Hans"));
+ EXPECT_FALSE(matches_locale("zh_HK", "zh_CN_#Hans"));
+ EXPECT_TRUE(matches_locale("en_GB", "en_GB"));
+ EXPECT_TRUE(matches_locale("en", "en_GB"));
+ EXPECT_FALSE(matches_locale("en_GB", "en"));
+ EXPECT_FALSE(matches_locale("en_GB", "en_US"));
+ EXPECT_FALSE(matches_locale("en_US", ""));
+ // Empty locale prefix in the PNG file will match the input locale.
+ EXPECT_TRUE(matches_locale("", "en_US"));
}