Skip to content

Commit 9996fb1

Browse files
committed
代码优化
1 parent fe8af28 commit 9996fb1

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

app/src/main/cpp/DexKit

Submodule DexKit updated 1 file

app/src/main/java/me/teble/xposed/autodaily/activity/common/MainActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ class MainActivity : ComponentActivity() {
144144
}
145145

146146
fun peekUserService(): Boolean {
147-
runCatching {
147+
try {
148148
return Shizuku.peekUserService(userServiceArgs, userServiceConnection)
149-
}.onFailure {
150-
Log.e("XALog", it.stackTraceToString())
149+
} catch (e: Throwable) {
150+
Log.e("XALog", e.stackTraceToString())
151151
}
152152
return false
153153
}

app/src/main/java/me/teble/xposed/autodaily/hook/MainHook.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
9898
ProxyManager.init
9999
asyncHook()
100100
}
101-
}.onFailure { Log.e("XALog", it.stackTraceToString()) }
101+
}.onFailure {
102+
moduleLoadInit = true
103+
ToastUtil.send(it.stackTraceToString(), true)
104+
Log.e("XALog", it.stackTraceToString())
105+
}
102106
}
103107
// TODO 分进程处理
104108
if (loadPackageParam.processName == loadPackageParam.packageName) {
@@ -170,7 +174,7 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
170174
//初始化hook
171175
LogUtil.d("initHook")
172176
initHook()
173-
moduleLoadSuccess = true
177+
moduleLoadInit = true
174178
TaskExecutor.startCorn()
175179
}
176180
}
@@ -184,7 +188,7 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
184188
}
185189
hookIsInit = true
186190
// 等待hook执行完毕
187-
while (!moduleLoadSuccess) {
191+
while (!moduleLoadInit) {
188192
Thread.sleep(100)
189193
}
190194
}.onFailure {

app/src/main/java/me/teble/xposed/autodaily/hook/base/ModuleInfo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ lateinit var modulePath: String
88
lateinit var moduleRes: XModuleResources
99

1010
val moduleClassLoader: ClassLoader = MainHook::class.java.classLoader!!
11-
var moduleLoadSuccess = false
11+
var moduleLoadInit = false

app/src/main/java/me/teble/xposed/autodaily/utils/TaskExecutor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import android.os.Message
66
import android.os.PowerManager
77
import cn.hutool.core.thread.ThreadUtil
88
import kotlinx.coroutines.*
9-
import me.teble.xposed.autodaily.hook.base.moduleLoadSuccess
9+
import me.teble.xposed.autodaily.hook.base.moduleLoadInit
1010
import me.teble.xposed.autodaily.hook.notification.XANotification
1111
import me.teble.xposed.autodaily.hook.utils.ToastUtil
1212
import me.teble.xposed.autodaily.task.cron.CronUtil
@@ -52,7 +52,7 @@ object TaskExecutor {
5252

5353
fun runTasks(userExec: Boolean) {
5454
scope.launch(Dispatchers.IO) {
55-
while (!moduleLoadSuccess) {
55+
while (!moduleLoadInit) {
5656
LogUtil.d("等待初始化完毕")
5757
delay(500)
5858
}

0 commit comments

Comments
 (0)