mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
refactor: move mount code to when block
This commit is contained in:
parent
5aefb3bc59
commit
7ba00cafd9
@ -97,11 +97,13 @@ class InstallerViewModel(
|
|||||||
|
|
||||||
val (selectedApp, patches, options) = input
|
val (selectedApp, patches, options) = input
|
||||||
|
|
||||||
_progress = MutableStateFlow(PatcherProgressManager.generateSteps(
|
_progress = MutableStateFlow(
|
||||||
app,
|
PatcherProgressManager.generateSteps(
|
||||||
patches.flatMap { (_, selected) -> selected },
|
app,
|
||||||
selectedApp
|
patches.flatMap { (_, selected) -> selected },
|
||||||
).toImmutableList())
|
selectedApp
|
||||||
|
).toImmutableList()
|
||||||
|
)
|
||||||
|
|
||||||
patcherWorkerId =
|
patcherWorkerId =
|
||||||
workerRepository.launchExpedited<PatcherWorker, PatcherWorker.Args>(
|
workerRepository.launchExpedited<PatcherWorker, PatcherWorker.Args>(
|
||||||
@ -186,23 +188,24 @@ class InstallerViewModel(
|
|||||||
is SelectedApp.Local -> {
|
is SelectedApp.Local -> {
|
||||||
if (selectedApp.shouldDelete) selectedApp.file.delete()
|
if (selectedApp.shouldDelete) selectedApp.file.delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is SelectedApp.Installed -> {
|
||||||
|
try {
|
||||||
|
installedApp?.let {
|
||||||
|
if (it.installType == InstallType.ROOT) {
|
||||||
|
rootInstaller.mount(packageName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e(tag, "Failed to mount", e)
|
||||||
|
app.toast(app.getString(R.string.failed_to_mount, e.simpleMessage()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
tempDir.deleteRecursively()
|
tempDir.deleteRecursively()
|
||||||
|
|
||||||
try {
|
|
||||||
if (input.selectedApp is SelectedApp.Installed) {
|
|
||||||
installedApp?.let {
|
|
||||||
if (it.installType == InstallType.ROOT) {
|
|
||||||
rootInstaller.mount(packageName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e(tag, "Failed to mount", e)
|
|
||||||
app.toast(app.getString(R.string.failed_to_mount, e.simpleMessage()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun signApk(): Boolean {
|
private suspend fun signApk(): Boolean {
|
||||||
@ -239,9 +242,13 @@ class InstallerViewModel(
|
|||||||
if (!signApk()) return@launch
|
if (!signApk()) return@launch
|
||||||
|
|
||||||
when (installType) {
|
when (installType) {
|
||||||
InstallType.DEFAULT -> { pm.installApp(listOf(signedFile)) }
|
InstallType.DEFAULT -> {
|
||||||
|
pm.installApp(listOf(signedFile))
|
||||||
|
}
|
||||||
|
|
||||||
InstallType.ROOT -> { installAsRoot() }
|
InstallType.ROOT -> {
|
||||||
|
installAsRoot()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
@ -286,7 +293,8 @@ class InstallerViewModel(
|
|||||||
app.toast(app.getString(R.string.install_app_fail, e.simpleMessage()))
|
app.toast(app.getString(R.string.install_app_fail, e.simpleMessage()))
|
||||||
try {
|
try {
|
||||||
rootInstaller.uninstall(packageName)
|
rootInstaller.uninstall(packageName)
|
||||||
} catch (_: Exception) { }
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user