mirror of
https://github.com/revanced/revanced-manager-compose-old.git
synced 2025-04-30 06:24:28 +02:00
feat: copy apk to storage after patching is done
This commit is contained in:
parent
ea1641bcea
commit
5408199dab
@ -7,6 +7,7 @@ import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Icon
|
||||
import android.os.Environment
|
||||
import android.os.PowerManager
|
||||
import android.util.Log
|
||||
import androidx.core.content.ContextCompat
|
||||
@ -40,7 +41,6 @@ import java.nio.file.StandardCopyOption
|
||||
|
||||
class PatcherWorker(context: Context, parameters: WorkerParameters, private val api: API) :
|
||||
CoroutineWorker(context, parameters), KoinComponent {
|
||||
|
||||
val tag = "ReVanced Manager"
|
||||
private val workdir = createWorkDir()
|
||||
|
||||
@ -94,7 +94,7 @@ class PatcherWorker(context: Context, parameters: WorkerParameters, private val
|
||||
val wakeLock: PowerManager.WakeLock =
|
||||
(applicationContext.getSystemService(Context.POWER_SERVICE) as PowerManager).run {
|
||||
newWakeLock(PowerManager.FULL_WAKE_LOCK, "$tag::Patcher").apply {
|
||||
acquire(10*60*1000L)
|
||||
acquire(10 * 60 * 1000L)
|
||||
}
|
||||
}
|
||||
Log.d(tag, "Acquired wakelock.")
|
||||
@ -107,6 +107,8 @@ class PatcherWorker(context: Context, parameters: WorkerParameters, private val
|
||||
applicationContext.filesDir.resolve("framework").also { it.mkdirs() }.absolutePath
|
||||
val integrationsCacheDir =
|
||||
applicationContext.filesDir.resolve("integrations-cache").also { it.mkdirs() }
|
||||
val reVancedFolder =
|
||||
Environment.getExternalStorageDirectory().resolve("ReVanced").also { it.mkdirs() }
|
||||
val appInfo = selectedAppPackage.value.get()
|
||||
|
||||
Logging.log += "Checking prerequisites\n"
|
||||
@ -195,6 +197,14 @@ class PatcherWorker(context: Context, parameters: WorkerParameters, private val
|
||||
Logging.log += "Signing apk\n"
|
||||
Signer("ReVanced", "s3cur3p@ssw0rd").signApk(patchedFile, outputFile)
|
||||
Logging.log += "Successfully patched!\n"
|
||||
withContext(Dispatchers.IO) {
|
||||
Files.copy(
|
||||
outputFile.inputStream(),
|
||||
reVancedFolder.resolve(appInfo.packageName + ".apk").toPath(),
|
||||
StandardCopyOption.REPLACE_EXISTING
|
||||
)
|
||||
}
|
||||
Logging.log += "Copied file to storage!\n"
|
||||
} finally {
|
||||
Log.d(tag, "Deleting workdir")
|
||||
workdir.deleteRecursively()
|
||||
@ -210,7 +220,6 @@ class PatcherWorker(context: Context, parameters: WorkerParameters, private val
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun createWorkDir(): File {
|
||||
return applicationContext.filesDir.resolve("tmp-${System.currentTimeMillis()}")
|
||||
.also { it.mkdirs() }
|
||||
|
@ -12,6 +12,7 @@ import app.revanced.manager.Variables.selectedAppPackage
|
||||
import app.revanced.manager.Variables.selectedPatches
|
||||
import app.revanced.manager.api.API
|
||||
import app.revanced.manager.ui.Resource
|
||||
import app.revanced.manager.util.tag
|
||||
import app.revanced.patcher.data.Context
|
||||
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
|
||||
import app.revanced.patcher.extensions.PatchExtensions.options
|
||||
@ -24,7 +25,6 @@ import kotlinx.parcelize.Parcelize
|
||||
|
||||
class PatcherScreenViewModel(private val app: Application, private val api: API) : ViewModel() {
|
||||
private lateinit var patchBundleFile: String
|
||||
private val tag = "ReVanced Manager"
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
@ -71,8 +71,9 @@ class PatcherScreenViewModel(private val app: Application, private val api: API)
|
||||
selectedAppPackage.value.get().publicSourceDir,
|
||||
PackageManager.GET_META_DATA
|
||||
)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
else {return null}
|
||||
}
|
||||
|
||||
fun checkSplitApk(): Boolean {
|
||||
|
Loading…
x
Reference in New Issue
Block a user