manager: Avoid unecessary function calls

in Home.kt the install function is called everytime you go to the HomeScreen, move it to MainActivity instead so it's executed on app launch only.
This commit is contained in:
silvzr
2024-12-21 03:49:44 +06:00
committed by Rifat Azad
parent 081e31f0f8
commit f439ff625c
2 changed files with 4 additions and 7 deletions

View File

@@ -45,6 +45,7 @@ import com.rifsxd.ksunext.ui.screen.BottomBarDestination
import com.rifsxd.ksunext.ui.theme.KernelSUTheme
import com.rifsxd.ksunext.ui.util.LocalSnackbarHost
import com.rifsxd.ksunext.ui.util.rootAvailable
import com.rifsxd.ksunext.ui.util.install
class MainActivity : ComponentActivity() {
@@ -58,6 +59,9 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
val isManager = Natives.becomeManager(ksuApp.packageName)
if (isManager) install()
setContent {
KernelSUTheme {
val navController = rememberNavController()

View File

@@ -70,13 +70,6 @@ fun HomeScreen(navigator: DestinationsNavigator) {
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
val isManager = Natives.becomeManager(ksuApp.packageName)
SideEffect {
if (isManager) {
Handler(Looper.getMainLooper()).postDelayed({
install()
}, 2000)
}
}
val ksuVersion = if (isManager) Natives.version else null
val lkmMode = ksuVersion?.let {
if (it >= Natives.MINIMAL_SUPPORTED_KERNEL_LKM && kernelVersion.isGKI()) Natives.isLkmMode else null