From 3931b1cc82c1edb8f39117d63e924c1f5a3bfbe1 Mon Sep 17 00:00:00 2001 From: aiselp Date: Wed, 14 Jun 2023 20:49:24 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/AssetAndUrlModuleSourceProvider.kt | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/autojs/autojs/engine/module/AssetAndUrlModuleSourceProvider.kt b/app/src/main/java/org/autojs/autojs/engine/module/AssetAndUrlModuleSourceProvider.kt index ca5781b5..e25ac4b5 100644 --- a/app/src/main/java/org/autojs/autojs/engine/module/AssetAndUrlModuleSourceProvider.kt +++ b/app/src/main/java/org/autojs/autojs/engine/module/AssetAndUrlModuleSourceProvider.kt @@ -26,7 +26,6 @@ class AssetAndUrlModuleSourceProvider( private val okHttpClient = OkHttpClient.Builder().followRedirects(true).build() private val contentResolver: ContentResolver = context.contentResolver private val moduleSources: ArrayList = arrayListOf(mBaseURI, npmModuleSource) - private val encryptionSource = File(context.filesDir, "project") companion object { val mBaseURI: URI = URI.create("file:/android_asset/modules") @@ -111,17 +110,14 @@ class AssetAndUrlModuleSourceProvider( uri: URI, base: URI?, validator: Any?, - ): ModuleSource? { - //只处理内部位于apk内部资源的脚本文件 - val i = if (uri.path.startsWith(encryptionSource.path)) { - val bytes = ByteArray(inputStream.available()) - inputStream.read(bytes) - inputStream.close() - if (isValidFile(bytes)) { - val clearText = decrypt(bytes, EncryptedScriptFileHeader.BLOCK_SIZE, bytes.size) - ByteArrayInputStream(clearText) - } else inputStream - } else inputStream + ): ModuleSource { + val bytes = ByteArray(inputStream.available()) + inputStream.read(bytes) + inputStream.close() + val i = if (isValidFile(bytes)) { + val clearText = decrypt(bytes, EncryptedScriptFileHeader.BLOCK_SIZE, bytes.size) + ByteArrayInputStream(clearText) + } else ByteArrayInputStream(bytes) return createModuleSource(i, uri, base, validator) }