Skip to content
This repository was archived by the owner on Dec 25, 2025. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package io.github.beakthoven.TrickyStoreOSS.core.config

import android.content.pm.IPackageManager
import android.os.FileObserver
import android.os.IBinder
import android.os.IInterface
import android.os.ServiceManager
import io.github.beakthoven.TrickyStoreOSS.CertificateHacker
Expand Down Expand Up @@ -127,10 +128,18 @@ object Config {
}

private var iPm: IPackageManager? = null
private val packageManagerDeathRecipient = object : IBinder.DeathRecipient {
override fun binderDied() {
(iPm as? IInterface)?.asBinder()?.unlinkToDeath(this, 0)
iPm = null
}
}

fun getPm(): IPackageManager? {
if (iPm == null || (iPm as? IInterface)?.asBinder()?.pingBinder() != true) {
iPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"))
if (iPm == null) {
val binder = ServiceManager.getService("package")
binder.linkToDeath(packageManagerDeathRecipient, 0)
iPm = IPackageManager.Stub.asInterface(binder)
}
return iPm
}
Expand Down Expand Up @@ -208,4 +217,4 @@ data class CustomPatchLevel(
val vendor: String? = null,
val boot: String? = null,
val all: String? = null
)
)