Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

fix: packageInstaller userId #280

Merged
merged 1 commit into from
Dec 11, 2023
Merged
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
12 changes: 7 additions & 5 deletions manager/src/main/java/org/lsposed/lspatch/util/ShizukuApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.pm.*
import android.os.Build
import android.os.IBinder
import android.os.IInterface
import android.os.Process
import android.os.SystemProperties
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -28,10 +29,11 @@ object ShizukuApi {
}

private val packageInstaller: PackageInstaller by lazy {
val userId = Process.myUserHandle().hashCode()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
Refine.unsafeCast(PackageInstallerHidden(iPackageInstaller, "com.android.shell", null, 0))
Refine.unsafeCast(PackageInstallerHidden(iPackageInstaller, "com.android.shell", null, userId))
} else {
Refine.unsafeCast(PackageInstallerHidden(iPackageInstaller, "com.android.shell", 0))
Refine.unsafeCast(PackageInstallerHidden(iPackageInstaller, "com.android.shell", userId))
}
}

Expand All @@ -56,11 +58,11 @@ object ShizukuApi {
}

fun isPackageInstalledWithoutPatch(packageName: String): Boolean {
// TODO: userId
val userId = Process.myUserHandle().hashCode()
val app = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
iPackageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA.toLong(), 0)
iPackageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA.toLong(), userId)
} else {
iPackageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA, 0)
iPackageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA, userId)
}
return (app != null) && (app.metaData?.containsKey("lspatch") != true)
}
Expand Down