Skip to content

Commit 0ba1888

Browse files
committed
feat: prepare some infrastructure for OhMyKeymint
add a method to pass Parcelable object to jni layer Signed-off-by: qwq233 <qwq233@qwq2333.top>
1 parent 44426ed commit 0ba1888

File tree

1 file changed

+13
-0
lines changed
  • service/src/main/java/io/github/a13e300/tricky_store

1 file changed

+13
-0
lines changed

service/src/main/java/io/github/a13e300/tricky_store/util.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package io.github.a13e300.tricky_store
33
import android.content.pm.IPackageManager
44
import android.content.pm.PackageManager
55
import android.os.Build
6+
import android.os.Parcel
7+
import android.os.Parcelable
68
import android.os.SystemProperties
79
import io.github.a13e300.tricky_store.Config.getPm
810
import org.bouncycastle.asn1.ASN1Encodable
@@ -123,3 +125,14 @@ fun String.toDER() = DEROctetString(this.toByteArray())
123125

124126
fun DEROctetString.toTaggedObj(tag: Int, explicit: Boolean = true) = DERTaggedObject(explicit, tag, this)
125127
fun String.trimLine() = trim().split("\n").joinToString("\n") { it.trim() }
128+
129+
fun Parcelable.toBytes(): ByteArray {
130+
val p = Parcel.obtain()
131+
return try {
132+
this.writeToParcel(p, 0)
133+
p.marshall()
134+
} finally {
135+
p.recycle()
136+
}
137+
}
138+

0 commit comments

Comments
 (0)