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

@@ -14,7 +14,7 @@
android:permission="android.permission.INTERACT_ACROSS_USERS_FULL" />
<service
android:name=".vendor.RootPackageManagerService"
android:name=".bg.RootServer"
android:exported="false"
tools:ignore="Instantiatable" />

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 {
@@ -13,6 +16,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) {
InstallMethod.valueOf(Settings.silentInstallMethod)
} else {
@@ -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.SHIZUKU -> ShizukuInstaller.install(apkFile)
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
@@ -108,6 +108,13 @@ object Vendor : VendorInterface {
}
}
override fun forceGetLatestUpdate(): UpdateInfo? {
val track = UpdateTrack.fromString(Settings.updateTrack)
return GitHubUpdateChecker().use { checker ->
checker.forceGetLatestUpdate(track)
}
}
override fun supportsSilentInstall(): Boolean {
return true
}
@@ -123,8 +130,7 @@ object Vendor : VendorInterface {
override suspend fun verifySilentInstallMethod(method: String): Boolean {
return when (method) {
"PACKAGE_INSTALLER" -> {
ApkInstaller.canSystemSilentInstall() &&
Application.application.packageManager.canRequestPackageInstalls()
ApkInstaller.canSystemSilentInstall()
}
"SHIZUKU" -> {
if (!ShizukuInstaller.isAvailable()) {
@@ -141,17 +147,13 @@ object Vendor : VendorInterface {
}
}
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)
}
}