diff --git a/.circleci/config.yml b/.circleci/config.yml index 5e9c02f..59e21f5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -112,6 +112,11 @@ jobs: ./gradlew :harmony:publishToMavenLocal ./gradlew :crypto:assembleRelease + - persist_to_workspace: + root: ~/repo + paths: + - . + Android-Harmony-Upload: docker: - image: cimg/android:2022.09.1 @@ -125,6 +130,8 @@ jobs: steps: - checkout + - attach_workspace: + at: ~/repo - run: name: Upload Harmony Library command: | @@ -144,6 +151,8 @@ jobs: steps: - checkout + - attach_workspace: + at: ~/repo - run: name: Upload Harmony Crypto command: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 4053440..a2e7d7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## Change Log +### Version 1.2.2 & Harmony-Crypto Version 0.1.1 / 2022-10-22 +- Fix bug where transaction file metadata was not being written right away +- Don't create unnecessary hash set if no string set is found for given key +- Update annotation library + ### Version 1.2.1 / 2022-09-17 - Fixes crash with putting a string set with a `null` item [#46](https://github.com/pablobaxter/Harmony/issues/46) diff --git a/README.md b/README.md index 8400acf..7d14ac1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![CircleCI](https://circleci.com/gh/pablobaxter/Harmony/tree/main.svg?style=shield)](https://circleci.com/gh/pablobaxter/Harmony/tree/main) [![GitHub](https://img.shields.io/github/license/pablobaxter/harmony)](https://github.com/pablobaxter/Harmony/blob/main/LICENSE) -[![Maven Central](https://img.shields.io/maven-central/v/com.frybits.harmony/harmony?label=Harmony)](https://search.maven.org/artifact/com.frybits.harmony/harmony/1.2.1/aar) [![Harmony API](https://img.shields.io/badge/API-17%2B-brightgreen.svg?style=flat&label=Harmony%20API)](https://android-arsenal.com/api?level=17) [![Maven Central](https://img.shields.io/maven-central/v/com.frybits.harmony/harmony-crypto?label=Harmony-Crypto)](https://search.maven.org/artifact/com.frybits.harmony/harmony-crypto/0.1.0/aar) [![Crypto API](https://img.shields.io/badge/API-23%2B-purple.svg?style=flat&label=Crypto%20API)](https://android-arsenal.com/api?level=23) +[![Maven Central](https://img.shields.io/maven-central/v/com.frybits.harmony/harmony?label=Harmony)](https://search.maven.org/artifact/com.frybits.harmony/harmony/1.2.2/aar) [![Harmony API](https://img.shields.io/badge/API-17%2B-brightgreen.svg?style=flat&label=Harmony%20API)](https://android-arsenal.com/api?level=17) [![Maven Central](https://img.shields.io/maven-central/v/com.frybits.harmony/harmony-crypto?label=Harmony-Crypto)](https://search.maven.org/artifact/com.frybits.harmony/harmony-crypto/0.1.1/aar) [![Crypto API](https://img.shields.io/badge/API-23%2B-purple.svg?style=flat&label=Crypto%20API)](https://android-arsenal.com/api?level=23) Working on multiprocess Android apps is a complex undertaking. One of the biggest challenges is managing shared data between the multiple processes. Most solutions rely on one process to be available for another to read the data, which can be quite slow and could potentially lead to ANRs. @@ -18,11 +18,11 @@ Harmony is a thread-safe, process-safe, full [`SharedPreferences`](https://devel - Supports Android API 17+ (Crypto Android API 23+) ## Download -The latest release is available on [Maven Central](https://search.maven.org/artifact/com.frybits.harmony/harmony/1.2.1/aar). +The latest release is available on [Maven Central](https://search.maven.org/artifact/com.frybits.harmony/harmony/1.2.2/aar). ### Gradle ``` -implementation 'com.frybits.harmony:harmony:1.2.1' -// implementation 'com.frybits.harmony:harmony-crypto:0.1.0' // For Encrypted SharedPreferences +implementation 'com.frybits.harmony:harmony:1.2.2' +// implementation 'com.frybits.harmony:harmony-crypto:0.1.1' // For Encrypted SharedPreferences ``` ## Usage diff --git a/app/build.gradle b/app/build.gradle index c7eb28e..6f07bc0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'frybits-application' android { + namespace 'com.frybits.harmony.app' defaultConfig { applicationId "com.frybits.harmony.app" targetSdk targetSdk_version diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a9084a7..e6c82d1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + - diff --git a/crypto/src/main/java/androidx/security/crypto/SecureHarmonyPreferences.kt b/crypto/src/main/java/androidx/security/crypto/SecureHarmonyPreferences.kt index fa24585..00998c5 100644 --- a/crypto/src/main/java/androidx/security/crypto/SecureHarmonyPreferences.kt +++ b/crypto/src/main/java/androidx/security/crypto/SecureHarmonyPreferences.kt @@ -150,12 +150,7 @@ private class SecureHarmonyPreferencesImpl( override fun getStringSet(key: String?, defValues: MutableSet?): MutableSet? { val obj = getDecryptedObject(key) @Suppress("UNCHECKED_CAST") - val result = (obj as Set?)?.toMutableSet() ?: hashSetOf() - return if (result.size > 0) { - result - } else { - defValues - } + return (obj as Set?)?.toMutableSet() ?: defValues } override fun getInt(key: String?, defValue: Int): Int { diff --git a/harmony/build.gradle b/harmony/build.gradle index ba95b61..3f9219c 100644 --- a/harmony/build.gradle +++ b/harmony/build.gradle @@ -1,5 +1,7 @@ apply plugin: 'frybits-library' +android.namespace 'com.frybits.harmony' + dependencies { // Kotlin implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" diff --git a/harmony/gradle.properties b/harmony/gradle.properties index 2d48fba..2da9394 100644 --- a/harmony/gradle.properties +++ b/harmony/gradle.properties @@ -1 +1 @@ -version=1.2.1 +version=1.2.2 diff --git a/harmony/src/main/AndroidManifest.xml b/harmony/src/main/AndroidManifest.xml deleted file mode 100644 index 2bea2ab..0000000 --- a/harmony/src/main/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/harmony/src/main/java/com/frybits/harmony/Harmony.kt b/harmony/src/main/java/com/frybits/harmony/Harmony.kt index fa92e48..97ffc8f 100644 --- a/harmony/src/main/java/com/frybits/harmony/Harmony.kt +++ b/harmony/src/main/java/com/frybits/harmony/Harmony.kt @@ -225,12 +225,7 @@ private class HarmonyImpl constructor( awaitForLoad() val obj = mapReentrantReadWriteLock.read { harmonyMap[key] } @Suppress("UNCHECKED_CAST") - val result = (obj as Set?)?.toMutableSet() ?: hashSetOf() - return if (result.size > 0) { - result - } else { - defValues - } + return (obj as Set?)?.toMutableSet() ?: defValues } override fun contains(key: String?): Boolean { @@ -635,12 +630,14 @@ private class HarmonyImpl constructor( FileOutputStream(harmonyTransactionsFile, true).use { outputStream -> val bufferedOutputStream = outputStream.buffered() // Transaction batching to improve cross-process replication - repeat(transactionMaxBatchCount) { - val peekedTransaction = transactionQueue.peek() ?: return@use - peekedTransaction.commitTransactionToOutputStream(bufferedOutputStream) - bufferedOutputStream.flush() - transactionQueue.remove(peekedTransaction) + run transactionQueue@ { + repeat(transactionMaxBatchCount) { + val peekedTransaction = transactionQueue.peek() ?: return@transactionQueue + peekedTransaction.commitTransactionToOutputStream(bufferedOutputStream) + transactionQueue.remove(peekedTransaction) + } } + bufferedOutputStream.flush() // Write all changes to the physical storage outputStream.sync() } diff --git a/target31test/build.gradle b/target31test/build.gradle index 4fab3d7..eb2b447 100644 --- a/target31test/build.gradle +++ b/target31test/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'frybits-test' android { + namespace 'com.frybits.harmony.test' targetProjectPath ":app" defaultConfig { diff --git a/target31test/src/main/AndroidManifest.xml b/target31test/src/main/AndroidManifest.xml deleted file mode 100644 index 73052d9..0000000 --- a/target31test/src/main/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - -