Skip to content

Commit 2215002

Browse files
SQLCipher for Android 3.0.0 binaries, test adjustments
1 parent d21c691 commit 2215002

File tree

8 files changed

+149
-122
lines changed

8 files changed

+149
-122
lines changed
0 Bytes
Binary file not shown.

libs/sqlcipher.jar

-988 Bytes
Binary file not shown.

libs/x86/libsqlcipher_android.so

0 Bytes
Binary file not shown.

net.zetetic.sqlcipher.test.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<option name="PROGUARD_CFG_PATH" value="/proguard.cfg" />
1212
<includeSystemProguardFile>false</includeSystemProguardFile>
1313
<includeAssetsFromLibraries>true</includeAssetsFromLibraries>
14+
<option name="COMPILE_CUSTOM_GENERATED_SOURCES" value="false" />
1415
<resOverlayFolders />
1516
</configuration>
1617
</facet>
@@ -25,7 +26,6 @@
2526
<excludeFolder url="file://$MODULE_DIR$/target/generated-sources/combined-assets" />
2627
<excludeFolder url="file://$MODULE_DIR$/target/generated-sources/combined-resources" />
2728
<excludeFolder url="file://$MODULE_DIR$/target/generated-sources/extracted-dependencies" />
28-
<excludeFolder url="file://$MODULE_DIR$/target/test-classes" />
2929
</content>
3030
<orderEntry type="sourceFolder" forTests="false" />
3131
<orderEntry type="jdk" jdkName="Maven Android 2.1 Platform" jdkType="Android SDK" />

net.zetetic.sqlcipher.test.iws

Lines changed: 102 additions & 114 deletions
Large diffs are not rendered by default.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package net.zetetic.tests;
2+
3+
import android.util.Log;
4+
import net.sqlcipher.database.SQLiteDatabase;
5+
import net.sqlcipher.database.SQLiteDatabaseHook;
6+
import net.zetetic.QueryHelper;
7+
import net.zetetic.ZeteticApplication;
8+
9+
import java.io.File;
10+
11+
public class CipherMigrateTest extends SQLCipherTest {
12+
13+
File olderFormatDatabase = ZeteticApplication.getInstance().getDatabasePath("2x.db");
14+
15+
@Override
16+
public boolean execute(SQLiteDatabase database) {
17+
database.close();
18+
final boolean[] status = {false};
19+
try {
20+
ZeteticApplication.getInstance().extractAssetToDatabaseDirectory("2x.db");
21+
SQLiteDatabaseHook hook = new SQLiteDatabaseHook() {
22+
public void preKey(SQLiteDatabase database) {}
23+
public void postKey(SQLiteDatabase database) {
24+
String value = QueryHelper.singleValueFromQuery(database, "PRAGMA cipher_migrate");
25+
status[0] = Integer.valueOf(value) == 0;
26+
}
27+
};
28+
database = SQLiteDatabase.openOrCreateDatabase(olderFormatDatabase,
29+
ZeteticApplication.DATABASE_PASSWORD, null, hook);
30+
if(database != null){
31+
database.close();
32+
}
33+
} catch (Exception e) {
34+
Log.i(TAG, "error", e);
35+
}
36+
return status[0];
37+
}
38+
39+
@Override
40+
public String getName() {
41+
return "Cipher Migrate Test";
42+
}
43+
}

src/main/java/net/zetetic/tests/MigrationUserVersion.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,13 @@ public boolean execute(SQLiteDatabase database) {
2929
File sourceDatabase = ZeteticApplication.getInstance().getDatabasePath(ZeteticApplication.ONE_X_USER_VERSION_DATABASE);
3030
SQLiteDatabase originalDatabase = SQLiteDatabase.openOrCreateDatabase(sourceDatabase, password, null, new SQLiteDatabaseHook() {
3131
public void preKey(SQLiteDatabase database) {
32-
database.rawExecSQL("PRAGMA cipher_default_use_hmac=off;");
3332
}
3433
public void postKey(SQLiteDatabase database) {
3534
database.rawExecSQL("PRAGMA cipher_migrate;");
3635
}
3736
});
38-
int userVersion = originalDatabase.getVersion();
39-
originalDatabase.close();
40-
SQLiteDatabase.upgradeDatabaseFormatFromVersion1To2(sourceDatabase, password);
41-
SQLiteDatabase migratedDatabase = SQLiteDatabase.openOrCreateDatabase(sourceDatabase, password, null, null);
42-
migratedDatabase.setVersion(userVersion);
43-
return migratedDatabase.getVersion() == userVersion;
37+
return originalDatabase.getVersion() > 0;
38+
4439
} catch (Exception e) {
4540
return false;
4641
}

src/main/java/net/zetetic/tests/TestSuiteRunner.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ private void runSuite(){
4040

4141
private List<SQLCipherTest> getTestsToRun(){
4242
List<SQLCipherTest> tests = new ArrayList<SQLCipherTest>();
43+
tests.add(new CipherMigrateTest());
4344
tests.add(new GetTypeFromCrossProcessCursorWrapperTest());
4445
tests.add(new InvalidPasswordTest());
4546
tests.add(new NullQueryResultTest());

0 commit comments

Comments
 (0)