Skip to content

Commit 389f716

Browse files
Changing the process for using a system provided ICU dat file or extracting one from assets
1 parent f4c818c commit 389f716

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/info/guardianproject/database/sqlcipher/SQLiteDatabase.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ private static void loadICUData(Context context) {
7878
File applicationFilesDirectory = context.getFilesDir();
7979
File icuDir = new File(applicationFilesDirectory, "icu");
8080
if(!icuDir.exists()) icuDir.mkdirs();
81-
File icuDataFile = new File(icuDir, "icudt44l.dat");
81+
File icuDataFile = new File(icuDir, "icudt46l.dat");
8282
if(!icuDataFile.exists()) {
83-
ZipInputStream in = new ZipInputStream(context.getAssets().open("icudt44l.zip"));
83+
ZipInputStream in = new ZipInputStream(context.getAssets().open("icudt46l.zip"));
8484
in.getNextEntry();
8585

8686
OutputStream out = new FileOutputStream(icuDataFile);
@@ -104,12 +104,13 @@ public static void loadLibs (Context context)
104104
System.loadLibrary("stlport_shared");
105105
System.loadLibrary("sqlcipher_android");
106106
System.loadLibrary("database_sqlcipher");
107-
107+
108+
boolean systemICUFileExists = new File("/system/usr/icu/icudt46l.dat").exists();
108109
File applicationFilesDirectory = context.getFilesDir();
109-
String icuRootPath = android.os.Build.VERSION.SDK_INT < 9 ? applicationFilesDirectory.getAbsolutePath()
110-
: "/system/usr";
110+
String icuRootPath = systemICUFileExists ? "/system/usr" : applicationFilesDirectory.getAbsolutePath();
111111
setICURoot(icuRootPath);
112-
if(android.os.Build.VERSION.SDK_INT < 9){
112+
113+
if(!systemICUFileExists){
113114
loadICUData(context);
114115
}
115116
}
@@ -917,6 +918,7 @@ public static SQLiteDatabase create(CursorFactory factory, String password) {
917918
* Close the database.
918919
*/
919920
public void close() {
921+
920922
if (!isOpen()) {
921923
return; // already closed
922924
}

0 commit comments

Comments
 (0)