This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
200 additions
and
12 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...detta/manager/installer/step/base/Step.kt → ...s/vendetta/manager/installer/step/Step.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../manager/installer/step/base/StepGroup.kt → ...detta/manager/installer/step/StepGroup.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...manager/installer/step/base/StepStatus.kt → ...etta/manager/installer/step/StepStatus.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
app/src/main/java/dev/beefers/vendetta/manager/installer/step/download/DownloadBaseStep.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
app/src/main/java/dev/beefers/vendetta/manager/installer/step/download/DownloadLangStep.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
app/src/main/java/dev/beefers/vendetta/manager/installer/step/download/DownloadLibsStep.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...c/main/java/dev/beefers/vendetta/manager/installer/step/download/DownloadResourcesStep.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...rc/main/java/dev/beefers/vendetta/manager/installer/step/download/DownloadVendettaStep.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package dev.beefers.vendetta.manager.installer.step.download | ||
|
||
import android.os.Build | ||
import androidx.compose.runtime.Stable | ||
import dev.beefers.vendetta.manager.R | ||
import dev.beefers.vendetta.manager.installer.step.download.base.DownloadStep | ||
import java.io.File | ||
|
||
@Stable | ||
class DownloadVendettaStep: DownloadStep() { | ||
|
||
override val nameRes = R.string.step_dl_vd | ||
|
||
override val destination = preferenceManager.moduleLocation | ||
|
||
override val url: String = "https://github.com/vendetta-mod/VendettaXposed/releases/latest/download/app-release.apk" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/src/main/java/dev/beefers/vendetta/manager/installer/step/patching/PatchManifestsStep.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package dev.beefers.vendetta.manager.installer.step.patching | ||
|
||
import com.github.diamondminer88.zip.ZipReader | ||
import com.github.diamondminer88.zip.ZipWriter | ||
import dev.beefers.vendetta.manager.R | ||
import dev.beefers.vendetta.manager.domain.manager.PreferenceManager | ||
import dev.beefers.vendetta.manager.installer.step.Step | ||
import dev.beefers.vendetta.manager.installer.step.StepGroup | ||
import dev.beefers.vendetta.manager.installer.step.StepRunner | ||
import dev.beefers.vendetta.manager.installer.step.download.DownloadBaseStep | ||
import dev.beefers.vendetta.manager.installer.step.download.DownloadLangStep | ||
import dev.beefers.vendetta.manager.installer.step.download.DownloadLibsStep | ||
import dev.beefers.vendetta.manager.installer.step.download.DownloadResourcesStep | ||
import dev.beefers.vendetta.manager.installer.util.ManifestPatcher | ||
import org.koin.core.component.inject | ||
|
||
class PatchManifestsStep : Step() { | ||
|
||
private val preferences: PreferenceManager by inject() | ||
|
||
override val group = StepGroup.PATCHING | ||
override val nameRes = R.string.step_patch_manifests | ||
|
||
override suspend fun run(runner: StepRunner) { | ||
val baseApk = runner.getCompletedStep<DownloadBaseStep>().destination | ||
val libsApk = runner.getCompletedStep<DownloadLibsStep>().destination | ||
val langApk = runner.getCompletedStep<DownloadLangStep>().destination | ||
val resApk = runner.getCompletedStep<DownloadResourcesStep>().destination | ||
|
||
arrayOf(baseApk, libsApk, langApk, resApk).forEach { apk -> | ||
val manifest = ZipReader(apk) | ||
.use { zip -> zip.openEntry("AndroidManifest.xml")?.read() } | ||
?: throw IllegalStateException("No manifest in ${apk.name}") | ||
|
||
ZipWriter(apk, true).use { zip -> | ||
val patchedManifestBytes = if (apk == baseApk) { | ||
ManifestPatcher.patchManifest( | ||
manifestBytes = manifest, | ||
packageName = preferences.packageName, | ||
appName = preferences.appName, | ||
debuggable = preferences.debuggable, | ||
) | ||
} else { | ||
ManifestPatcher.renamePackage(manifest, preferences.packageName) | ||
} | ||
|
||
zip.deleteEntry( | ||
"AndroidManifest.xml", | ||
apk == libsApk | ||
) // Preserve alignment in libs apk | ||
zip.writeEntry("AndroidManifest.xml", patchedManifestBytes) | ||
} | ||
} | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
app/src/main/java/dev/beefers/vendetta/manager/installer/step/patching/PresignApksStep.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package dev.beefers.vendetta.manager.installer.step.patching | ||
|
||
import android.os.Build | ||
import com.github.diamondminer88.zip.ZipCompression | ||
import com.github.diamondminer88.zip.ZipReader | ||
import com.github.diamondminer88.zip.ZipWriter | ||
import dev.beefers.vendetta.manager.R | ||
import dev.beefers.vendetta.manager.domain.manager.PreferenceManager | ||
import dev.beefers.vendetta.manager.installer.step.Step | ||
import dev.beefers.vendetta.manager.installer.step.StepGroup | ||
import dev.beefers.vendetta.manager.installer.step.StepRunner | ||
import dev.beefers.vendetta.manager.installer.step.download.DownloadBaseStep | ||
import dev.beefers.vendetta.manager.installer.step.download.DownloadLangStep | ||
import dev.beefers.vendetta.manager.installer.step.download.DownloadLibsStep | ||
import dev.beefers.vendetta.manager.installer.step.download.DownloadResourcesStep | ||
import dev.beefers.vendetta.manager.installer.util.ManifestPatcher | ||
import dev.beefers.vendetta.manager.installer.util.Signer | ||
import org.koin.core.component.inject | ||
import java.io.File | ||
|
||
class PresignApksStep( | ||
private val signedDir: File | ||
) : Step() { | ||
|
||
override val group = StepGroup.PATCHING | ||
override val nameRes = R.string.step_signing | ||
|
||
override suspend fun run(runner: StepRunner) { | ||
val baseApk = runner.getCompletedStep<DownloadBaseStep>().destination | ||
val libsApk = runner.getCompletedStep<DownloadLibsStep>().destination | ||
val langApk = runner.getCompletedStep<DownloadLangStep>().destination | ||
val resApk = runner.getCompletedStep<DownloadResourcesStep>().destination | ||
|
||
signedDir.mkdirs() | ||
val apks = listOf(baseApk, libsApk, langApk, resApk) | ||
|
||
// Align resources.arsc due to targeting api 30 for silent install | ||
if(Build.VERSION.SDK_INT >= 30) { | ||
for (file in apks) { | ||
val bytes = ZipReader(file).use { | ||
if (it.entryNames.contains("resources.arsc")) { | ||
it.openEntry("resources.arsc")?.read() | ||
} else { | ||
null | ||
} | ||
} ?: continue | ||
|
||
ZipWriter(file, true).use { | ||
it.deleteEntry("resources.arsc", true) | ||
it.writeEntry("resources.arsc", bytes, ZipCompression.NONE, 4096) | ||
} | ||
} | ||
} | ||
|
||
apks.forEach { | ||
Signer.signApk(it, File(signedDir, it.name)) | ||
} | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
app/src/main/java/dev/beefers/vendetta/manager/installer/step/patching/ReplaceIconStep.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package dev.beefers.vendetta.manager.installer.step.patching | ||
|
||
import android.content.Context | ||
import com.github.diamondminer88.zip.ZipWriter | ||
import dev.beefers.vendetta.manager.R | ||
import dev.beefers.vendetta.manager.installer.step.Step | ||
import dev.beefers.vendetta.manager.installer.step.StepGroup | ||
import dev.beefers.vendetta.manager.installer.step.StepRunner | ||
import dev.beefers.vendetta.manager.installer.step.download.DownloadBaseStep | ||
import org.koin.core.component.inject | ||
|
||
class ReplaceIconStep : Step() { | ||
|
||
val context: Context by inject() | ||
|
||
override val group = StepGroup.PATCHING | ||
override val nameRes = R.string.step_change_icon | ||
|
||
override suspend fun run(runner: StepRunner) { | ||
val baseApk = runner.getCompletedStep<DownloadBaseStep>().destination | ||
|
||
ZipWriter(baseApk, true).use { apk -> | ||
val mipmaps = | ||
arrayOf("mipmap-xhdpi-v4", "mipmap-xxhdpi-v4", "mipmap-xxxhdpi-v4") | ||
val icons = arrayOf( | ||
"ic_logo_foreground.png", | ||
"ic_logo_square.png", | ||
"ic_logo_foreground.png" | ||
) | ||
|
||
for (icon in icons) { | ||
val newIcon = context.assets.open("icons/$icon") | ||
.use { it.readBytes() } | ||
|
||
for (mipmap in mipmaps) { | ||
val path = "res/$mipmap/$icon" | ||
apk.deleteEntry(path) | ||
apk.writeEntry(path, newIcon) | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |