From 402e579a69391e7633754066eb8e6480bd9f247d Mon Sep 17 00:00:00 2001 From: Redjard Date: Sat, 9 Mar 2024 19:48:43 +0100 Subject: [PATCH] Fix shizuku being buggy for multi user setups (#494) * Fix #493 Fetch the current userid separately because shizuku always runs as the main user and would otherwise install and update for the main user * Update app/src/main/java/eu/kanade/tachiyomi/extension/installer/ShizukuInstaller.kt --------- Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> --- .../kanade/tachiyomi/extension/installer/ShizukuInstaller.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/installer/ShizukuInstaller.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/installer/ShizukuInstaller.kt index c85611acf..24a8cb377 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/installer/ShizukuInstaller.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/installer/ShizukuInstaller.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.extension.installer import android.app.Service import android.content.pm.PackageManager +import android.os.Process import eu.kanade.tachiyomi.extension.model.InstallStep import eu.kanade.tachiyomi.util.system.getUriSize import eu.kanade.tachiyomi.util.system.toast @@ -49,7 +50,8 @@ class ShizukuInstaller(private val service: Service) : Installer(service) { try { val size = service.getUriSize(entry.uri) ?: throw IllegalStateException() service.contentResolver.openInputStream(entry.uri)!!.use { - val createCommand = "pm install-create --user current -r -i ${service.packageName} -S $size" + val userId = Process.myUserHandle().hashCode() + val createCommand = "pm install-create --user $userId -r -i ${service.packageName} -S $size" val createResult = exec(createCommand) sessionId = SESSION_ID_REGEX.find(createResult.out)?.value ?: throw RuntimeException("Failed to create install session")