fix dynamic

pull/21/head
fengyuecanzhu 3 years ago
parent 87d7680d46
commit 3cd5ee34c7
  1. 1
      .idea/gradle.xml
  2. 2
      app/src/test/java/Test.java
  3. 2
      dynamic/build.gradle
  4. 73
      dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt

@ -19,5 +19,6 @@
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
<option name="offlineMode" value="true" />
</component>
</project>

@ -117,7 +117,7 @@ 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");
File file = new File("D:\\Java\\AndroidSdk\\build-tools\\29.0.3\\dynamic-test.dex");
System.out.println(MD5Utils.INSTANCE.getFileMD5s(file, 32));
}
}

@ -5,7 +5,7 @@ plugins {
android {
compileSdkVersion 29
buildToolsVersion '29.0.3'
defaultConfig {
minSdkVersion 21
targetSdkVersion 29

@ -2,19 +2,66 @@ package xyz.fycz.dynamic
import android.app.AlertDialog
import android.content.Context
import android.content.DialogInterface
import android.os.Bundle
import me.fycz.maple.MapleBridge
import me.fycz.maple.MapleUtils
import me.fycz.maple.MethodHook
import me.fycz.maple.MethodReplacement
/**
* @author fengyue
* @date 2022/3/29 11:59
*/
class AppLoadImpl : IAppLoader {
val spuName = "FYReader_plugin"
override fun onLoad(appParam: AppParam) {
/*try {
announce(appParam, "风月读书插件测试",
"2022-03-23\n当你看到这条消息时,表示插件成功加载", "2022-03-30")
}
private fun announce(appParam: AppParam, title: String, msg: String, key: String) {
try {
MapleUtils.findAndHookMethod(
"xyz.fycz.myreader.ui.activity.MainActivity",
appParam.classLoader,
"onCreate",
Bundle::class.java,
object : MethodHook() {
override fun afterHookedMethod(param: MapleBridge.MethodHookParam) {
val context = param.thisObject as Context
val spu = context.getSharedPreferences(spuName, Context.MODE_PRIVATE)
val hasRead = spu.getBoolean(key, false)
if (!hasRead) {
AlertDialog.Builder(context)
.setTitle(title)
.setMessage(msg)
.setPositiveButton("我知道了") { _, _ ->
spu.edit().run {
putBoolean(key, true)
apply()
}
}.create().show()
MapleUtils.callStaticMethod(
MapleUtils.findClass(
"xyz.fycz.myreader.util.utils.AdUtils",
appParam.classLoader
),"adRecord",
arrayOf(String::class.java, String::class.java),
"plugin", "success"
)
}
}
}
)
} catch (e: Exception) {
e.printStackTrace()
MapleUtils.log(e)
}
}
/*fun noAd(appParam: AppParam) {
try {
MapleUtils.findAndHookMethod(
"xyz.fycz.myreader.util.utils.AdUtils",
appParam.classLoader,
@ -37,25 +84,5 @@ 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)
}*/
}
}*/
}
Loading…
Cancel
Save