diff options
-rw-r--r-- | android/Android.bp | 5 | ||||
-rw-r--r-- | android/sqlite3_android.cpp | 26 | ||||
-rw-r--r-- | dist/Android.bp | 7 | ||||
-rw-r--r-- | dist/Android.patch | 34 | ||||
-rw-r--r-- | dist/sqlite3.c | 9 |
5 files changed, 70 insertions, 11 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( diff --git a/dist/Android.bp b/dist/Android.bp index a943f61..7639450 100644 --- a/dist/Android.bp +++ b/dist/Android.bp @@ -66,6 +66,10 @@ cc_defaults { cc_library { name: "libsqlite", defaults: ["sqlite-defaults"], + vendor_available: true, + vndk: { + enabled: true, + }, srcs: ["sqlite3.c"], @@ -100,6 +104,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 98b9f1f..27c5147 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-05-24 17:13:50.000000000 +0200 -+++ ./shell.c 2017-05-24 19:24:05.290434785 +0200 +--- orig/shell.c 2017-06-09 18:50:55.552361036 +0900 ++++ ./shell.c 2017-06-09 18:50:55.636359925 +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-05-24 17:13:50.000000000 +0200 -+++ ./sqlite3.c 2017-05-24 19:24:05.339433935 +0200 -@@ -33542,7 +33542,7 @@ +--- orig/sqlite3.c 2017-06-26 14:41:48.608892557 +0900 ++++ ./sqlite3.c 2017-08-10 10:30:27.105711381 +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 +@@ -33542,7 +33551,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; -@@ -33578,7 +33578,7 @@ +@@ -33578,7 +33587,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; -@@ -34152,7 +34152,7 @@ +@@ -34152,7 +34161,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; } -@@ -115926,7 +115926,7 @@ +@@ -115928,7 +115937,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; } -@@ -149753,13 +149753,25 @@ +@@ -149763,13 +149772,25 @@ ** module with sqlite. */ if( SQLITE_OK==rc diff --git a/dist/sqlite3.c b/dist/sqlite3.c index 9db21a8..a1be12b 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 |