Compare commits

...
4 Commits
Author SHA1 Message Date
iceBear67 483598da0c temporary fix 2026-07-16 09:17:36 +00:00
n3t1zen 601429d63d use my keystore 2026-05-05 12:04:02 +08:00
n3t1zen f27b2f7e08 temporary fix for building 2026-05-05 12:03:23 +08:00
n3t1zen 9932774a1d limit memory... 2026-05-05 11:52:51 +08:00
14 changed files with 92 additions and 6 deletions
Binary file not shown.
@@ -2,6 +2,7 @@ package io.nekohasekai.sfa.vendor
import io.nekohasekai.libbox.HTTPResponseWriteToProgressHandler import io.nekohasekai.libbox.HTTPResponseWriteToProgressHandler
import io.nekohasekai.libbox.Libbox import io.nekohasekai.libbox.Libbox
import io.nekohasekai.libbox.writeToWithProgress
import io.nekohasekai.sfa.Application import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.update.UpdateState import io.nekohasekai.sfa.update.UpdateState
import io.nekohasekai.sfa.utils.HTTPClient import io.nekohasekai.sfa.utils.HTTPClient
@@ -0,0 +1,27 @@
package io.nekohasekai.libbox
class FDroidMirror(
val url: String,
val name: String,
val country: String,
)
class FDroidMirrorIterator(
private val items: List<FDroidMirror>,
) {
private var index = 0
fun hasNext(): Boolean = index < items.size
fun next(): FDroidMirror = items[index++]
}
class FDroidMirrorPingResult(
val url: String,
val latencyMs: Int,
)
class FDroidUpdateResult(
val versionCode: Int,
val versionName: String,
val downloadURL: String,
val fileSize: Long,
)
@@ -0,0 +1,5 @@
package io.nekohasekai.libbox
interface HTTPResponseWriteToProgressHandler {
fun update(progress: Long, total: Long)
}
@@ -0,0 +1,34 @@
package io.nekohasekai.libbox
fun HTTPResponse.writeToWithProgress(path: String, handler: HTTPResponseWriteToProgressHandler) {
writeTo(path)
}
fun ConnectionOwner.setAndroidPackageNames(names: StringIterator) {
if (names.hasNext()) {
androidPackageName = names.next()
}
}
fun ProcessInfo.packageNames(): StringIterator? {
val name = packageName ?: return null
if (name.isEmpty()) return null
return object : StringIterator {
private var consumed = false
override fun len(): Int = 1
override fun hasNext(): Boolean = !consumed
override fun next(): String { consumed = true; return name }
}
}
fun getFDroidMirrors(): FDroidMirrorIterator {
return FDroidMirrorIterator(emptyList())
}
fun pingFDroidMirror(url: String): FDroidMirrorPingResult {
return FDroidMirrorPingResult(url, -1)
}
fun checkFDroidUpdate(mirrorUrl: String, packageName: String, versionCode: Int, cachePath: String): FDroidUpdateResult? {
return null
}
@@ -0,0 +1,3 @@
package io.nekohasekai.libbox
interface NeighborUpdateListener
@@ -16,6 +16,7 @@ import io.nekohasekai.libbox.PlatformInterface
import io.nekohasekai.libbox.StringIterator import io.nekohasekai.libbox.StringIterator
import io.nekohasekai.libbox.TunOptions import io.nekohasekai.libbox.TunOptions
import io.nekohasekai.libbox.WIFIState import io.nekohasekai.libbox.WIFIState
import io.nekohasekai.libbox.setAndroidPackageNames
import io.nekohasekai.sfa.Application import io.nekohasekai.sfa.Application
import java.net.Inet6Address import java.net.Inet6Address
import java.net.InetSocketAddress import java.net.InetSocketAddress
@@ -2,6 +2,7 @@ package io.nekohasekai.sfa.bg
import android.app.Service import android.app.Service
import android.content.Intent import android.content.Intent
import io.nekohasekai.libbox.NeighborUpdateListener
import io.nekohasekai.libbox.Notification import io.nekohasekai.libbox.Notification
class ProxyService : class ProxyService :
@@ -14,6 +15,10 @@ class ProxyService :
override fun onBind(intent: Intent) = service.onBind() override fun onBind(intent: Intent) = service.onBind()
override fun onDestroy() = service.onDestroy() override fun onDestroy() = service.onDestroy()
fun closeNeighborMonitor(listener: NeighborUpdateListener?) {
}
override fun sendNotification(notification: Notification) = service.sendNotification(notification) override fun sendNotification(notification: Notification) = service.sendNotification(notification)
fun startNeighborMonitor(listener: NeighborUpdateListener?) {
}
} }
@@ -7,6 +7,7 @@ import android.net.VpnService
import android.os.Build import android.os.Build
import android.os.IBinder import android.os.IBinder
import android.util.Log import android.util.Log
import io.nekohasekai.libbox.NeighborUpdateListener
import io.nekohasekai.libbox.Notification import io.nekohasekai.libbox.Notification
import io.nekohasekai.libbox.TunOptions import io.nekohasekai.libbox.TunOptions
import io.nekohasekai.sfa.database.Settings import io.nekohasekai.sfa.database.Settings
@@ -51,6 +52,9 @@ class VPNService :
protect(fd) protect(fd)
} }
fun closeNeighborMonitor(listener: NeighborUpdateListener?) {
}
var systemProxyAvailable = false var systemProxyAvailable = false
var systemProxyEnabled = false var systemProxyEnabled = false
@@ -182,4 +186,6 @@ class VPNService :
} }
override fun sendNotification(notification: Notification) = service.sendNotification(notification) override fun sendNotification(notification: Notification) = service.sendNotification(notification)
fun startNeighborMonitor(listener: NeighborUpdateListener?) {
}
} }
@@ -1,6 +1,7 @@
package io.nekohasekai.sfa.compose.model package io.nekohasekai.sfa.compose.model
import androidx.compose.runtime.Immutable import androidx.compose.runtime.Immutable
import io.nekohasekai.libbox.packageNames
import io.nekohasekai.sfa.ktx.toList import io.nekohasekai.sfa.ktx.toList
import io.nekohasekai.libbox.Connection as LibboxConnection import io.nekohasekai.libbox.Connection as LibboxConnection
import io.nekohasekai.libbox.ProcessInfo as LibboxProcessInfo import io.nekohasekai.libbox.ProcessInfo as LibboxProcessInfo
@@ -84,6 +84,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect import androidx.lifecycle.compose.LifecycleEventEffect
import androidx.navigation.NavController import androidx.navigation.NavController
import io.nekohasekai.libbox.Libbox import io.nekohasekai.libbox.Libbox
import io.nekohasekai.libbox.getFDroidMirrors
import io.nekohasekai.sfa.Application import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.BuildConfig import io.nekohasekai.sfa.BuildConfig
import io.nekohasekai.sfa.R import io.nekohasekai.sfa.R
@@ -838,7 +839,7 @@ fun AppSettingsScreen(navController: NavController) {
supportingContent = { supportingContent = {
val mirrorUrl = Settings.fdroidMirrorUrl val mirrorUrl = Settings.fdroidMirrorUrl
val mirrorName = remember(mirrorUrl) { val mirrorName = remember(mirrorUrl) {
val iter = Libbox.getFDroidMirrors() val iter = getFDroidMirrors()
var name: String? = null var name: String? = null
while (iter.hasNext()) { while (iter.hasNext()) {
val m = iter.next() val m = iter.next()
@@ -52,6 +52,8 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.navigation.NavController import androidx.navigation.NavController
import io.nekohasekai.libbox.Libbox import io.nekohasekai.libbox.Libbox
import io.nekohasekai.libbox.getFDroidMirrors
import io.nekohasekai.libbox.pingFDroidMirror
import io.nekohasekai.sfa.R import io.nekohasekai.sfa.R
import io.nekohasekai.sfa.compose.topbar.OverrideTopBar import io.nekohasekai.sfa.compose.topbar.OverrideTopBar
import io.nekohasekai.sfa.database.Settings import io.nekohasekai.sfa.database.Settings
@@ -99,7 +101,7 @@ fun FDroidMirrorScreen(navController: NavController) {
val builtinMirrors = remember { val builtinMirrors = remember {
val mirrors = mutableListOf<MirrorEntry>() val mirrors = mutableListOf<MirrorEntry>()
val iter = Libbox.getFDroidMirrors() val iter = getFDroidMirrors()
while (iter.hasNext()) { while (iter.hasNext()) {
val m = iter.next() val m = iter.next()
mirrors.add(MirrorEntry(url = m.url, name = m.name, country = m.country)) mirrors.add(MirrorEntry(url = m.url, name = m.name, country = m.country))
@@ -132,7 +134,7 @@ fun FDroidMirrorScreen(navController: NavController) {
scope.launch { scope.launch {
allMirrors.map { mirror -> allMirrors.map { mirror ->
async(Dispatchers.IO) { async(Dispatchers.IO) {
val r = Libbox.pingFDroidMirror(mirror.url) val r = pingFDroidMirror(mirror.url)
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
if (r.latencyMs < 0) { if (r.latencyMs < 0) {
latencyErrors[r.url] = true latencyErrors[r.url] = true
@@ -1,7 +1,7 @@
package io.nekohasekai.sfa.update package io.nekohasekai.sfa.update
import android.content.Context import android.content.Context
import io.nekohasekai.libbox.Libbox import io.nekohasekai.libbox.checkFDroidUpdate as libboxCheckFDroidUpdate
import io.nekohasekai.sfa.database.Settings import io.nekohasekai.sfa.database.Settings
fun checkFDroidUpdate(context: Context): UpdateInfo? { fun checkFDroidUpdate(context: Context): UpdateInfo? {
@@ -9,7 +9,7 @@ fun checkFDroidUpdate(context: Context): UpdateInfo? {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
val versionCode = context.packageManager.getPackageInfo(packageName, 0).versionCode val versionCode = context.packageManager.getPackageInfo(packageName, 0).versionCode
val result = Libbox.checkFDroidUpdate( val result = libboxCheckFDroidUpdate(
Settings.fdroidMirrorUrl, Settings.fdroidMirrorUrl,
packageName, packageName,
versionCode, versionCode,
+1 -1
View File
@@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html # http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process. # Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings. # The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx8192m -Dfile.encoding=UTF-8 org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode. # When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit # This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects