Skip to content

Commit

Permalink
feat: make deployWithAdb support Manager for Injector
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed Dec 25, 2024
1 parent 5abb762 commit 753ad25
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/main/kotlin/com/aliucord/gradle/task/DeployWithAdbTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.options.Option
import se.vidstige.jadb.*
import java.nio.charset.StandardCharsets

abstract class DeployWithAdbTask : DefaultTask() {
@get:Input
Expand Down Expand Up @@ -60,28 +59,27 @@ abstract class DeployWithAdbTask : DefaultTask() {
file = file.resolve("Injector.dex")
}

var path = "/storage/emulated/0/Aliucord/"

if (extension.projectType.get() == ProjectType.PLUGIN) {
path += "plugins/"
val remotePath = when (extension.projectType.get()) {
ProjectType.PLUGIN -> "/storage/emulated/0/Aliucord/plugins/${file.name}"
ProjectType.CORE -> "/storage/emulated/0/Aliucord/Aliucord.zip"
ProjectType.INJECTOR -> "/storage/emulated/0/Android/data/com.aliucord.manager/cache/injector/${project.version}.custom.dex"
}
device.push(file, RemoteFile(remotePath))

device.push(file, RemoteFile(path + file.name))
val activityName = when (extension.projectType.get()) {
ProjectType.PLUGIN, ProjectType.CORE -> "com.aliucord/com.discord.app.AppActivity\$Main"
ProjectType.INJECTOR -> "com.aliucord.manager/com.aliucord.manager.MainActivity"
}

if (extension.projectType.get() != ProjectType.INJECTOR) {
val args = arrayListOf("start", "-S", "-n", "com.aliucord/com.discord.app.AppActivity\$Main")
val args = arrayListOf("start", "-S", "-n", activityName)
if (waitForDebugger) args += "-D"

if (waitForDebugger) {
args.add("-D")
}
val response = device.executeShell("am", *args.toTypedArray())
.readAllBytes()
.decodeToString()

val response = String(
device.executeShell("am", *args.toTypedArray()).readAllBytes(), StandardCharsets.UTF_8
)

if (response.contains("Error")) {
logger.error(response)
}
if (response.contains("Error")) {
logger.error(response)
}

logger.lifecycle("Deployed $file to ${device.serial}")
Expand Down

0 comments on commit 753ad25

Please sign in to comment.