Loading minui/Android.mk +8 −2 Original line number Original line Diff line number Diff line Loading @@ -28,7 +28,10 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \ libdrm \ libdrm \ libsync_recovery libsync_recovery LOCAL_STATIC_LIBRARIES := libpng LOCAL_STATIC_LIBRARIES := \ libpng \ libbase LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Werror LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include Loading Loading @@ -61,7 +64,10 @@ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) include $(CLEAR_VARS) LOCAL_MODULE := libminui LOCAL_MODULE := libminui LOCAL_WHOLE_STATIC_LIBRARIES += libminui LOCAL_WHOLE_STATIC_LIBRARIES += libminui LOCAL_SHARED_LIBRARIES := libpng LOCAL_SHARED_LIBRARIES := \ libpng \ libbase LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Werror LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include Loading minui/include/minui/minui.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <sys/types.h> #include <sys/types.h> #include <functional> #include <functional> #include <string> // // // Graphics. // Graphics. Loading Loading @@ -93,7 +94,7 @@ int ev_get_epollfd(); // Resources // Resources // // bool matches_locale(const char* prefix, const char* locale); bool matches_locale(const std::string& prefix, const std::string& locale); // res_create_*_surface() functions return 0 if no error, else // res_create_*_surface() functions return 0 if no error, else // negative. // negative. Loading minui/resources.cpp +23 −10 Original line number Original line Diff line number Diff line Loading @@ -25,8 +25,11 @@ #include <sys/types.h> #include <sys/types.h> #include <unistd.h> #include <unistd.h> #include <regex> #include <string> #include <vector> #include <vector> #include <android-base/strings.h> #include <png.h> #include <png.h> #include "minui/minui.h" #include "minui/minui.h" Loading Loading @@ -371,16 +374,26 @@ int res_create_alpha_surface(const char* name, GRSurface** pSurface) { // This function tests if a locale string stored in PNG (prefix) matches // This function tests if a locale string stored in PNG (prefix) matches // the locale string provided by the system (locale). // the locale string provided by the system (locale). bool matches_locale(const char* prefix, const char* locale) { bool matches_locale(const std::string& prefix, const std::string& locale) { if (locale == nullptr) { // 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; return false; } } std::regex loc_regex(prefix.substr(0, separator) + "-[A-Za-z]*" + prefix.substr(separator)); // Return true if the whole string of prefix matches the top part of return std::regex_match(locale, loc_regex); // 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, int res_create_localized_alpha_surface(const char* name, Loading recovery.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -122,7 +122,7 @@ static const int BATTERY_READ_TIMEOUT_IN_SEC = 10; static const int BATTERY_OK_PERCENTAGE = 20; static const int BATTERY_OK_PERCENTAGE = 20; static const int BATTERY_WITH_CHARGER_OK_PERCENTAGE = 15; static const int BATTERY_WITH_CHARGER_OK_PERCENTAGE = 15; static constexpr const char* RECOVERY_WIPE = "/etc/recovery.wipe"; 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 std::string locale; static bool has_cache = false; static bool has_cache = false; Loading res-hdpi/images/erasing_text.png −496 B (49 KiB) Loading image diff... Loading
minui/Android.mk +8 −2 Original line number Original line Diff line number Diff line Loading @@ -28,7 +28,10 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \ libdrm \ libdrm \ libsync_recovery libsync_recovery LOCAL_STATIC_LIBRARIES := libpng LOCAL_STATIC_LIBRARIES := \ libpng \ libbase LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Werror LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include Loading Loading @@ -61,7 +64,10 @@ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) include $(CLEAR_VARS) LOCAL_MODULE := libminui LOCAL_MODULE := libminui LOCAL_WHOLE_STATIC_LIBRARIES += libminui LOCAL_WHOLE_STATIC_LIBRARIES += libminui LOCAL_SHARED_LIBRARIES := libpng LOCAL_SHARED_LIBRARIES := \ libpng \ libbase LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Werror LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include Loading
minui/include/minui/minui.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <sys/types.h> #include <sys/types.h> #include <functional> #include <functional> #include <string> // // // Graphics. // Graphics. Loading Loading @@ -93,7 +94,7 @@ int ev_get_epollfd(); // Resources // Resources // // bool matches_locale(const char* prefix, const char* locale); bool matches_locale(const std::string& prefix, const std::string& locale); // res_create_*_surface() functions return 0 if no error, else // res_create_*_surface() functions return 0 if no error, else // negative. // negative. Loading
minui/resources.cpp +23 −10 Original line number Original line Diff line number Diff line Loading @@ -25,8 +25,11 @@ #include <sys/types.h> #include <sys/types.h> #include <unistd.h> #include <unistd.h> #include <regex> #include <string> #include <vector> #include <vector> #include <android-base/strings.h> #include <png.h> #include <png.h> #include "minui/minui.h" #include "minui/minui.h" Loading Loading @@ -371,16 +374,26 @@ int res_create_alpha_surface(const char* name, GRSurface** pSurface) { // This function tests if a locale string stored in PNG (prefix) matches // This function tests if a locale string stored in PNG (prefix) matches // the locale string provided by the system (locale). // the locale string provided by the system (locale). bool matches_locale(const char* prefix, const char* locale) { bool matches_locale(const std::string& prefix, const std::string& locale) { if (locale == nullptr) { // 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; return false; } } std::regex loc_regex(prefix.substr(0, separator) + "-[A-Za-z]*" + prefix.substr(separator)); // Return true if the whole string of prefix matches the top part of return std::regex_match(locale, loc_regex); // 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, int res_create_localized_alpha_surface(const char* name, Loading
recovery.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -122,7 +122,7 @@ static const int BATTERY_READ_TIMEOUT_IN_SEC = 10; static const int BATTERY_OK_PERCENTAGE = 20; static const int BATTERY_OK_PERCENTAGE = 20; static const int BATTERY_WITH_CHARGER_OK_PERCENTAGE = 15; static const int BATTERY_WITH_CHARGER_OK_PERCENTAGE = 15; static constexpr const char* RECOVERY_WIPE = "/etc/recovery.wipe"; 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 std::string locale; static bool has_cache = false; static bool has_cache = false; Loading