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

Commit

Permalink
fix: packageInstaller userId
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonKhew96 committed Dec 11, 2023
1 parent 4bf1371 commit 57d3574
Showing 1 changed file with 7 additions and 5 deletions.
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

0 comments on commit 57d3574

Please sign in to comment.