Adding context flag to open database with no localized collators

Bug: 25956606
Change-Id: I209a8d18a7e83c1af54309fae8607f8b46772196
This commit is contained in:
Sunny Goyal
2015-12-02 09:51:02 -08:00
parent e03d5e4973
commit a21e6b2fac
5 changed files with 20 additions and 0 deletions

View File

@@ -7908,6 +7908,7 @@ package android.content {
field public static final int MODE_APPEND = 32768; // 0x8000
field public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 8; // 0x8
field public static final deprecated int MODE_MULTI_PROCESS = 4; // 0x4
field public static final int MODE_NO_LOCALIZED_COLLATORS = 16; // 0x10
field public static final int MODE_PRIVATE = 0; // 0x0
field public static final deprecated int MODE_WORLD_READABLE = 1; // 0x1
field public static final deprecated int MODE_WORLD_WRITEABLE = 2; // 0x2

View File

@@ -8155,6 +8155,7 @@ package android.content {
field public static final int MODE_APPEND = 32768; // 0x8000
field public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 8; // 0x8
field public static final deprecated int MODE_MULTI_PROCESS = 4; // 0x4
field public static final int MODE_NO_LOCALIZED_COLLATORS = 16; // 0x10
field public static final int MODE_PRIVATE = 0; // 0x0
field public static final deprecated int MODE_WORLD_READABLE = 1; // 0x1
field public static final deprecated int MODE_WORLD_WRITEABLE = 2; // 0x2

View File

@@ -7908,6 +7908,7 @@ package android.content {
field public static final int MODE_APPEND = 32768; // 0x8000
field public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 8; // 0x8
field public static final deprecated int MODE_MULTI_PROCESS = 4; // 0x4
field public static final int MODE_NO_LOCALIZED_COLLATORS = 16; // 0x10
field public static final int MODE_PRIVATE = 0; // 0x0
field public static final deprecated int MODE_WORLD_READABLE = 1; // 0x1
field public static final deprecated int MODE_WORLD_WRITEABLE = 2; // 0x2

View File

@@ -589,6 +589,9 @@ class ContextImpl extends Context {
if ((mode & MODE_ENABLE_WRITE_AHEAD_LOGGING) != 0) {
flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING;
}
if ((mode & MODE_NO_LOCALIZED_COLLATORS) != 0) {
flags |= SQLiteDatabase.NO_LOCALIZED_COLLATORS;
}
SQLiteDatabase db = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler);
setFilePermissionsFromMode(f.getPath(), mode, 0);
return db;

View File

@@ -159,6 +159,16 @@ public abstract class Context {
*/
public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008;
/**
* Database open flag: when set, the database is opened without support for
* localized collators.
*
* @see #openOrCreateDatabase(String, int, CursorFactory)
* @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler)
* @see SQLiteDatabase#NO_LOCALIZED_COLLATORS
*/
public static final int MODE_NO_LOCALIZED_COLLATORS = 0x0010;
/** @hide */
@IntDef(flag = true,
value = {
@@ -1271,6 +1281,7 @@ public abstract class Context {
* default operation, {@link #MODE_WORLD_READABLE}
* and {@link #MODE_WORLD_WRITEABLE} to control permissions.
* Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default.
* Use {@link #MODE_NO_LOCALIZED_COLLATORS} to disable localized collators.
* @param factory An optional factory class that is called to instantiate a
* cursor when query is called.
*
@@ -1281,6 +1292,7 @@ public abstract class Context {
* @see #MODE_WORLD_READABLE
* @see #MODE_WORLD_WRITEABLE
* @see #MODE_ENABLE_WRITE_AHEAD_LOGGING
* @see #MODE_NO_LOCALIZED_COLLATORS
* @see #deleteDatabase
*/
public abstract SQLiteDatabase openOrCreateDatabase(String name,
@@ -1298,6 +1310,7 @@ public abstract class Context {
* default operation, {@link #MODE_WORLD_READABLE}
* and {@link #MODE_WORLD_WRITEABLE} to control permissions.
* Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default.
* Use {@link #MODE_NO_LOCALIZED_COLLATORS} to disable localized collators.
* @param factory An optional factory class that is called to instantiate a
* cursor when query is called.
* @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database
@@ -1309,6 +1322,7 @@ public abstract class Context {
* @see #MODE_WORLD_READABLE
* @see #MODE_WORLD_WRITEABLE
* @see #MODE_ENABLE_WRITE_AHEAD_LOGGING
* @see #MODE_NO_LOCALIZED_COLLATORS
* @see #deleteDatabase
*/
public abstract SQLiteDatabase openOrCreateDatabase(String name,