diff options
author | Jiyong Park <jiyong@google.com> | 2017-08-09 20:15:42 +0900 |
---|---|---|
committer | Jiyong Park <jiyong@google.com> | 2017-08-10 20:42:59 +0900 |
commit | 58d1be38f60cfe427d2dddea2ecdba52eeb4485f (patch) | |
tree | deaa5e2923ecc77df80d9487af179d9888dc5487 /android | |
parent | 39a32b46137c57b816e71d73438e4fac69b6b9d6 (diff) |
Don't use ICU when built for vendors
libicuuc.so isn't available for vendors, thus ICU is turned off when
libsqlite is built for vendors.
Bug: 64104535
Test: BOARD_VNDK_VERSION=current m -j libsqlite.vendor
Merged-In: I682502ba5bdc5f76a0363a95d01b1081c1bc01a4
Change-Id: I682502ba5bdc5f76a0363a95d01b1081c1bc01a4
(cherry picked from commit b4076dfd66f114263a1f70cf3ba73c2d55ccb3b0)
Diffstat (limited to 'android')
-rw-r--r-- | android/Android.bp | 5 | ||||
-rw-r--r-- | android/sqlite3_android.cpp | 26 |
2 files changed, 29 insertions, 2 deletions
diff --git a/android/Android.bp b/android/Android.bp index 7c17c6a..299dc31 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -12,6 +12,11 @@ cc_library_static { "libicuuc", "libicui18n", ], + target: { + vendor: { + exclude_shared_libs: ["libicuuc", "libicui18n"], + }, + }, export_include_dirs: ["."], } diff --git a/android/sqlite3_android.cpp b/android/sqlite3_android.cpp index 4174a13..da40647 100644 --- a/android/sqlite3_android.cpp +++ b/android/sqlite3_android.cpp @@ -21,10 +21,19 @@ #include <string.h> #include <unistd.h> +// ICU is turned off when sqlite is built for VNDK +#ifndef __ANDROID_VNDK__ +#define SQLITE_ENABLE_ICU +#else +#undef SQLITE_ENABLE_ICU +#endif + +#ifdef SQLITE_ENABLE_ICU #include <unicode/ucol.h> #include <unicode/uiter.h> #include <unicode/ustring.h> #include <unicode/utypes.h> +#endif //SQLITE_ENABLE_ICU #include <log/log.h> #include "sqlite3_android.h" @@ -34,6 +43,7 @@ #define SMALL_BUFFER_SIZE 10 #define PHONE_NUMBER_BUFFER_SIZE 40 +#ifdef SQLITE_ENABLE_ICU static int collate16(void *p, int n1, const void *v1, int n2, const void *v2) { UCollator *coll = (UCollator *) p; @@ -72,6 +82,7 @@ static int collate8(void *p, int n1, const void *v1, int n2, const void *v2) return 0; } } +#endif // SQLITE_ENABLE_ICU static void phone_numbers_equal(sqlite3_context * context, int argc, sqlite3_value ** argv) { @@ -205,6 +216,7 @@ static void delete_file(sqlite3_context * context, int argc, sqlite3_value ** ar } } +#ifdef SQLITE_ENABLE_ICU static void tokenize_auxdata_delete(void * data) { sqlite3_stmt * statement = (sqlite3_stmt *)data; @@ -413,8 +425,15 @@ static void localized_collator_dtor(UCollator* collator) // This collator may be removed in the near future, so you MUST not use now. #define PHONEBOOK_COLLATOR_NAME "PHONEBOOK" -extern "C" int register_localized_collators(sqlite3* handle, const char* systemLocale, int utf16Storage) +#endif // SQLITE_ENABLE_ICU + +extern "C" int register_localized_collators(sqlite3* handle __attribute((unused)), + const char* systemLocale __attribute((unused)), + int utf16Storage __attribute((unused))) { +// This function is no-op for the VNDK, but should exist in case when some vendor +// module has a reference to this function. +#ifdef SQLITE_ENABLE_ICU UErrorCode status = U_ZERO_ERROR; UCollator* collator = ucol_open(systemLocale, &status); if (U_FAILURE(status)) { @@ -478,14 +497,16 @@ extern "C" int register_localized_collators(sqlite3* handle, const char* systemL return err; } //// PHONEBOOK_COLLATOR +#endif //SQLITE_ENABLE_ICU return SQLITE_OK; } -extern "C" int register_android_functions(sqlite3 * handle, int utf16Storage) +extern "C" int register_android_functions(sqlite3 * handle, int utf16Storage __attribute((unused))) { int err; +#ifdef SQLITE_ENABLE_ICU UErrorCode status = U_ZERO_ERROR; UCollator * collator = ucol_open(NULL, &status); @@ -511,6 +532,7 @@ extern "C" int register_android_functions(sqlite3 * handle, int utf16Storage) if (err != SQLITE_OK) { return err; } +#endif // SQLITE_ENABLE_ICU // Register the PHONE_NUM_EQUALS function err = sqlite3_create_function( |