diff --git a/xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/HMAService.kt b/xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/HMAService.kt index 160ec1fa..88996c5b 100644 --- a/xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/HMAService.kt +++ b/xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/HMAService.kt @@ -116,7 +116,7 @@ class HMAService(val pms: IPackageManager) : IHMAService.Stub() { } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - frameworkHooks.add(ZygoteArgsHook(this)) + frameworkHooks.add(PlatformCompatHook(this)) } frameworkHooks.forEach(IFrameworkHook::load) diff --git a/xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/hook/ZygoteArgsHook.kt b/xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/hook/FrameworkCompatHook.kt similarity index 64% rename from xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/hook/ZygoteArgsHook.kt rename to xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/hook/FrameworkCompatHook.kt index 7b541263..71d77ece 100644 --- a/xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/hook/ZygoteArgsHook.kt +++ b/xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/hook/FrameworkCompatHook.kt @@ -1,23 +1,22 @@ package icu.nullptr.hidemyapplist.xposed.hook import android.annotation.TargetApi +import android.content.pm.ApplicationInfo 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.CommonUtils -import icu.nullptr.hidemyapplist.common.Constants.* import icu.nullptr.hidemyapplist.xposed.HMAService import icu.nullptr.hidemyapplist.xposed.logE import icu.nullptr.hidemyapplist.xposed.logI @TargetApi(Build.VERSION_CODES.S) -class ZygoteArgsHook(private val service: HMAService) : IFrameworkHook { +class PlatformCompatHook(private val service: HMAService) : IFrameworkHook { companion object { - private const val TAG = "ZygoteArgsHook" + private const val TAG = "PlatformCompatHook" private val sAppDataIsolationEnabled = CommonUtils.isAppDataIsolationEnabled - private val sVoldAppDataIsolationEnabled = CommonUtils.isVoldAppDataIsolationEnabled } private var hook: XC_MethodHook.Unhook? = null @@ -26,19 +25,18 @@ class ZygoteArgsHook(private val service: HMAService) : IFrameworkHook { if (!service.config.forceMountData) return logI(TAG, "Load hook") logI(TAG, "App data isolation enabled: $sAppDataIsolationEnabled") - logI(TAG, "Vold app data isolation enabled: $sVoldAppDataIsolationEnabled") - hook = findMethod("android.os.ZygoteProcess") { - name == "startViaZygote" + hook = findMethod("com.android.server.compat.PlatformCompat") { + name == "isChangeEnabled" }.hookBefore { param -> runCatching { - val uid = param.args[2] as Int - if (uid == UID_SYSTEM) return@hookBefore - val apps = service.pms.getPackagesForUid(uid) ?: return@hookBefore + val changeId = param.args[0] as Long + val appInfo = param.args[1] as ApplicationInfo + if (changeId.toInt() != 143937733) return@hookBefore + val apps = service.pms.getPackagesForUid(appInfo.uid) ?: return@hookBefore for (app in apps) { if (service.isHookEnabled(app)) { - if (sAppDataIsolationEnabled) param.args[20] = true // boolean bindMountAppsData - if (sVoldAppDataIsolationEnabled) param.args[21] = true // boolean bindMountAppStorageDirs - logI(TAG, "@startViaZygote force mount data: $uid $app") + if (sAppDataIsolationEnabled) param.result = true + logI(TAG, "@startViaZygote force mount data: ${appInfo.uid} $app") return@hookBefore } }