Fix #172
This commit is contained in:
parent
ea67333b28
commit
38fa62bfea
7 changed files with 28 additions and 5 deletions
|
|
@ -36,7 +36,7 @@ val minSdkVer by extra(24)
|
|||
val targetSdkVer by extra(33)
|
||||
|
||||
val appVerName by extra("3.0.0")
|
||||
val serviceVerCode by extra(82)
|
||||
val serviceVerCode by extra(83)
|
||||
val minBackupVerCode by extra(65)
|
||||
|
||||
val androidSourceCompatibility = JavaVersion.VERSION_11
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package icu.nullptr.hidemyapplist.common;
|
|||
import java.util.Set;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String APP_PACKAGE_NAME = "com.tsng.hidemyapplist";
|
||||
public static final String CLASS_PMS = "com.android.server.pm.PackageManagerService";
|
||||
public static final String[] CLASS_EXT_PMS = {
|
||||
|
|
@ -14,6 +15,8 @@ public class Constants {
|
|||
public static final int TRANSACTION = 'H' << 24 | 'M' << 16 | 'A' << 8 | 'D';
|
||||
public static final int ACTION_GET_BINDER = 1;
|
||||
|
||||
public static final int UID_SYSTEM = 1000;
|
||||
|
||||
public static final Set<String> packagesShouldNotHide = Set.of(
|
||||
"android",
|
||||
"android.media",
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.github.kyuubiran.ezxhelper.utils.argTypes
|
|||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.github.kyuubiran.ezxhelper.utils.method
|
||||
import com.github.kyuubiran.ezxhelper.utils.staticMethod
|
||||
import icu.nullptr.hidemyapplist.common.BuildConfig
|
||||
import icu.nullptr.hidemyapplist.common.Constants
|
||||
|
||||
object BridgeService {
|
||||
|
|
@ -17,7 +18,7 @@ object BridgeService {
|
|||
private var appUid = 0
|
||||
|
||||
fun start(pms: IPackageManager) {
|
||||
logI(TAG, "Initialize HMAService")
|
||||
logI(TAG, "Initialize HMAService - Version ${BuildConfig.SERVICE_VERSION}")
|
||||
val service = HMAService(pms)
|
||||
appUid = Utils.getPackageUidCompat(service.pms, Constants.APP_PACKAGE_NAME, 0, 0)
|
||||
logD(TAG, "Client uid: $appUid")
|
||||
|
|
|
|||
|
|
@ -33,6 +33,13 @@ object Utils {
|
|||
return this.invokeMethodAutoAs<String>("getNameForUid", Binder.getCallingUid())
|
||||
}
|
||||
|
||||
fun <T> binderLocalScope(block: () -> T): T {
|
||||
val identity = Binder.clearCallingIdentity()
|
||||
val result = block()
|
||||
Binder.restoreCallingIdentity(identity)
|
||||
return result
|
||||
}
|
||||
|
||||
fun getPackageNameFromPackageSettings(packageSettings: Any): String {
|
||||
return with(packageSettings.toString()) {
|
||||
substring(lastIndexOf(' ') + 1, lastIndexOf('/'))
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.os.Build
|
|||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import icu.nullptr.hidemyapplist.common.Constants
|
||||
import icu.nullptr.hidemyapplist.xposed.HMAService
|
||||
import icu.nullptr.hidemyapplist.xposed.Utils
|
||||
import icu.nullptr.hidemyapplist.xposed.logE
|
||||
|
|
@ -26,7 +27,10 @@ class PmsHookTarget28(private val service: HMAService) : IFrameworkHook {
|
|||
}.hookBefore { param ->
|
||||
runCatching {
|
||||
val callingUid = param.args[1] as Int
|
||||
val callingApps = service.pms.getPackagesForUid(callingUid) ?: return@hookBefore
|
||||
if (callingUid == Constants.UID_SYSTEM) return@hookBefore
|
||||
val callingApps = Utils.binderLocalScope {
|
||||
service.pms.getPackagesForUid(callingUid)
|
||||
} ?: return@hookBefore
|
||||
val targetApp = Utils.getPackageNameFromPackageSettings(param.args[0])
|
||||
for (caller in callingApps) {
|
||||
if (service.shouldHide(caller, targetApp)) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.os.Build
|
|||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import icu.nullptr.hidemyapplist.common.Constants
|
||||
import icu.nullptr.hidemyapplist.xposed.HMAService
|
||||
import icu.nullptr.hidemyapplist.xposed.Utils
|
||||
import icu.nullptr.hidemyapplist.xposed.logE
|
||||
|
|
@ -26,7 +27,10 @@ class PmsHookTarget30(private val service: HMAService) : IFrameworkHook {
|
|||
}.hookBefore { param ->
|
||||
runCatching {
|
||||
val callingUid = param.args[0] as Int
|
||||
val callingApps = service.pms.getPackagesForUid(callingUid) ?: return@hookBefore
|
||||
if (callingUid == Constants.UID_SYSTEM) return@hookBefore
|
||||
val callingApps = Utils.binderLocalScope {
|
||||
service.pms.getPackagesForUid(callingUid)
|
||||
} ?: return@hookBefore
|
||||
val targetApp = Utils.getPackageNameFromPackageSettings(param.args[2])
|
||||
for (caller in callingApps) {
|
||||
if (service.shouldHide(caller, targetApp)) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.os.Build
|
|||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import icu.nullptr.hidemyapplist.common.Constants
|
||||
import icu.nullptr.hidemyapplist.xposed.HMAService
|
||||
import icu.nullptr.hidemyapplist.xposed.Utils
|
||||
import icu.nullptr.hidemyapplist.xposed.logE
|
||||
|
|
@ -34,7 +35,10 @@ class PmsHookTarget33(private val service: HMAService) : IFrameworkHook {
|
|||
runCatching {
|
||||
val snapshot = param.args[0]
|
||||
val callingUid = param.args[1] as Int
|
||||
val callingApps = getPackagesForUidMethod.invoke(snapshot, callingUid) as Array<String>? ?: return@hookBefore
|
||||
if (callingUid == Constants.UID_SYSTEM) return@hookBefore
|
||||
val callingApps = Utils.binderLocalScope {
|
||||
getPackagesForUidMethod.invoke(snapshot, callingUid) as Array<String>?
|
||||
} ?: return@hookBefore
|
||||
val targetApp = Utils.getPackageNameFromPackageSettings(param.args[3]) // PackageSettings <- PackageStateInternal
|
||||
for (caller in callingApps) {
|
||||
if (service.shouldHide(caller, targetApp)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue