Skip to content

A rootless Android app that boots Alpine Linux: run containers (Podman/Docker/LXC) and GUI desktop apps.

feat(settings): show Podroid's own forwards above the user's rules

ExTvbad2d1fba671
diff --git a/app/src/main/java/com/excp/podroid/ui/screens/settings/SettingsScreen.kt b/app/src/main/java/com/excp/podroid/ui/screens/settings/SettingsScreen.kt
index eb6ab94..ca3b48b 100644
--- a/app/src/main/java/com/excp/podroid/ui/screens/settings/SettingsScreen.kt
+++ b/app/src/main/java/com/excp/podroid/ui/screens/settings/SettingsScreen.kt
@@ -76,6 +76,8 @@ import com.excp.podroid.data.repository.PortForwardRule
import com.excp.podroid.engine.EngineSelection
import com.excp.podroid.engine.VmState
import com.excp.podroid.engine.avf.AvfDiagnostics
+import com.excp.podroid.service.PodroidService
+import com.excp.podroid.x11.X11Constants
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import androidx.compose.runtime.rememberCoroutineScope
@@ -282,6 +284,7 @@ fun SettingsScreen(
)
PortForwardSection(
rules = portForwardRules,
+ sshEnabled = ui.sshEnabled,
onAdd = { showAddDialog = true },
onRemove = { viewModel.removePortForward(it) },
)
@@ -523,6 +526,7 @@ fun SettingsScreen(
@Composable
private fun PortForwardSection(
rules: List<PortForwardRule>,
+ sshEnabled: Boolean,
onAdd: () -> Unit,
onRemove: (PortForwardRule) -> Unit,
) {
@@ -530,6 +534,31 @@ private fun PortForwardSection(
label = stringResource(R.string.port_forwards_count, rules.size),
rightSlot = { PodroidInlineAction(label = stringResource(R.string.add_btn), onClick = onAdd) },
)
+
+ // The forwards Podroid sets up itself. They never appear in the rule list
+ // because they are not user rules, which left people reading netstat in the
+ // guest and guessing what had claimed a port, or trying to add a rule on one
+ // and getting a refusal with no visible reason.
+ ReservedForwardRow(
+ hostPort = PodroidService.SSH_HOST_PORT,
+ guestPort = 22,
+ purpose = stringResource(
+ if (sshEnabled) R.string.port_forward_purpose_ssh else R.string.port_forward_purpose_ssh_off
+ ),
+ dimmed = !sshEnabled,
+ )
+ ReservedForwardRow(
+ hostPort = X11Constants.VNC_PORT,
+ guestPort = X11Constants.VNC_PORT,
+ purpose = stringResource(R.string.port_forward_purpose_vnc),
+ dimmed = false,
+ )
+ ReservedForwardRow(
+ hostPort = X11Constants.AUDIO_PORT,
+ guestPort = X11Constants.AUDIO_PORT,
+ purpose = stringResource(R.string.port_forward_purpose_audio),
+ dimmed = false,
+ )
rules.forEach { rule ->
key(rule.hostPort, rule.protocol) {
Row(
@@ -562,6 +591,41 @@ private fun PortForwardSection(
}
}
+/** One of Podroid's own forwards: shown for reference, with no delete action. */
+@Composable
+private fun ReservedForwardRow(
+ hostPort: Int,
+ guestPort: Int,
+ purpose: String,
+ dimmed: Boolean,
+) {
+ val tint = MaterialTheme.colorScheme.onSurfaceVariant
+ .copy(alpha = if (dimmed) 0.5f else 1f)
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(vertical = PodroidTokens.Spacing.SM),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.SpaceBetween,
+ ) {
+ Text(
+ text = "$hostPort → $guestPort (tcp)",
+ style = MaterialTheme.typography.bodyMedium,
+ color = tint,
+ fontFamily = PodroidTokens.mono(),
+ )
+ Text(
+ text = purpose,
+ style = MaterialTheme.typography.bodySmall,
+ color = tint,
+ )
+ }
+ HorizontalDivider(
+ color = MaterialTheme.colorScheme.outline,
+ thickness = 1.dp,
+ )
+}
+
/**
* Mirrors the setup wizard's storage-access toggle: turn it on and, if needed,
* jump straight to the system MANAGE_EXTERNAL_STORAGE grant screen.
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index ff8f54b..569251b 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -120,6 +120,10 @@
<string name="port_forward_table_full">端口转发已达上限 %1$d 条,请先删除一条。</string>
<string name="reset">重置</string>
<string name="remove">删除</string>
+ <string name="port_forward_purpose_ssh">SSH</string>
+ <string name="port_forward_purpose_ssh_off">SSH (已关闭)</string>
+ <string name="port_forward_purpose_vnc">桌面,仅限本机</string>
+ <string name="port_forward_purpose_audio">桌面音频,仅限本机</string>
<string name="port_forwards_count">端口转发 (%1$d)</string>
<string name="none">无</string>
<string name="active">活动</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b378c87..3713ff0 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -120,6 +120,10 @@
<string name="port_forward_table_full">Limit of %1$d port forwards reached. Remove one first.</string>
<string name="reset">Reset</string>
<string name="remove">Remove</string>
+ <string name="port_forward_purpose_ssh">SSH</string>
+ <string name="port_forward_purpose_ssh_off">SSH (off)</string>
+ <string name="port_forward_purpose_vnc">Desktop, this phone only</string>
+ <string name="port_forward_purpose_audio">Desktop audio, this phone only</string>
<string name="port_forwards_count">Port forwards (%1$d)</string>
<string name="none">None</string>
<string name="active">active</string>