fix: Fix shizuku being buggy for multi user setups

Fetch the current userid separately because shizuku always runs as the main user and would otherwise install and update for the main user
This commit is contained in:
Redjard 2024-11-20 13:25:24 +07:00 committed by Ahmad Ansori Palembani
parent fabc9f4c1b
commit fa0e565fa5
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
2 changed files with 4 additions and 1 deletions

View file

@ -30,6 +30,7 @@ The format is simplified version of [Keep a Changelog](https://keepachangelog.co
- Handle some uncaught crashes - Handle some uncaught crashes
- Fixed crashes due to GestureDetector's firstEvent is sometimes null on some devices - Fixed crashes due to GestureDetector's firstEvent is sometimes null on some devices
- Fixed download failed caused by invalid XML 1.0 character - Fixed download failed caused by invalid XML 1.0 character
- Fixed issues with shizuku in a multi user setup (@Redjard)
### Other ### Other
- Simplify network helper code - Simplify network helper code

View file

@ -6,6 +6,7 @@ import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Process
import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.localbroadcastmanager.content.LocalBroadcastManager
import co.touchlab.kermit.Logger import co.touchlab.kermit.Logger
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
@ -92,7 +93,8 @@ class ShizukuInstaller(private val context: Context, val finishedQueue: (Shizuku
val size = context.getUriSize(entry.uri) ?: throw IllegalStateException() val size = context.getUriSize(entry.uri) ?: throw IllegalStateException()
context.contentResolver.openInputStream(entry.uri)!!.use { context.contentResolver.openInputStream(entry.uri)!!.use {
val createCommand = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { val createCommand = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
"pm install-create --user current -r -i ${context.packageName} -S $size" val userId = Process.myUserHandle().hashCode()
"pm install-create --user $userId current -r -i ${context.packageName} -S $size"
} else { } else {
"pm install-create -r -i ${context.packageName} -S $size" "pm install-create -r -i ${context.packageName} -S $size"
} }