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.OlmPkEncryption
|
||||
import org.matrix.olm.OlmPkSigning
|
||||
import org.matrix.olm.OlmUtility
|
||||
|
||||
fun <T> withOlmEncryption(block: (OlmPkEncryption) -> T): T {
|
||||
val olmPkEncryption = OlmPkEncryption()
|
||||
|
@ -46,3 +47,12 @@ fun <T> withOlmSigning(block: (OlmPkSigning) -> T): T {
|
|||
olmPkSigning.releaseSigning()
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> withOlmUtility(block: (OlmUtility) -> T): T {
|
||||
val olmUtility = OlmUtility()
|
||||
try {
|
||||
return block(olmUtility)
|
||||
} finally {
|
||||
olmUtility.releaseUtility()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue