mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Add withOlmUtility facility
This commit is contained in:
parent
25bbd7c526
commit
9b7c2599a7
@ -19,6 +19,7 @@ package im.vector.matrix.android.internal.crypto.tools
|
|||||||
import org.matrix.olm.OlmPkDecryption
|
import org.matrix.olm.OlmPkDecryption
|
||||||
import org.matrix.olm.OlmPkEncryption
|
import org.matrix.olm.OlmPkEncryption
|
||||||
import org.matrix.olm.OlmPkSigning
|
import org.matrix.olm.OlmPkSigning
|
||||||
|
import org.matrix.olm.OlmUtility
|
||||||
|
|
||||||
fun <T> withOlmEncryption(block: (OlmPkEncryption) -> T): T {
|
fun <T> withOlmEncryption(block: (OlmPkEncryption) -> T): T {
|
||||||
val olmPkEncryption = OlmPkEncryption()
|
val olmPkEncryption = OlmPkEncryption()
|
||||||
@ -46,3 +47,12 @@ fun <T> withOlmSigning(block: (OlmPkSigning) -> T): T {
|
|||||||
olmPkSigning.releaseSigning()
|
olmPkSigning.releaseSigning()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <T> withOlmUtility(block: (OlmUtility) -> T): T {
|
||||||
|
val olmUtility = OlmUtility()
|
||||||
|
try {
|
||||||
|
return block(olmUtility)
|
||||||
|
} finally {
|
||||||
|
olmUtility.releaseUtility()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user