bug修复

This commit is contained in:
aiselp
2023-06-14 20:49:24 +08:00
parent 9579db0f25
commit 3931b1cc82

View File

@@ -26,7 +26,6 @@ class AssetAndUrlModuleSourceProvider(
private val okHttpClient = OkHttpClient.Builder().followRedirects(true).build() private val okHttpClient = OkHttpClient.Builder().followRedirects(true).build()
private val contentResolver: ContentResolver = context.contentResolver private val contentResolver: ContentResolver = context.contentResolver
private val moduleSources: ArrayList<URI> = arrayListOf(mBaseURI, npmModuleSource) private val moduleSources: ArrayList<URI> = arrayListOf(mBaseURI, npmModuleSource)
private val encryptionSource = File(context.filesDir, "project")
companion object { companion object {
val mBaseURI: URI = URI.create("file:/android_asset/modules") val mBaseURI: URI = URI.create("file:/android_asset/modules")
@@ -111,17 +110,14 @@ class AssetAndUrlModuleSourceProvider(
uri: URI, uri: URI,
base: URI?, base: URI?,
validator: Any?, validator: Any?,
): ModuleSource? { ): ModuleSource {
//只处理内部位于apk内部资源的脚本文件 val bytes = ByteArray(inputStream.available())
val i = if (uri.path.startsWith(encryptionSource.path)) { inputStream.read(bytes)
val bytes = ByteArray(inputStream.available()) inputStream.close()
inputStream.read(bytes) val i = if (isValidFile(bytes)) {
inputStream.close() val clearText = decrypt(bytes, EncryptedScriptFileHeader.BLOCK_SIZE, bytes.size)
if (isValidFile(bytes)) { ByteArrayInputStream(clearText)
val clearText = decrypt(bytes, EncryptedScriptFileHeader.BLOCK_SIZE, bytes.size) } else ByteArrayInputStream(bytes)
ByteArrayInputStream(clearText)
} else inputStream
} else inputStream
return createModuleSource(i, uri, base, validator) return createModuleSource(i, uri, base, validator)
} }