Call register_localized_collators() with the current locale.
Make JNI function for setLocale() call register_localized_collators()
with the current locale, not previous one, every time it is possible.
This is a partial cherry-pick of b945639d0c3fa1850c07a2b80f476c8d242a8bde
BUG: 2514026
Change-Id: I584f1f68814dc084e699714e9d14a034123b49da
diff --git a/core/jni/android_database_SQLiteDatabase.cpp b/core/jni/android_database_SQLiteDatabase.cpp
index 020aff4a..f20dadb 100644
--- a/core/jni/android_database_SQLiteDatabase.cpp
+++ b/core/jni/android_database_SQLiteDatabase.cpp
@@ -262,7 +262,7 @@
goto done;
}
- dbLocale = (rowCount >= 1) ? meta[1 * colCount + 0] : NULL;
+ dbLocale = (rowCount >= 1) ? meta[colCount] : NULL;
if (dbLocale != NULL && !strcmp(dbLocale, locale8)) {
// database locale is the same as the desired locale; set up the collators and go
@@ -273,7 +273,8 @@
if ((flags & OPEN_READONLY)) {
// read-only database, so we're going to have to put up with whatever we got
- err = register_localized_collators(handle, dbLocale ? dbLocale : locale8, UTF16_STORAGE);
+ // For registering new index. Not for modifing the read-only database.
+ err = register_localized_collators(handle, locale8, UTF16_STORAGE);
if (err != SQLITE_OK) throw_sqlite3_exception(env, handle);
goto done;
}
@@ -286,7 +287,7 @@
goto done;
}
- err = register_localized_collators(handle, dbLocale ? dbLocale : locale8, UTF16_STORAGE);
+ err = register_localized_collators(handle, locale8, UTF16_STORAGE);
if (err != SQLITE_OK) {
LOGE("register_localized_collators() failed setting locale\n");
throw_sqlite3_exception(env, handle);