Fix signing info bug, simplify PmsHook, add caf and calyxos to custom ROM preset
This commit is contained in:
parent
c67c1a6e4e
commit
1bb5764aef
6 changed files with 119 additions and 234 deletions
|
|
@ -21,6 +21,16 @@ class CustomROMPreset() : BasePreset("custom_rom") {
|
|||
return true
|
||||
}
|
||||
|
||||
// CAF (CodeAuroraForum) apps
|
||||
if (packageName.startsWith("com.caf.")) {
|
||||
return true
|
||||
}
|
||||
|
||||
// CalyxOS
|
||||
if (packageName.startsWith("org.calyxos.")) {
|
||||
return true
|
||||
}
|
||||
|
||||
// AOSPA
|
||||
if (packageName.startsWith("co.aospa.")) {
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -16,14 +16,15 @@ import icu.nullptr.hidemyapplist.xposed.logE
|
|||
import icu.nullptr.hidemyapplist.xposed.logI
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
class PmsHookTarget28(private val service: HMAService) : IFrameworkHook {
|
||||
class PmsHookTarget28(service: HMAService) : PmsHookTargetBase(service) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "PmsHookTarget28"
|
||||
}
|
||||
|
||||
private val hooks = mutableListOf<XC_MethodHook.Unhook>()
|
||||
private var lastFilteredApp: AtomicReference<String?> = AtomicReference(null)
|
||||
// not required until SDK 30
|
||||
override val fakeSystemPackageInstallInfo = null
|
||||
override val fakeUserPackageInstallInfo = null
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun load() {
|
||||
|
|
@ -88,32 +89,6 @@ class PmsHookTarget28(private val service: HMAService) : IFrameworkHook {
|
|||
}
|
||||
}
|
||||
|
||||
hooks += findMethod(service.pms::class.java, findSuper = true) {
|
||||
name == "getInstallerPackageName"
|
||||
}.hookBefore { param ->
|
||||
val targetApp = param.args[0] as String?
|
||||
|
||||
val callingUid = Binder.getCallingUid()
|
||||
if (callingUid == Constants.UID_SYSTEM) return@hookBefore
|
||||
val callingApps = Utils.binderLocalScope {
|
||||
service.pms.getPackagesForUid(callingUid)
|
||||
} ?: return@hookBefore
|
||||
for (caller in callingApps) {
|
||||
val blockingMode = service.shouldHideInstallationSource(caller, targetApp)
|
||||
when (blockingMode) {
|
||||
1 -> param.result = VENDING_PACKAGE_NAME
|
||||
2 -> param.result = null
|
||||
else -> continue
|
||||
}
|
||||
|
||||
service.filterCount++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun unload() {
|
||||
hooks.forEach(XC_MethodHook.Unhook::unhook)
|
||||
hooks.clear()
|
||||
super.load()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
package icu.nullptr.hidemyapplist.xposed.hook
|
||||
|
||||
import android.os.Binder
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.github.kyuubiran.ezxhelper.utils.findConstructor
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethodOrNull
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.github.kyuubiran.ezxhelper.utils.paramCount
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import icu.nullptr.hidemyapplist.common.Constants
|
||||
import icu.nullptr.hidemyapplist.common.Constants.VENDING_PACKAGE_NAME
|
||||
import icu.nullptr.hidemyapplist.common.Utils
|
||||
|
|
@ -17,16 +15,15 @@ import icu.nullptr.hidemyapplist.xposed.Utils4Xposed
|
|||
import icu.nullptr.hidemyapplist.xposed.logD
|
||||
import icu.nullptr.hidemyapplist.xposed.logE
|
||||
import icu.nullptr.hidemyapplist.xposed.logI
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
class PmsHookTarget30(private val service: HMAService) : IFrameworkHook {
|
||||
class PmsHookTarget30(service: HMAService) : PmsHookTargetBase(service) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "PmsHookTarget30"
|
||||
}
|
||||
|
||||
private val fakeSystemPackageInstallInfo by lazy {
|
||||
override val fakeSystemPackageInstallInfo: Any by lazy {
|
||||
findConstructor(
|
||||
"android.content.pm.InstallSourceInfo"
|
||||
) {
|
||||
|
|
@ -39,29 +36,19 @@ class PmsHookTarget30(private val service: HMAService) : IFrameworkHook {
|
|||
)
|
||||
}
|
||||
|
||||
private val fakeUserPackageInstallInfo by lazy {
|
||||
var psInfo = Utils.getPackageInfoCompat(
|
||||
service.pms,
|
||||
VENDING_PACKAGE_NAME,
|
||||
0L,
|
||||
0
|
||||
).signingInfo
|
||||
|
||||
override val fakeUserPackageInstallInfo: Any by lazy {
|
||||
findConstructor(
|
||||
"android.content.pm.InstallSourceInfo"
|
||||
) {
|
||||
paramCount == 4
|
||||
}.newInstance(
|
||||
VENDING_PACKAGE_NAME,
|
||||
psInfo,
|
||||
psSigningInfo,
|
||||
VENDING_PACKAGE_NAME,
|
||||
VENDING_PACKAGE_NAME,
|
||||
)
|
||||
}
|
||||
|
||||
private val hooks = mutableSetOf<XC_MethodHook.Unhook>()
|
||||
private var lastFilteredApp: AtomicReference<String?> = AtomicReference(null)
|
||||
|
||||
override fun load() {
|
||||
logI(TAG, "Load hook")
|
||||
hooks += findMethod("com.android.server.pm.AppsFilter") {
|
||||
|
|
@ -90,57 +77,6 @@ class PmsHookTarget30(private val service: HMAService) : IFrameworkHook {
|
|||
}
|
||||
}
|
||||
|
||||
findMethodOrNull(service.pms::class.java, findSuper = true) {
|
||||
name == "getInstallSourceInfo"
|
||||
}?.hookBefore { param ->
|
||||
val targetApp = param.args[0] as String?
|
||||
|
||||
val callingUid = Binder.getCallingUid()
|
||||
if (callingUid == Constants.UID_SYSTEM) return@hookBefore
|
||||
val callingApps = Utils.binderLocalScope {
|
||||
service.pms.getPackagesForUid(callingUid)
|
||||
} ?: return@hookBefore
|
||||
for (caller in callingApps) {
|
||||
val blockingMode = service.shouldHideInstallationSource(caller, targetApp)
|
||||
when (blockingMode) {
|
||||
1 -> param.result = fakeUserPackageInstallInfo
|
||||
2 -> param.result = fakeSystemPackageInstallInfo
|
||||
else -> continue
|
||||
}
|
||||
|
||||
service.filterCount++
|
||||
break
|
||||
}
|
||||
}?.let {
|
||||
hooks.add(it)
|
||||
}
|
||||
|
||||
hooks += findMethod(service.pms::class.java, findSuper = true) {
|
||||
name == "getInstallerPackageName"
|
||||
}.hookBefore { param ->
|
||||
val targetApp = param.args[0] as String?
|
||||
|
||||
val callingUid = Binder.getCallingUid()
|
||||
if (callingUid == Constants.UID_SYSTEM) return@hookBefore
|
||||
val callingApps = Utils.binderLocalScope {
|
||||
service.pms.getPackagesForUid(callingUid)
|
||||
} ?: return@hookBefore
|
||||
for (caller in callingApps) {
|
||||
val blockingMode = service.shouldHideInstallationSource(caller, targetApp)
|
||||
when (blockingMode) {
|
||||
1 -> param.result = VENDING_PACKAGE_NAME
|
||||
2 -> param.result = null
|
||||
else -> continue
|
||||
}
|
||||
|
||||
service.filterCount++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun unload() {
|
||||
hooks.forEach(XC_MethodHook.Unhook::unhook)
|
||||
hooks.clear()
|
||||
super.load()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package icu.nullptr.hidemyapplist.xposed.hook
|
||||
|
||||
import android.content.pm.PackageInstaller
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Binder
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
|
|
@ -21,7 +22,7 @@ import icu.nullptr.hidemyapplist.xposed.logI
|
|||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||
class PmsHookTarget33(private val service: HMAService) : IFrameworkHook {
|
||||
class PmsHookTarget33(service: HMAService) : PmsHookTargetBase(service) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "PmsHookTarget33"
|
||||
|
|
@ -33,7 +34,7 @@ class PmsHookTarget33(private val service: HMAService) : IFrameworkHook {
|
|||
}
|
||||
}
|
||||
|
||||
private val fakeSystemPackageInstallInfo by lazy {
|
||||
override val fakeSystemPackageInstallInfo: Any by lazy {
|
||||
findConstructor(
|
||||
"android.content.pm.InstallSourceInfo"
|
||||
) {
|
||||
|
|
@ -47,30 +48,20 @@ class PmsHookTarget33(private val service: HMAService) : IFrameworkHook {
|
|||
)
|
||||
}
|
||||
|
||||
private val fakeUserPackageInstallInfo by lazy {
|
||||
var psInfo = Utils.getPackageInfoCompat(
|
||||
service.pms,
|
||||
VENDING_PACKAGE_NAME,
|
||||
0L,
|
||||
0
|
||||
).signingInfo
|
||||
|
||||
override val fakeUserPackageInstallInfo: Any by lazy {
|
||||
findConstructor(
|
||||
"android.content.pm.InstallSourceInfo"
|
||||
) {
|
||||
paramCount == 5
|
||||
}.newInstance(
|
||||
VENDING_PACKAGE_NAME,
|
||||
psInfo,
|
||||
psSigningInfo,
|
||||
VENDING_PACKAGE_NAME,
|
||||
VENDING_PACKAGE_NAME,
|
||||
PackageInstaller.PACKAGE_SOURCE_STORE,
|
||||
)
|
||||
}
|
||||
|
||||
private val hooks = mutableSetOf<XC_MethodHook.Unhook>()
|
||||
private var lastFilteredApp: AtomicReference<String?> = AtomicReference(null)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun load() {
|
||||
logI(TAG, "Load hook")
|
||||
|
|
@ -101,57 +92,6 @@ class PmsHookTarget33(private val service: HMAService) : IFrameworkHook {
|
|||
}
|
||||
}
|
||||
|
||||
findMethodOrNull(service.pms::class.java, findSuper = true) {
|
||||
name == "getInstallSourceInfo"
|
||||
}?.hookBefore { param ->
|
||||
val targetApp = param.args[0] as String?
|
||||
|
||||
val callingUid = Binder.getCallingUid()
|
||||
if (callingUid == Constants.UID_SYSTEM) return@hookBefore
|
||||
val callingApps = Utils.binderLocalScope {
|
||||
service.pms.getPackagesForUid(callingUid)
|
||||
} ?: return@hookBefore
|
||||
for (caller in callingApps) {
|
||||
val blockingMode = service.shouldHideInstallationSource(caller, targetApp)
|
||||
when (blockingMode) {
|
||||
1 -> param.result = fakeUserPackageInstallInfo
|
||||
2 -> param.result = fakeSystemPackageInstallInfo
|
||||
else -> continue
|
||||
}
|
||||
|
||||
service.filterCount++
|
||||
break
|
||||
}
|
||||
}?.let {
|
||||
hooks.add(it)
|
||||
}
|
||||
|
||||
hooks += findMethod(service.pms::class.java, findSuper = true) {
|
||||
name == "getInstallerPackageName"
|
||||
}.hookBefore { param ->
|
||||
val targetApp = param.args[0] as String?
|
||||
|
||||
val callingUid = Binder.getCallingUid()
|
||||
if (callingUid == Constants.UID_SYSTEM) return@hookBefore
|
||||
val callingApps = Utils.binderLocalScope {
|
||||
service.pms.getPackagesForUid(callingUid)
|
||||
} ?: return@hookBefore
|
||||
for (caller in callingApps) {
|
||||
val blockingMode = service.shouldHideInstallationSource(caller, targetApp)
|
||||
when (blockingMode) {
|
||||
1 -> param.result = VENDING_PACKAGE_NAME
|
||||
2 -> param.result = null
|
||||
else -> continue
|
||||
}
|
||||
|
||||
service.filterCount++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun unload() {
|
||||
hooks.forEach(XC_MethodHook.Unhook::unhook)
|
||||
hooks.clear()
|
||||
super.load()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package icu.nullptr.hidemyapplist.xposed.hook
|
||||
|
||||
import android.content.pm.PackageInstaller
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Binder
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
|
|
@ -9,7 +10,6 @@ import com.github.kyuubiran.ezxhelper.utils.findMethod
|
|||
import com.github.kyuubiran.ezxhelper.utils.findMethodOrNull
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.github.kyuubiran.ezxhelper.utils.paramCount
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import icu.nullptr.hidemyapplist.common.Constants
|
||||
import icu.nullptr.hidemyapplist.common.Constants.VENDING_PACKAGE_NAME
|
||||
import icu.nullptr.hidemyapplist.common.Utils
|
||||
|
|
@ -18,10 +18,9 @@ import icu.nullptr.hidemyapplist.xposed.Utils4Xposed
|
|||
import icu.nullptr.hidemyapplist.xposed.logD
|
||||
import icu.nullptr.hidemyapplist.xposed.logE
|
||||
import icu.nullptr.hidemyapplist.xposed.logI
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||
class PmsHookTarget34(private val service: HMAService) : IFrameworkHook {
|
||||
class PmsHookTarget34(service: HMAService) : PmsHookTargetBase(service) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "PmsHookTarget34"
|
||||
|
|
@ -33,7 +32,7 @@ class PmsHookTarget34(private val service: HMAService) : IFrameworkHook {
|
|||
}
|
||||
}
|
||||
|
||||
private val fakeSystemPackageInstallInfo by lazy {
|
||||
override val fakeSystemPackageInstallInfo: Any by lazy {
|
||||
findConstructor(
|
||||
"android.content.pm.InstallSourceInfo"
|
||||
) {
|
||||
|
|
@ -48,21 +47,14 @@ class PmsHookTarget34(private val service: HMAService) : IFrameworkHook {
|
|||
)
|
||||
}
|
||||
|
||||
private val fakeUserPackageInstallInfo by lazy {
|
||||
var psInfo = Utils.getPackageInfoCompat(
|
||||
service.pms,
|
||||
VENDING_PACKAGE_NAME,
|
||||
0L,
|
||||
0
|
||||
).signingInfo
|
||||
|
||||
override val fakeUserPackageInstallInfo: Any by lazy {
|
||||
findConstructor(
|
||||
"android.content.pm.InstallSourceInfo"
|
||||
) {
|
||||
paramCount == 6
|
||||
}.newInstance(
|
||||
VENDING_PACKAGE_NAME,
|
||||
psInfo,
|
||||
psSigningInfo,
|
||||
VENDING_PACKAGE_NAME,
|
||||
VENDING_PACKAGE_NAME,
|
||||
VENDING_PACKAGE_NAME,
|
||||
|
|
@ -70,9 +62,6 @@ class PmsHookTarget34(private val service: HMAService) : IFrameworkHook {
|
|||
)
|
||||
}
|
||||
|
||||
private val hooks = mutableSetOf<XC_MethodHook.Unhook>()
|
||||
private var lastFilteredApp: AtomicReference<String?> = AtomicReference(null)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun load() {
|
||||
logI(TAG, "Load hook")
|
||||
|
|
@ -132,57 +121,6 @@ class PmsHookTarget34(private val service: HMAService) : IFrameworkHook {
|
|||
hooks.add(it)
|
||||
}
|
||||
|
||||
findMethodOrNull(service.pms::class.java, findSuper = true) {
|
||||
name == "getInstallSourceInfo"
|
||||
}?.hookBefore { param ->
|
||||
val targetApp = param.args[0] as String?
|
||||
|
||||
val callingUid = Binder.getCallingUid()
|
||||
if (callingUid == Constants.UID_SYSTEM) return@hookBefore
|
||||
val callingApps = Utils.binderLocalScope {
|
||||
service.pms.getPackagesForUid(callingUid)
|
||||
} ?: return@hookBefore
|
||||
for (caller in callingApps) {
|
||||
val blockingMode = service.shouldHideInstallationSource(caller, targetApp)
|
||||
when (blockingMode) {
|
||||
1 -> param.result = fakeUserPackageInstallInfo
|
||||
2 -> param.result = fakeSystemPackageInstallInfo
|
||||
else -> continue
|
||||
}
|
||||
|
||||
service.filterCount++
|
||||
break
|
||||
}
|
||||
}?.let {
|
||||
hooks.add(it)
|
||||
}
|
||||
|
||||
hooks += findMethod(service.pms::class.java, findSuper = true) {
|
||||
name == "getInstallerPackageName"
|
||||
}.hookBefore { param ->
|
||||
val targetApp = param.args[0] as String?
|
||||
|
||||
val callingUid = Binder.getCallingUid()
|
||||
if (callingUid == Constants.UID_SYSTEM) return@hookBefore
|
||||
val callingApps = Utils.binderLocalScope {
|
||||
service.pms.getPackagesForUid(callingUid)
|
||||
} ?: return@hookBefore
|
||||
for (caller in callingApps) {
|
||||
val blockingMode = service.shouldHideInstallationSource(caller, targetApp)
|
||||
when (blockingMode) {
|
||||
1 -> param.result = VENDING_PACKAGE_NAME
|
||||
2 -> param.result = null
|
||||
else -> continue
|
||||
}
|
||||
|
||||
service.filterCount++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun unload() {
|
||||
hooks.forEach(XC_MethodHook.Unhook::unhook)
|
||||
hooks.clear()
|
||||
super.load()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,86 @@
|
|||
package icu.nullptr.hidemyapplist.xposed.hook
|
||||
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Binder
|
||||
import android.os.Build
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethodOrNull
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import icu.nullptr.hidemyapplist.common.Constants
|
||||
import icu.nullptr.hidemyapplist.common.Constants.VENDING_PACKAGE_NAME
|
||||
import icu.nullptr.hidemyapplist.common.Utils
|
||||
import icu.nullptr.hidemyapplist.xposed.HMAService
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
abstract class PmsHookTargetBase(protected val service: HMAService) : IFrameworkHook {
|
||||
protected val hooks = mutableListOf<XC_MethodHook.Unhook>()
|
||||
protected var lastFilteredApp: AtomicReference<String?> = AtomicReference(null)
|
||||
|
||||
protected val psSigningInfo by lazy {
|
||||
Utils.getPackageInfoCompat(
|
||||
service.pms,
|
||||
VENDING_PACKAGE_NAME,
|
||||
PackageManager.GET_SIGNING_CERTIFICATES.toLong(),
|
||||
0
|
||||
).signingInfo
|
||||
}
|
||||
|
||||
abstract val fakeSystemPackageInstallInfo: Any?
|
||||
abstract val fakeUserPackageInstallInfo: Any?
|
||||
|
||||
override fun load() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
findMethodOrNull(service.pms::class.java, findSuper = true) {
|
||||
name == "getInstallSourceInfo"
|
||||
}?.hookBefore { param ->
|
||||
val targetApp = param.args[0] as String?
|
||||
|
||||
val callingUid = Binder.getCallingUid()
|
||||
if (callingUid == Constants.UID_SYSTEM) return@hookBefore
|
||||
val callingApps = Utils.binderLocalScope {
|
||||
service.pms.getPackagesForUid(callingUid)
|
||||
} ?: return@hookBefore
|
||||
for (caller in callingApps) {
|
||||
when (service.shouldHideInstallationSource(caller, targetApp)) {
|
||||
1 -> param.result = fakeUserPackageInstallInfo
|
||||
2 -> param.result = fakeSystemPackageInstallInfo
|
||||
else -> continue
|
||||
}
|
||||
|
||||
service.filterCount++
|
||||
break
|
||||
}
|
||||
}?.let {
|
||||
hooks.add(it)
|
||||
}
|
||||
}
|
||||
|
||||
hooks += findMethod(service.pms::class.java, findSuper = true) {
|
||||
name == "getInstallerPackageName"
|
||||
}.hookBefore { param ->
|
||||
val targetApp = param.args[0] as String?
|
||||
|
||||
val callingUid = Binder.getCallingUid()
|
||||
if (callingUid == Constants.UID_SYSTEM) return@hookBefore
|
||||
val callingApps = Utils.binderLocalScope {
|
||||
service.pms.getPackagesForUid(callingUid)
|
||||
} ?: return@hookBefore
|
||||
for (caller in callingApps) {
|
||||
when (service.shouldHideInstallationSource(caller, targetApp)) {
|
||||
1 -> param.result = VENDING_PACKAGE_NAME
|
||||
2 -> param.result = null
|
||||
else -> continue
|
||||
}
|
||||
|
||||
service.filterCount++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final override fun unload() {
|
||||
hooks.forEach(XC_MethodHook.Unhook::unhook)
|
||||
hooks.clear()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue