diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 36a5e3f4..5e3cd9ca 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,12 +3,6 @@ xmlns:tools="http://schemas.android.com/tools" package="com.tsng.hidemyapplist"> - - - - - - diff --git a/app/src/main/java/com/tsng/hidemyapplist/xposed/PackageManagerService.kt b/app/src/main/java/com/tsng/hidemyapplist/xposed/PackageManagerService.kt index 936f663c..ea214566 100644 --- a/app/src/main/java/com/tsng/hidemyapplist/xposed/PackageManagerService.kt +++ b/app/src/main/java/com/tsng/hidemyapplist/xposed/PackageManagerService.kt @@ -37,8 +37,7 @@ import kotlin.concurrent.thread object PackageManagerService { private const val hmaApp = "com.tsng.hidemyapplist" - private const val dataDir = "/data/misc/hide_my_applist" - private val logFile = File("$dataDir/tmp/runtime.log") + private val customPms = arrayOf( "com.android.server.pm.OplusPackageManagerService", "com.android.server.pm.OppoPackageManagerService" @@ -51,6 +50,8 @@ object PackageManagerService { private var riruModuleVersion = 0 private var mLock = Any() + private lateinit var dataDir: String + private lateinit var logFile: File private lateinit var token: String @Volatile @@ -83,17 +84,20 @@ object PackageManagerService { } } - private fun generateToken() { + private fun generateRandomString(length: Int): String { val leftLimit = 97 // letter 'a' val rightLimit = 122 // letter 'z' - val targetStringLength = 10 val random = Random() - val buffer = StringBuilder(targetStringLength) - for (i in 0 until targetStringLength) { + val buffer = StringBuilder(length) + for (i in 0 until length) { val randomLimitedInt = leftLimit + (random.nextFloat() * (rightLimit - leftLimit + 1)).toInt() buffer.append(randomLimitedInt.toChar()) } - token = buffer.toString() + return buffer.toString() + } + + private fun generateToken() { + token = generateRandomString(10) File("$dataDir/tmp/token").writeText(token) } @@ -251,7 +255,7 @@ object PackageManagerService { param.result = provideLogs() arg == "cleanLogs" -> { - synchronized(mLock) { with(logFile) { delete(); createNewFile() } } + synchronized(mLock) { logFile.apply { delete(); createNewFile() } } param.result = "OK" } @@ -295,7 +299,7 @@ object PackageManagerService { private fun syncWithRiru() { /* If riru extension not installed, make tmp by the service */ - with(File("$dataDir/tmp/riru_v")) { + File("$dataDir/tmp/riru_v").apply { if (exists()) { var minApkVersion: Int try { @@ -316,17 +320,30 @@ object PackageManagerService { File("$dataDir/tmp/stop_riru").createNewFile() Log.e("System service version too old to work with the new riru extension") } - } else { - File(dataDir).mkdir() - File("$dataDir/tmp").deleteRecursively() - File("$dataDir/tmp").mkdir() + delete() + } else File("$dataDir/tmp").apply { + deleteRecursively() + mkdirs() } - delete() } } + private fun searchDataDir() { + File("/data/misc/hide_my_applist").deleteRecursively() + File("/data/system").list()?.forEach { + if (it.startsWith("hide_my_applist")) { + dataDir = "/data/system/$it" + } + } + if (!this::dataDir.isInitialized) { + dataDir = "/data/system/hide_my_applist_" + generateRandomString(16) + } + logFile = File("$dataDir/tmp/runtime.log") + } + /* Load system service */ fun entry() { + searchDataDir() syncWithRiru() generateToken() try { @@ -362,6 +379,7 @@ object PackageManagerService { File("$dataDir/tmp/system_apps.list").appendText("$pkg\n") Log.i("System hook installed (Version ${BuildConfig.SERVICE_VERSION})") + Log.i("Data directory is at $dataDir") }) /* ---Deal with 💩 ROMs--- */ @@ -404,7 +422,10 @@ object PackageManagerService { "getPackageInfo", "getPackageGids", - "getApplicationInfo" + "getApplicationInfo", + "getInstallSourceInfo", + "getLaunchIntentForPackage", + "getLeanbackLaunchIntentForPackage" -> setResult(method, "API requests", null) "queryIntentActivities", diff --git a/app/src/main/java/com/tsng/hidemyapplist/xposed/XposedEntry.kt b/app/src/main/java/com/tsng/hidemyapplist/xposed/XposedEntry.kt index 51790bd0..8dae20a7 100644 --- a/app/src/main/java/com/tsng/hidemyapplist/xposed/XposedEntry.kt +++ b/app/src/main/java/com/tsng/hidemyapplist/xposed/XposedEntry.kt @@ -19,8 +19,7 @@ class XposedEntry : IXposedHookZygoteInit, IXposedHookLoadPackage { EzXHelperInit.setToastTag("HMA") if (hostPackageName == BuildConfig.APPLICATION_ID) { - getFieldBySig("Lcom/tsng/hidemyapplist/app/MyApplication;->isModuleActivated:Z") - .setBoolean(null, true) + getFieldBySig("Lcom/tsng/hidemyapplist/app/MyApplication;->isModuleActivated:Z").setBoolean(null, true) } if (hostPackageName == "android") PackageManagerService.entry() diff --git a/app/src/main/res/values-fr/strings_settings.xml b/app/src/main/res/values-fr/strings_settings.xml index bd291927..9501413b 100644 --- a/app/src/main/res/values-fr/strings_settings.xml +++ b/app/src/main/res/values-fr/strings_settings.xml @@ -10,7 +10,7 @@ Stopper le service du système Redémarrage nécessaire pour redémarrer le service Nettoyer l\’environnement de fonctionnement en même temps? - Supprimer le cache du service du système dans /data/misc/hide_my_applist. Cela signifie que vous devez lancer l\’application du module une fois manuellement après le prochain redémarrage afin d\’activer les interceptions, et les compteurs d\’interceptions seront également nettoyés. + Supprimer le cache du service du système dans /data/system/hide_my_applist_*. Cela signifie que vous devez lancer l\’application du module une fois manuellement après le prochain redémarrage afin d\’activer les interceptions, et les compteurs d\’interceptions seront également nettoyés. Forcer le nettoyage de l\’environnement d\’exécution (root) Uniquement si le service du système ne parvient pas à démarrer, ou sinon vous devriez cliquer sur l\’option ci-dessous. Environnement de fonctionnement nettoyé diff --git a/app/src/main/res/values-zh-rCN/strings_settings.xml b/app/src/main/res/values-zh-rCN/strings_settings.xml index 93089115..1a485e20 100644 --- a/app/src/main/res/values-zh-rCN/strings_settings.xml +++ b/app/src/main/res/values-zh-rCN/strings_settings.xml @@ -10,7 +10,7 @@ 终止系统服务 需要重启设备才能重新启动服务 是否同时清理运行环境 - 移除位于 /data/misc/hide_my_applist 的系统服务缓存,这会使下次重启后需要先手动打开一次模块 APP 才能使拦截生效,同时拦截次数记录也会被清空。 + 移除位于 /data/system/hide_my_applist_* 的系统服务缓存,这会使下次重启后需要先手动打开一次模块 APP 才能使拦截生效,同时拦截次数记录也会被清空。 强制清理运行环境 (root) 当且仅当系统服务无法启动时尝试此选项,否则你应该点击终止系统服务并自动执行清理 运行环境清理完成 diff --git a/app/src/main/res/values-zh-rTW/strings_settings.xml b/app/src/main/res/values-zh-rTW/strings_settings.xml index 4899d8dc..bf79a7e0 100644 --- a/app/src/main/res/values-zh-rTW/strings_settings.xml +++ b/app/src/main/res/values-zh-rTW/strings_settings.xml @@ -10,7 +10,7 @@ 終止系統服務 需要重啟設備才能重新啟動服務 是否同時清理運作環境 - 移除位於 /data/misc/hide_my_applist 的系統服務緩存,這會使下次重啟後需要先手動打開一次模組應用程式才能使攔截生效,同時攔截次數記錄也會被清空。 + 移除位於 /data/system/hide_my_applist_* 的系統服務緩存,這會使下次重啟後需要先手動打開一次模組應用程式才能使攔截生效,同時攔截次數記錄也會被清空。 強制清理運作環境 (root) 當且僅當系統服務無法啟動時嘗試此選項,否則你應該點擊終止系統服務並自動執行清理 運作環境清理完成 diff --git a/app/src/main/res/values/strings_settings.xml b/app/src/main/res/values/strings_settings.xml index d615fbea..d7e96e9f 100644 --- a/app/src/main/res/values/strings_settings.xml +++ b/app/src/main/res/values/strings_settings.xml @@ -10,7 +10,7 @@ Stop system service Need reboot to restart service Clean runtime environment at the same time? - Remove system service cache in /data/misc/hide_my_applist. This means you need to launch the module app once manually after next reboot in order to enable interceptions, and interception counts will also be cleaned. + Remove system service cache in /data/system/hide_my_applist_*. This means you need to launch the module app once manually after next reboot in order to enable interceptions, and interception counts will also be cleaned. Force clean runtime environment (root) Only if system service fails to start, otherwise you should click the above option. Runtime environment cleaned diff --git a/build.gradle.kts b/build.gradle.kts index 15965490..f45279af 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,9 +14,9 @@ val buildToolsVer by extra("31.0.0") val ndkVer by extra("23.0.7599858") val appVerName by extra("2.2") -val appVerCode by extra(65) -val serviceVer by extra(65) -val minRiruVer by extra(26) +val appVerCode by extra(66) +val serviceVer by extra(66) +val minRiruVer by extra(28) val minBackupVer by extra(65) val gitCommitCount by extra("git rev-list HEAD --count".execute()) diff --git a/settings.gradle.kts b/settings.gradle.kts index 28138a1f..fc195911 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,7 +7,7 @@ pluginManagement { plugins { id("com.android.application").version("7.1.0-alpha13") id("com.android.library").version("7.1.0-alpha13") - id("org.jetbrains.kotlin.android").version("1.5.30") + id("org.jetbrains.kotlin.android").version("1.5.31") } }