From 2a8eb64ce037a7007c47f7c8b2312074bf6586b1 Mon Sep 17 00:00:00 2001 From: Nick Parker Date: Thu, 3 Mar 2022 16:06:21 -0600 Subject: [PATCH 1/8] Check result of moveToFirst when querying pragma value --- .../java/net/sqlcipher/database/SQLiteDatabase.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/android-database-sqlcipher/src/main/java/net/sqlcipher/database/SQLiteDatabase.java b/android-database-sqlcipher/src/main/java/net/sqlcipher/database/SQLiteDatabase.java index 8bf94945..d368c46f 100644 --- a/android-database-sqlcipher/src/main/java/net/sqlcipher/database/SQLiteDatabase.java +++ b/android-database-sqlcipher/src/main/java/net/sqlcipher/database/SQLiteDatabase.java @@ -3180,12 +3180,15 @@ private static ArrayList> getAttachedDbs(SQLiteDatabase dbO } private Pair getResultFromPragma(String command) { + Pair result = new Pair(false, ""); Cursor cursor = rawQuery(command, new Object[]{}); - if(cursor == null) return new Pair(false, ""); - cursor.moveToFirst(); - String value = cursor.getString(0); + if(cursor == null) return result; + if(cursor.moveToFirst()){ + String value = cursor.getString(0); + result = new Pair(true, value); + } cursor.close(); - return new Pair(true, value); + return result; } From 96fb7311949153648b786f7bc86581b814105307 Mon Sep 17 00:00:00 2001 From: Nick Parker Date: Fri, 8 Jul 2022 12:07:56 -0500 Subject: [PATCH 2/8] Update Gradle to 7.4.2 and Android Gradle plugin to 7.2.1 --- android-database-sqlcipher/build.gradle | 2 + android-database-sqlcipher/maven.gradle | 56 +++++++++--------------- build.gradle | 2 +- gradle.properties | 1 + gradle/wrapper/gradle-wrapper.properties | 5 ++- 5 files changed, 28 insertions(+), 38 deletions(-) create mode 100644 gradle.properties diff --git a/android-database-sqlcipher/build.gradle b/android-database-sqlcipher/build.gradle index 7ed66afd..e80aec7c 100644 --- a/android-database-sqlcipher/build.gradle +++ b/android-database-sqlcipher/build.gradle @@ -24,10 +24,12 @@ android { buildTypes { debug { debuggable true + buildConfigField("String", "VERSION_NAME", "\"${clientVersionNumber}\"") } release { debuggable false minifyEnabled false + buildConfigField("String", "VERSION_NAME", "\"${clientVersionNumber}\"") } } diff --git a/android-database-sqlcipher/maven.gradle b/android-database-sqlcipher/maven.gradle index 3d72a2cb..cd98c647 100644 --- a/android-database-sqlcipher/maven.gradle +++ b/android-database-sqlcipher/maven.gradle @@ -1,4 +1,4 @@ -apply plugin: "maven" +apply plugin: "maven-publish" apply plugin: "signing" import org.gradle.plugins.signing.Sign @@ -36,56 +36,42 @@ gradle.taskGraph.whenReady { taskGraph -> } } -afterEvaluate { project -> - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - pom.groupId = mavenGroup - pom.artifactId = mavenArtifactId - pom.version = mavenVersionName - - repository(url: getReleaseRepositoryUrl()) { - authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) - } - snapshotRepository(url: getSnapshotRepositoryUrl()) { - authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) - } - - pom.project { - name mavenArtifactId - packaging mavenPackaging - description mavenPomDescription - url mavenPomUrl - scm { - url mavenScmUrl - connection mavenScmConnection - developerConnection mavenScmDeveloperConnection - } +afterEvaluate { project -> + publishing { + publications { + mavenJava(MavenPublication) { + groupId = mavenGroup + artifactId = mavenArtifactId + version = mavenPomDescription + pom { + name = mavenArtifactId + description = mavenPomDescription + url = mavenPomUrl licenses { license { - url mavenLicenseUrl + url = mavenLicenseUrl } } - developers { developer { - name mavenDeveloperName - email mavenDeveloperEmail - organization mavenDeveloperOrganization - organizationUrl mavenDeveloperUrl + name = mavenDeveloperName + email = mavenDeveloperEmail } } + scm { + connection = mavenScmConnection + developerConnection = mavenScmDeveloperConnection + url = mavenScmUrl + } } } } } signing { - required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } + required { isReleaseBuild() } sign configurations.archives } diff --git a/build.gradle b/build.gradle index 45688c10..be596c39 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { } } dependencies { - classpath "com.android.tools.build:gradle:3.4.1" + classpath 'com.android.tools.build:gradle:7.2.1' classpath "gradle.plugin.org.ec4j.gradle:editorconfig-gradle-plugin:0.0.3" } } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..2d8d1e4d --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +android.useAndroidX=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffb59778..8e9cc23a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Fri Jul 08 11:01:47 CDT 2022 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip +zipStoreBase=GRADLE_USER_HOME From 77efcfc503e9fe5624decf8f956ae8a5ae082be4 Mon Sep 17 00:00:00 2001 From: Nick Parker Date: Fri, 8 Jul 2022 13:34:58 -0500 Subject: [PATCH 3/8] Remove gradle directory path to NDK, will be on PATH --- android-database-sqlcipher/native.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android-database-sqlcipher/native.gradle b/android-database-sqlcipher/native.gradle index a9c36290..8a04803b 100644 --- a/android-database-sqlcipher/native.gradle +++ b/android-database-sqlcipher/native.gradle @@ -163,7 +163,7 @@ def executeNdkBuild(outputDir, androidMkDirectory, applicationMkFile, "ANDROID_NATIVE_ROOT_DIR": "${androidNativeRootDir}", "NDK_APP_PLATFORM" : "${androidVersion}"] environment(environmentVariables) - commandLine "${android.ndkDirectory}/ndk-build", "V=1", "${ndkBuildType}", + commandLine "ndk-build", "V=1", "${ndkBuildType}", "--environment-overrides", outputDirectory, "-C", androidMkDirectory, applicationFile } From 9073e41c7f2b89e77f412dff24ff8f25af4a8b2c Mon Sep 17 00:00:00 2001 From: Nick Parker Date: Wed, 3 Aug 2022 11:25:06 -0500 Subject: [PATCH 4/8] Adjustments to upload artifacts to Maven Central --- Makefile | 2 +- android-database-sqlcipher/maven.gradle | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 40602971..7a42f371 100644 --- a/Makefile +++ b/Makefile @@ -87,7 +87,7 @@ publish-remote-release: -PopensslAndroidLibRoot="$(OPENSSL_ANDROID_LIB_ROOT)" \ -PsqlcipherCFlags="$(SQLCIPHER_CFLAGS)" \ -PsqlcipherAndroidClientVersion="$(SQLCIPHER_ANDROID_VERSION)" \ - uploadArchives + android-database-sqlcipher:publish collect-nexus-info := \ read -p "Enter Nexus username:" nexusUsername; \ diff --git a/android-database-sqlcipher/maven.gradle b/android-database-sqlcipher/maven.gradle index cd98c647..30b2d519 100644 --- a/android-database-sqlcipher/maven.gradle +++ b/android-database-sqlcipher/maven.gradle @@ -42,9 +42,10 @@ afterEvaluate { project -> publishing { publications { mavenJava(MavenPublication) { + from components.release groupId = mavenGroup artifactId = mavenArtifactId - version = mavenPomDescription + version = mavenVersionName pom { name = mavenArtifactId description = mavenPomDescription @@ -68,10 +69,20 @@ afterEvaluate { project -> } } } + repositories { + maven { + def releasesRepoUrl = getReleaseRepositoryUrl() + url = releasesRepoUrl + credentials { + username = getRepositoryUsername() + password = getRepositoryPassword() + } + } + } } signing { - required { isReleaseBuild() } + required { isReleaseBuild() && gradle.taskGraph.hasTask("publish") } sign configurations.archives } From 5164a1ba002929c739f6c31fafae588ac7a914f5 Mon Sep 17 00:00:00 2001 From: Nick Parker Date: Wed, 3 Aug 2022 12:09:13 -0500 Subject: [PATCH 5/8] Adjustments to sign artifacts, release/local repo URL --- android-database-sqlcipher/maven.gradle | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/android-database-sqlcipher/maven.gradle b/android-database-sqlcipher/maven.gradle index 30b2d519..1e62a540 100644 --- a/android-database-sqlcipher/maven.gradle +++ b/android-database-sqlcipher/maven.gradle @@ -71,8 +71,10 @@ afterEvaluate { project -> } repositories { maven { - def releasesRepoUrl = getReleaseRepositoryUrl() - url = releasesRepoUrl + def repoUrl = isReleaseBuild() + ? getReleaseRepositoryUrl() + : getSnapshotRepositoryUrl(); + url = repoUrl credentials { username = getRepositoryUsername() password = getRepositoryPassword() @@ -83,7 +85,7 @@ afterEvaluate { project -> signing { required { isReleaseBuild() && gradle.taskGraph.hasTask("publish") } - sign configurations.archives + sign publishing.publications.mavenJava } task androidSourcesJar(type: Jar) { From a3a4a5aea35ba5badd07da3d79e1709389ce4f31 Mon Sep 17 00:00:00 2001 From: Nick Parker Date: Wed, 14 Sep 2022 08:12:18 -0500 Subject: [PATCH 6/8] Adjust maven repo url syntax --- android-database-sqlcipher/maven.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android-database-sqlcipher/maven.gradle b/android-database-sqlcipher/maven.gradle index 1e62a540..59389bc7 100644 --- a/android-database-sqlcipher/maven.gradle +++ b/android-database-sqlcipher/maven.gradle @@ -73,7 +73,7 @@ afterEvaluate { project -> maven { def repoUrl = isReleaseBuild() ? getReleaseRepositoryUrl() - : getSnapshotRepositoryUrl(); + : getSnapshotRepositoryUrl() url = repoUrl credentials { username = getRepositoryUsername() From 310abc1391dc30fb619d5921ac32f060b1171c48 Mon Sep 17 00:00:00 2001 From: Nick Parker Date: Wed, 14 Sep 2022 08:13:15 -0500 Subject: [PATCH 7/8] Add SQLCIPHER_CFLAGS environment variable to build instructions --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f35aefc3..6a45ea2c 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ The latest AAR binary package information can be [here](https://www.zetetic.net/ ### Compatibility -SQLCipher for Android runs on Android 4.1–Android 12, for `armeabi-v7a`, `x86`, `x86_64`, and `arm64_v8a` architectures. +SQLCipher for Android runs on Android 4.1–Android 13, for `armeabi-v7a`, `x86`, `x86_64`, and `arm64_v8a` architectures. ### Contributions @@ -55,11 +55,11 @@ such as having the following line in your module's `build.gradle` `dependencies` closure: ```gradle -implementation "net.zetetic:android-database-sqlcipher:4.5.0" +implementation "net.zetetic:android-database-sqlcipher:4.5.2" implementation "androidx.sqlite:sqlite:2.0.1" ``` -(replacing `4.5.0` with the version you want) +(replacing `4.5.2` with the version you want) @@ -144,11 +144,12 @@ To complete the `make` command, the `ANDROID_NDK_HOME` environment variable must ``` SQLCIPHER_ROOT=/some/path/to/sqlcipher-folder \ OPENSSL_ROOT=/some/path/to/openssl-folder \ -SQLCIPHER_ANDROID_VERSION="4.5.0" \ +SQLCIPHER_CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2" \ +SQLCIPHER_ANDROID_VERSION="4.5.2" \ make build-release ``` -You may also optionally include `SQLCIPHER_CFLAGS` to override the default features SQLCipher core is compiled with. If `SQLCIPHER_CFLAGS` is defined, make sure `-DSQLITE_HAS_CODEC` is included in the list of flags. +You may specify other build flags/features within `SQLCIPHER_CFLAGS`, however, specifying `-DSQLITE_HAS_CODEC` and `-DSQLITE_TEMP_STORE` is necessary In the list of flags. ### License From 62166f771cd04c6400380add5ceec492cfb87d75 Mon Sep 17 00:00:00 2001 From: Nick Parker Date: Wed, 14 Sep 2022 08:14:55 -0500 Subject: [PATCH 8/8] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a45ea2c..3dc500d0 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ SQLCIPHER_ANDROID_VERSION="4.5.2" \ make build-release ``` -You may specify other build flags/features within `SQLCIPHER_CFLAGS`, however, specifying `-DSQLITE_HAS_CODEC` and `-DSQLITE_TEMP_STORE` is necessary In the list of flags. +You may specify other build flags/features within `SQLCIPHER_CFLAGS`, however, specifying `-DSQLITE_HAS_CODEC` and `-DSQLITE_TEMP_STORE` is necessary in the list of flags. ### License