mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-04-30 14:04:26 +02:00
fix: Move temporary files outside of the cache directory (#2122)
This commit is contained in:
parent
936a9efd0b
commit
e869db0555
@ -1,10 +1,11 @@
|
|||||||
package app.revanced.manager.data.platform
|
package app.revanced.manager.data.platform
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.Manifest
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import androidx.activity.result.contract.ActivityResultContract
|
import androidx.activity.result.contract.ActivityResultContract
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import app.revanced.manager.util.RequestManageStorageContract
|
import app.revanced.manager.util.RequestManageStorageContract
|
||||||
@ -16,7 +17,7 @@ class Filesystem(private val app: Application) {
|
|||||||
* A directory that gets cleared when the app restarts.
|
* A directory that gets cleared when the app restarts.
|
||||||
* Do not store paths to this directory in a parcel.
|
* Do not store paths to this directory in a parcel.
|
||||||
*/
|
*/
|
||||||
val tempDir = app.cacheDir.resolve("ephemeral").apply {
|
val tempDir = app.getDir("ephemeral", Context.MODE_PRIVATE).apply {
|
||||||
deleteRecursively()
|
deleteRecursively()
|
||||||
mkdirs()
|
mkdirs()
|
||||||
}
|
}
|
||||||
|
@ -193,6 +193,9 @@ class PatcherWorker(
|
|||||||
Result.failure()
|
Result.failure()
|
||||||
} finally {
|
} finally {
|
||||||
patchedApk.delete()
|
patchedApk.delete()
|
||||||
|
if (args.input is SelectedApp.Local && args.input.temporary) {
|
||||||
|
args.input.file.delete()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class AppSelectorViewModel(
|
|||||||
private val pm: PM,
|
private val pm: PM,
|
||||||
private val patchBundleRepository: PatchBundleRepository
|
private val patchBundleRepository: PatchBundleRepository
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
private val inputFile = File(app.cacheDir, "input.apk").also {
|
private val inputFile = File(app.filesDir, "input.apk").also {
|
||||||
it.delete()
|
it.delete()
|
||||||
}
|
}
|
||||||
val appList = pm.appList
|
val appList = pm.appList
|
||||||
|
@ -48,7 +48,6 @@ import kotlinx.coroutines.flow.StateFlow
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.time.withTimeout
|
import kotlinx.coroutines.time.withTimeout
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import kotlinx.coroutines.withTimeout
|
|
||||||
import org.koin.core.component.KoinComponent
|
import org.koin.core.component.KoinComponent
|
||||||
import org.koin.core.component.inject
|
import org.koin.core.component.inject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@ -189,26 +188,14 @@ class PatcherViewModel(
|
|||||||
app.unregisterReceiver(installBroadcastReceiver)
|
app.unregisterReceiver(installBroadcastReceiver)
|
||||||
workManager.cancelWorkById(patcherWorkerId)
|
workManager.cancelWorkById(patcherWorkerId)
|
||||||
|
|
||||||
when (val selectedApp = input.selectedApp) {
|
if (input.selectedApp is SelectedApp.Installed && installedApp?.installType == InstallType.ROOT) {
|
||||||
is SelectedApp.Local -> {
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
if (selectedApp.temporary) selectedApp.file.delete()
|
uiSafe(app, R.string.failed_to_mount, "Failed to mount") {
|
||||||
}
|
withTimeout(Duration.ofMinutes(1L)) {
|
||||||
|
rootInstaller.mount(packageName)
|
||||||
is SelectedApp.Installed -> {
|
|
||||||
GlobalScope.launch(Dispatchers.Main) {
|
|
||||||
uiSafe(app, R.string.failed_to_mount, "Failed to mount") {
|
|
||||||
installedApp?.let {
|
|
||||||
if (it.installType == InstallType.ROOT) {
|
|
||||||
withTimeout(Duration.ofMinutes(1L)) {
|
|
||||||
rootInstaller.mount(packageName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> Unit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tempDir.deleteRecursively()
|
tempDir.deleteRecursively()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user