You've already forked KernelSU-Next
mirror of
https://github.com/KernelSU-Next/KernelSU-Next.git
synced 2025-08-27 23:46:34 +00:00
manager: move the wx platform init to the Application class so it starts as soon as the app process launches
This commit is contained in:
@@ -11,6 +11,10 @@ import okhttp3.Cache
|
|||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import com.rifsxd.ksunext.ui.webui.initPlatform
|
||||||
|
|
||||||
lateinit var ksuApp: KernelSUApplication
|
lateinit var ksuApp: KernelSUApplication
|
||||||
|
|
||||||
@@ -24,6 +28,9 @@ class KernelSUApplication : Application() {
|
|||||||
|
|
||||||
Platform.setHiddenApiExemptions()
|
Platform.setHiddenApiExemptions()
|
||||||
|
|
||||||
|
// Pre-initialize WX Platform as early as possible
|
||||||
|
launchPlatformInit()
|
||||||
|
|
||||||
val context = this
|
val context = this
|
||||||
val iconSize = resources.getDimensionPixelSize(android.R.dimen.app_icon_size)
|
val iconSize = resources.getDimensionPixelSize(android.R.dimen.app_icon_size)
|
||||||
Coil.setImageLoader(
|
Coil.setImageLoader(
|
||||||
@@ -54,5 +61,11 @@ class KernelSUApplication : Application() {
|
|||||||
}.build()
|
}.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun launchPlatformInit() {
|
||||||
|
// Use a coroutine to avoid blocking the main thread
|
||||||
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
|
initPlatform()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import androidx.navigation.NavBackStackEntry
|
|||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||||
import com.dergoogler.mmrl.platform.Platform
|
|
||||||
import com.ramcosta.composedestinations.DestinationsNavHost
|
import com.ramcosta.composedestinations.DestinationsNavHost
|
||||||
import com.ramcosta.composedestinations.animations.NavHostAnimatedDestinationStyle
|
import com.ramcosta.composedestinations.animations.NavHostAnimatedDestinationStyle
|
||||||
import com.ramcosta.composedestinations.generated.destinations.ExecuteModuleActionScreenDestination
|
import com.ramcosta.composedestinations.generated.destinations.ExecuteModuleActionScreenDestination
|
||||||
@@ -54,7 +53,6 @@ import com.rifsxd.ksunext.ui.theme.KernelSUTheme
|
|||||||
import com.rifsxd.ksunext.ui.util.LocalSnackbarHost
|
import com.rifsxd.ksunext.ui.util.LocalSnackbarHost
|
||||||
import com.rifsxd.ksunext.ui.util.rootAvailable
|
import com.rifsxd.ksunext.ui.util.rootAvailable
|
||||||
import com.rifsxd.ksunext.ui.util.install
|
import com.rifsxd.ksunext.ui.util.install
|
||||||
import com.rifsxd.ksunext.ui.webui.initPlatform
|
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
|
|
||||||
@@ -83,11 +81,6 @@ class MainActivity : ComponentActivity() {
|
|||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
|
|
||||||
// pre-init platform to faster start WebUI X activities
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
initPlatform()
|
|
||||||
}
|
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
|
|||||||
Reference in New Issue
Block a user