Compare commits

...
40 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
世界 3b3883ef2c Bump version 1.13.11 2026-04-23 07:23:36 +08:00
世界 a3f4ca31d1 Bump version 1.13.10 2026-04-21 17:33:49 +08:00
世界 67a19777ce Bump version 1.13.9 2026-04-20 08:15:59 +08:00
世界 f929e52e41 Restrict beta settings to beta versions 2026-04-20 08:04:58 +08:00
世界 c8491c9212 Fix LocalResolver blocking on missing default network
Return `missing default interface` immediately instead of suspending
inside `DefaultNetworkMonitor.require()` when no default network is
available.
2026-04-20 00:14:19 +08:00
世界 2d7efc04a7 Add long-press copy on App and Core version items 2026-04-20 00:14:19 +08:00
世界 ea63fb0f8b Fix checkDefaultInterfaceUpdate 2026-04-19 22:39:11 +08:00
世界 dfe64c11d2 Fix back gesture from connection details skipping list
On phones, the Connections list and Connection Details share a single
ModalBottomSheet. System back was consumed by the sheet's default dismiss
handler, closing the sheet and returning to Dashboard. The in-app back
button just cleared selectedConnectionId, returning to the list.

Add a BackHandler that runs only while a connection is selected, matching
the in-app back button behavior. Swipe-to-dismiss remains unchanged.
2026-04-19 21:58:30 +08:00
世界 1b8f348fe1 Add compatibility for the new version of LSPosed 2026-04-19 21:05:23 +08:00
世界 509ef85646 Fix deprecated check error 2026-04-19 21:05:17 +08:00
世界 ab09918615 Bump version 1.13.8 2026-04-14 14:30:55 +08:00
世界 fea0f3a7ba Bump version 1.13.7 2026-04-10 16:21:53 +08:00
世界 9752f4845f Fix notification 2026-04-10 16:21:48 +08:00
世界 4f0826b94d Bump version 1.13.6 2026-04-06 23:08:25 +08:00
世界 cba1cc3ce0 Bump version 1.13.5 2026-03-30 22:43:28 +08:00
世界 080488932f Add download progress 2026-03-30 22:40:29 +08:00
世界 834a5f7df0 Bump version 1.13.4 2026-03-26 13:27:21 +08:00
世界 f6c225df65 Fix command client connect crash 2026-03-25 14:01:21 +08:00
世界 2cb1987080 Fix resource leaks in service startup error cleanup 2026-03-23 19:58:11 +08:00
世界 330eaee346 Pass all package names for shared UID connections 2026-03-23 18:27:30 +08:00
世界 cf145b5374 Dispatch log callbacks to main thread
Move allLogs/bufferedLogs mutations in appendLogs, clearLogs,
and setDefaultLogLevel into viewModelScope.launch(Dispatchers.Main)
to avoid concurrent iteration from the search debounce flow.
2026-03-21 12:42:18 +08:00
世界 3692d54420 Add Allow Bypass VPN setting to service screen
Add a toggle in the service settings screen that calls
VpnService.Builder.allowBypass() when enabled, with a description
linking to Android documentation. Always show the Service item
in the settings list (remove battery-optimization-gated visibility).
2026-03-16 19:35:14 +08:00
世界 b3515329c2 Fix profile navigation 2026-03-16 19:34:46 +08:00
世界 a7caf965a0 Fix FileProvider unable to resolve cacheDir paths 2026-03-16 19:34:46 +08:00
世界 6f09892c71 Bump 1.13.3 2026-03-15 17:00:03 +08:00
世界 8ba9fe2548 Fix config file path collision 2026-03-15 14:07:55 +08:00
世界 62c1b49c9e Fix ConnectivityService discovery on APEX-rewritten devices 2026-03-12 22:44:48 +08:00
世界 c2f1fd8e67 Fix DebugInfoExporter hanging 2026-03-12 22:34:43 +08:00
世界 d64e3b4235 Fix ParceledListSlice ClassLoader and RootClient service binding
- Use proper ClassLoader in ParceledListSlice.createFromParcel instead of null
- Add early root permission check in RootClient.bindService
- Migrate RootService.bind to bindOrTask for proper error propagation
2026-03-12 22:27:48 +08:00
世界 0d31ac467f Bump 1.13.3-beta.1 2026-03-11 17:40:24 +08:00
世界 868c1de2ff Add F-Droid as update check sources 2026-03-11 16:45:27 +08:00
世界 0d1ee7aa80 Hide service settings when battery optimization is already ignored 2026-03-11 16:42:03 +08:00
世界 7777469b5d Bump version 1.13.2 2026-03-07 15:54:27 +08:00
世界 172199dfc3 Bump version 2026-03-05 21:44:20 +08:00
世界 99791bdffb Update dependencies 2026-03-02 14:50:17 +08:00
世界 7d1e7c72ce Bump version 2026-02-28 14:40:57 +08:00
65 changed files with 1691 additions and 386 deletions
Binary file not shown.
@@ -1,6 +1,8 @@
package io.nekohasekai.sfa.vendor
import io.nekohasekai.libbox.HTTPResponseWriteToProgressHandler
import io.nekohasekai.libbox.Libbox
import io.nekohasekai.libbox.writeToWithProgress
import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.update.UpdateState
import io.nekohasekai.sfa.utils.HTTPClient
@@ -27,7 +29,15 @@ class ApkDownloader : Closeable {
request.setURL(url)
val response = request.execute()
response.writeTo(apkFile.absolutePath)
response.writeToWithProgress(
apkFile.absolutePath,
object : HTTPResponseWriteToProgressHandler {
override fun update(progress: Long, total: Long) {
UpdateState.downloadProgress.value =
if (total > 0) progress.toFloat() / total.toFloat() else null
}
},
)
if (!apkFile.exists() || apkFile.length() == 0L) {
throw Exception("Download failed: empty file")
@@ -86,9 +86,7 @@ class GitHubUpdateChecker : Closeable {
}
}
private fun isNewerThanCurrent(versionName: String): Boolean {
return Libbox.compareSemver(versionName, BuildConfig.VERSION_NAME)
}
private fun isNewerThanCurrent(versionName: String): Boolean = Libbox.compareSemver(versionName, BuildConfig.VERSION_NAME)
private fun isBetterVersion(version: VersionMetadata, other: VersionMetadata): Boolean {
if (Libbox.compareSemver(version.versionName, other.versionName)) {
@@ -11,8 +11,10 @@ import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager
import androidx.work.WorkerParameters
import io.nekohasekai.sfa.database.Settings
import io.nekohasekai.sfa.update.UpdateSource
import io.nekohasekai.sfa.update.UpdateState
import io.nekohasekai.sfa.update.UpdateTrack
import io.nekohasekai.sfa.update.checkFDroidUpdate
import java.util.concurrent.TimeUnit
class UpdateWorker(private val appContext: Context, params: WorkerParameters) : CoroutineWorker(appContext, params) {
@@ -59,8 +61,13 @@ class UpdateWorker(private val appContext: Context, params: WorkerParameters) :
Log.d(TAG, "Checking for updates...")
return try {
val track = UpdateTrack.fromString(Settings.updateTrack)
val updateInfo = GitHubUpdateChecker().use { it.checkUpdate(track) }
val updateInfo = when (UpdateSource.fromString(Settings.updateSource)) {
UpdateSource.FDROID -> checkFDroidUpdate(appContext)
UpdateSource.GITHUB -> {
val track = UpdateTrack.fromString(Settings.updateTrack)
GitHubUpdateChecker().use { it.checkUpdate(track) }
}
}
if (updateInfo == null) {
Log.d(TAG, "No update available")
@@ -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
@@ -162,7 +162,6 @@ class BoxService(private val service: Service, private val platformInterface: Pl
android.Manifest.permission.ACCESS_BACKGROUND_LOCATION
}
if (!service.hasPermission(wifiPermission)) {
closeService()
stopAndAlert(Alert.RequestLocationPermission)
return
}
@@ -243,7 +242,6 @@ class BoxService(private val service: Service, private val platformInterface: Pl
android.Manifest.permission.ACCESS_BACKGROUND_LOCATION
}
if (!service.hasPermission(wifiPermission)) {
closeService()
stopAndAlert(Alert.RequestLocationPermission)
return
}
@@ -311,6 +309,16 @@ class BoxService(private val service: Service, private val platformInterface: Pl
private suspend fun stopAndAlert(type: Alert, message: String? = null) {
Settings.startedByUser = false
val pfd = fileDescriptor
if (pfd != null) {
pfd.close()
fileDescriptor = null
}
DefaultNetworkMonitor.stop()
if (::commandServer.isInitialized) {
closeService()
commandServer.close()
}
withContext(Dispatchers.Main) {
if (receiverRegistered) {
service.unregisterReceiver(receiver)
@@ -321,6 +329,7 @@ class BoxService(private val service: Service, private val platformInterface: Pl
callback.onServiceAlert(type.ordinal, message)
}
status.value = Status.Stopped
service.stopSelf()
}
}
@@ -13,11 +13,13 @@ import java.io.StringWriter
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.zip.Deflater
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
object DebugInfoExporter {
private const val TAG = "DebugInfoExporter"
private const val BUFFER_SIZE = 128 * 1024
fun export(context: Context, outputPath: String, packageName: String): String {
Log.i(TAG, "export start: output=$outputPath, package=$packageName")
@@ -94,43 +96,27 @@ object DebugInfoExporter {
private fun addFrameworkEntries(zip: ZipOutputStream, warnings: MutableList<String>): Int {
var count = 0
val roots =
listOf(
File("/system/framework"),
File("/system_ext/framework"),
File("/product/framework"),
File("/vendor/framework"),
)
val root = File("/system/framework")
if (!root.isDirectory) return 0
val targetFiles = setOf("framework.jar", "services.jar")
for (root in roots) {
if (!root.isDirectory) continue
val destPrefix = "framework/${root.name}"
val files = root.listFiles() ?: emptyArray()
for (file in files) {
if (!file.isFile) continue
if (file.name !in targetFiles) continue
if (addFileEntry(zip, file, "$destPrefix/${file.name}", warnings)) {
count++
}
val files = root.listFiles() ?: emptyArray()
for (file in files) {
if (!file.isFile) continue
if (file.name !in targetFiles) continue
if (addFileEntry(zip, file, "framework/${file.name}", warnings, noCompression = true)) {
count++
}
}
return count
}
private fun addApexEntries(zip: ZipOutputStream, warnings: MutableList<String>): Int {
var count = 0
val tetheringApex = File("/apex/com.android.tethering/javalib")
if (!tetheringApex.isDirectory) return 0
val destPrefix = "framework/apex_com.android.tethering"
val files = tetheringApex.listFiles() ?: emptyArray()
for (file in files) {
if (!file.isFile) continue
if (!file.name.lowercase(Locale.US).endsWith(".jar")) continue
if (addFileEntry(zip, file, "$destPrefix/${file.name}", warnings)) {
count++
}
val file = File("/apex/com.android.tethering/javalib/service-connectivity.jar")
if (!file.isFile) {
warnings.add("missing file: ${file.path}")
return 0
}
return count
return if (addFileEntry(zip, file, "framework/apex_com.android.tethering/service-connectivity.jar", warnings, noCompression = true)) 1 else 0
}
private fun addLogEntries(zip: ZipOutputStream, warnings: MutableList<String>, context: Context): Int {
@@ -222,16 +208,22 @@ object DebugInfoExporter {
return count
}
private fun addFileEntry(zip: ZipOutputStream, file: File, entryName: String, warnings: MutableList<String>): Boolean {
private fun addFileEntry(
zip: ZipOutputStream,
file: File,
entryName: String,
warnings: MutableList<String>,
noCompression: Boolean = false,
): Boolean {
if (!file.isFile) {
warnings.add("missing file: ${file.path}")
return false
}
try {
val entry = ZipEntry(entryName)
zip.putNextEntry(entry)
if (noCompression) zip.setLevel(Deflater.NO_COMPRESSION)
zip.putNextEntry(ZipEntry(entryName))
BufferedInputStream(FileInputStream(file)).use { input ->
val buffer = ByteArray(16 * 1024)
val buffer = ByteArray(BUFFER_SIZE)
while (true) {
val read = input.read(buffer)
if (read <= 0) break
@@ -239,9 +231,11 @@ object DebugInfoExporter {
}
}
zip.closeEntry()
if (noCompression) zip.setLevel(Deflater.DEFAULT_COMPRESSION)
return true
} catch (e: Throwable) {
warnings.add("zip failed ${file.path}: ${e.message}")
if (noCompression) zip.setLevel(Deflater.DEFAULT_COMPRESSION)
return false
}
}
@@ -263,11 +257,10 @@ object DebugInfoExporter {
command: List<String>,
): CommandResult? = try {
val process = ProcessBuilder(command).redirectErrorStream(true).start()
val entry = ZipEntry(entryName)
zip.putNextEntry(entry)
zip.putNextEntry(ZipEntry(entryName))
var bytes = 0L
process.inputStream.use { input ->
val buffer = ByteArray(16 * 1024)
val buffer = ByteArray(BUFFER_SIZE)
while (true) {
val read = input.read(buffer)
if (read <= 0) break
@@ -43,17 +43,20 @@ object DefaultNetworkMonitor {
private fun checkDefaultInterfaceUpdate(newNetwork: Network?) {
val listener = listener ?: return
if (newNetwork != null) {
val interfaceName =
(Application.connectivity.getLinkProperties(newNetwork) ?: return).interfaceName
for (times in 0 until 10) {
val linkProperties = Application.connectivity.getLinkProperties(newNetwork)
if (linkProperties == null) {
Thread.sleep(100)
continue
}
var interfaceIndex: Int
try {
interfaceIndex = NetworkInterface.getByName(interfaceName).index
interfaceIndex = NetworkInterface.getByName(linkProperties.interfaceName).index
} catch (e: Exception) {
Thread.sleep(100)
continue
}
listener.updateDefaultInterface(interfaceName, interfaceIndex, false, false)
listener.updateDefaultInterface(linkProperties.interfaceName, interfaceIndex, false, false)
}
} else {
listener.updateDefaultInterface("", -1, false, false)
@@ -23,8 +23,8 @@ object LocalResolver : LocalDNSTransport {
@RequiresApi(Build.VERSION_CODES.Q)
override fun exchange(ctx: ExchangeContext, message: ByteArray) {
val defaultNetwork = DefaultNetworkMonitor.defaultNetwork ?: error("missing default interface")
return runBlocking {
val defaultNetwork = DefaultNetworkMonitor.require()
suspendCoroutine { continuation ->
val signal = CancellationSignal()
ctx.onCancel(signal::cancel)
@@ -63,8 +63,8 @@ object LocalResolver : LocalDNSTransport {
}
override fun lookup(ctx: ExchangeContext, network: String, domain: String) {
val defaultNetwork = DefaultNetworkMonitor.defaultNetwork ?: error("missing default interface")
return runBlocking {
val defaultNetwork = DefaultNetworkMonitor.require()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
suspendCoroutine { continuation ->
val signal = CancellationSignal()
@@ -136,7 +136,7 @@ public class ParceledListSlice<T extends Parcelable> implements Parcelable {
new Parcelable.ClassLoaderCreator<ParceledListSlice>() {
@Override
public ParceledListSlice createFromParcel(Parcel in) {
return new ParceledListSlice(in, null);
return new ParceledListSlice(in, ParceledListSlice.class.getClassLoader());
}
@Override
@@ -16,6 +16,7 @@ import io.nekohasekai.libbox.PlatformInterface
import io.nekohasekai.libbox.StringIterator
import io.nekohasekai.libbox.TunOptions
import io.nekohasekai.libbox.WIFIState
import io.nekohasekai.libbox.setAndroidPackageNames
import io.nekohasekai.sfa.Application
import java.net.Inet6Address
import java.net.InetSocketAddress
@@ -58,7 +59,7 @@ interface PlatformInterfaceWrapper : PlatformInterface {
val owner = ConnectionOwner()
owner.userId = uid
owner.userName = packages?.firstOrNull() ?: ""
owner.androidPackageName = packages?.firstOrNull() ?: ""
owner.setAndroidPackageNames(StringArray(packages?.toList()?.iterator() ?: emptyList<String>().iterator()))
return owner
} catch (e: Exception) {
Log.e("PlatformInterface", "getConnectionOwnerUid", e)
@@ -2,6 +2,7 @@ package io.nekohasekai.sfa.bg
import android.app.Service
import android.content.Intent
import io.nekohasekai.libbox.NeighborUpdateListener
import io.nekohasekai.libbox.Notification
class ProxyService :
@@ -14,6 +15,10 @@ class ProxyService :
override fun onBind(intent: Intent) = service.onBind()
override fun onDestroy() = service.onDestroy()
fun closeNeighborMonitor(listener: NeighborUpdateListener?) {
}
override fun sendNotification(notification: Notification) = service.sendNotification(notification)
fun startNeighborMonitor(listener: NeighborUpdateListener?) {
}
}
@@ -6,6 +6,7 @@ import android.content.ServiceConnection
import android.content.pm.PackageInfo
import android.os.IBinder
import android.os.RemoteException
import androidx.core.content.ContextCompat
import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.ipc.RootService
import io.nekohasekai.sfa.Application
@@ -17,7 +18,9 @@ import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import java.io.IOException
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
object RootClient {
init {
@@ -53,6 +56,10 @@ object RootClient {
suspend fun bindService(): IRootService = connectionMutex.withLock {
service?.let { return it }
if (Shell.isAppGrantedRoot() == false) {
throw IOException("permission denied")
}
return withContext(Dispatchers.Main) {
suspendCancellableCoroutine { continuation ->
val conn = object : ServiceConnection {
@@ -72,7 +79,30 @@ object RootClient {
}
val intent = Intent(Application.application, RootServer::class.java)
RootService.bind(intent, conn)
val task = RootService.bindOrTask(
intent,
ContextCompat.getMainExecutor(Application.application),
conn,
)
if (task == null) {
// Already connected, onServiceConnected will fire
} else {
Shell.EXECUTOR.execute {
try {
val shell = Shell.getShell()
if (shell.isRoot) {
shell.execTask(task)
} else {
continuation.resumeWithException(
IOException("permission denied"),
)
}
} catch (e: Exception) {
continuation.resumeWithException(e)
}
}
}
continuation.invokeOnCancellation {
RootService.unbind(conn)
@@ -7,6 +7,7 @@ import android.net.VpnService
import android.os.Build
import android.os.IBinder
import android.util.Log
import io.nekohasekai.libbox.NeighborUpdateListener
import io.nekohasekai.libbox.Notification
import io.nekohasekai.libbox.TunOptions
import io.nekohasekai.sfa.database.Settings
@@ -51,6 +52,9 @@ class VPNService :
protect(fd)
}
fun closeNeighborMonitor(listener: NeighborUpdateListener?) {
}
var systemProxyAvailable = false
var systemProxyEnabled = false
@@ -66,6 +70,10 @@ class VPNService :
builder.setMetered(false)
}
if (Settings.allowBypass) {
builder.allowBypass()
}
val inet4Address = options.inet4Address
while (inet4Address.hasNext()) {
val address = inet4Address.next()
@@ -178,4 +186,6 @@ class VPNService :
}
override fun sendNotification(notification: Notification) = service.sendNotification(notification)
fun startNeighborMonitor(listener: NeighborUpdateListener?) {
}
}
@@ -8,6 +8,7 @@ import android.net.Uri
import android.net.VpnService
import android.os.Build
import android.os.Bundle
import androidx.activity.compose.BackHandler
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
@@ -42,6 +43,7 @@ import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.NavigationBar
@@ -113,6 +115,7 @@ import io.nekohasekai.sfa.compose.theme.SFATheme
import io.nekohasekai.sfa.compose.topbar.LocalTopBarController
import io.nekohasekai.sfa.compose.topbar.TopBarController
import io.nekohasekai.sfa.compose.topbar.TopBarEntry
import io.nekohasekai.sfa.constant.Action
import io.nekohasekai.sfa.constant.Alert
import io.nekohasekai.sfa.constant.ServiceMode
import io.nekohasekai.sfa.constant.Status
@@ -225,6 +228,10 @@ class MainActivity :
pendingNavigationRoute.value = "settings/privilege"
}
val uri = intent.data ?: return
if (intent.action == Action.OPEN_URL) {
launchCustomTab(uri.toString())
return
}
if (uri.scheme == "sing-box" && uri.host == "import-remote-profile") {
try {
val profile = Libbox.parseRemoteProfileImportLink(uri.toString())
@@ -565,10 +572,22 @@ class MainActivity :
color = MaterialTheme.colorScheme.error,
)
} else {
Row(verticalAlignment = Alignment.CenterVertically) {
CircularProgressIndicator(modifier = Modifier.size(24.dp))
Spacer(modifier = Modifier.width(12.dp))
Text(stringResource(R.string.downloading))
val progress by UpdateState.downloadProgress
Column {
if (progress != null) {
Text("${stringResource(R.string.downloading)} ${(progress!! * 100).toInt()}%")
} else {
Text(stringResource(R.string.downloading))
}
Spacer(modifier = Modifier.height(8.dp))
if (progress != null) {
LinearProgressIndicator(
progress = { progress!! },
modifier = Modifier.fillMaxWidth(),
)
} else {
LinearProgressIndicator(modifier = Modifier.fillMaxWidth())
}
}
}
}
@@ -580,6 +599,7 @@ class MainActivity :
downloadJob = null
showDownloadDialog = false
downloadError = null
UpdateState.downloadProgress.value = null
},
) {
Text(stringResource(if (downloadError != null) R.string.ok else android.R.string.cancel))
@@ -1088,6 +1108,10 @@ class MainActivity :
}
}
BackHandler(enabled = selectedConnectionId != null) {
selectedConnectionId = null
}
ModalBottomSheet(
onDismissRequest = {
showConnectionsSheet = false
@@ -1,12 +1,13 @@
package io.nekohasekai.sfa.compose.model
import androidx.compose.runtime.Immutable
import io.nekohasekai.libbox.packageNames
import io.nekohasekai.sfa.ktx.toList
import io.nekohasekai.libbox.Connection as LibboxConnection
import io.nekohasekai.libbox.ProcessInfo as LibboxProcessInfo
@Immutable
data class ProcessInfo(val processId: Long, val userId: Int, val userName: String, val processPath: String, val packageName: String) {
data class ProcessInfo(val processId: Long, val userId: Int, val userName: String, val processPath: String, val packageNames: List<String>) {
companion object {
fun from(processInfo: LibboxProcessInfo?): ProcessInfo? {
if (processInfo == null) return null
@@ -15,7 +16,7 @@ data class ProcessInfo(val processId: Long, val userId: Int, val userName: Strin
userId = processInfo.userID,
userName = processInfo.userName ?: "",
processPath = processInfo.processPath ?: "",
packageName = processInfo.packageName ?: "",
packageNames = processInfo.packageNames()?.toList() ?: emptyList(),
)
}
}
@@ -66,7 +67,7 @@ data class Connection(
domain.contains(content, ignoreCase = true) ||
outbound.contains(content, ignoreCase = true) ||
rule.contains(content, ignoreCase = true) ||
processInfo?.packageName?.contains(content, ignoreCase = true) == true
processInfo?.packageNames?.any { it.contains(content, ignoreCase = true) } == true
private fun performSearchType(type: String, value: String): Boolean = when (type) {
"network" -> network.equals(value, ignoreCase = true)
@@ -79,7 +80,7 @@ data class Connection(
"rule" -> rule.contains(value, ignoreCase = true)
"protocol" -> protocolName.equals(value, ignoreCase = true)
"user" -> user.contains(value, ignoreCase = true)
"package" -> processInfo?.packageName?.contains(value, ignoreCase = true) == true
"package" -> processInfo?.packageNames?.any { it.contains(value, ignoreCase = true) } == true
"chain" -> chain.any { it.contains(value, ignoreCase = true) }
else -> false
}
@@ -28,6 +28,7 @@ import io.nekohasekai.sfa.compose.screen.profile.EditProfileRoute
import io.nekohasekai.sfa.compose.screen.profileoverride.PerAppProxyScreen
import io.nekohasekai.sfa.compose.screen.settings.AppSettingsScreen
import io.nekohasekai.sfa.compose.screen.settings.CoreSettingsScreen
import io.nekohasekai.sfa.compose.screen.settings.FDroidMirrorScreen
import io.nekohasekai.sfa.compose.screen.settings.PrivilegeSettingsScreen
import io.nekohasekai.sfa.compose.screen.settings.ProfileOverrideScreen
import io.nekohasekai.sfa.compose.screen.settings.ServiceSettingsScreen
@@ -224,6 +225,16 @@ fun SFANavHost(
AppSettingsScreen(navController = navController)
}
composable(
route = "settings/fdroid_mirror",
enterTransition = slideInFromRight,
exitTransition = slideOutToLeft,
popEnterTransition = slideInFromLeft,
popExitTransition = slideOutToRight,
) {
FDroidMirrorScreen(navController = navController)
}
composable(
route = "settings/core",
enterTransition = slideInFromRight,
@@ -241,8 +241,9 @@ class ProfileImportHandler(private val context: Context) {
}
// Save config file
val fileID = ProfileManager.nextFileID()
val configDirectory = File(context.filesDir, "configs").also { it.mkdirs() }
val configFile = File(configDirectory, "${profile.userOrder}.json")
val configFile = File(configDirectory, "$fileID.json")
configFile.writeText(content.config)
typedProfile.path = configFile.path
@@ -268,8 +269,9 @@ class ProfileImportHandler(private val context: Context) {
}
// Create empty config file for remote profile
val fileID = ProfileManager.nextFileID()
val configDirectory = File(context.filesDir, "configs").also { it.mkdirs() }
val configFile = File(configDirectory, "${profile.userOrder}.json")
val configFile = File(configDirectory, "$fileID.json")
configFile.writeText("{}")
typedProfile.path = configFile.path
@@ -370,8 +372,9 @@ class ProfileImportHandler(private val context: Context) {
}
// Save the configuration file
val fileID = ProfileManager.nextFileID()
val configDirectory = File(context.filesDir, "configs").also { it.mkdirs() }
val configFile = File(configDirectory, "${profile.userOrder}.json")
val configFile = File(configDirectory, "$fileID.json")
configFile.writeText(jsonContent)
typedProfile.path = configFile.path
@@ -247,7 +247,7 @@ fun ConnectionDetailsScreen(
}
connection.processInfo?.let { processInfo ->
if (processInfo.packageName.isNotEmpty() ||
if (processInfo.packageNames.isNotEmpty() ||
processInfo.processPath.isNotEmpty() ||
processInfo.processId > 0
) {
@@ -282,10 +282,10 @@ fun ConnectionDetailsScreen(
monospace = true,
)
}
if (processInfo.packageName.isNotEmpty()) {
if (processInfo.packageNames.isNotEmpty()) {
DetailRow(
label = stringResource(R.string.connection_package_name),
value = processInfo.packageName,
value = processInfo.packageNames.joinToString(", "),
monospace = true,
)
}
@@ -82,7 +82,7 @@ private fun rememberAppInfo(packageName: String): AppInfo? {
@Composable
fun ConnectionItem(connection: Connection, onClick: () -> Unit, onClose: () -> Unit, modifier: Modifier = Modifier) {
var showContextMenu by remember { mutableStateOf(false) }
val packageName = connection.processInfo?.packageName?.takeIf { it.isNotEmpty() }
val packageName = connection.processInfo?.packageNames?.firstOrNull()
val appInfo = packageName?.let { rememberAppInfo(it) }
Box(modifier = modifier) {
@@ -200,7 +200,7 @@ class DashboardViewModel :
private fun checkDeprecatedNotes() {
viewModelScope.launch(Dispatchers.IO) {
try {
runCatching {
// Check if deprecated warnings are disabled
if (Settings.disableDeprecatedWarnings) {
return@launch
@@ -227,8 +227,6 @@ class DashboardViewModel :
}
}
}
} catch (e: Exception) {
sendError(e)
}
}
}
@@ -42,7 +42,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.ui.graphics.lerp
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -52,6 +51,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.lerp
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
@@ -19,8 +19,8 @@ import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.graphics.lerp
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.lerp
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
@@ -81,15 +81,19 @@ class LogViewModel :
override fun setDefaultLogLevel(level: Int) {
val logLevel = LogLevel.entries.find { it.priority == level } ?: error("Unknown log level: $level")
_uiState.update { it.copy(defaultLogLevel = logLevel) }
updateDisplayedLogs()
viewModelScope.launch(Dispatchers.Main) {
_uiState.update { it.copy(defaultLogLevel = logLevel) }
updateDisplayedLogs()
}
}
override fun clearLogs() {
allLogs.clear()
bufferedLogs.clear()
_uiState.update { it.copy(isPaused = false) }
updateDisplayedLogs()
viewModelScope.launch(Dispatchers.Main) {
allLogs.clear()
bufferedLogs.clear()
_uiState.update { it.copy(isPaused = false) }
updateDisplayedLogs()
}
}
override fun requestClearLogs() {
@@ -104,23 +108,25 @@ class LogViewModel :
override fun appendLogs(message: List<LogEntry>) {
val processedLogs = message.map { processLogEntry(it) }
if (_uiState.value.isPaused) {
bufferedLogs.addAll(processedLogs)
} else {
val totalSize = allLogs.size + processedLogs.size
val removeCount = (totalSize - maxLines).coerceAtLeast(0)
viewModelScope.launch(Dispatchers.Main) {
if (_uiState.value.isPaused) {
bufferedLogs.addAll(processedLogs)
} else {
val totalSize = allLogs.size + processedLogs.size
val removeCount = (totalSize - maxLines).coerceAtLeast(0)
if (removeCount > 0) {
repeat(removeCount) {
allLogs.removeFirst()
if (removeCount > 0) {
repeat(removeCount) {
allLogs.removeFirst()
}
}
}
allLogs.addAll(processedLogs)
updateDisplayedLogs()
allLogs.addAll(processedLogs)
updateDisplayedLogs()
if (_autoScrollEnabled.value && !_uiState.value.isPaused && !_uiState.value.isSearchActive) {
scrollToBottom()
if (_autoScrollEnabled.value && !_uiState.value.isPaused && !_uiState.value.isSearchActive) {
scrollToBottom()
}
}
}
}
@@ -92,12 +92,11 @@ fun EditProfileContentScreen(
profileId: Long,
onNavigateBack: () -> Unit,
modifier: Modifier = Modifier,
profileName: String = "",
isReadOnly: Boolean = false,
) {
val viewModel: EditProfileContentViewModel =
viewModel(
factory = EditProfileContentViewModel.Factory(profileId, profileName, isReadOnly),
factory = EditProfileContentViewModel.Factory(profileId, isReadOnly),
)
val uiState by viewModel.uiState.collectAsState()
val context = LocalContext.current
@@ -38,11 +38,10 @@ data class EditProfileContentUiState(
val profileName: String = "", // Add profile name
)
class EditProfileContentViewModel(private val profileId: Long, initialProfileName: String = "", initialIsReadOnly: Boolean = false) : ViewModel() {
class EditProfileContentViewModel(private val profileId: Long, initialIsReadOnly: Boolean = false) : ViewModel() {
private val _uiState =
MutableStateFlow(
EditProfileContentUiState(
profileName = initialProfileName,
isReadOnly = initialIsReadOnly,
),
)
@@ -211,7 +210,7 @@ class EditProfileContentViewModel(private val profileId: Long, initialProfileNam
originalContent = content,
hasUnsavedChanges = false,
isLoading = false,
// Keep profileName and isReadOnly from initial state - no need to update
profileName = loadedProfile.name,
)
}
}
@@ -584,13 +583,12 @@ class EditProfileContentViewModel(private val profileId: Long, initialProfileNam
class Factory(
private val profileId: Long,
private val initialProfileName: String = "",
private val initialIsReadOnly: Boolean = false,
) : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(EditProfileContentViewModel::class.java)) {
return EditProfileContentViewModel(profileId, initialProfileName, initialIsReadOnly) as T
return EditProfileContentViewModel(profileId, initialIsReadOnly) as T
}
throw IllegalArgumentException("Unknown ViewModel class")
}
@@ -1,5 +1,6 @@
package io.nekohasekai.sfa.compose.screen.profile
import android.net.Uri
import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.core.tween
import androidx.compose.runtime.Composable
@@ -64,12 +65,12 @@ fun EditProfileRoute(profileId: Long, onNavigateBack: () -> Unit, modifier: Modi
profileId = profileId,
onNavigateBack = onNavigateBack,
onNavigateToIconSelection = { currentIconId ->
navController.navigate("icon_selection/${currentIconId ?: "null"}") {
navController.navigate("icon_selection/${Uri.encode(currentIconId ?: "null")}") {
launchSingleTop = true
}
},
onNavigateToEditContent = { profileName, isReadOnly ->
navController.navigate("edit_content/$profileName/$isReadOnly") {
onNavigateToEditContent = { isReadOnly ->
navController.navigate("edit_content/$isReadOnly") {
launchSingleTop = true
}
},
@@ -128,13 +129,9 @@ fun EditProfileRoute(profileId: Long, onNavigateBack: () -> Unit, modifier: Modi
}
composable(
route = "edit_content/{profileName}/{isReadOnly}",
route = "edit_content/{isReadOnly}",
arguments =
listOf(
navArgument("profileName") {
type = NavType.StringType
defaultValue = ""
},
navArgument("isReadOnly") {
type = NavType.BoolType
defaultValue = false
@@ -165,7 +162,6 @@ fun EditProfileRoute(profileId: Long, onNavigateBack: () -> Unit, modifier: Modi
)
},
) { backStackEntry ->
val profileName = backStackEntry.arguments?.getString("profileName") ?: ""
val isReadOnly = backStackEntry.arguments?.getBoolean("isReadOnly") ?: false
EditProfileContentScreen(
@@ -173,7 +169,6 @@ fun EditProfileRoute(profileId: Long, onNavigateBack: () -> Unit, modifier: Modi
onNavigateBack = {
navController.popBackStack("edit_profile", inclusive = false)
},
profileName = profileName,
isReadOnly = isReadOnly,
)
}
@@ -79,7 +79,7 @@ fun EditProfileScreen(
profileId: Long,
onNavigateBack: () -> Unit,
onNavigateToIconSelection: (currentIconId: String?) -> Unit = {},
onNavigateToEditContent: (profileName: String, isReadOnly: Boolean) -> Unit = { _, _ -> },
onNavigateToEditContent: (isReadOnly: Boolean) -> Unit = {},
viewModel: EditProfileViewModel = viewModel(),
) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
@@ -473,7 +473,6 @@ fun EditProfileScreen(
.clip(RoundedCornerShape(12.dp))
.clickable {
onNavigateToEditContent(
uiState.name,
uiState.profileType == TypedProfile.Type.Remote,
)
},
@@ -7,10 +7,15 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.text.format.Formatter
import android.util.Log
import android.widget.Toast
import androidx.appcompat.app.AppCompatDelegate
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
@@ -25,8 +30,11 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.ContentCopy
import androidx.compose.material.icons.outlined.AdminPanelSettings
import androidx.compose.material.icons.outlined.Autorenew
import androidx.compose.material.icons.outlined.DeleteForever
import androidx.compose.material.icons.outlined.DeleteSweep
import androidx.compose.material.icons.outlined.Download
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material.icons.outlined.Language
@@ -41,9 +49,12 @@ import androidx.compose.material3.Badge
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.ListItem
import androidx.compose.material3.ListItemDefaults
import androidx.compose.material3.MaterialTheme
@@ -62,6 +73,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
@@ -71,13 +83,17 @@ import androidx.core.os.LocaleListCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
import androidx.navigation.NavController
import io.nekohasekai.libbox.Libbox
import io.nekohasekai.libbox.getFDroidMirrors
import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.BuildConfig
import io.nekohasekai.sfa.R
import io.nekohasekai.sfa.compose.component.UpdateAvailableDialog
import io.nekohasekai.sfa.compose.topbar.OverrideTopBar
import io.nekohasekai.sfa.database.Settings
import io.nekohasekai.sfa.ktx.clipboardText
import io.nekohasekai.sfa.update.UpdateCheckException
import io.nekohasekai.sfa.update.UpdateSource
import io.nekohasekai.sfa.update.UpdateState
import io.nekohasekai.sfa.update.UpdateTrack
import io.nekohasekai.sfa.utils.HookStatusClient
@@ -88,10 +104,11 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.xmlpull.v1.XmlPullParser
import java.io.File
import java.util.Locale
import android.provider.Settings as AndroidSettings
@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
@Composable
fun AppSettingsScreen(navController: NavController) {
OverrideTopBar {
@@ -113,10 +130,12 @@ fun AppSettingsScreen(navController: NavController) {
val hasUpdate by UpdateState.hasUpdate
val updateInfo by UpdateState.updateInfo
val isChecking by UpdateState.isChecking
var showSourceDialog by remember { mutableStateOf(false) }
var currentSource by remember { mutableStateOf(Settings.updateSource) }
var showTrackDialog by remember { mutableStateOf(false) }
var currentTrack by remember { mutableStateOf(Settings.updateTrack) }
var checkUpdateEnabled by remember { mutableStateOf(Settings.checkUpdateEnabled) }
var showErrorDialog by remember { mutableStateOf<Int?>(null) }
var showErrorDialog by remember { mutableStateOf<String?>(null) }
var silentInstallEnabled by remember { mutableStateOf(Settings.silentInstallEnabled) }
var silentInstallMethod by remember { mutableStateOf(Settings.silentInstallMethod) }
@@ -132,6 +151,7 @@ fun AppSettingsScreen(navController: NavController) {
var downloadJob by remember { mutableStateOf<Job?>(null) }
var downloadError by remember { mutableStateOf<String?>(null) }
var showUpdateAvailableDialog by remember { mutableStateOf(false) }
var showVersionMenu by remember { mutableStateOf(false) }
var notificationEnabled by remember { mutableStateOf(true) }
var dynamicNotification by remember { mutableStateOf(Settings.dynamicNotification) }
@@ -144,8 +164,22 @@ fun AppSettingsScreen(navController: NavController) {
mutableStateOf(if (appLocales.isEmpty) "" else appLocales.toLanguageTags())
}
var cacheSize by remember { mutableStateOf(0L) }
var cacheSizeText by remember { mutableStateOf("") }
fun refreshCacheSize() {
scope.launch(Dispatchers.IO) {
val size = calculateDirSize(context.cacheDir)
withContext(Dispatchers.Main) {
cacheSize = size
cacheSizeText = Formatter.formatFileSize(context, size)
}
}
}
LaunchedEffect(Unit) {
HookStatusClient.refresh()
refreshCacheSize()
}
// Re-check states when returning from background (e.g., after granting permission)
@@ -183,6 +217,21 @@ fun AppSettingsScreen(navController: NavController) {
}
}
if (showSourceDialog) {
UpdateSourceDialog(
currentSource = currentSource,
onSourceSelected = { source ->
currentSource = source
UpdateState.clear()
scope.launch(Dispatchers.IO) {
Settings.updateSource = source
}
showSourceDialog = false
},
onDismiss = { showSourceDialog = false },
)
}
if (showTrackDialog) {
UpdateTrackDialog(
currentTrack = currentTrack,
@@ -198,11 +247,11 @@ fun AppSettingsScreen(navController: NavController) {
)
}
showErrorDialog?.let { messageRes ->
showErrorDialog?.let { message ->
AlertDialog(
onDismissRequest = { showErrorDialog = null },
title = { Text(stringResource(R.string.check_update)) },
text = { Text(stringResource(messageRes)) },
text = { Text(message) },
confirmButton = {
TextButton(onClick = { showErrorDialog = null }) {
Text(stringResource(R.string.ok))
@@ -223,10 +272,22 @@ fun AppSettingsScreen(navController: NavController) {
color = MaterialTheme.colorScheme.error,
)
} else {
Row(verticalAlignment = Alignment.CenterVertically) {
CircularProgressIndicator(modifier = Modifier.size(24.dp))
Spacer(modifier = Modifier.width(12.dp))
Text(stringResource(R.string.downloading))
val progress by UpdateState.downloadProgress
Column {
if (progress != null) {
Text("${stringResource(R.string.downloading)} ${(progress!! * 100).toInt()}%")
} else {
Text(stringResource(R.string.downloading))
}
Spacer(modifier = Modifier.height(8.dp))
if (progress != null) {
LinearProgressIndicator(
progress = { progress!! },
modifier = Modifier.fillMaxWidth(),
)
} else {
LinearProgressIndicator(modifier = Modifier.fillMaxWidth())
}
}
}
}
@@ -238,6 +299,7 @@ fun AppSettingsScreen(navController: NavController) {
downloadJob = null
showDownloadDialog = false
downloadError = null
UpdateState.downloadProgress.value = null
},
) {
Text(stringResource(if (downloadError != null) R.string.ok else android.R.string.cancel))
@@ -381,39 +443,70 @@ fun AppSettingsScreen(navController: NavController) {
),
) {
Column {
ListItem(
headlineContent = {
Text(
stringResource(R.string.app_version_title),
style = MaterialTheme.typography.bodyLarge,
)
},
supportingContent = {
Text(
BuildConfig.VERSION_NAME,
style = MaterialTheme.typography.bodyMedium,
)
},
leadingContent = {
Icon(
imageVector = Icons.Outlined.Info,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
)
},
trailingContent = {
if (hasUpdate) {
Badge(containerColor = MaterialTheme.colorScheme.primary) { Text("New") }
Box {
ListItem(
headlineContent = {
Text(
stringResource(R.string.app_version_title),
style = MaterialTheme.typography.bodyLarge,
)
},
supportingContent = {
Text(
BuildConfig.VERSION_NAME,
style = MaterialTheme.typography.bodyMedium,
)
},
leadingContent = {
Icon(
imageVector = Icons.Outlined.Info,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
)
},
trailingContent = {
if (hasUpdate) {
Badge(containerColor = MaterialTheme.colorScheme.primary) { Text("New") }
}
},
modifier =
Modifier
.clip(RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp))
.combinedClickable(
onClick = {},
onLongClick = { showVersionMenu = true },
),
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
Box(modifier = Modifier.align(Alignment.BottomEnd)) {
DropdownMenu(
expanded = showVersionMenu,
onDismissRequest = { showVersionMenu = false },
) {
DropdownMenuItem(
text = { Text(stringResource(R.string.per_app_proxy_action_copy)) },
leadingIcon = {
Icon(
imageVector = Icons.Filled.ContentCopy,
contentDescription = null,
)
},
onClick = {
clipboardText = BuildConfig.VERSION_NAME
Toast.makeText(
context,
R.string.copied_to_clipboard,
Toast.LENGTH_SHORT,
).show()
showVersionMenu = false
},
)
}
},
modifier =
Modifier
.clip(RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp)),
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
}
}
ListItem(
headlineContent = {
@@ -440,13 +533,80 @@ fun AppSettingsScreen(navController: NavController) {
},
modifier =
Modifier
.clip(RoundedCornerShape(bottomStart = 12.dp, bottomEnd = 12.dp))
.clickable { showLanguageDialog = true },
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
ListItem(
headlineContent = {
Text(
stringResource(R.string.cache_size),
style = MaterialTheme.typography.bodyLarge,
)
},
supportingContent = {
if (cacheSizeText.isNotEmpty()) {
Text(cacheSizeText, style = MaterialTheme.typography.bodyMedium)
}
},
leadingContent = {
Icon(
imageVector = Icons.Outlined.DeleteSweep,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
)
},
modifier =
Modifier
.clip(
if (cacheSize > 0L) {
RoundedCornerShape(0.dp)
} else {
RoundedCornerShape(bottomStart = 12.dp, bottomEnd = 12.dp)
},
),
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
if (cacheSize > 0L) {
ListItem(
headlineContent = {
Text(
stringResource(R.string.clear_cache),
style = MaterialTheme.typography.bodyLarge,
)
},
leadingContent = {
Icon(
imageVector = Icons.Outlined.DeleteForever,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
)
},
modifier =
Modifier
.clip(RoundedCornerShape(bottomStart = 12.dp, bottomEnd = 12.dp))
.clickable {
scope.launch(Dispatchers.IO) {
context.cacheDir?.listFiles()?.forEach { it.deleteRecursively() }
withContext(Dispatchers.Main) {
cacheSize = 0L
cacheSizeText = Formatter.formatFileSize(context, 0L)
}
}
},
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
}
}
}
@@ -555,14 +715,21 @@ fun AppSettingsScreen(navController: NavController) {
),
) {
Column {
val isFDroid = UpdateSource.fromString(currentSource) == UpdateSource.FDROID
val updateItemCount =
run {
var count = 0
if (Vendor.supportsTrackSelection()) {
if (Vendor.updateSources.size > 1) {
count += 1
}
if (Vendor.hasCustomUpdate) {
count += 1
}
if (isFDroid) {
count += 1
}
count += 1
if (Vendor.supportsSilentInstall()) {
if (Vendor.hasCustomUpdate) {
count += 1
if (silentInstallEnabled) {
count += 1
@@ -574,7 +741,7 @@ fun AppSettingsScreen(navController: NavController) {
}
}
}
if (Vendor.supportsAutoUpdate()) {
if (Vendor.hasCustomUpdate) {
count += 1
}
count
@@ -592,7 +759,39 @@ fun AppSettingsScreen(navController: NavController) {
}
}
if (Vendor.supportsTrackSelection()) {
if (Vendor.updateSources.size > 1) {
ListItem(
headlineContent = {
Text(
stringResource(R.string.update_source),
style = MaterialTheme.typography.bodyLarge,
)
},
supportingContent = {
val sourceName = when (UpdateSource.fromString(currentSource)) {
UpdateSource.GITHUB -> stringResource(R.string.update_source_github)
UpdateSource.FDROID -> stringResource(R.string.update_source_fdroid)
}
Text(sourceName, style = MaterialTheme.typography.bodyMedium)
},
leadingContent = {
Icon(
imageVector = Icons.Outlined.NewReleases,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
)
},
modifier =
updateItemModifier()
.clickable { showSourceDialog = true },
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
}
if (Vendor.hasCustomUpdate) {
ListItem(
headlineContent = {
Text(
@@ -601,9 +800,13 @@ fun AppSettingsScreen(navController: NavController) {
)
},
supportingContent = {
val trackName = when (UpdateTrack.fromString(currentTrack)) {
UpdateTrack.STABLE -> stringResource(R.string.update_track_stable)
UpdateTrack.BETA -> stringResource(R.string.update_track_beta)
val trackName = if (isFDroid) {
stringResource(R.string.update_track_stable)
} else {
when (UpdateTrack.fromString(currentTrack)) {
UpdateTrack.STABLE -> stringResource(R.string.update_track_stable)
UpdateTrack.BETA -> stringResource(R.string.update_track_beta)
}
}
Text(trackName, style = MaterialTheme.typography.bodyMedium)
},
@@ -615,8 +818,63 @@ fun AppSettingsScreen(navController: NavController) {
)
},
modifier =
updateItemModifier().let {
if (isFDroid) it.alpha(0.38f) else it.clickable { showTrackDialog = true }
},
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
}
if (isFDroid) {
ListItem(
headlineContent = {
Text(
stringResource(R.string.fdroid_mirror),
style = MaterialTheme.typography.bodyLarge,
)
},
supportingContent = {
val mirrorUrl = Settings.fdroidMirrorUrl
val mirrorName = remember(mirrorUrl) {
val iter = getFDroidMirrors()
var name: String? = null
while (iter.hasNext()) {
val m = iter.next()
if (m.url == mirrorUrl) {
name = m.name
break
}
}
if (name == null) {
val customMirrors = Settings.fdroidCustomMirrors
for (entry in customMirrors) {
val parts = entry.split("|", limit = 2)
if (parts.size == 2 && parts[1] == mirrorUrl) {
name = parts[0]
break
}
}
}
name ?: mirrorUrl
}
Text(
mirrorName,
style = MaterialTheme.typography.bodyMedium,
)
},
leadingContent = {
Icon(
imageVector = Icons.Outlined.Speed,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
)
},
modifier =
updateItemModifier()
.clickable { showTrackDialog = true },
.clickable { navController.navigate("settings/fdroid_mirror") },
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
@@ -656,7 +914,7 @@ fun AppSettingsScreen(navController: NavController) {
),
)
if (Vendor.supportsSilentInstall()) {
if (Vendor.hasCustomUpdate) {
ListItem(
headlineContent = {
Text(
@@ -836,7 +1094,7 @@ fun AppSettingsScreen(navController: NavController) {
}
}
if (Vendor.supportsAutoUpdate()) {
if (Vendor.hasCustomUpdate) {
ListItem(
headlineContent = {
Text(
@@ -940,15 +1198,17 @@ fun AppSettingsScreen(navController: NavController) {
val result = Vendor.checkUpdateAsync()
UpdateState.setUpdate(result)
if (result == null) {
showErrorDialog = R.string.no_updates_available
showErrorDialog = context.getString(R.string.no_updates_available)
} else {
showUpdateAvailableDialog = true
}
} catch (_: UpdateCheckException.TrackNotSupported) {
UpdateState.setUpdate(null)
showErrorDialog = R.string.update_track_not_supported
} catch (_: Exception) {
showErrorDialog = context.getString(R.string.update_track_not_supported)
} catch (e: Exception) {
Log.e("AppSettingsScreen", "checkUpdateAsync failed", e)
UpdateState.setUpdate(null)
showErrorDialog = e.message
}
}
UpdateState.isChecking.value = false
@@ -998,6 +1258,53 @@ fun AppSettingsScreen(navController: NavController) {
}
}
@Composable
private fun UpdateSourceDialog(
currentSource: String,
onSourceSelected: (String) -> Unit,
onDismiss: () -> Unit,
) {
val sources = listOf(
"github" to stringResource(R.string.update_source_github),
"fdroid" to stringResource(R.string.update_source_fdroid),
)
AlertDialog(
onDismissRequest = onDismiss,
title = { Text(stringResource(R.string.update_source)) },
text = {
Column {
sources.forEach { (value, label) ->
Row(
modifier =
Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(8.dp))
.clickable { onSourceSelected(value) }
.padding(vertical = 8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
RadioButton(
selected = currentSource == value,
onClick = { onSourceSelected(value) },
)
Text(
text = label,
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.padding(start = 8.dp),
)
}
}
}
},
confirmButton = {
TextButton(onClick = onDismiss) {
Text(stringResource(android.R.string.cancel))
}
},
)
}
@Composable
private fun UpdateTrackDialog(
currentTrack: String,
@@ -1108,6 +1415,15 @@ private fun LanguageDialog(
)
}
private fun calculateDirSize(dir: File?): Long {
if (dir == null || !dir.exists()) return 0
var size = 0L
dir.listFiles()?.forEach { file ->
size += if (file.isDirectory) calculateDirSize(file) else file.length()
}
return size
}
private fun getSupportedLocales(context: Context): List<Locale> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
val localeConfig = LocaleConfig(context)
@@ -5,8 +5,11 @@ import android.content.Context
import android.content.Intent
import android.provider.DocumentsContract
import android.widget.Toast
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
@@ -18,6 +21,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.ContentCopy
import androidx.compose.material.icons.outlined.DeleteForever
import androidx.compose.material.icons.outlined.FolderOpen
import androidx.compose.material.icons.outlined.Info
@@ -25,6 +29,8 @@ import androidx.compose.material.icons.outlined.Storage
import androidx.compose.material.icons.outlined.WarningAmber
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@@ -41,6 +47,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
@@ -52,11 +59,12 @@ import io.nekohasekai.libbox.Libbox
import io.nekohasekai.sfa.R
import io.nekohasekai.sfa.compose.topbar.OverrideTopBar
import io.nekohasekai.sfa.database.Settings
import io.nekohasekai.sfa.ktx.clipboardText
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
@Composable
fun CoreSettingsScreen(navController: NavController) {
OverrideTopBar {
@@ -77,6 +85,7 @@ fun CoreSettingsScreen(navController: NavController) {
val scope = rememberCoroutineScope()
var dataSize by remember { mutableStateOf("") }
val version = remember { Libbox.version() }
var showVersionMenu by remember { mutableStateOf(false) }
var disableDeprecatedWarnings by remember { mutableStateOf(Settings.disableDeprecatedWarnings) }
// Calculate data size on launch
@@ -114,34 +123,66 @@ fun CoreSettingsScreen(navController: NavController) {
) {
Column {
// Version Info
ListItem(
headlineContent = {
Text(
stringResource(R.string.core_version_title),
style = MaterialTheme.typography.bodyLarge,
)
},
supportingContent = {
Text(
version,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(top = 4.dp),
)
},
leadingContent = {
Icon(
imageVector = Icons.Outlined.Info,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
)
},
modifier = Modifier.clip(RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp)),
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
Box {
ListItem(
headlineContent = {
Text(
stringResource(R.string.core_version_title),
style = MaterialTheme.typography.bodyLarge,
)
},
supportingContent = {
Text(
version,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(top = 4.dp),
)
},
leadingContent = {
Icon(
imageVector = Icons.Outlined.Info,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
)
},
modifier = Modifier
.clip(RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp))
.combinedClickable(
onClick = {},
onLongClick = { showVersionMenu = true },
),
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
Box(modifier = Modifier.align(Alignment.BottomEnd)) {
DropdownMenu(
expanded = showVersionMenu,
onDismissRequest = { showVersionMenu = false },
) {
DropdownMenuItem(
text = { Text(stringResource(R.string.per_app_proxy_action_copy)) },
leadingIcon = {
Icon(
imageVector = Icons.Filled.ContentCopy,
contentDescription = null,
)
},
onClick = {
clipboardText = version
Toast.makeText(
context,
R.string.copied_to_clipboard,
Toast.LENGTH_SHORT,
).show()
showVersionMenu = false
},
)
}
}
}
// Data Size
ListItem(
@@ -181,57 +222,58 @@ fun CoreSettingsScreen(navController: NavController) {
}
}
// Options Section
Spacer(modifier = Modifier.height(16.dp))
if (version.contains("-")) {
Spacer(modifier = Modifier.height(16.dp))
Text(
text = stringResource(R.string.options),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(horizontal = 32.dp, vertical = 8.dp),
)
Card(
modifier =
Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
colors =
CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainer,
),
) {
ListItem(
headlineContent = {
Text(
stringResource(R.string.disable_deprecated_warnings),
style = MaterialTheme.typography.bodyLarge,
)
},
leadingContent = {
Icon(
imageVector = Icons.Outlined.WarningAmber,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
)
},
trailingContent = {
Switch(
checked = disableDeprecatedWarnings,
onCheckedChange = { checked ->
disableDeprecatedWarnings = checked
scope.launch(Dispatchers.IO) {
Settings.disableDeprecatedWarnings = checked
}
},
)
},
modifier = Modifier.clip(RoundedCornerShape(12.dp)),
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
),
Text(
text = stringResource(R.string.beta_settings),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(horizontal = 32.dp, vertical = 8.dp),
)
Card(
modifier =
Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
colors =
CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainer,
),
) {
ListItem(
headlineContent = {
Text(
stringResource(R.string.disable_deprecated_warnings),
style = MaterialTheme.typography.bodyLarge,
)
},
leadingContent = {
Icon(
imageVector = Icons.Outlined.WarningAmber,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
)
},
trailingContent = {
Switch(
checked = disableDeprecatedWarnings,
onCheckedChange = { checked ->
disableDeprecatedWarnings = checked
scope.launch(Dispatchers.IO) {
Settings.disableDeprecatedWarnings = checked
}
},
)
},
modifier = Modifier.clip(RoundedCornerShape(12.dp)),
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
}
}
// Working Directory Section
@@ -0,0 +1,458 @@
package io.nekohasekai.sfa.compose.screen.settings
import android.webkit.URLUtil
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.outlined.Add
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material.icons.outlined.Speed
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.ListItemDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import io.nekohasekai.libbox.Libbox
import io.nekohasekai.libbox.getFDroidMirrors
import io.nekohasekai.libbox.pingFDroidMirror
import io.nekohasekai.sfa.R
import io.nekohasekai.sfa.compose.topbar.OverrideTopBar
import io.nekohasekai.sfa.database.Settings
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
private data class MirrorEntry(
val url: String,
val name: String,
val country: String,
val isCustom: Boolean = false,
)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FDroidMirrorScreen(navController: NavController) {
OverrideTopBar {
TopAppBar(
title = { Text(stringResource(R.string.fdroid_mirror)) },
navigationIcon = {
IconButton(onClick = { navController.navigateUp() }) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(R.string.content_description_back),
)
}
},
)
}
val scope = rememberCoroutineScope()
var selectedMirrorUrl by remember { mutableStateOf(Settings.fdroidMirrorUrl) }
var isTesting by remember { mutableStateOf(false) }
val latencyResults = remember { mutableStateMapOf<String, Int>() }
val latencyErrors = remember { mutableStateMapOf<String, Boolean>() }
var showAddForm by remember { mutableStateOf(false) }
var newMirrorName by remember { mutableStateOf("") }
var newMirrorUrl by remember { mutableStateOf("") }
var urlError by remember { mutableStateOf<String?>(null) }
val invalidUrlMessage = stringResource(R.string.fdroid_mirror_invalid_url)
var customMirrors by remember { mutableStateOf(Settings.fdroidCustomMirrors) }
val builtinMirrors = remember {
val mirrors = mutableListOf<MirrorEntry>()
val iter = getFDroidMirrors()
while (iter.hasNext()) {
val m = iter.next()
mirrors.add(MirrorEntry(url = m.url, name = m.name, country = m.country))
}
mirrors
}
val parsedCustomMirrors = remember(customMirrors) {
customMirrors.map { entry ->
val parts = entry.split("|", limit = 2)
if (parts.size == 2) {
MirrorEntry(url = parts[1], name = parts[0], country = "", isCustom = true)
} else {
MirrorEntry(url = entry, name = entry, country = "", isCustom = true)
}
}
}
val allMirrors = builtinMirrors + parsedCustomMirrors
fun selectMirror(url: String) {
selectedMirrorUrl = url
Settings.fdroidMirrorUrl = url
}
fun testAllMirrors() {
isTesting = true
latencyResults.clear()
latencyErrors.clear()
scope.launch {
allMirrors.map { mirror ->
async(Dispatchers.IO) {
val r = pingFDroidMirror(mirror.url)
withContext(Dispatchers.Main) {
if (r.latencyMs < 0) {
latencyErrors[r.url] = true
} else {
latencyResults[r.url] = r.latencyMs
}
}
}
}.awaitAll()
val fastest = latencyResults.minByOrNull { it.value }
if (fastest != null) {
selectMirror(fastest.key)
}
isTesting = false
}
}
val grouped = remember(builtinMirrors) {
builtinMirrors.groupBy { it.country }
}
val countryOrder = remember(grouped) { grouped.keys.toList() }
Column(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.surface)
.verticalScroll(rememberScrollState())
.padding(vertical = 8.dp),
) {
FilledTonalButton(
onClick = { testAllMirrors() },
enabled = !isTesting,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
) {
if (isTesting) {
CircularProgressIndicator(
modifier = Modifier.size(18.dp),
strokeWidth = 2.dp,
)
Spacer(modifier = Modifier.width(8.dp))
Text(stringResource(R.string.fdroid_mirror_testing))
} else {
Icon(
imageVector = Icons.Outlined.Speed,
contentDescription = null,
modifier = Modifier.size(18.dp),
)
Spacer(modifier = Modifier.width(8.dp))
Text(stringResource(R.string.fdroid_mirror_test_all))
}
}
Spacer(modifier = Modifier.height(8.dp))
countryOrder.forEach { country ->
val mirrors = grouped[country] ?: return@forEach
Text(
text = country,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(horizontal = 32.dp, vertical = 8.dp),
)
Card(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainer,
),
) {
Column {
mirrors.forEachIndexed { index, mirror ->
val shape = when {
mirrors.size == 1 -> RoundedCornerShape(12.dp)
index == 0 -> RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp)
index == mirrors.lastIndex -> RoundedCornerShape(
bottomStart = 12.dp,
bottomEnd = 12.dp,
)
else -> RoundedCornerShape(0.dp)
}
ListItem(
headlineContent = {
Text(
mirror.name,
style = MaterialTheme.typography.bodyLarge,
)
},
leadingContent = {
RadioButton(
selected = selectedMirrorUrl == mirror.url,
onClick = { selectMirror(mirror.url) },
)
},
trailingContent = {
LatencyBadge(
url = mirror.url,
latencyResults = latencyResults,
latencyErrors = latencyErrors,
)
},
modifier = Modifier
.clip(shape)
.clickable { selectMirror(mirror.url) },
colors = ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
}
}
}
Spacer(modifier = Modifier.height(8.dp))
}
Text(
text = stringResource(R.string.fdroid_mirror_custom),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(horizontal = 32.dp, vertical = 8.dp),
)
Card(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainer,
),
) {
Column {
parsedCustomMirrors.forEachIndexed { index, mirror ->
val isLast = index == parsedCustomMirrors.lastIndex && !showAddForm
val shape = when {
index == 0 && isLast -> RoundedCornerShape(12.dp)
index == 0 -> RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp)
isLast -> RoundedCornerShape(
bottomStart = 12.dp,
bottomEnd = 12.dp,
)
else -> RoundedCornerShape(0.dp)
}
ListItem(
headlineContent = {
Text(
mirror.name,
style = MaterialTheme.typography.bodyLarge,
)
},
supportingContent = {
Text(
mirror.url,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
},
leadingContent = {
RadioButton(
selected = selectedMirrorUrl == mirror.url,
onClick = { selectMirror(mirror.url) },
)
},
trailingContent = {
Row(verticalAlignment = Alignment.CenterVertically) {
LatencyBadge(
url = mirror.url,
latencyResults = latencyResults,
latencyErrors = latencyErrors,
)
IconButton(onClick = {
val encoded = "${mirror.name}|${mirror.url}"
val newSet = customMirrors.toMutableSet()
newSet.remove(encoded)
customMirrors = newSet
Settings.fdroidCustomMirrors = newSet
if (selectedMirrorUrl == mirror.url) {
selectMirror("https://f-droid.org/repo")
}
}) {
Icon(
imageVector = Icons.Outlined.Delete,
contentDescription = stringResource(R.string.fdroid_mirror_delete),
tint = MaterialTheme.colorScheme.error,
)
}
}
},
modifier = Modifier
.clip(shape)
.clickable { selectMirror(mirror.url) },
colors = ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
}
if (showAddForm) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
OutlinedTextField(
value = newMirrorName,
onValueChange = { newMirrorName = it },
label = { Text(stringResource(R.string.fdroid_mirror_name_hint)) },
singleLine = true,
modifier = Modifier.fillMaxWidth(),
)
OutlinedTextField(
value = newMirrorUrl,
onValueChange = {
newMirrorUrl = it
urlError = null
},
label = { Text(stringResource(R.string.fdroid_mirror_url_hint)) },
singleLine = true,
isError = urlError != null,
supportingText = urlError?.let { { Text(it) } },
modifier = Modifier.fillMaxWidth(),
)
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End,
verticalAlignment = Alignment.CenterVertically,
) {
Button(onClick = {
val url = newMirrorUrl.trim().trimEnd('/')
if (!URLUtil.isHttpsUrl(url)) {
urlError = invalidUrlMessage
return@Button
}
val name = newMirrorName.trim().ifEmpty { url }
val encoded = "$name|$url"
val newSet = customMirrors.toMutableSet()
newSet.add(encoded)
customMirrors = newSet
Settings.fdroidCustomMirrors = newSet
newMirrorName = ""
newMirrorUrl = ""
urlError = null
showAddForm = false
}) {
Text(stringResource(R.string.fdroid_mirror_add_action))
}
}
}
} else {
ListItem(
headlineContent = {
Text(
stringResource(R.string.fdroid_mirror_add),
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.primary,
)
},
leadingContent = {
Icon(
imageVector = Icons.Outlined.Add,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
)
},
modifier = Modifier
.clip(
if (parsedCustomMirrors.isEmpty()) {
RoundedCornerShape(12.dp)
} else {
RoundedCornerShape(bottomStart = 12.dp, bottomEnd = 12.dp)
},
)
.clickable { showAddForm = true },
colors = ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
}
}
}
Spacer(modifier = Modifier.height(16.dp))
}
}
@Composable
private fun LatencyBadge(
url: String,
latencyResults: Map<String, Int>,
latencyErrors: Map<String, Boolean>,
) {
val latency = latencyResults[url]
val failed = latencyErrors[url] == true
when {
latency != null -> {
Text(
text = stringResource(R.string.fdroid_mirror_latency, latency),
style = MaterialTheme.typography.labelMedium,
color = when {
latency < 100 -> MaterialTheme.colorScheme.primary
latency < 500 -> MaterialTheme.colorScheme.onSurfaceVariant
else -> MaterialTheme.colorScheme.error
},
)
}
failed -> {
Text(
text = stringResource(R.string.fdroid_mirror_failed),
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.error,
)
}
else -> {}
}
}
@@ -16,6 +16,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.ClickableText
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
@@ -26,8 +28,11 @@ import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.ListItemDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
@@ -35,18 +40,28 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import io.nekohasekai.sfa.R
import io.nekohasekai.sfa.bg.ServiceConnection
import io.nekohasekai.sfa.compose.topbar.OverrideTopBar
import io.nekohasekai.sfa.database.Settings
import io.nekohasekai.sfa.ktx.launchCustomTab
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@@ -66,14 +81,13 @@ fun ServiceSettingsScreen(navController: NavController, serviceConnection: Servi
}
val context = LocalContext.current
// Check battery optimization status
val scope = rememberCoroutineScope()
var isBatteryOptimizationIgnored by remember { mutableStateOf(false) }
// Activity result launcher for battery optimization permission
var allowBypass by remember { mutableStateOf(Settings.allowBypass) }
val requestBatteryOptimizationLauncher =
rememberLauncherForActivityResult(
ActivityResultContracts.StartActivityForResult(),
) { _ ->
// Recheck the status after returning from settings
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val pm = context.getSystemService(PowerManager::class.java)
isBatteryOptimizationIgnored =
@@ -81,7 +95,6 @@ fun ServiceSettingsScreen(navController: NavController, serviceConnection: Servi
}
}
// Check battery optimization status on launch
LaunchedEffect(Unit) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val pm = context.getSystemService(PowerManager::class.java)
@@ -100,7 +113,6 @@ fun ServiceSettingsScreen(navController: NavController, serviceConnection: Servi
.verticalScroll(rememberScrollState())
.padding(vertical = 8.dp),
) {
// Background Permission Card (only show if battery optimization is not ignored)
if (!isBatteryOptimizationIgnored && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Card(
modifier =
@@ -171,6 +183,93 @@ fun ServiceSettingsScreen(navController: NavController, serviceConnection: Servi
}
}
// VPN Section
Spacer(modifier = Modifier.height(16.dp))
Text(
text = "VPN",
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(horizontal = 32.dp, vertical = 8.dp),
)
Card(
modifier =
Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
colors =
CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainer,
),
) {
val descriptionText = stringResource(R.string.allow_bypass_description)
val linkText = stringResource(R.string.android_documentation)
val linkColor = MaterialTheme.colorScheme.primary
val textColor = MaterialTheme.colorScheme.onSurfaceVariant
val textStyle = MaterialTheme.typography.bodyMedium
ListItem(
headlineContent = {
Text(
stringResource(R.string.allow_bypass),
style = MaterialTheme.typography.bodyLarge,
)
},
supportingContent = {
val annotatedString = buildAnnotatedString {
withStyle(SpanStyle(color = textColor)) {
append(descriptionText)
}
append("\n\n")
pushStringAnnotation(tag = "URL", annotation = ALLOW_BYPASS_DOC_URL)
withStyle(
SpanStyle(
color = linkColor,
textDecoration = TextDecoration.Underline,
),
) {
append(linkText)
}
pop()
}
ClickableText(
text = annotatedString,
style = textStyle,
modifier = Modifier.padding(top = 4.dp),
onClick = { offset ->
annotatedString.getStringAnnotations(
tag = "URL",
start = offset,
end = offset,
).firstOrNull()?.let {
context.launchCustomTab(it.item)
}
},
)
},
trailingContent = {
Switch(
checked = allowBypass,
onCheckedChange = { checked ->
allowBypass = checked
scope.launch(Dispatchers.IO) {
Settings.allowBypass = checked
}
},
)
},
modifier = Modifier.clip(RoundedCornerShape(12.dp)),
colors =
ListItemDefaults.colors(
containerColor = Color.Transparent,
),
)
}
Spacer(modifier = Modifier.height(16.dp))
}
}
private const val ALLOW_BYPASS_DOC_URL =
"https://developer.android.com/reference/android/net/VpnService.Builder#allowBypass()"
@@ -1,7 +1,5 @@
package io.nekohasekai.sfa.compose.screen.settings
import android.os.Build
import android.os.PowerManager
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
@@ -37,10 +35,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
@@ -70,15 +65,8 @@ fun SettingsScreen(navController: NavController) {
val hookStatus by HookStatusClient.status.collectAsState()
val hasPendingPrivilegeDowngrade = HookModuleUpdateNotifier.isDowngrade(hookStatus)
val hasPendingPrivilegeUpdate = HookModuleUpdateNotifier.isUpgrade(hookStatus)
var isBatteryOptimizationIgnored by remember { mutableStateOf(true) }
LaunchedEffect(Unit) {
HookStatusClient.refresh()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val pm = context.getSystemService(PowerManager::class.java)
isBatteryOptimizationIgnored =
pm?.isIgnoringBatteryOptimizations(context.packageName) == true
}
}
Column(
@@ -167,11 +155,6 @@ fun SettingsScreen(navController: NavController) {
tint = MaterialTheme.colorScheme.primary,
)
},
trailingContent = {
if (!isBatteryOptimizationIgnored) {
Badge(containerColor = MaterialTheme.colorScheme.primary)
}
},
modifier = Modifier.clickable { navController.navigate("settings/service") },
colors =
ListItemDefaults.colors(
@@ -5,7 +5,10 @@ object SettingsKey {
const val SERVICE_MODE = "service_mode"
const val CHECK_UPDATE_ENABLED = "check_update_enabled"
const val UPDATE_CHECK_PROMPTED = "update_check_prompted"
const val UPDATE_SOURCE = "update_source"
const val UPDATE_TRACK = "update_track"
const val FDROID_MIRROR_URL = "fdroid_mirror_url"
const val FDROID_CUSTOM_MIRRORS = "fdroid_custom_mirrors"
const val SILENT_INSTALL_ENABLED = "silent_install_enabled"
const val SILENT_INSTALL_METHOD = "silent_install_method"
const val AUTO_UPDATE_ENABLED = "auto_update_enabled"
@@ -20,6 +23,7 @@ object SettingsKey {
const val PER_APP_PROXY_MANAGED_LIST = "per_app_proxy_managed_list"
const val PER_APP_PROXY_PACKAGE_QUERY_MODE = "per_app_proxy_package_query_mode"
const val ALLOW_BYPASS = "allow_bypass"
const val SYSTEM_PROXY_ENABLED = "system_proxy_enabled"
const val PRIVILEGE_SETTINGS_ENABLED = "hide_settings_enabled"
@@ -41,6 +41,7 @@ object Settings {
var serviceMode by dataStore.string(SettingsKey.SERVICE_MODE) { ServiceMode.NORMAL }
var startedByUser by dataStore.boolean(SettingsKey.STARTED_BY_USER)
var updateSource by dataStore.string(SettingsKey.UPDATE_SOURCE) { "github" }
var checkUpdateEnabled by dataStore.boolean(SettingsKey.CHECK_UPDATE_ENABLED) { false }
var updateCheckPrompted by dataStore.boolean(SettingsKey.UPDATE_CHECK_PROMPTED) { false }
var updateTrack by dataStore.string(SettingsKey.UPDATE_TRACK) {
@@ -62,6 +63,8 @@ object Settings {
"SHIZUKU"
}
}
var fdroidMirrorUrl by dataStore.string(SettingsKey.FDROID_MIRROR_URL) { "https://f-droid.org/repo" }
var fdroidCustomMirrors by dataStore.stringSet(SettingsKey.FDROID_CUSTOM_MIRRORS) { emptySet() }
var autoUpdateEnabled by dataStore.boolean(SettingsKey.AUTO_UPDATE_ENABLED) { false }
var dynamicNotification by dataStore.boolean(SettingsKey.DYNAMIC_NOTIFICATION) { true }
var disableDeprecatedWarnings by dataStore.boolean(SettingsKey.DISABLE_DEPRECATED_WARNINGS) { false }
@@ -93,6 +96,7 @@ object Settings {
perAppProxyList
}
var allowBypass by dataStore.boolean(SettingsKey.ALLOW_BYPASS) { false }
var systemProxyEnabled by dataStore.boolean(SettingsKey.SYSTEM_PROXY_ENABLED) { true }
var privilegeSettingsEnabled by dataStore.boolean(SettingsKey.PRIVILEGE_SETTINGS_ENABLED) { false }
@@ -0,0 +1,27 @@
package io.nekohasekai.sfa.update
import android.content.Context
import io.nekohasekai.libbox.checkFDroidUpdate as libboxCheckFDroidUpdate
import io.nekohasekai.sfa.database.Settings
fun checkFDroidUpdate(context: Context): UpdateInfo? {
val packageName = context.packageName
@Suppress("DEPRECATION")
val versionCode = context.packageManager.getPackageInfo(packageName, 0).versionCode
val result = libboxCheckFDroidUpdate(
Settings.fdroidMirrorUrl,
packageName,
versionCode,
context.cacheDir.absolutePath,
) ?: return null
return UpdateInfo(
versionCode = result.versionCode,
versionName = result.versionName,
downloadUrl = result.downloadURL,
releaseUrl = "https://f-droid.org/packages/$packageName/",
releaseNotes = null,
isPrerelease = false,
fileSize = result.fileSize,
)
}
@@ -0,0 +1,14 @@
package io.nekohasekai.sfa.update
enum class UpdateSource {
GITHUB,
FDROID,
;
companion object {
fun fromString(value: String): UpdateSource = when (value.lowercase()) {
"fdroid" -> FDROID
else -> GITHUB
}
}
}
@@ -11,6 +11,7 @@ object UpdateState {
val isChecking = mutableStateOf(false)
val isDownloading = mutableStateOf(false)
val downloadProgress = mutableStateOf<Float?>(null)
val downloadError = mutableStateOf<String?>(null)
val cachedApkFile = mutableStateOf<File?>(null)
@@ -38,6 +39,7 @@ object UpdateState {
hasUpdate.value = false
updateInfo.value = null
isDownloading.value = false
downloadProgress.value = null
downloadError.value = null
installStatus.value = InstallStatus.Idle
cachedApkFile.value = null
@@ -46,6 +48,7 @@ object UpdateState {
fun resetDownload() {
isDownloading.value = false
downloadProgress.value = null
downloadError.value = null
}
@@ -100,7 +100,12 @@ open class CommandClient(
}
options.statusInterval = 1 * 1000 * 1000 * 1000
val commandClient = CommandClient(clientHandler, options)
commandClient.connect()
try {
commandClient.connect()
} catch (e: Exception) {
Log.d("CommandClient", "connect failed", e)
return
}
this.commandClient = commandClient
}
@@ -4,6 +4,7 @@ import android.app.Activity
import androidx.camera.core.ImageAnalysis
import io.nekohasekai.sfa.compose.screen.qrscan.QRCodeCropArea
import io.nekohasekai.sfa.update.UpdateInfo
import io.nekohasekai.sfa.update.UpdateSource
interface VendorInterface {
fun checkUpdate(activity: Activity, byUser: Boolean)
@@ -14,53 +15,17 @@ interface VendorInterface {
onCropArea: ((QRCodeCropArea?) -> Unit)? = null,
): ImageAnalysis.Analyzer?
/**
* Check if Per-app Proxy feature is available
* @return true if available, false if disabled (e.g., for Play Store builds)
*/
fun isPerAppProxyAvailable(): Boolean = true
/**
* Check if track selection is available (e.g., stable/beta)
* @return true if track selection is supported
*/
fun supportsTrackSelection(): Boolean = false
val hasCustomUpdate: Boolean get() = false
val updateSources: List<UpdateSource> get() = listOf(UpdateSource.GITHUB)
/**
* Check for updates asynchronously
* @return UpdateInfo if update is available, null otherwise
*/
fun checkUpdateAsync(): UpdateInfo? = null
/**
* Check if silent install feature is available
* @return true if silent install is supported (Other flavor only)
*/
fun supportsSilentInstall(): Boolean = false
/**
* Check if auto update feature is available
* @return true if auto update is supported (Other flavor only)
*/
fun supportsAutoUpdate(): Boolean = false
/**
* Schedule auto update worker
*/
fun scheduleAutoUpdate() {}
/**
* Verify if the specified silent install method is available
* @param method The install method (SHIZUKU or ROOT)
* @return true if the method is available and working
*/
suspend fun verifySilentInstallMethod(method: String): Boolean = false
/**
* Download and install an APK update
* @param context The context
* @param downloadUrl The URL to download the APK from
* @throws Exception if download or install fails
*/
suspend fun downloadAndInstall(context: android.content.Context, downloadUrl: String): Unit = throw UnsupportedOperationException("Not supported in this flavor")
}
@@ -0,0 +1,49 @@
package io.nekohasekai.sfa.xposed
import android.content.Context
import io.nekohasekai.sfa.xposed.hooks.HookIConnectivityManagerOnTransact
import io.nekohasekai.sfa.xposed.hooks.hidevpn.ConnectivityServiceHookHelper
import io.nekohasekai.sfa.xposed.hooks.hidevpn.HookNetworkCapabilitiesWriteToParcel
import io.nekohasekai.sfa.xposed.hooks.hidevpn.HookNetworkInterfaceGetName
import io.nekohasekai.sfa.xposed.hooks.hidevpnapp.HookPackageManagerGetInstalledPackages
object HookInstaller {
private const val TAG = "XposedInit"
private val activityThreadClass by lazy { Class.forName("android.app.ActivityThread") }
private val currentActivityThreadMethod by lazy { activityThreadClass.getMethod("currentActivityThread") }
private val getSystemContextMethod by lazy { activityThreadClass.getMethod("getSystemContext") }
fun install(classLoader: ClassLoader) {
val systemContext = resolveSystemContext()
HookErrorStore.i(TAG, "handleSystemServerLoaded")
val hooks = arrayOf(
ConnectivityServiceHookHelper(classLoader),
HookIConnectivityManagerOnTransact(classLoader, systemContext),
HookPackageManagerGetInstalledPackages(classLoader),
HookNetworkCapabilitiesWriteToParcel(),
HookNetworkInterfaceGetName(classLoader),
)
hooks.forEach { hook ->
try {
hook.injectHook()
} catch (e: Throwable) {
HookErrorStore.e(
TAG,
"Failed to inject ${hook.javaClass.simpleName}",
e,
)
}
}
}
private fun resolveSystemContext(): Context? = try {
val currentThread = currentActivityThreadMethod.invoke(null)
getSystemContextMethod.invoke(currentThread) as? Context
} catch (e: Throwable) {
HookErrorStore.e(TAG, "resolveSystemContext failed", e)
null
}
}
@@ -1,54 +1,16 @@
package io.nekohasekai.sfa.xposed
import android.content.Context
import io.github.libxposed.api.XposedInterface
import io.github.libxposed.api.XposedModule
import io.github.libxposed.api.XposedModuleInterface
import io.nekohasekai.sfa.xposed.hooks.HookIConnectivityManagerOnTransact
import io.nekohasekai.sfa.xposed.hooks.hidevpn.ConnectivityServiceHookHelper
import io.nekohasekai.sfa.xposed.hooks.hidevpn.HookNetworkCapabilitiesWriteToParcel
import io.nekohasekai.sfa.xposed.hooks.hidevpn.HookNetworkInterfaceGetName
import io.nekohasekai.sfa.xposed.hooks.hidevpnapp.HookPackageManagerGetInstalledPackages
class XposedInit(base: XposedInterface, param: XposedModuleInterface.ModuleLoadedParam) : XposedModule(base, param) {
private val activityThreadClass by lazy { Class.forName("android.app.ActivityThread") }
private val currentActivityThreadMethod by lazy { activityThreadClass.getMethod("currentActivityThread") }
private val getSystemContextMethod by lazy { activityThreadClass.getMethod("getSystemContext") }
override fun onSystemServerLoaded(param: XposedModuleInterface.SystemServerLoadedParam) {
val systemContext = resolveSystemContext()
HookErrorStore.i("XposedInit", "handleSystemServerLoaded")
val hooks = arrayOf(
ConnectivityServiceHookHelper(param.classLoader),
HookIConnectivityManagerOnTransact(param.classLoader, systemContext),
HookPackageManagerGetInstalledPackages(param.classLoader),
HookNetworkCapabilitiesWriteToParcel(),
HookNetworkInterfaceGetName(param.classLoader),
)
hooks.forEach { hook ->
try {
hook.injectHook()
} catch (e: Throwable) {
HookErrorStore.e(
"XposedInit",
"Failed to inject ${hook.javaClass.simpleName}",
e,
)
}
}
HookInstaller.install(param.classLoader)
}
companion object {
const val TAG = "sing-box-lsposed"
}
private fun resolveSystemContext(): Context? = try {
val currentThread = currentActivityThreadMethod.invoke(null)
getSystemContextMethod.invoke(currentThread) as? Context
} catch (e: Throwable) {
HookErrorStore.e("XposedInit", "resolveSystemContext failed", e)
null
}
}
@@ -0,0 +1,11 @@
package io.nekohasekai.sfa.xposed
import io.github.libxposed.api.XposedModule
import io.github.libxposed.api.XposedModuleInterface
class XposedInit101 : XposedModule() {
override fun onSystemServerStarting(param: XposedModuleInterface.SystemServerStartingParam) {
HookInstaller.install(param.classLoader)
}
}
@@ -6,6 +6,7 @@ import android.net.Network
import android.net.NetworkInfo
import android.os.Build
import android.os.IBinder
import android.os.Parcel
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XposedHelpers
import io.nekohasekai.sfa.xposed.HookErrorStore
@@ -26,6 +27,7 @@ class ConnectivityServiceHookHelper(private val classLoader: ClassLoader) : XHoo
private val hooked = AtomicBoolean(false)
private val initializerHooked = AtomicBoolean(false)
private var classLoadUnhook: XC_MethodHook.Unhook? = null
private var onTransactUnhook: XC_MethodHook.Unhook? = null
private val serviceManagerHooked = AtomicBoolean(false)
private var connectivityClassLoader: ClassLoader = classLoader
private val skipLogKeys = ConcurrentHashMap<String, Boolean>()
@@ -53,6 +55,7 @@ class ConnectivityServiceHookHelper(private val classLoader: ClassLoader) : XHoo
}
hookConnectivityServiceInitializer()
hookClassLoaderFallback()
hookOnTransactFallback()
tryHookFromServiceManager()
}
@@ -148,12 +151,39 @@ class ConnectivityServiceHookHelper(private val classLoader: ClassLoader) : XHoo
}
}
HookErrorStore.i(SOURCE, "ConnectivityService class not found in known classloaders")
val initializerNames = listOf(
"com.android.server.ConnectivityServiceInitializer",
"com.android.server.ConnectivityServiceInitializerB",
)
for (name in initializerNames) {
for (loader in loaders) {
val initCls = try {
if (loader != null) Class.forName(name, false, loader) else Class.forName(name)
} catch (_: Throwable) {
null
} ?: continue
try {
val field = initCls.getDeclaredField("mConnectivity")
val fieldType = field.type
if (fieldType.name.endsWith(".ConnectivityService")) {
HookErrorStore.i(
SOURCE,
"ConnectivityService class found via $name.mConnectivity: ${fieldType.name}",
)
return fieldType
}
} catch (_: Throwable) {
}
}
}
return null
}
private fun hookConnectivityServiceInitializer() {
if (sdkInt < 31 || sdkInt >= 33) {
HookErrorStore.d(SOURCE, "Skip ConnectivityServiceInitializer: sdk=$sdkInt (only exists in API 31-32)")
if (sdkInt < 31) {
HookErrorStore.d(SOURCE, "Skip ConnectivityServiceInitializer: sdk=$sdkInt (requires API 31+)")
return
}
val candidates = listOf(
@@ -238,20 +268,20 @@ class ConnectivityServiceHookHelper(private val classLoader: ClassLoader) : XHoo
classLoadUnhook = null
return
}
when (name) {
"com.android.server.ConnectivityService" -> {
when {
name == "com.android.server.ConnectivityService" ||
name.endsWith(".com.android.server.ConnectivityService") -> {
val cls = param.result as? Class<*> ?: return
HookErrorStore.i(
SOURCE,
"ConnectivityService loaded via ${param.thisObject.javaClass.name}",
"ConnectivityService loaded via ${param.thisObject.javaClass.name}: $name",
)
installHooks(cls, "loadClass")
classLoadUnhook?.unhook()
classLoadUnhook = null
}
"com.android.server.ConnectivityServiceInitializer",
"com.android.server.ConnectivityServiceInitializerB",
-> {
name == "com.android.server.ConnectivityServiceInitializer" ||
name == "com.android.server.ConnectivityServiceInitializerB" -> {
if (sdkInt < 31) return
if (initializerHooked.get()) return
val cls = param.result as? Class<*> ?: return
@@ -322,6 +352,41 @@ class ConnectivityServiceHookHelper(private val classLoader: ClassLoader) : XHoo
}
}
private fun hookOnTransactFallback() {
if (onTransactUnhook != null) return
try {
val stub = XposedHelpers.findClass("android.net.IConnectivityManager\$Stub", classLoader)
onTransactUnhook = XposedHelpers.findAndHookMethod(
stub,
"onTransact",
Int::class.javaPrimitiveType,
Parcel::class.java,
Parcel::class.java,
Int::class.javaPrimitiveType,
object : SafeMethodHook(SOURCE) {
override fun beforeHook(param: MethodHookParam) {
if (hooked.get()) {
onTransactUnhook?.unhook()
onTransactUnhook = null
return
}
val serviceClass = param.thisObject.javaClass
HookErrorStore.i(
SOURCE,
"ConnectivityService discovered via onTransact: ${serviceClass.name}",
)
installHooks(serviceClass, "onTransact")
onTransactUnhook?.unhook()
onTransactUnhook = null
}
},
)
HookErrorStore.i(SOURCE, "Hooked IConnectivityManager.Stub.onTransact for discovery")
} catch (e: Throwable) {
HookErrorStore.w(SOURCE, "Hook onTransact fallback failed: ${e.message}", e)
}
}
private fun hookConnectivityServiceInitializerClass(cls: Class<*>) {
if (sdkInt < 31) return
if (initializerHooked.get()) return
+4
View File
@@ -198,12 +198,16 @@
<string name="source_code">کد منبع</string>
<string name="sponsor">حامی مالی</string>
<string name="working_directory">پوشه کاری</string>
<string name="beta_settings">تنظیمات بتا</string>
<string name="disable_deprecated_warnings">غیرفعال‌کردن هشدارهای منسوخ</string>
<string name="notification_settings">اعلان‌ها</string>
<string name="enable_notification">فعال‌کردن اعلان</string>
<string name="dynamic_notification">نمایش سرعت بلادرنگ در اعلان</string>
<string name="disable_notification_description">به دلیل محدودیت‌های اندروید، ابتدا باید مجوز اعلان را بدهید، سپس دسته‌بندی اعلان را در تنظیمات غیرفعال کنید.</string>
<string name="disable_notification_description_legacy">به دلیل محدودیت‌های اندروید، ابتدا باید مجوز اعلان را بدهید، سپس اعلان‌ها را در اطلاعات برنامه غیرفعال کنید.</string>
<string name="allow_bypass">اجازه دور زدن VPN</string>
<string name="allow_bypass_description">در صورت فعال بودن، برنامه‌ها می‌توانند این اتصال VPN را دور بزنند و مستقیماً از شبکه اصلی استفاده کنند.</string>
<string name="android_documentation">مستندات Android</string>
<string name="auto_redirect">تغییر مسیر خودکار</string>
<string name="auto_redirect_description">نیازمند دسترسی ROOT</string>
<string name="system_http_proxy">پراکسی HTTP سیستم</string>
@@ -198,12 +198,16 @@
<string name="source_code">Исходный код</string>
<string name="sponsor">Поддержать</string>
<string name="working_directory">Рабочая директория</string>
<string name="beta_settings">Бета-настройки</string>
<string name="disable_deprecated_warnings">Отключить предупреждения об устаревании</string>
<string name="notification_settings">Уведомления</string>
<string name="enable_notification">Включить уведомления</string>
<string name="dynamic_notification">Отображать скорость в реальном времени в уведомлении</string>
<string name="disable_notification_description">Из-за ограничений Android необходимо сначала предоставить разрешение на уведомления, а затем отключить категорию уведомлений в настройках.</string>
<string name="disable_notification_description_legacy">Из-за ограничений Android необходимо сначала предоставить разрешение на уведомления, а затем отключить уведомления в сведениях о приложении.</string>
<string name="allow_bypass">Разрешить обход VPN</string>
<string name="allow_bypass_description">Если включено, приложения могут обойти это VPN-соединение и использовать базовую сеть напрямую.</string>
<string name="android_documentation">Документация Android</string>
<string name="auto_redirect">Автоматическое перенаправление</string>
<string name="auto_redirect_description">Требуются права ROOT</string>
<string name="system_http_proxy">Системный HTTP-прокси</string>
+23 -1
View File
@@ -198,12 +198,18 @@
<string name="source_code">源代码</string>
<string name="sponsor">赞助</string>
<string name="working_directory">工作目录</string>
<string name="beta_settings">Beta 版设置</string>
<string name="disable_deprecated_warnings">禁用弃用警告</string>
<string name="cache_size">缓存大小</string>
<string name="clear_cache">清除缓存</string>
<string name="notification_settings">通知</string>
<string name="enable_notification">启用通知</string>
<string name="dynamic_notification">在通知中显示实时网速</string>
<string name="disable_notification_description">由于 Android 限制,您需要先授权通知权限,然后前往系统设置中关闭通知类别。</string>
<string name="disable_notification_description_legacy">由于 Android 限制,您需要先授权通知权限,然后前往应用信息中关闭通知。</string>
<string name="allow_bypass">允许绕过 VPN</string>
<string name="allow_bypass_description">启用后,应用可以绕过此 VPN 连接,直接使用底层网络。</string>
<string name="android_documentation">Android 文档</string>
<string name="auto_redirect">自动重定向</string>
<string name="auto_redirect_description">需要 ROOT 权限</string>
<string name="system_http_proxy">系统 HTTP 代理</string>
@@ -266,7 +272,7 @@
<string name="check_update_prompt_github">是否启用从 **GitHub** 自动检查更新?</string>
<string name="update_track">更新轨道</string>
<string name="update_track_stable">稳定版</string>
<string name="update_track_beta">测试</string>
<string name="update_track_beta">Beta </string>
<string name="update_track_not_supported">当前轨道尚不支持检查更新</string>
<string name="view_release">查看发布</string>
<string name="downloading">下载中…</string>
@@ -275,6 +281,22 @@
<string name="new_version_available">有新版本可用:%s</string>
<string name="auto_update">自动更新</string>
<string name="auto_update_description">在后台自动下载和安装更新</string>
<string name="update_source">更新来源</string>
<string name="update_source_github">GitHub</string>
<string name="update_source_fdroid">F-Droid</string>
<string name="fdroid_mirror">F-Droid 镜像</string>
<string name="fdroid_mirror_test_all">根据延迟自动选择</string>
<string name="fdroid_mirror_testing">测试中…</string>
<string name="fdroid_mirror_latency">%d ms</string>
<string name="fdroid_mirror_failed">失败</string>
<string name="fdroid_mirror_untested"></string>
<string name="fdroid_mirror_add">添加镜像</string>
<string name="fdroid_mirror_name_hint">名称</string>
<string name="fdroid_mirror_url_hint">URL</string>
<string name="fdroid_mirror_custom">自定义</string>
<string name="fdroid_mirror_invalid_url">无效的 URL</string>
<string name="fdroid_mirror_add_action">添加</string>
<string name="fdroid_mirror_delete">删除</string>
<!-- Silent Install -->
<string name="silent_install">静默安装</string>
+23 -1
View File
@@ -198,12 +198,18 @@
<string name="source_code">原始碼</string>
<string name="sponsor">贊助</string>
<string name="working_directory">工作目錄</string>
<string name="beta_settings">Beta 版設定</string>
<string name="disable_deprecated_warnings">停用過時警告</string>
<string name="cache_size">快取大小</string>
<string name="clear_cache">清除快取</string>
<string name="notification_settings">通知</string>
<string name="enable_notification">啟用通知</string>
<string name="dynamic_notification">在通知中顯示即時網速</string>
<string name="disable_notification_description">由於 Android 限制,您需要先授權通知權限,然後前往系統設定中關閉通知類別。</string>
<string name="disable_notification_description_legacy">由於 Android 限制,您需要先授權通知權限,然後前往應用程式資訊中關閉通知。</string>
<string name="allow_bypass">允許繞過 VPN</string>
<string name="allow_bypass_description">啟用後,應用程式可以繞過此 VPN 連線,直接使用底層網路。</string>
<string name="android_documentation">Android 文件</string>
<string name="auto_redirect">自動重定向</string>
<string name="auto_redirect_description">需要 ROOT 權限</string>
<string name="system_http_proxy">系統 HTTP 代理</string>
@@ -266,7 +272,7 @@
<string name="check_update_prompt_github">是否啟用從 **GitHub** 自動檢查更新?</string>
<string name="update_track">更新通道</string>
<string name="update_track_stable">穩定版</string>
<string name="update_track_beta">測試</string>
<string name="update_track_beta">Beta </string>
<string name="update_track_not_supported">目前通道尚不支援檢查更新</string>
<string name="view_release">查看發布</string>
<string name="downloading">下載中…</string>
@@ -275,6 +281,22 @@
<string name="new_version_available">有新版本可用:%s</string>
<string name="auto_update">自動更新</string>
<string name="auto_update_description">在背景自動下載並安裝更新</string>
<string name="update_source">更新來源</string>
<string name="update_source_github">GitHub</string>
<string name="update_source_fdroid">F-Droid</string>
<string name="fdroid_mirror">F-Droid 鏡像</string>
<string name="fdroid_mirror_test_all">依延遲自動選擇</string>
<string name="fdroid_mirror_testing">測試中…</string>
<string name="fdroid_mirror_latency">%d ms</string>
<string name="fdroid_mirror_failed">失敗</string>
<string name="fdroid_mirror_untested"></string>
<string name="fdroid_mirror_add">新增鏡像</string>
<string name="fdroid_mirror_name_hint">名稱</string>
<string name="fdroid_mirror_url_hint">URL</string>
<string name="fdroid_mirror_custom">自訂</string>
<string name="fdroid_mirror_invalid_url">無效的 URL</string>
<string name="fdroid_mirror_add_action">新增</string>
<string name="fdroid_mirror_delete">刪除</string>
<!-- Silent Install -->
<string name="silent_install">靜默安裝</string>
+22
View File
@@ -198,12 +198,18 @@
<string name="source_code">Source Code</string>
<string name="sponsor">Sponsor</string>
<string name="working_directory">Working Directory</string>
<string name="beta_settings">Beta Settings</string>
<string name="disable_deprecated_warnings">Disable Deprecated Warnings</string>
<string name="cache_size">Cache Size</string>
<string name="clear_cache">Clear Cache</string>
<string name="notification_settings">Notification</string>
<string name="enable_notification">Enable Notification</string>
<string name="dynamic_notification">Display realtime speed in notification</string>
<string name="disable_notification_description">Due to Android restrictions, you must first grant notification permission, then go to Settings to disable the notification category.</string>
<string name="disable_notification_description_legacy">Due to Android restrictions, you must first grant notification permission, then go to App Info to disable notifications.</string>
<string name="allow_bypass">Allow Bypass</string>
<string name="allow_bypass_description">If enabled, applications can bypass this VPN connection and instead use the underlying network directly.</string>
<string name="android_documentation">Android Documentation</string>
<string name="auto_redirect">Auto Redirect</string>
<string name="auto_redirect_description">ROOT permission required</string>
<string name="system_http_proxy">System HTTP Proxy</string>
@@ -264,6 +270,9 @@
<string name="check_update_automatic">Automatic Update Check</string>
<string name="check_update_prompt_play">Would you like to enable automatic update checking from **Play Store**?</string>
<string name="check_update_prompt_github">Would you like to enable automatic update checking from **GitHub**?</string>
<string name="update_source">Update Source</string>
<string name="update_source_github">GitHub</string>
<string name="update_source_fdroid">F-Droid</string>
<string name="update_track">Update Track</string>
<string name="update_track_stable">Stable</string>
<string name="update_track_beta">Beta</string>
@@ -275,6 +284,19 @@
<string name="new_version_available">New version available: %s</string>
<string name="auto_update">Auto Update</string>
<string name="auto_update_description">Automatically download and install updates in background</string>
<string name="fdroid_mirror">F-Droid Mirror</string>
<string name="fdroid_mirror_test_all">Auto Select by Latency</string>
<string name="fdroid_mirror_testing">Testing…</string>
<string name="fdroid_mirror_latency">%d ms</string>
<string name="fdroid_mirror_failed">Failed</string>
<string name="fdroid_mirror_untested"></string>
<string name="fdroid_mirror_add">Add Mirror</string>
<string name="fdroid_mirror_name_hint">Name</string>
<string name="fdroid_mirror_url_hint">URL</string>
<string name="fdroid_mirror_custom">Custom</string>
<string name="fdroid_mirror_invalid_url">Invalid URL</string>
<string name="fdroid_mirror_add_action">Add</string>
<string name="fdroid_mirror_delete">Delete</string>
<!-- Silent Install -->
<string name="silent_install">Silent Install</string>
+3
View File
@@ -3,4 +3,7 @@
<cache-path
name="cache"
path="/" />
<external-files-path
name="external_files"
path="/" />
</paths>
@@ -1 +1,2 @@
io.nekohasekai.sfa.xposed.XposedInit
io.nekohasekai.sfa.xposed.XposedInit101
@@ -1,3 +1,3 @@
minApiVersion=100
targetApiVersion=100
targetApiVersion=101
staticScope=true
+12 -9
View File
@@ -13,8 +13,10 @@ import io.nekohasekai.sfa.compose.screen.qrscan.QRCodeCropArea
import io.nekohasekai.sfa.database.Settings
import io.nekohasekai.sfa.update.UpdateCheckException
import io.nekohasekai.sfa.update.UpdateInfo
import io.nekohasekai.sfa.update.UpdateSource
import io.nekohasekai.sfa.update.UpdateState
import io.nekohasekai.sfa.update.UpdateTrack
import io.nekohasekai.sfa.update.checkFDroidUpdate
object Vendor : VendorInterface {
private const val TAG = "Vendor"
@@ -93,19 +95,20 @@ object Vendor : VendorInterface {
onCropArea: ((QRCodeCropArea?) -> Unit)?,
): ImageAnalysis.Analyzer? = null
override fun supportsTrackSelection(): Boolean = true
override val hasCustomUpdate = true
override fun checkUpdateAsync(): UpdateInfo? {
val track = UpdateTrack.fromString(Settings.updateTrack)
return GitHubUpdateChecker().use { checker ->
checker.checkUpdate(track)
override val updateSources = listOf(UpdateSource.GITHUB, UpdateSource.FDROID)
override fun checkUpdateAsync(): UpdateInfo? = when (UpdateSource.fromString(Settings.updateSource)) {
UpdateSource.FDROID -> checkFDroidUpdate(Application.application)
UpdateSource.GITHUB -> {
val track = UpdateTrack.fromString(Settings.updateTrack)
GitHubUpdateChecker().use { checker ->
checker.checkUpdate(track)
}
}
}
override fun supportsSilentInstall(): Boolean = true
override fun supportsAutoUpdate(): Boolean = true
override fun scheduleAutoUpdate() {
UpdateWorker.schedule(io.nekohasekai.sfa.Application.application)
}
@@ -93,7 +93,7 @@ object Vendor : VendorInterface {
onCropArea: ((QRCodeCropArea?) -> Unit)?,
): ImageAnalysis.Analyzer? = null
override fun supportsTrackSelection(): Boolean = true
override val hasCustomUpdate = true
override fun checkUpdateAsync(): UpdateInfo? {
val track = UpdateTrack.fromString(Settings.updateTrack)
@@ -102,10 +102,6 @@ object Vendor : VendorInterface {
}
}
override fun supportsSilentInstall(): Boolean = true
override fun supportsAutoUpdate(): Boolean = true
override fun scheduleAutoUpdate() {
UpdateWorker.schedule(io.nekohasekai.sfa.Application.application)
}
-2
View File
@@ -92,7 +92,5 @@ object Vendor : VendorInterface {
}
}
override fun supportsTrackSelection(): Boolean = false
override fun checkUpdateAsync(): UpdateInfo? = null
}
+1 -1
View File
@@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# 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.
# 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
+1 -1
View File
@@ -1,5 +1,5 @@
[versions]
spotless = "8.1.0"
spotless = "8.2.1"
ktlint = "1.7.1"
[plugins]
+1 -1
View File
@@ -1,7 +1,7 @@
#Mon Jul 07 14:05:29 CST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
@@ -21,9 +21,19 @@ import io.github.libxposed.api.utils.DexParser;
*/
public class XposedInterfaceWrapper implements XposedInterface {
private final XposedInterface mBase;
private volatile XposedInterface mBase;
XposedInterfaceWrapper(@NonNull XposedInterface base) {
public XposedInterfaceWrapper() {
}
public XposedInterfaceWrapper(@NonNull XposedInterface base) {
mBase = base;
}
public final void attachFramework(@NonNull XposedInterface base) {
if (mBase != null) {
throw new IllegalStateException("Framework already attached");
}
mBase = base;
}
@@ -9,11 +9,16 @@ import androidx.annotation.NonNull;
@SuppressWarnings("unused")
public abstract class XposedModule extends XposedInterfaceWrapper implements XposedModuleInterface {
/**
* Instantiates a new Xposed module.<br/>
* When the module is loaded into the target process, the constructor will be called.
*
* @param base The implementation interface provided by the framework, should not be used by the module
* @param param Information about the process in which the module is loaded
* No-arg constructor for API 101 contract: the framework instantiates the module via
* {@code Class.getDeclaredConstructor()}, then calls {@link #attachFramework}.
*/
public XposedModule() {
super();
}
/**
* Two-arg constructor for API 100 contract: the framework instantiates the module via
* {@code (XposedInterface, ModuleLoadedParam)} and attaches the framework base inline.
*/
public XposedModule(@NonNull XposedInterface base, @NonNull ModuleLoadedParam param) {
super(base);
@@ -1,5 +1,6 @@
package io.github.libxposed.api;
import android.app.AppComponentFactory;
import android.content.pm.ApplicationInfo;
import android.os.Build;
@@ -32,7 +33,7 @@ public interface XposedModuleInterface {
}
/**
* Wraps information about system server.
* Wraps information about system server. API 100 flavor.
*/
interface SystemServerLoadedParam {
/**
@@ -44,6 +45,26 @@ public interface XposedModuleInterface {
ClassLoader getClassLoader();
}
/**
* Wraps information about system server. API 101 flavor.
*/
interface SystemServerStartingParam {
@NonNull
ClassLoader getClassLoader();
}
/**
* Wraps information about a package whose classloader is ready. API 101.
*/
interface PackageReadyParam extends PackageLoadedParam {
@NonNull
ClassLoader getClassLoader();
@RequiresApi(Build.VERSION_CODES.P)
@NonNull
AppComponentFactory getAppComponentFactory();
}
/**
* Wraps information about the package being loaded.
*/
@@ -99,10 +120,28 @@ public interface XposedModuleInterface {
}
/**
* Gets notified when the system server is loaded.
* Gets notified when the system server is loaded. API 100.
*
* @param param Information about system server
*/
default void onSystemServerLoaded(@NonNull SystemServerLoadedParam param) {
}
/**
* API 101: invoked once per process after the module instance is attached.
*/
default void onModuleLoaded(@NonNull ModuleLoadedParam param) {
}
/**
* API 101: invoked when a package's classloader is ready.
*/
default void onPackageReady(@NonNull PackageReadyParam param) {
}
/**
* API 101: replaces {@link #onSystemServerLoaded(SystemServerLoadedParam)}.
*/
default void onSystemServerStarting(@NonNull SystemServerStartingParam param) {
}
}
+3 -3
View File
@@ -1,5 +1,5 @@
VERSION_CODE=623
VERSION_NAME=1.13.0-rc.6
GO_VERSION=go1.25.7
VERSION_CODE=662
VERSION_NAME=1.13.11
GO_VERSION=go1.25.9