summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--OWNERS3
-rwxr-xr-xUPDATE-SOURCE.bash102
-rw-r--r--android/Android.bp7
-rw-r--r--android/OldPhoneNumberUtilsTest.cpp42
-rw-r--r--android/PhoneNumberUtilsTest.cpp8
-rw-r--r--dist/Android.bp17
-rw-r--r--dist/Android.patch62
-rw-r--r--dist/README-Android2
-rw-r--r--dist/shell.c23
-rw-r--r--dist/sqlite3.c36
10 files changed, 246 insertions, 56 deletions
diff --git a/OWNERS b/OWNERS
index cc1f868..7e19942 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,2 +1,3 @@
omakoto@google.com
-fkupolov@google.com
+jsharkey@android.com
+yamasani@google.com
diff --git a/UPDATE-SOURCE.bash b/UPDATE-SOURCE.bash
new file mode 100755
index 0000000..408ce07
--- /dev/null
+++ b/UPDATE-SOURCE.bash
@@ -0,0 +1,102 @@
+#!/bin/bash
+#
+# Copyright (C) 2018 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This script updates SQLite source files with a SQLite tarball.
+#
+# Usage: UPDATE-SOURCE.bash SQLITE-SOURCE.tgz
+#
+# This script must be executed in $ANDROID_BUILD_TOP/external/sqlite/
+#
+
+set -e
+
+script_name="$(basename "$0")"
+
+source_tgz="$1"
+source_ext_dir="$1.extracted"
+
+die() {
+ echo "$script_name: $*"
+ exit 1
+}
+
+echo_and_exec() {
+ echo " Running: $@"
+ "$@"
+}
+
+# Make sure the source tgz file exists.
+pwd="$(pwd)"
+if [[ ! "$pwd" =~ .*/external/sqlite/? ]] ; then
+ die 'Execute this script in $ANDROID_BUILD_TOP/external/sqlite/'
+fi
+
+# Make sure the source tgz file exists.
+
+if [[ ! -f "$source_tgz" ]] ; then
+ die " Missing or invalid argument.
+
+ Usage: $script_name SQLITE-SOURCE_TGZ
+"
+fi
+
+
+echo
+echo "# Extracting the source tgz..."
+echo_and_exec rm -fr "$source_ext_dir"
+echo_and_exec mkdir -p "$source_ext_dir"
+echo_and_exec tar xvf "$source_tgz" -C "$source_ext_dir" --strip-components=1
+
+echo
+echo "# Making file sqlite3.c in $source_ext_dir ..."
+(
+ cd "$source_ext_dir"
+ echo_and_exec ./configure
+ echo_and_exec make -j 4 sqlite3.c
+)
+
+echo
+echo "# Copying the source files ..."
+for to in dist/orig/ dist/ ; do
+ echo_and_exec cp "$source_ext_dir/"{shell.c,sqlite3.c,sqlite3.h,sqlite3ext.h} "$to"
+done
+
+echo
+echo "# Applying Android.patch ..."
+(
+ cd dist
+ echo_and_exec patch -i Android.patch
+)
+
+echo
+echo "# Regenerating Android.patch ..."
+(
+ cd dist
+ echo_and_exec bash -c '(for x in orig/*; do diff -u -d $x ${x#orig/}; done) > Android.patch'
+)
+
+cat <<EOF
+
+=======================================================
+
+ Finished successfully!
+
+ Make sure to update README.version
+
+=======================================================
+
+EOF
+
diff --git a/android/Android.bp b/android/Android.bp
index 9173a03..50adbe8 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -17,13 +17,12 @@ cc_library_static {
include_dirs: ["external/sqlite/dist"],
shared_libs: [
"liblog",
- "libicuuc",
- "libicui18n",
+ "libandroidicu",
],
target: {
vendor: {
cflags: ["-USQLITE_ENABLE_ICU"],
- exclude_shared_libs: ["libicuuc", "libicui18n"],
+ exclude_shared_libs: ["libandroidicu"],
},
},
export_include_dirs: ["."],
@@ -39,6 +38,8 @@ cc_test {
"-Werror",
],
srcs: [
+ "OldPhoneNumberUtils.cpp",
+ "OldPhoneNumberUtilsTest.cpp",
"PhoneNumberUtils.cpp",
"PhoneNumberUtilsTest.cpp",
],
diff --git a/android/OldPhoneNumberUtilsTest.cpp b/android/OldPhoneNumberUtilsTest.cpp
index 777ae71..fdd4135 100644
--- a/android/OldPhoneNumberUtilsTest.cpp
+++ b/android/OldPhoneNumberUtilsTest.cpp
@@ -33,32 +33,32 @@
using namespace android;
-TEST(PhoneNumberUtils, compareLooseNullOrEmpty) {
+TEST(OldPhoneNumberUtils, compareLooseNullOrEmpty) {
EXPECT_FALSE(phone_number_compare_loose(NULL, NULL));
EXPECT_FALSE(phone_number_compare_loose("", NULL));
EXPECT_FALSE(phone_number_compare_loose(NULL, ""));
EXPECT_FALSE(phone_number_compare_loose("", ""));
}
-TEST(PhoneNumberUtils, compareLooseDigitsSame) {
+TEST(OldPhoneNumberUtils, compareLooseDigitsSame) {
EXPECT_TRUE(phone_number_compare_loose("999", "999"));
EXPECT_TRUE(phone_number_compare_loose("119", "119"));
}
-TEST(PhoneNumberUtils, compareLooseDigitsDifferent) {
+TEST(OldPhoneNumberUtils, compareLooseDigitsDifferent) {
EXPECT_FALSE(phone_number_compare_loose("123456789", "923456789"));
EXPECT_FALSE(phone_number_compare_loose("123456789", "123456781"));
EXPECT_FALSE(phone_number_compare_loose("123456789", "1234567890"));
EXPECT_TRUE(phone_number_compare_loose("123456789", "0123456789"));
}
-TEST(PhoneNumberUtils, compareLooseGoogle) {
+TEST(OldPhoneNumberUtils, compareLooseGoogle) {
EXPECT_TRUE(phone_number_compare_loose("650-253-0000", "6502530000"));
EXPECT_TRUE(phone_number_compare_loose("650-253-0000", "650 253 0000"));
EXPECT_TRUE(phone_number_compare_loose("650 253 0000", "6502530000"));
}
-TEST(PhoneNumberUtils, compareLooseTrunkPrefixUs) {
+TEST(OldPhoneNumberUtils, compareLooseTrunkPrefixUs) {
// trunk (NDD) prefix must be properly handled in US
EXPECT_TRUE(phone_number_compare_loose("650-253-0000", "1-650-253-0000"));
EXPECT_TRUE(phone_number_compare_loose("650-253-0000", " 1-650-253-0000"));
@@ -72,11 +72,11 @@ TEST(PhoneNumberUtils, compareLooseTrunkPrefixUs) {
EXPECT_TRUE(phone_number_compare_loose("0111 650-253-0000", "6502530000"));
}
-TEST(PhoneNumberUtils, compareLooseDifferentCountryCode) {
+TEST(OldPhoneNumberUtils, compareLooseDifferentCountryCode) {
EXPECT_FALSE(phone_number_compare_loose("+19012345678", "+819012345678"));
}
-TEST(PhoneNumberUtils, compareLooseTrunkJapan) {
+TEST(OldPhoneNumberUtils, compareLooseTrunkJapan) {
EXPECT_TRUE(phone_number_compare_loose("+31771234567", "0771234567"));
EXPECT_TRUE(phone_number_compare_loose("090-1234-5678", "+819012345678"));
EXPECT_TRUE(phone_number_compare_loose("090(1234)5678", "+819012345678"));
@@ -87,24 +87,24 @@ TEST(PhoneNumberUtils, compareLooseTrunkJapan) {
EXPECT_TRUE(phone_number_compare_loose("+81-90-1234-5678", "090-1234-5678"));
}
-TEST(PhoneNumberUtils, compareLooseTrunkRussia) {
+TEST(OldPhoneNumberUtils, compareLooseTrunkRussia) {
EXPECT_TRUE(phone_number_compare_loose("+79161234567", "89161234567"));
}
-TEST(PhoneNumberUtils, compareLooseTrunkFrance) {
+TEST(OldPhoneNumberUtils, compareLooseTrunkFrance) {
EXPECT_TRUE(phone_number_compare_loose("+33123456789", "0123456789"));
}
-TEST(PhoneNumberUtils, compareLooseTrunkHungary) {
+TEST(OldPhoneNumberUtils, compareLooseTrunkHungary) {
EXPECT_TRUE(phone_number_compare_loose("+36 1 234 5678", "06 1234-5678"));
}
-TEST(PhoneNumberUtils, compareLooseTrunkMexico) {
+TEST(OldPhoneNumberUtils, compareLooseTrunkMexico) {
EXPECT_TRUE(phone_number_compare_loose("+52 55 1234 5678", "01 55 1234 5678"));
}
-TEST(PhoneNumberUtils, compareLooseTrunkMongolia) {
+TEST(OldPhoneNumberUtils, compareLooseTrunkMongolia) {
EXPECT_TRUE(phone_number_compare_loose("+976 1 123 4567", "01 1 23 4567"));
EXPECT_TRUE(phone_number_compare_loose("+976 2 234 5678", "02 2 34 5678"));
}
@@ -113,12 +113,12 @@ TEST(PhoneNumberUtils, compareLooseTrunkNetherlandsCities) {
EXPECT_TRUE(phone_number_compare_loose("+31771234567", "0771234567"));
}
-TEST(PhoneNumberUtils, compareLooseInternationalJapan) {
+TEST(OldPhoneNumberUtils, compareLooseInternationalJapan) {
EXPECT_FALSE(phone_number_compare_loose("+818012345678", "+819012345678"));
EXPECT_TRUE(phone_number_compare_loose("+819012345678", "+819012345678"));
}
-TEST(PhoneNumberUtils, compareLooseTrunkIgnoreJapan) {
+TEST(OldPhoneNumberUtils, compareLooseTrunkIgnoreJapan) {
// Trunk prefix must not be ignored in Japan
EXPECT_TRUE(phone_number_compare_loose("090-1234-5678", "90-1234-5678"));
EXPECT_FALSE(phone_number_compare_loose("090-1234-5678", "080-1234-5678"));
@@ -128,17 +128,17 @@ TEST(PhoneNumberUtils, compareLooseTrunkIgnoreJapan) {
EXPECT_FALSE(phone_number_compare_loose("+81-90-1234-5678", "+81-090-1234-5678"));
}
-TEST(PhoneNumberUtils, compareLooseInternationalNational) {
+TEST(OldPhoneNumberUtils, compareLooseInternationalNational) {
EXPECT_TRUE(phone_number_compare_loose("+593(800)123-1234", "8001231234"));
}
-TEST(PhoneNumberUtils, compareLooseTwoContinuousZeros) {
+TEST(OldPhoneNumberUtils, compareLooseTwoContinuousZeros) {
// Two continuous 0 at the begining of the phone string should be
// treated as trunk prefix for caller id purposes.
EXPECT_TRUE(phone_number_compare_loose("008001231234", "8001231234"));
}
-TEST(PhoneNumberUtils, compareLooseCallerIdThailandUs) {
+TEST(OldPhoneNumberUtils, compareLooseCallerIdThailandUs) {
// Test broken caller ID seen on call from Thailand to the US
EXPECT_TRUE(phone_number_compare_loose("+66811234567", "166811234567"));
// Confirm that the bug found before does not re-appear.
@@ -148,7 +148,7 @@ TEST(PhoneNumberUtils, compareLooseCallerIdThailandUs) {
EXPECT_TRUE(phone_number_compare_loose("+44 207 792 3490", "00 207 792 3490"));
}
-TEST(PhoneNumberUtils, compareLooseNamp1661) {
+TEST(OldPhoneNumberUtils, compareLooseNamp1661) {
// This is not related to Thailand case. NAMP "1" + region code "661".
EXPECT_TRUE(phone_number_compare_loose("16610001234", "6610001234"));
}
@@ -160,7 +160,7 @@ TEST(PhoneNumberUtils, compareLooseAlphaDifferent) {
EXPECT_TRUE(phone_number_compare_loose("abcd", "bcde"));
}
-TEST(PhoneNumberUtils, compareLooseAlphaNumericDifferent) {
+TEST(OldPhoneNumberUtils, compareLooseAlphaNumericDifferent) {
EXPECT_FALSE(phone_number_compare_loose("1-800-flowers", "800-flowers"));
// TODO: "flowers" and "adcdefg" should not match
//EXPECT_FALSE(phone_number_compare_loose("1-800-flowers", "1-800-abcdefg"));
@@ -168,11 +168,11 @@ TEST(PhoneNumberUtils, compareLooseAlphaNumericDifferent) {
// TODO: we currently do not support this comparison. It maybe nice to support this
// TODO: in the future.
-//TEST(PhoneNumberUtils, compareLooseLettersToDigits) {
+//TEST(OldPhoneNumberUtils, compareLooseLettersToDigits) {
// EXPECT_TRUE(phone_number_compare_loose("1-800-flowers", "1-800-356-9377"));
//}
-TEST(PhoneNumberUtils, compareLooseWrongPrefix) {
+TEST(OldPhoneNumberUtils, compareLooseWrongPrefix) {
// Japan
EXPECT_FALSE(phone_number_compare_loose("290-1234-5678", "+819012345678"));
EXPECT_FALSE(phone_number_compare_loose("+819012345678", "290-1234-5678"));
diff --git a/android/PhoneNumberUtilsTest.cpp b/android/PhoneNumberUtilsTest.cpp
index ce90c0a..8e4692c 100644
--- a/android/PhoneNumberUtilsTest.cpp
+++ b/android/PhoneNumberUtilsTest.cpp
@@ -194,7 +194,7 @@ TEST(PhoneNumberUtils, compareStrictWrongPrefix) {
EXPECT_FALSE(phone_number_compare_strict("+14504503605", "5504503605"));
}
-TEST(PhoneNumberUtils, phone_number_stripped_reversed_inter) {
+TEST(PhoneNumberUtils, compareStrict_phone_number_stripped_reversed_inter) {
char out[6];
int outlen;
@@ -220,3 +220,9 @@ TEST(PhoneNumberUtils, phone_number_stripped_reversed_inter) {
// Ignoring non-dialable
ASSERT_STRIPPED_REVERSE("1A2 3?4", "4321");
}
+
+TEST(PhoneNumberUtils, compareStrictRussianNumbers) {
+ EXPECT_FALSE(phone_number_compare_strict("84951234567", "+84951234567"));
+
+ EXPECT_FALSE(phone_number_compare_strict("88001234567", "+88001234567"));
+}
diff --git a/dist/Android.bp b/dist/Android.bp
index 2211d1f..54cd389 100644
--- a/dist/Android.bp
+++ b/dist/Android.bp
@@ -37,6 +37,7 @@ cc_defaults {
"-DSQLITE_DEFAULT_FILE_PERMISSIONS=0600",
"-DSQLITE_SECURE_DELETE",
"-DSQLITE_ENABLE_BATCH_ATOMIC_WRITE",
+ "-DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD",
"-Wno-unused-parameter",
"-Werror",
],
@@ -79,8 +80,7 @@ cc_library {
"libdl",
"liblog",
"libutils",
- "libicuuc",
- "libicui18n",
+ "libandroidicu",
],
cflags: ["-DSQLITE_ENABLE_ICU"],
@@ -95,8 +95,7 @@ cc_library {
},
not_windows: {
shared_libs: [
- "libicuuc",
- "libicui18n",
+ "libandroidicu",
],
// include android specific methods
@@ -107,7 +106,7 @@ cc_library {
},
vendor: {
cflags: ["-USQLITE_ENABLE_ICU"],
- exclude_shared_libs: ["libicuuc", "libicui18n"],
+ exclude_shared_libs: ["libandroidicu"],
},
},
@@ -126,20 +125,14 @@ cc_binary {
srcs: ["shell.c"],
- tags: ["debug"],
-
target: {
android: {
shared_libs: [
"libsqlite",
- "libicuuc",
- "libicui18n",
+ "libandroidicu",
"liblog",
"libutils",
],
- static_libs: [
- "libicuandroid_utils",
- ],
},
host: {
cflags: ["-DNO_ANDROID_FUNCS=1"],
diff --git a/dist/Android.patch b/dist/Android.patch
index c5f7e1d..0da8ef6 100644
--- a/dist/Android.patch
+++ b/dist/Android.patch
@@ -1,13 +1,12 @@
-diff -r -u -d orig/shell.c ./shell.c
---- orig/shell.c 2018-04-13 17:25:47.747857988 -0700
-+++ ./shell.c 2018-04-13 17:25:47.787857731 -0700
+--- orig/shell.c 2018-02-20 10:41:05.477047088 +0000
++++ shell.c 2019-03-15 19:21:22.193972160 +0000
@@ -87,6 +87,12 @@
#endif
#include <ctype.h>
#include <stdarg.h>
+// Begin Android Add
+#ifndef NO_ANDROID_FUNCS
-+#include "IcuUtils.h"
++#include <aicu/AIcu.h>
+#include <sqlite3_android.h>
+#endif
+// End Android Add
@@ -21,7 +20,7 @@ diff -r -u -d orig/shell.c ./shell.c
+
+ // Begin Android Add
+ #ifndef NO_ANDROID_FUNCS
-+ InitializeIcuOrDie();
++ AIcu_initializeIcuOrDie();
+ int err = register_localized_collators(p->db, "en_US", 0);
+ if (err != SQLITE_OK) {
+ fprintf(stderr, "register_localized_collators() failed\n");
@@ -38,10 +37,47 @@ diff -r -u -d orig/shell.c ./shell.c
if( p->openMode==SHELL_OPEN_ZIPFILE ){
char *zSql = sqlite3_mprintf(
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
-diff -r -u -d orig/sqlite3.c ./sqlite3.c
---- orig/sqlite3.c 2018-12-27 15:39:18.784267281 -0800
-+++ ./sqlite3.c 2018-12-27 15:39:18.788267250 -0800
-@@ -34428,7 +34428,7 @@
+--- orig/sqlite3.c 2019-01-14 19:10:21.799582821 +0000
++++ sqlite3.c 2019-01-14 19:10:21.847582627 +0000
+@@ -30672,6 +30672,10 @@
+ # include <sys/mount.h>
+ #endif
+
++#if defined(__BIONIC__)
++# include <android/fdsan.h>
++#endif
++
+ #ifdef HAVE_UTIME
+ # include <utime.h>
+ #endif
+@@ -31422,6 +31426,12 @@
+ #if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
+ osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
+ #endif
++
++#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
++ uint64_t tag = android_fdsan_create_owner_tag(
++ ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
++ android_fdsan_exchange_owner_tag(fd, 0, tag);
++#endif
+ }
+ return fd;
+ }
+@@ -31954,7 +31964,13 @@
+ ** and move on.
+ */
+ static void robust_close(unixFile *pFile, int h, int lineno){
++#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
++ uint64_t tag = android_fdsan_create_owner_tag(
++ ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
++ if( android_fdsan_close_with_tag(h, tag) ){
++#else
+ if( osClose(h) ){
++#endif
+ unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
+ pFile ? pFile->zPath : 0, lineno);
+ }
+@@ -34428,7 +34444,7 @@
SimulateIOError( rc=1 );
if( rc!=0 ){
storeLastErrno((unixFile*)id, errno);
@@ -50,7 +86,7 @@ diff -r -u -d orig/sqlite3.c ./sqlite3.c
}
*pSize = buf.st_size;
-@@ -34464,7 +34464,7 @@
+@@ -34464,7 +34480,7 @@
struct stat buf; /* Used to hold return values of fstat() */
if( osFstat(pFile->h, &buf) ){
@@ -59,7 +95,7 @@ diff -r -u -d orig/sqlite3.c ./sqlite3.c
}
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
-@@ -35139,7 +35139,7 @@
+@@ -35139,7 +35155,7 @@
** with the same permissions.
*/
if( osFstat(pDbFd->h, &sStat) ){
@@ -68,7 +104,7 @@ diff -r -u -d orig/sqlite3.c ./sqlite3.c
goto shm_open_err;
}
-@@ -118054,7 +118054,7 @@
+@@ -118054,7 +118070,7 @@
}
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
sqlite3SetString(pzErrMsg, db, "unsupported file format");
@@ -77,7 +113,7 @@ diff -r -u -d orig/sqlite3.c ./sqlite3.c
goto initone_error_out;
}
-@@ -152769,13 +152769,25 @@
+@@ -152769,13 +152785,25 @@
** module with sqlite.
*/
if( SQLITE_OK==rc
diff --git a/dist/README-Android b/dist/README-Android
index 0ceec52..6811bad 100644
--- a/dist/README-Android
+++ b/dist/README-Android
@@ -5,4 +5,4 @@ They are immortalized in Android.patch to ease future upgrades.
This file can be regenerated using:
-diff -r -u -d orig . | grep -v "Only in" > Android.patch
+(for x in orig/*; do diff -u -d $x ${x#orig/}; done) > Android.patch
diff --git a/dist/shell.c b/dist/shell.c
index 41baf67..73f8b85 100644
--- a/dist/shell.c
+++ b/dist/shell.c
@@ -87,6 +87,12 @@ typedef unsigned char u8;
#endif
#include <ctype.h>
#include <stdarg.h>
+// Begin Android Add
+#ifndef NO_ANDROID_FUNCS
+#include <aicu/AIcu.h>
+#include <sqlite3_android.h>
+#endif
+// End Android Add
#if !defined(_WIN32) && !defined(WIN32)
# include <signal.h>
@@ -10389,6 +10395,23 @@ static void open_db(ShellState *p, int keepAlive){
editFunc, 0, 0);
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
editFunc, 0, 0);
+
+ // Begin Android Add
+ #ifndef NO_ANDROID_FUNCS
+ AIcu_initializeIcuOrDie();
+ int err = register_localized_collators(p->db, "en_US", 0);
+ if (err != SQLITE_OK) {
+ fprintf(stderr, "register_localized_collators() failed\n");
+ exit(1);
+ }
+ err = register_android_functions(p->db, 0);
+ if (err != SQLITE_OK) {
+ fprintf(stderr, "register_android_functions() failed\n");
+ exit(1);
+ }
+ #endif
+ // End Android Add
+
if( p->openMode==SHELL_OPEN_ZIPFILE ){
char *zSql = sqlite3_mprintf(
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
diff --git a/dist/sqlite3.c b/dist/sqlite3.c
index d14e246..16a098d 100644
--- a/dist/sqlite3.c
+++ b/dist/sqlite3.c
@@ -30672,6 +30672,10 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
# include <sys/mount.h>
#endif
+#if defined(__BIONIC__)
+# include <android/fdsan.h>
+#endif
+
#ifdef HAVE_UTIME
# include <utime.h>
#endif
@@ -31422,6 +31426,12 @@ static int robust_open(const char *z, int f, mode_t m){
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
#endif
+
+#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
+ uint64_t tag = android_fdsan_create_owner_tag(
+ ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
+ android_fdsan_exchange_owner_tag(fd, 0, tag);
+#endif
}
return fd;
}
@@ -31954,7 +31964,13 @@ static int unixLogErrorAtLine(
** and move on.
*/
static void robust_close(unixFile *pFile, int h, int lineno){
+#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
+ uint64_t tag = android_fdsan_create_owner_tag(
+ ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
+ if( android_fdsan_close_with_tag(h, tag) ){
+#else
if( osClose(h) ){
+#endif
unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
pFile ? pFile->zPath : 0, lineno);
}
@@ -34428,7 +34444,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
SimulateIOError( rc=1 );
if( rc!=0 ){
storeLastErrno((unixFile*)id, errno);
- return SQLITE_IOERR_FSTAT;
+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
}
*pSize = buf.st_size;
@@ -34464,7 +34480,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
struct stat buf; /* Used to hold return values of fstat() */
if( osFstat(pFile->h, &buf) ){
- return SQLITE_IOERR_FSTAT;
+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
}
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
@@ -35139,7 +35155,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
** with the same permissions.
*/
if( osFstat(pDbFd->h, &sStat) ){
- rc = SQLITE_IOERR_FSTAT;
+ rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath);
goto shm_open_err;
}
@@ -118054,7 +118070,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
}
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
sqlite3SetString(pzErrMsg, db, "unsupported file format");
- rc = SQLITE_ERROR;
+ rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;";
goto initone_error_out;
}
@@ -152770,13 +152786,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
** module with sqlite.
*/
if( SQLITE_OK==rc
+#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
&& SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
+#endif
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
){
+#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
+ rc = sqlite3_create_module_v2(
+ db, "fts1", &fts3Module, (void *)pHash, 0
+ );
+ if(rc) return rc;
+ rc = sqlite3_create_module_v2(
+ db, "fts2", &fts3Module, (void *)pHash, 0
+ );
+ if(rc) return rc;
+#endif
rc = sqlite3_create_module_v2(
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
);