Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bcpkix-jdk18on = "1.77"
binary-compatibility-validator = "0.15.1"
core-ktx = "1.15.0"
guava = "33.2.1-jre"
jadb = "1.2.1"
jadb = "1.2.1.1"
kotlin = "2.0.20"
kotlinx-coroutines = "1.8.1"
kotlinx-serialization = "1.7.1"
Expand Down
3 changes: 3 additions & 0 deletions src/androidMain/AndroidManifest.xml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is adding the manifest like this correct?

Copy link
Member

@oSumAtrIX oSumAtrIX May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that libraries can have a manifest. Basically the target apps manifest needs to add this, you can (maybe) remove the file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ok now, I didn't see that for other permissions the lint debug error was just suppressed. I did the same.

However the new JADB version is still not released, can you manually do it?

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ENFORCE_UPDATE_OWNERSHIP"/>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageInstaller
import android.content.pm.PackageManager
import android.os.Build
import androidx.core.content.ContextCompat
import app.revanced.library.installation.installer.Installer.Apk
import java.io.Closeable
Expand Down Expand Up @@ -89,6 +90,8 @@ class LocalInstaller(
private val sessionParams = PackageInstaller.SessionParams(
PackageInstaller.SessionParams.MODE_FULL_INSTALL,
).apply {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
setRequestUpdateOwnership(true)
setInstallReason(PackageManager.INSTALL_REASON_USER)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import app.revanced.library.installation.installer.Installer.Apk
import se.vidstige.jadb.JadbException
import se.vidstige.jadb.managers.Package
import se.vidstige.jadb.managers.PackageManager
import se.vidstige.jadb.managers.PackageManager.UPDATE_OWNERSHIP
import java.nio.charset.StandardCharsets

/**
* [AdbInstaller] for installing and uninstalling [Apk] files using ADB.
Expand All @@ -25,10 +27,19 @@ class AdbInstaller(
logger.fine("Connected to $deviceSerial")
}

override suspend fun install(apk: Apk): AdbInstallerResult {
logger.info("Installing ${apk.file.name}")
private fun getSdkVersion(): Int? = runCatching {
device.executeShell("getprop", "ro.build.version.sdk")
.bufferedReader(StandardCharsets.UTF_8)
.use { it.readLine()?.trim()?.toInt() }
}.getOrNull()

return runPackageManager { install(apk.file) }
override suspend fun install(apk: Apk): AdbInstallerResult {
getSdkVersion().let {
return runPackageManager {
if (it == null || it < 34) install(apk.file)
else installWithOptions(apk.file, arrayListOf(UPDATE_OWNERSHIP))
}
}
}

override suspend fun uninstall(packageName: String): AdbInstallerResult {
Expand All @@ -48,4 +59,4 @@ class AdbInstaller(
} catch (e: JadbException) {
AdbInstallerResult.Failure(e)
}
}
}
Loading