Add vpn hide xposed module

This commit is contained in:
世界
2026-01-07 20:31:27 +08:00
parent 8a8686b3df
commit cd83cbfe9e
152 changed files with 12994 additions and 2782 deletions

View File

@@ -4,37 +4,63 @@ import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.os.Build
import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.BuildConfig
import io.nekohasekai.sfa.bg.RootClient
import io.nekohasekai.sfa.database.Settings
import io.nekohasekai.sfa.utils.HookStatusClient
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
object PackageQueryManager {
val needsPrivilegedQuery: Boolean = false
val strategy: PackageQueryStrategy
get() = when {
HookStatusClient.status.value?.active == true -> PackageQueryStrategy.ForcedRoot
BuildConfig.FLAVOR == "play" -> PackageQueryStrategy.UserSelected(queryMode.value)
else -> PackageQueryStrategy.Direct
}
private val _queryMode = MutableStateFlow("")
val showModeSelector: Boolean
get() = strategy is PackageQueryStrategy.UserSelected
private val _queryMode = MutableStateFlow(Settings.perAppProxyPackageQueryMode)
val queryMode: StateFlow<String> = _queryMode
val shizukuInstalled: StateFlow<Boolean> = MutableStateFlow(false)
val shizukuBinderReady: StateFlow<Boolean> = MutableStateFlow(false)
val shizukuPermissionGranted: StateFlow<Boolean> = MutableStateFlow(false)
val rootAvailable: StateFlow<Boolean?> = MutableStateFlow(null)
val rootServiceConnected: StateFlow<Boolean> = MutableStateFlow(false)
val rootAvailable: StateFlow<Boolean?> get() = RootClient.rootAvailable
val rootServiceConnected: StateFlow<Boolean> get() = RootClient.serviceConnected
fun isShizukuAvailable(): Boolean = false
fun registerListeners() {}
fun registerListeners() {
_queryMode.value = Settings.perAppProxyPackageQueryMode
}
fun unregisterListeners() {}
fun requestShizukuPermission() {}
suspend fun checkRootAvailable(): Boolean = false
fun refreshShizukuState() {}
suspend fun checkRootAvailable(): Boolean {
return RootClient.checkRootAvailable()
}
fun setQueryMode(mode: String) {
_queryMode.value = mode
}
suspend fun getInstalledPackages(flags: Int): List<PackageInfo> {
return when (val s = strategy) {
is PackageQueryStrategy.ForcedRoot -> RootClient.getInstalledPackages(flags)
is PackageQueryStrategy.UserSelected -> RootClient.getInstalledPackages(flags)
is PackageQueryStrategy.Direct -> getPackagesViaPackageManager(flags)
}
}
private fun getPackagesViaPackageManager(flags: Int): List<PackageInfo> {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
Application.packageManager.getInstalledPackages(
PackageManager.PackageInfoFlags.of(flags.toLong())