mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Merge pull request #269 from PisLuanyao/master
fix NativeLoader for Emu
This commit is contained in:
commit
61ffb37951
@ -89,6 +89,7 @@ internal object NativeLoader {
|
|||||||
val soPath = getLibFilePath(name)
|
val soPath = getLibFilePath(name)
|
||||||
val soFile = File(soDir, name)
|
val soFile = File(soDir, name)
|
||||||
fun reloadSo(tmp: File? = null) {
|
fun reloadSo(tmp: File? = null) {
|
||||||
|
XposedBridge.log("[Shamrock] 重载SO文件 $soFile")
|
||||||
LogCenter.log("SO文件大小不一致或不存在,正在重新加载", Level.INFO)
|
LogCenter.log("SO文件大小不一致或不存在,正在重新加载", Level.INFO)
|
||||||
soFile.delete()
|
soFile.delete()
|
||||||
if (tmp == null) moduleClassLoader.getResourceAsStream(soPath).use { origin ->
|
if (tmp == null) moduleClassLoader.getResourceAsStream(soPath).use { origin ->
|
||||||
@ -99,7 +100,7 @@ internal object NativeLoader {
|
|||||||
if (!soFile.exists()) {
|
if (!soFile.exists()) {
|
||||||
reloadSo()
|
reloadSo()
|
||||||
} else {
|
} else {
|
||||||
val tmpSoFile = soFile.resolve("$name.tmp").also { file ->
|
val tmpSoFile = File(soDir, "$name.tmp").also { file ->
|
||||||
if (file.exists()) file.delete()
|
if (file.exists()) file.delete()
|
||||||
file.outputStream().use {
|
file.outputStream().use {
|
||||||
moduleClassLoader.getResourceAsStream(soPath).use { origin ->
|
moduleClassLoader.getResourceAsStream(soPath).use { origin ->
|
||||||
@ -107,11 +108,12 @@ internal object NativeLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
XposedBridge.log("[Shamrock] 正在校验${name}库文件")
|
||||||
if (soFile.length() != tmpSoFile.length() || MD5.getFileMD5(soFile).let {
|
if (soFile.length() != tmpSoFile.length() || MD5.getFileMD5(soFile).let {
|
||||||
it != MD5.getFileMD5(tmpSoFile)
|
it != MD5.getFileMD5(tmpSoFile)
|
||||||
}) {
|
}) {
|
||||||
reloadSo(tmpSoFile)
|
reloadSo(tmpSoFile)
|
||||||
}
|
} else { tmpSoFile.delete() }
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
System.load(soFile.absolutePath)
|
System.load(soFile.absolutePath)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user