diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 79a07b8..10085f0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -6,6 +6,8 @@
+
+
diff --git a/app/src/main/java/com/neodesktop/dmodem/modem/ModemService.kt b/app/src/main/java/com/neodesktop/dmodem/modem/ModemService.kt
index 242fc10..6e93ce5 100644
--- a/app/src/main/java/com/neodesktop/dmodem/modem/ModemService.kt
+++ b/app/src/main/java/com/neodesktop/dmodem/modem/ModemService.kt
@@ -53,6 +53,9 @@ class ModemService : Service() {
companion object {
private const val TAG = "ModemService"
+ private const val NO_LOCAL_NETWORK = "Android hasn't allowed D-Modem on the local network, so a SIP server " +
+ "there can't be reached (\"Operation not permitted\"): allow it in Android's settings, " +
+ "Apps > D-Modem > Permissions, then start the modem again"
private const val ACTION_START = "com.neodesktop.dmodem.START"
private const val ACTION_STOP = "com.neodesktop.dmodem.STOP"
/** the ringing call put out of sight (its notification's Ignore) */
@@ -182,6 +185,8 @@ class ModemService : Service() {
return
}
ModemState.setError(null)
+ // (not a failure: the SIP server may be on the internet, which needs no leave)
+ if (!settings.peer && !localNetworkAllowed()) log(NO_LOCAL_NETWORK)
ModemState.setRun(ModemState.Run.STARTING)
if (!startNative()) {
fail(ModemState.error.value ?: "the modem didn't start")
@@ -348,6 +353,8 @@ class ModemService : Service() {
private val nativeListener = object : NativeModem.Listener {
override fun onLog(line: String) {
ModemState.log.add(line)
+ // (what Android says when the LAN isn't the app's to reach)
+ if (line.endsWith("Operation not permitted") && !localNetworkAllowed()) log(NO_LOCAL_NETWORK)
}
override fun onStatus(status: NativeModem.Status) {
@@ -548,6 +555,12 @@ class ModemService : Service() {
}
}
+ /** whether the LAN may be reached: Android 17 asks the user (ACCESS_LOCAL_NETWORK); before, any app may */
+ private fun localNetworkAllowed(): Boolean =
+ android.os.Build.VERSION.SDK_INT < 37 ||
+ checkSelfPermission(android.Manifest.permission.ACCESS_LOCAL_NETWORK) ==
+ android.content.pm.PackageManager.PERMISSION_GRANTED
+
private fun log(line: String) {
Log.i(TAG, line)
ModemState.log.add("app: $line")
diff --git a/app/src/main/java/com/neodesktop/dmodem/ui/LogScreen.kt b/app/src/main/java/com/neodesktop/dmodem/ui/LogScreen.kt
index 3364c8b..937f762 100644
--- a/app/src/main/java/com/neodesktop/dmodem/ui/LogScreen.kt
+++ b/app/src/main/java/com/neodesktop/dmodem/ui/LogScreen.kt
@@ -2,13 +2,16 @@
// Copyright (C) 2026 Neo-Desktop
package com.neodesktop.dmodem.ui
+import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
+import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
@@ -16,6 +19,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalClipboardManager
+import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -30,10 +35,19 @@ fun LogScreen(modifier: Modifier = Modifier) {
if (lines.isNotEmpty()) state.scrollToItem(lines.size - 1)
}
Column(modifier.fillMaxSize().padding(8.dp)) {
- OutlinedButton(onClick = { ModemState.log.clear() }) { Text("Clear") }
- LazyColumn(state = state, modifier = Modifier.fillMaxWidth().weight(1f)) {
- items(lines) { l ->
- Text(l, fontFamily = FontFamily.Monospace, style = MaterialTheme.typography.bodySmall)
+ val clipboard = LocalClipboardManager.current
+ Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ OutlinedButton(onClick = { ModemState.log.clear() }) { Text("Clear") }
+ // (all of it, for a bug report; a line's text can be selected too)
+ OutlinedButton(onClick = { clipboard.setText(AnnotatedString(lines.joinToString("\n"))) }, enabled = lines.isNotEmpty()) {
+ Text("Copy")
+ }
+ }
+ SelectionContainer(Modifier.fillMaxWidth().weight(1f)) {
+ LazyColumn(state = state, modifier = Modifier.fillMaxSize()) {
+ items(lines) { l ->
+ Text(l, fontFamily = FontFamily.Monospace, style = MaterialTheme.typography.bodySmall)
+ }
}
}
}
diff --git a/app/src/main/java/com/neodesktop/dmodem/ui/MainActivity.kt b/app/src/main/java/com/neodesktop/dmodem/ui/MainActivity.kt
index cf8b6bd..6f541be 100644
--- a/app/src/main/java/com/neodesktop/dmodem/ui/MainActivity.kt
+++ b/app/src/main/java/com/neodesktop/dmodem/ui/MainActivity.kt
@@ -47,18 +47,18 @@ class MainActivity : ComponentActivity() {
/** a tab to go to, from outside the content (a call answered from its notification) */
private val goTo = kotlinx.coroutines.flow.MutableStateFlow(null)
- private val askNotifications =
- registerForActivityResult(ActivityResultContracts.RequestPermission()) { }
+ private val askPermissions =
+ registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
- if (Build.VERSION.SDK_INT >= 33 &&
- ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) !=
- PackageManager.PERMISSION_GRANTED
- ) {
- askNotifications.launch(Manifest.permission.POST_NOTIFICATIONS)
- }
+ // notifications, and the LAN (a SIP server, an SSH host, a bridge's client there: Android 17 asks)
+ val wanted = buildList {
+ if (Build.VERSION.SDK_INT >= 33) add(Manifest.permission.POST_NOTIFICATIONS)
+ if (Build.VERSION.SDK_INT >= 37) add(Manifest.permission.ACCESS_LOCAL_NETWORK)
+ }.filter { ContextCompat.checkSelfPermission(this, it) != PackageManager.PERMISSION_GRANTED }
+ if (wanted.isNotEmpty()) askPermissions.launch(wanted.toTypedArray())
// the internet host's service, if it was on (the app in the foreground now: it may start)
lifecycleScope.launch {
val b = com.neodesktop.dmodem.settings.BridgeSettingsStore(applicationContext).current()