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,8 +4,9 @@
<application>
<service
android:name=".vendor.RootPackageManagerService"
tools:node="remove" />
android:name=".bg.RootServer"
android:exported="false"
tools:ignore="Instantiatable" />
</application>
</manifest>

View File

@@ -1,7 +1,10 @@
package io.nekohasekai.sfa.vendor
import android.content.Context
import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.database.Settings
import io.nekohasekai.sfa.utils.HookStatusClient
import io.nekohasekai.sfa.xposed.XposedActivation
import java.io.File
enum class InstallMethod {
@@ -12,6 +15,11 @@ enum class InstallMethod {
object ApkInstaller {
fun getConfiguredMethod(): InstallMethod {
if (HookStatusClient.status.value?.active == true ||
XposedActivation.isActivated(Application.application)
) {
return InstallMethod.ROOT
}
return if (Settings.silentInstallEnabled) {
val method = Settings.silentInstallMethod
if (method == "SHIZUKU") InstallMethod.ROOT else InstallMethod.valueOf(method)
@@ -20,8 +28,8 @@ object ApkInstaller {
}
}
suspend fun install(context: Context, apkFile: File, method: InstallMethod = getConfiguredMethod()): Result<Unit> {
return when (method) {
suspend fun install(context: Context, apkFile: File, method: InstallMethod = getConfiguredMethod()) {
when (method) {
InstallMethod.ROOT -> RootInstaller.install(apkFile)
InstallMethod.PACKAGE_INSTALLER -> SystemPackageInstaller.install(context, apkFile)
}

View File

@@ -9,7 +9,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.R
import io.nekohasekai.sfa.database.Settings
import io.nekohasekai.sfa.ui.profile.QRCodeCropArea
import io.nekohasekai.sfa.compose.screen.qrscan.QRCodeCropArea
import io.nekohasekai.sfa.update.UpdateCheckException
import io.nekohasekai.sfa.update.UpdateInfo
import io.nekohasekai.sfa.update.UpdateState
@@ -123,25 +123,20 @@ object Vendor : VendorInterface {
override suspend fun verifySilentInstallMethod(method: String): Boolean {
return when (method) {
"PACKAGE_INSTALLER" -> {
ApkInstaller.canSystemSilentInstall() &&
Application.application.packageManager.canRequestPackageInstalls()
ApkInstaller.canSystemSilentInstall()
}
"ROOT" -> RootInstaller.checkAccess()
else -> false
}
}
override suspend fun downloadAndInstall(context: android.content.Context, downloadUrl: String): Result<Unit> {
return try {
val cachedApk = UpdateState.cachedApkFile.value
val apkFile = if (cachedApk != null && cachedApk.exists() && cachedApk.length() > 0) {
cachedApk
} else {
ApkDownloader().use { it.download(downloadUrl) }
}
ApkInstaller.install(context, apkFile)
} catch (e: Exception) {
Result.failure(e)
override suspend fun downloadAndInstall(context: android.content.Context, downloadUrl: String) {
val cachedApk = UpdateState.cachedApkFile.value
val apkFile = if (cachedApk != null && cachedApk.exists() && cachedApk.length() > 0) {
cachedApk
} else {
ApkDownloader().use { it.download(downloadUrl) }
}
ApkInstaller.install(context, apkFile)
}
}