Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
f3cc5b4e2c
3 changed files with 28 additions and 3 deletions
|
|
@ -83,9 +83,19 @@ object HookScriptLoaderModule : Module() {
|
|||
|
||||
runBlocking {
|
||||
val ready = async { HookStateHolder.readyDeferred.join() }
|
||||
val download = async { UpdaterModule.downloadScript().join() }
|
||||
val isCustomUrl = UpdaterModule.isCustomUrlEnabled
|
||||
|
||||
awaitAll(ready, download)
|
||||
if (!mainScript.exists() || isCustomUrl) {
|
||||
val reason = if (isCustomUrl) "Custom URL enabled" else "Main script does not exist"
|
||||
Log.i("$reason, downloading before load...")
|
||||
val download =
|
||||
async { UpdaterModule.downloadScript(showUpdateDialog = false).join() }
|
||||
awaitAll(ready, download)
|
||||
} else {
|
||||
Log.i("Main script exists, updating in background...")
|
||||
UpdaterModule.downloadScript(showUpdateDialog = true)
|
||||
ready.await()
|
||||
}
|
||||
}
|
||||
|
||||
val loadSynchronously = args[2]
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import ShiggyXposed.xposed.Utils
|
|||
import ShiggyXposed.xposed.Utils.Companion.JSON
|
||||
import ShiggyXposed.xposed.Utils.Companion.reloadApp
|
||||
import ShiggyXposed.xposed.Utils.Log
|
||||
import ShiggyXposed.xposed.modules.bridge.BridgeModule
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.call.*
|
||||
import io.ktor.client.engine.cio.*
|
||||
|
|
@ -38,6 +39,8 @@ data class EndpointInfo(val paths: ArrayList<String>, val hash: String? = null,
|
|||
|
||||
object UpdaterModule : Module() {
|
||||
private lateinit var config: LoaderConfig
|
||||
val isCustomUrlEnabled: Boolean
|
||||
get() = config.customLoadUrl.enabled
|
||||
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
private var lastActivity: WeakReference<Activity>? = null
|
||||
|
||||
|
|
@ -64,9 +67,15 @@ object UpdaterModule : Module() {
|
|||
config = runCatching {
|
||||
if (configFile.exists()) JSON.decodeFromString<LoaderConfig>(configFile.readText()) else LoaderConfig()
|
||||
}.getOrDefault(LoaderConfig())
|
||||
|
||||
BridgeModule.registerMethod("revenge.updater.clear") {
|
||||
if (bundle.exists()) bundle.delete()
|
||||
if (etag.exists()) etag.delete()
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun downloadScript(activity: Activity? = null): Job = scope.launch {
|
||||
fun downloadScript(activity: Activity? = null, showUpdateDialog: Boolean = true): Job = scope.launch {
|
||||
try {
|
||||
HttpClient(CIO) {
|
||||
expectSuccess = false
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import android.os.Build
|
|||
import android.widget.Toast
|
||||
import ShiggyXposed.xposed.Module
|
||||
import ShiggyXposed.xposed.Utils
|
||||
import ShiggyXposed.xposed.Utils.Companion.reloadApp
|
||||
import java.io.File
|
||||
|
||||
object AdditionalBridgeMethodsModule : Module() {
|
||||
|
|
@ -47,6 +48,11 @@ object AdditionalBridgeMethodsModule : Module() {
|
|||
|
||||
file.writeText(contents as String)
|
||||
}
|
||||
|
||||
BridgeModule.registerMethod("Shiggy.app.reload") {
|
||||
reloadApp()
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivity(activity: Activity) = with(activity) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue