diff options
-rw-r--r-- | android/Android.bp | 5 | ||||
-rw-r--r-- | android/sqlite3_android.cpp | 26 | ||||
-rw-r--r-- | dist/Android.bp | 6 | ||||
-rw-r--r-- | dist/Android.patch | 34 | ||||
-rw-r--r-- | dist/sqlite3.c | 9 |
5 files changed, 69 insertions, 11 deletions
diff --git a/android/Android.bp b/android/Android.bp index c610e34..bbe6fed 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -13,6 +13,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( diff --git a/dist/Android.bp b/dist/Android.bp index 9f1c602..75d03ab 100644 --- a/dist/Android.bp +++ b/dist/Android.bp @@ -68,6 +68,9 @@ cc_library { name: "libsqlite", defaults: ["sqlite-defaults"], vendor_available: true, + vndk: { + enabled: true, + }, srcs: ["sqlite3.c"], @@ -102,6 +105,9 @@ cc_library { windows: { enabled: true, }, + vendor: { + exclude_shared_libs: ["libicuuc", "libicui18n"], + }, }, export_include_dirs: ["."], diff --git a/dist/Android.patch b/dist/Android.patch index bdc8f86..8132ee2 100644 --- a/dist/Android.patch +++ b/dist/Android.patch @@ -1,6 +1,6 @@ diff -r -u -d orig/shell.c ./shell.c ---- orig/shell.c 2017-08-01 10:40:56.000000000 -0700 -+++ ./shell.c 2017-08-02 11:00:50.083038316 -0700 +--- orig/shell.c 2017-07-21 09:46:53.488326209 +0900 ++++ ./shell.c 2017-07-21 09:46:53.620324492 +0900 @@ -52,6 +52,12 @@ #endif #include <ctype.h> @@ -38,9 +38,25 @@ diff -r -u -d orig/shell.c ./shell.c } diff -r -u -d orig/sqlite3.c ./sqlite3.c ---- orig/sqlite3.c 2017-08-01 10:40:56.000000000 -0700 -+++ ./sqlite3.c 2017-08-02 11:00:50.135037255 -0700 -@@ -33618,7 +33618,7 @@ +--- orig/sqlite3.c 2017-08-04 10:42:31.294648222 +0900 ++++ ./sqlite3.c 2017-08-10 00:35:18.935880997 +0900 +@@ -84,6 +84,15 @@ + #endif + + /* ++** When sqlite is built for the VNDK, ICU is disabled because ++** libicuuc.so and libicui18n.so aren't available then. ++** TODO(b/64514237): move this to Android.bp ++*/ ++#ifdef __ANDROID_VNDK__ ++#undef SQLITE_ENABLE_ICU ++#endif ++ ++/* + ** Include the header file used to customize the compiler options for MSVC. + ** This should be done first so that it can successfully prevent spurious + ** compiler warnings due to subsequent content in this file and other files +@@ -33618,7 +33627,7 @@ SimulateIOError( rc=1 ); if( rc!=0 ){ storeLastErrno((unixFile*)id, errno); @@ -49,7 +65,7 @@ diff -r -u -d orig/sqlite3.c ./sqlite3.c } *pSize = buf.st_size; -@@ -33654,7 +33654,7 @@ +@@ -33654,7 +33663,7 @@ struct stat buf; /* Used to hold return values of fstat() */ if( osFstat(pFile->h, &buf) ){ @@ -58,7 +74,7 @@ diff -r -u -d orig/sqlite3.c ./sqlite3.c } nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk; -@@ -34262,7 +34262,7 @@ +@@ -34262,7 +34271,7 @@ ** with the same permissions. */ if( osFstat(pDbFd->h, &sStat) ){ @@ -67,7 +83,7 @@ diff -r -u -d orig/sqlite3.c ./sqlite3.c goto shm_open_err; } -@@ -116120,7 +116120,7 @@ +@@ -116120,7 +116129,7 @@ } if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){ sqlite3SetString(pzErrMsg, db, "unsupported file format"); @@ -76,7 +92,7 @@ diff -r -u -d orig/sqlite3.c ./sqlite3.c goto initone_error_out; } -@@ -149914,13 +149914,25 @@ +@@ -149914,13 +149923,25 @@ ** module with sqlite. */ if( SQLITE_OK==rc diff --git a/dist/sqlite3.c b/dist/sqlite3.c index 59bba65..3eaac07 100644 --- a/dist/sqlite3.c +++ b/dist/sqlite3.c @@ -84,6 +84,15 @@ #endif /* +** When sqlite is built for the VNDK, ICU is disabled because +** libicuuc.so and libicui18n.so aren't available then. +** TODO(b/64514237): move this to Android.bp +*/ +#ifdef __ANDROID_VNDK__ +#undef SQLITE_ENABLE_ICU +#endif + +/* ** Include the header file used to customize the compiler options for MSVC. ** This should be done first so that it can successfully prevent spurious ** compiler warnings due to subsequent content in this file and other files |