Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/android/morphe-library.api
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public final class app/morphe/library/installation/installer/AdbInstaller : app/
public synthetic fun <init> (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getInstallation (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun install (Lapp/morphe/library/installation/installer/Installer$Apk;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun install (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun uninstall (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

Expand Down Expand Up @@ -79,6 +80,7 @@ public abstract class app/morphe/library/installation/installer/Installer {
public abstract fun getInstallation (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
protected final fun getLogger ()Ljava/util/logging/Logger;
public abstract fun install (Lapp/morphe/library/installation/installer/Installer$Apk;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun install (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun uninstall (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

Expand All @@ -95,6 +97,7 @@ public final class app/morphe/library/installation/installer/LocalInstaller : ap
public fun close ()V
public fun getInstallation (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun install (Lapp/morphe/library/installation/installer/Installer$Apk;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun install (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun uninstall (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

Expand Down Expand Up @@ -128,6 +131,7 @@ public abstract class app/morphe/library/installation/installer/RootInstaller :
public fun getInstallation (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
protected final fun getShellCommandRunner ()Lapp/morphe/library/installation/command/ShellCommandRunner;
public fun install (Lapp/morphe/library/installation/installer/Installer$Apk;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun install (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
protected final fun invoke (Ljava/lang/String;)Lapp/morphe/library/installation/command/RunResult;
protected final fun move (Ljava/io/File;Ljava/lang/String;)V
public fun uninstall (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down
3 changes: 3 additions & 0 deletions api/jvm/morphe-library.api
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public final class app/morphe/library/installation/installer/AdbInstaller : app/
public synthetic fun <init> (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getInstallation (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun install (Lapp/morphe/library/installation/installer/Installer$Apk;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun install (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun uninstall (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

Expand Down Expand Up @@ -55,6 +56,7 @@ public abstract class app/morphe/library/installation/installer/Installer {
public abstract fun getInstallation (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
protected final fun getLogger ()Ljava/util/logging/Logger;
public abstract fun install (Lapp/morphe/library/installation/installer/Installer$Apk;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun install (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun uninstall (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

Expand All @@ -74,6 +76,7 @@ public abstract class app/morphe/library/installation/installer/RootInstaller :
public fun getInstallation (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
protected final fun getShellCommandRunner ()Lapp/morphe/library/installation/command/ShellCommandRunner;
public fun install (Lapp/morphe/library/installation/installer/Installer$Apk;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun install (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
protected final fun invoke (Ljava/lang/String;)Lapp/morphe/library/installation/command/RunResult;
protected final fun move (Ljava/io/File;Ljava/lang/String;)V
public fun uninstall (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ android = "8.9.3"
binary-compatibility-validator = "0.18.1"
core-ktx = "1.18.0"
guava = "33.5.0-jre"
jadb = "1.2.1"
jadb = "1.2.3"
kotlin = "2.2.21"
libsu = "5.2.2"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.content.IntentFilter
import android.content.pm.PackageInstaller
import android.content.pm.PackageManager
import androidx.core.content.ContextCompat
import app.morphe.library.installation.installer.Installer.Apk
import java.io.Closeable
import java.io.File

Expand Down Expand Up @@ -66,6 +65,26 @@ class LocalInstaller(
}
}

override suspend fun install(apks: List<Apk>) {
logger.info("Installing ${apks.joinToString(", ") { it.file.name }}")

val packageInstaller = context.packageManager.packageInstaller

packageInstaller.openSession(packageInstaller.createSession(sessionParams)).use { session ->
for (apk in apks) {
apk.file.inputStream().use { inputStream ->
// openWrite needs a unique name for each call
session.openWrite(apk.file.name, 0, apk.file.length()).use { outputStream ->
inputStream.copyTo(outputStream)
// flush
session.fsync(outputStream)
}
}
}
session.commit(intentSender)
}
}

@SuppressLint("MissingPermission")
override suspend fun uninstall(packageName: String) {
logger.info("Uninstalling $packageName")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class AdbInstaller(
return runPackageManager { install(apk.file) }
}

override suspend fun install(apks: List<Apk>): AdbInstallerResult {
logger.info("Installing ${apks.joinToString(", ") { it.file.name }}")

return runPackageManager { install(apks.map { it.file }) }
}

override suspend fun uninstall(packageName: String): AdbInstallerResult {
logger.info("Uninstalling $packageName")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package app.morphe.library.installation.installer

import app.morphe.library.installation.installer.Installer.Apk
import java.io.File
import java.util.logging.Logger

Expand All @@ -25,6 +24,15 @@ abstract class Installer<TInstallerResult, TInstallation : Installation> interna
*/
abstract suspend fun install(apk: Apk): TInstallerResult

/**
* Installs the [Apk] files.
*
* @param apks The [Apk] files.
*
* @return The result of the installation.
*/
abstract suspend fun install(apks: List<Apk>): TInstallerResult

/**
* Uninstalls the package.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import app.morphe.library.installation.installer.Constants.RESTART
import app.morphe.library.installation.installer.Constants.TMP_FILE_PATH
import app.morphe.library.installation.installer.Constants.UMOUNT
import app.morphe.library.installation.installer.Constants.invoke
import app.morphe.library.installation.installer.Installer.Apk
import app.morphe.library.installation.installer.RootInstaller.NoRootPermissionException
import java.io.File

/**
Expand Down Expand Up @@ -70,6 +68,10 @@ abstract class RootInstaller internal constructor(
return RootInstallerResult.SUCCESS
}

override suspend fun install(apks: List<Apk>): RootInstallerResult {
TODO()
}

override suspend fun uninstall(packageName: String): RootInstallerResult {
logger.info("Uninstalling $packageName by unmounting")

Expand Down
Loading