From 87d7680d46601e5d0ea65f354cb2f831303818a8 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Tue, 29 Mar 2022 16:25:47 +0800 Subject: [PATCH] v2.4.3 --- app/src/main/assets/updatelog.fy | 3 +++ .../xyz/fycz/myreader/entity/PluginConfig.kt | 6 ++++- .../myreader/ui/activity/SplashActivity.java | 1 + .../fycz/myreader/util/utils/PluginUtils.kt | 12 ++++++++- app/src/test/java/Test.java | 9 ++++--- app/version_code.properties | 2 +- .../main/java/xyz/fycz/dynamic/AppLoadImpl.kt | 25 ++++++++++++++++++- 7 files changed, 51 insertions(+), 7 deletions(-) diff --git a/app/src/main/assets/updatelog.fy b/app/src/main/assets/updatelog.fy index f3d3149..a2dc0d2 100644 --- a/app/src/main/assets/updatelog.fy +++ b/app/src/main/assets/updatelog.fy @@ -1,6 +1,9 @@ +2022.03.29 风月读书v2.4.3 更新内容: 1、修复存在同名章节时后面章节内容加载前面章节的问题 +2、修复启动页面加载超时的问题 +3、新增动态插件 2022.03.25 风月读书v2.4.2 diff --git a/app/src/main/java/xyz/fycz/myreader/entity/PluginConfig.kt b/app/src/main/java/xyz/fycz/myreader/entity/PluginConfig.kt index a6b07c6..553a0ae 100644 --- a/app/src/main/java/xyz/fycz/myreader/entity/PluginConfig.kt +++ b/app/src/main/java/xyz/fycz/myreader/entity/PluginConfig.kt @@ -9,5 +9,9 @@ data class PluginConfig( val versionCode: Int, val version: String, val url: String, + val md5: String,//32位 val changelog: String -) +) { + constructor(name: String, versionCode: Int) : + this(name, versionCode, "", "", "", "") +} diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java index 56ef387..f159d5f 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java @@ -366,6 +366,7 @@ public class SplashActivity extends BaseActivity { private void adTimeout(int time) { if (time == 0) { WAIT_INTERVAL = 0; + SharedPreAdUtils.getInstance().putLong("splashAdTime", System.currentTimeMillis()); startNormal(); } else { handler.postDelayed(adTimeOutRunnable, 1000); diff --git a/app/src/main/java/xyz/fycz/myreader/util/utils/PluginUtils.kt b/app/src/main/java/xyz/fycz/myreader/util/utils/PluginUtils.kt index 3dcb729..956f97c 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/utils/PluginUtils.kt +++ b/app/src/main/java/xyz/fycz/myreader/util/utils/PluginUtils.kt @@ -17,6 +17,7 @@ import xyz.fycz.myreader.model.third3.http.text import xyz.fycz.myreader.util.SharedPreUtils import xyz.fycz.myreader.util.ToastUtils import java.io.File +import java.util.* /** @@ -38,7 +39,7 @@ object PluginUtils { config = GSON.fromJsonObject(configJson) val oldConfig = GSON.fromJsonObject( SharedPreUtils.getInstance().getString("pluginConfig") - ) ?: PluginConfig("dynamic.dex", 100, "", "", "") + ) ?: PluginConfig("dynamic.dex", 100) if (config != null) { if (config!!.versionCode > oldConfig.versionCode) { downloadPlugin(config!!) @@ -47,6 +48,11 @@ object PluginUtils { } else { config = oldConfig } + if (config!!.md5.lowercase(Locale.getDefault()) + != getPluginMD5(config!!)?.lowercase(Locale.getDefault()) + ) { + downloadPlugin(config!!) + } }.onSuccess { loadAppLoader(App.getmContext(), config) } @@ -60,6 +66,10 @@ object PluginUtils { .writeBytes(res.byteStream().readBytes()) } + private fun getPluginMD5(config: PluginConfig): String? { + return MD5Utils.getFileMD5s(FileUtils.getFile(APPCONST.PLUGIN_DIR_PATH + config.name), 32) + } + private fun loadAppLoader(context: Context, config: PluginConfig?) { config?.let { val pluginPath = APPCONST.PLUGIN_DIR_PATH + it.name diff --git a/app/src/test/java/Test.java b/app/src/test/java/Test.java index e2dfb69..168db9f 100644 --- a/app/src/test/java/Test.java +++ b/app/src/test/java/Test.java @@ -7,6 +7,7 @@ import java.util.List; import xyz.fycz.myreader.model.sourceAnalyzer.BaseAnalyzer; import xyz.fycz.myreader.util.utils.FileUtils; +import xyz.fycz.myreader.util.utils.MD5Utils; import xyz.fycz.myreader.util.utils.NetworkUtils; /** @@ -114,7 +115,9 @@ public class Test { //} } - - - + @org.junit.Test + public void md5(){ + File file = new File("D:\\Java\\AndroidSdk\\build-tools\\29.0.3\\dynamic_v1.0.2.dex"); + System.out.println(MD5Utils.INSTANCE.getFileMD5s(file, 32)); + } } diff --git a/app/version_code.properties b/app/version_code.properties index 54a2cb3..baea358 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,3 +1,3 @@ #Fri Jun 18 21:45:31 CST 2021 -VERSION_CODE=242 +VERSION_CODE=243 NEED_CREATE_RELEASE=true diff --git a/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt b/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt index a2e3bc0..d10ca33 100644 --- a/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt +++ b/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt @@ -1,5 +1,8 @@ package xyz.fycz.dynamic +import android.app.AlertDialog +import android.content.Context +import android.os.Bundle import me.fycz.maple.MapleBridge import me.fycz.maple.MapleUtils import me.fycz.maple.MethodHook @@ -11,7 +14,7 @@ import me.fycz.maple.MethodReplacement */ class AppLoadImpl : IAppLoader { override fun onLoad(appParam: AppParam) { - try { + /*try { MapleUtils.findAndHookMethod( "xyz.fycz.myreader.util.utils.AdUtils", appParam.classLoader, @@ -34,5 +37,25 @@ class AppLoadImpl : IAppLoader { e.printStackTrace() MapleUtils.log(e) } + + try { + MapleUtils.findAndHookMethod( + "xyz.fycz.myreader.ui.activity.MainActivity", + appParam.classLoader, + "onCreate", + Bundle::class.java, + object : MethodHook() { + override fun afterHookedMethod(param: MapleBridge.MethodHookParam) { + AlertDialog.Builder(param.thisObject as Context) + .setTitle("风月读书插件") + .setMessage("此消息由风月读书插件提供") + .create().show() + } + } + ) + } catch (e: Exception) { + e.printStackTrace() + MapleUtils.log(e) + }*/ } } \ No newline at end of file