From 5fcfb5cdd58fefb6241580e5fb5f2b158dcfc25c Mon Sep 17 00:00:00 2001 From: Ushie Date: Thu, 11 Jul 2024 01:42:23 +0300 Subject: [PATCH 1/2] feat(Installer): Temporarily use DEFAULT if SHIZUKU permissions are not granted --- .../installer/step/installing/InstallStep.kt | 10 +++++++++- .../manager/ui/activity/MainActivity.kt | 19 ------------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/dev/beefers/vendetta/manager/installer/step/installing/InstallStep.kt b/app/src/main/java/dev/beefers/vendetta/manager/installer/step/installing/InstallStep.kt index dc353de3..f552e7ca 100644 --- a/app/src/main/java/dev/beefers/vendetta/manager/installer/step/installing/InstallStep.kt +++ b/app/src/main/java/dev/beefers/vendetta/manager/installer/step/installing/InstallStep.kt @@ -7,6 +7,7 @@ import dev.beefers.vendetta.manager.domain.manager.PreferenceManager import dev.beefers.vendetta.manager.installer.Installer import dev.beefers.vendetta.manager.installer.session.SessionInstaller import dev.beefers.vendetta.manager.installer.shizuku.ShizukuInstaller +import dev.beefers.vendetta.manager.installer.shizuku.ShizukuPermissions import dev.beefers.vendetta.manager.installer.step.Step import dev.beefers.vendetta.manager.installer.step.StepGroup import dev.beefers.vendetta.manager.installer.step.StepRunner @@ -38,7 +39,14 @@ class InstallStep( ?.takeIf { it.isNotEmpty() } ?: throw Error("Missing APKs from LSPatch step; failure likely") - val installer: Installer = when (preferences.installMethod) { + val installMethod = if (preferences.installMethod == InstallMethod.SHIZUKU && !ShizukuPermissions.waitShizukuPermissions()) { + // Temporarily use DEFAULT if SHIZUKU permissions are not granted + InstallMethod.DEFAULT + } else { + preferences.installMethod + } + + val installer: Installer = when (installMethod) { InstallMethod.DEFAULT -> SessionInstaller(context) InstallMethod.SHIZUKU -> ShizukuInstaller(context) } diff --git a/app/src/main/java/dev/beefers/vendetta/manager/ui/activity/MainActivity.kt b/app/src/main/java/dev/beefers/vendetta/manager/ui/activity/MainActivity.kt index 7d98d57b..62641cdf 100644 --- a/app/src/main/java/dev/beefers/vendetta/manager/ui/activity/MainActivity.kt +++ b/app/src/main/java/dev/beefers/vendetta/manager/ui/activity/MainActivity.kt @@ -6,27 +6,17 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge -import androidx.compose.animation.ExperimentalAnimationApi import androidx.core.app.ActivityCompat import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen -import androidx.lifecycle.lifecycleScope import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.transitions.SlideTransition -import dev.beefers.vendetta.manager.domain.manager.InstallMethod -import dev.beefers.vendetta.manager.domain.manager.PreferenceManager -import dev.beefers.vendetta.manager.installer.shizuku.ShizukuPermissions import dev.beefers.vendetta.manager.ui.screen.home.HomeScreen import dev.beefers.vendetta.manager.ui.screen.installer.InstallerScreen import dev.beefers.vendetta.manager.ui.theme.VendettaManagerTheme import dev.beefers.vendetta.manager.utils.DiscordVersion import dev.beefers.vendetta.manager.utils.Intents -import kotlinx.coroutines.launch -import org.koin.android.ext.android.inject class MainActivity : ComponentActivity() { - - private val preferences: PreferenceManager by inject() - override fun onCreate(savedInstanceState: Bundle?) { installSplashScreen() enableEdgeToEdge() @@ -41,14 +31,6 @@ class MainActivity : ComponentActivity() { ) } - if (preferences.installMethod == InstallMethod.SHIZUKU) { - lifecycleScope.launch { - if (!ShizukuPermissions.waitShizukuPermissions()) { - preferences.installMethod = InstallMethod.DEFAULT - } - } - } - val screen = if (intent.action == Intents.Actions.INSTALL && version != null) { InstallerScreen(DiscordVersion.fromVersionCode(version)!!) } else { @@ -63,5 +45,4 @@ class MainActivity : ComponentActivity() { } } } - } From 37096aca0240d81d6cdcb1949ce5c51941e90cec Mon Sep 17 00:00:00 2001 From: Ushie Date: Thu, 11 Jul 2024 01:47:36 +0300 Subject: [PATCH 2/2] feat(Updater): Temporarily use DEFAULT if SHIZUKU permissions are not granted --- .../manager/ui/viewmodel/home/HomeViewModel.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/dev/beefers/vendetta/manager/ui/viewmodel/home/HomeViewModel.kt b/app/src/main/java/dev/beefers/vendetta/manager/ui/viewmodel/home/HomeViewModel.kt index c335a212..b7ee6eae 100644 --- a/app/src/main/java/dev/beefers/vendetta/manager/ui/viewmodel/home/HomeViewModel.kt +++ b/app/src/main/java/dev/beefers/vendetta/manager/ui/viewmodel/home/HomeViewModel.kt @@ -22,6 +22,7 @@ import dev.beefers.vendetta.manager.domain.repository.RestRepository import dev.beefers.vendetta.manager.installer.Installer import dev.beefers.vendetta.manager.installer.session.SessionInstaller import dev.beefers.vendetta.manager.installer.shizuku.ShizukuInstaller +import dev.beefers.vendetta.manager.installer.shizuku.ShizukuPermissions import dev.beefers.vendetta.manager.network.dto.Release import dev.beefers.vendetta.manager.network.utils.CommitsPagingSource import dev.beefers.vendetta.manager.network.utils.dataOrNull @@ -129,7 +130,14 @@ class HomeViewModel( downloadManager.downloadUpdate(update) isUpdating = false - val installer: Installer = when (prefs.installMethod) { + val installMethod = if (prefs.installMethod == InstallMethod.SHIZUKU && !ShizukuPermissions.waitShizukuPermissions()) { + // Temporarily use DEFAULT if SHIZUKU permissions are not granted + InstallMethod.DEFAULT + } else { + prefs.installMethod + } + + val installer: Installer = when (installMethod) { InstallMethod.DEFAULT -> SessionInstaller(context) InstallMethod.SHIZUKU -> ShizukuInstaller(context) }