diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 2dc7e53..976a899 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -19,6 +19,5 @@
-
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 3783618..b526bd5 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -36,5 +36,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/render.experimental.xml b/.idea/render.experimental.xml
new file mode 100644
index 0000000..fe25d78
--- /dev/null
+++ b/.idea/render.experimental.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index dadc77d..6ab7a24 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -153,7 +153,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// androidx
- implementation 'androidx.core:core-ktx:1.6.0'
+ implementation "androidx.core:core-ktx:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.appcompat:appcompat:1.3.1'
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 956f97c..7a2cf80 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
@@ -48,7 +48,7 @@ object PluginUtils {
} else {
config = oldConfig
}
- if (config!!.md5.lowercase(Locale.getDefault())
+ if (!App.isDebug() && config!!.md5.lowercase(Locale.getDefault())
!= getPluginMD5(config!!)?.lowercase(Locale.getDefault())
) {
downloadPlugin(config!!)
diff --git a/build.gradle b/build.gradle
index caa4464..1e61446 100644
--- a/build.gradle
+++ b/build.gradle
@@ -28,6 +28,7 @@ allprojects {
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://artifact.bytedance.com/repository/pangle'}
+ mavenLocal()
}
/*gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
diff --git a/dynamic/build.gradle b/dynamic/build.gradle
index 9dfa1bb..8d4c01e 100644
--- a/dynamic/build.gradle
+++ b/dynamic/build.gradle
@@ -30,9 +30,11 @@ android {
}
dependencies {
- implementation 'androidx.core:core-ktx:1.6.0'
+ implementation "androidx.core:core-ktx:$kotlin_version"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
- compileOnly("me.fycz.maple:maple:1.6")
+ compileOnly("me.fycz.maple:maple:1.7")
+ compileOnly 'org.greenrobot:greendao:3.3.0'
+ compileOnly project(":app")
}
\ No newline at end of file
diff --git a/dynamic/src/androidTest/java/xyz/fycz/dynamic/ExampleInstrumentedTest.kt b/dynamic/src/androidTest/java/xyz/fycz/dynamic/ExampleInstrumentedTest.kt
index 2a072e6..0819eca 100644
--- a/dynamic/src/androidTest/java/xyz/fycz/dynamic/ExampleInstrumentedTest.kt
+++ b/dynamic/src/androidTest/java/xyz/fycz/dynamic/ExampleInstrumentedTest.kt
@@ -2,11 +2,13 @@ package xyz.fycz.dynamic
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
+import me.fycz.maple.MapleUtils
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
+import xyz.fycz.myreader.application.App
/**
* Instrumented test, which will execute on an Android device.
@@ -16,9 +18,19 @@ import org.junit.Assert.*
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
- fun useAppContext() {
+ fun testFix() {
// Context of the app under test.
- val appContext = InstrumentationRegistry.getInstrumentation().targetContext
- assertEquals("xyz.fycz.dynamic.test", appContext.packageName)
+ if (App.getVersionCode() == 243) {
+ try {
+ App243Fix.fixGetAllNoLocalSource()
+ } catch (e: Exception) {
+ MapleUtils.log(e)
+ }
+ try {
+ App243Fix.fixAdTimeout()
+ } catch (e: Exception) {
+ MapleUtils.log(e)
+ }
+ }
}
}
\ No newline at end of file
diff --git a/dynamic/src/main/java/xyz/fycz/dynamic/App243Fix.kt b/dynamic/src/main/java/xyz/fycz/dynamic/App243Fix.kt
new file mode 100644
index 0000000..4b9c803
--- /dev/null
+++ b/dynamic/src/main/java/xyz/fycz/dynamic/App243Fix.kt
@@ -0,0 +1,93 @@
+package xyz.fycz.dynamic
+
+import android.os.Handler
+import me.fycz.maple.MapleBridge
+import me.fycz.maple.MapleUtils
+import me.fycz.maple.MethodHook
+import me.fycz.maple.MethodReplacement
+import xyz.fycz.myreader.greendao.DbManager
+import xyz.fycz.myreader.greendao.entity.rule.BookSource
+import xyz.fycz.myreader.greendao.gen.BookSourceDao
+import xyz.fycz.myreader.model.sourceAnalyzer.BookSourceManager
+import xyz.fycz.myreader.ui.activity.SplashActivity
+import xyz.fycz.myreader.util.SharedPreAdUtils
+import xyz.fycz.myreader.util.utils.AdUtils
+
+/**
+ * @author fengyue
+ * @date 2022/3/31 9:21
+ */
+object App243Fix {
+ private fun getAllNoLocalSource(): List {
+ return DbManager.getDaoSession().bookSourceDao.queryBuilder()
+ .where(BookSourceDao.Properties.SourceEName.isNull)
+ .where(BookSourceDao.Properties.SourceType.isNotNull)
+ .orderAsc(BookSourceDao.Properties.OrderNum)
+ .list()
+ }
+
+
+ fun fixGetAllNoLocalSource() {
+ MapleUtils.findAndHookMethod(
+ BookSourceManager::class.java,
+ "getAllNoLocalSource",
+ object : MethodReplacement() {
+ override fun replaceHookedMethod(param: MapleBridge.MethodHookParam): Any {
+ return getAllNoLocalSource()
+ }
+ }
+ )
+ }
+
+ private fun adTimeOut(param: MapleBridge.MethodHookParam) {
+ val time = param.args[0] as Int
+ val obj = param.thisObject
+ if (time == 0) {
+ MapleUtils.setStaticIntField(SplashActivity::class.java, "WAIT_INTERVAL", 0)
+ SharedPreAdUtils.getInstance()
+ .putLong("splashAdTime", System.currentTimeMillis())
+ MapleUtils.callMethod(obj, "startNormal")
+ SharedPreAdUtils.getInstance().putBoolean("adTimeOut", true)
+ } else {
+ if (time > 5){
+ MapleUtils.setIntField(obj, "timeOut", 5)
+ }
+ val handler = MapleUtils.getObjectField(obj, "handler") as Handler
+ val adTimeOutRunnable = MapleUtils.getObjectField(obj, "adTimeOutRunnable") as Runnable
+ handler.postDelayed(adTimeOutRunnable, 1000)
+ }
+ }
+
+ fun fixAdTimeout() {
+ MapleUtils.findAndHookMethod(
+ SplashActivity::class.java,
+ "adTimeout",
+ Int::class.javaPrimitiveType,
+ object : MethodReplacement() {
+ override fun replaceHookedMethod(param: MapleBridge.MethodHookParam) {
+ adTimeOut(param)
+ }
+ }
+ )
+ MapleUtils.findAndHookMethod(
+ SplashActivity::class.java,
+ "countTodayAd",
+ object : MethodHook(){
+ override fun afterHookedMethod(param: MapleBridge.MethodHookParam) {
+ SharedPreAdUtils.getInstance().putBoolean("adTimeOut", false)
+ }
+ }
+ )
+ MapleUtils.findAndHookMethod(
+ AdUtils::class.java,
+ "backSplashAd",
+ object : MethodHook(){
+ override fun beforeHookedMethod(param: MapleBridge.MethodHookParam) {
+ if (SharedPreAdUtils.getInstance().getBoolean("adTimeOut")){
+ param.result = false
+ }
+ }
+ }
+ )
+ }
+}
\ No newline at end of file
diff --git a/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt b/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt
index 21b898c..7f25fe9 100644
--- a/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt
+++ b/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt
@@ -2,22 +2,39 @@ 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 xyz.fycz.myreader.application.App
+import xyz.fycz.myreader.util.utils.AdUtils
/**
* @author fengyue
* @date 2022/3/29 11:59
*/
class AppLoadImpl : IAppLoader {
- val spuName = "FYReader_plugin"
+ private val spuName = "FYReader_plugin"
+ private val spu = App.getmContext().getSharedPreferences(spuName, Context.MODE_PRIVATE)
override fun onLoad(appParam: AppParam) {
- announce(appParam, "风月读书插件测试",
- "2022-03-23\n当你看到这条消息时,表示插件成功加载", "2022-03-30")
+ if (App.getVersionCode() == 243) {
+ val key = "2022-03-31"
+ try {
+ App243Fix.fixGetAllNoLocalSource()
+ fixResult(key, "getAllNoLocalSource", true)
+ } catch (e: Exception) {
+ MapleUtils.log(e)
+ fixResult(key, "getAllNoLocalSource", false)
+ }
+ try {
+ App243Fix.fixAdTimeout()
+ fixResult(key, "adTimeout", true)
+ } catch (e: Exception) {
+ MapleUtils.log(e)
+ fixResult(key, "adTimeout", false)
+ }
+ }
}
private fun announce(appParam: AppParam, title: String, msg: String, key: String) {
@@ -30,26 +47,19 @@ class AppLoadImpl : IAppLoader {
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"
- )
+ spu.edit().run {
+ putBoolean(key, true)
+ apply()
+ }
+ AdUtils.adRecord("plugin", "adSuccess")
}
}
}
@@ -60,6 +70,17 @@ class AppLoadImpl : IAppLoader {
}
}
+ private fun fixResult(key: String, name: String, success: Boolean) {
+ val res = if (success) "Success" else "Failed"
+ if (!spu.getBoolean("$key-$name-$res", false)) {
+ AdUtils.adRecord(name, "fx$res")
+ spu.edit().run {
+ putBoolean("$key-$name-$res", true)
+ apply()
+ }
+ }
+ }
+
/*fun noAd(appParam: AppParam) {
try {
MapleUtils.findAndHookMethod(