-
Notifications
You must be signed in to change notification settings - Fork 0
Add GPU driver support and sensors features #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
65fe0a0
1f87430
fd09517
3aae569
c7bc616
a9309e0
6e57741
3b1e30d
6476d98
293b403
720b9f8
c96dc58
e257f2c
53b3376
8ffff87
d577e67
d873552
7416520
36b680c
4f6ff6e
68ed060
3750f80
374e987
4d51b92
9da8f06
52dbf59
521c5fd
c5be440
59844df
a64deda
5c68ec0
a3bc75c
be0d758
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package com.droidspaces.app.ui.component | ||
|
|
||
| import androidx.compose.foundation.clickable | ||
| import androidx.compose.foundation.layout.* | ||
| import androidx.compose.material.icons.Icons | ||
| import androidx.compose.material.icons.filled.Wifi | ||
| import androidx.compose.material3.* | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.text.font.FontWeight | ||
| import androidx.compose.ui.unit.dp | ||
| import com.droidspaces.app.R | ||
|
|
||
| @Composable | ||
| fun NetworkModeSelector( | ||
| networkMode: String, | ||
| onModeSelected: (String) -> Unit | ||
| ) { | ||
| Card( | ||
| colors = CardDefaults.cardColors( | ||
| containerColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f) | ||
| ), | ||
| modifier = Modifier.fillMaxWidth() | ||
| ) { | ||
| Column( | ||
| modifier = Modifier.padding(16.dp) | ||
| ) { | ||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| Icon( | ||
| imageVector = Icons.Default.Wifi, | ||
| contentDescription = null, | ||
| tint = MaterialTheme.colorScheme.primary | ||
| ) | ||
| Spacer(modifier = Modifier.width(16.dp)) | ||
| Column { | ||
| Text( | ||
| text = stringResource(R.string.network_mode_title), | ||
| style = MaterialTheme.typography.titleMedium, | ||
| fontWeight = FontWeight.SemiBold | ||
| ) | ||
| Text( | ||
| text = stringResource(R.string.network_mode_description), | ||
| style = MaterialTheme.typography.bodySmall, | ||
| color = MaterialTheme.colorScheme.onSurfaceVariant | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| Spacer(modifier = Modifier.height(8.dp)) | ||
|
|
||
| val modes = listOf( | ||
| "host" to stringResource(R.string.network_mode_host), | ||
| "nat" to stringResource(R.string.network_mode_nat), | ||
| "macvlan" to stringResource(R.string.network_mode_macvlan) | ||
| ) | ||
|
|
||
| modes.forEach { (mode, label) -> | ||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .padding(vertical = 4.dp) | ||
| .clickable { onModeSelected(mode) } | ||
| ) { | ||
| RadioButton( | ||
| selected = (networkMode == mode), | ||
| onClick = { onModeSelected(mode) } | ||
| ) | ||
| Text( | ||
| text = label, | ||
| style = MaterialTheme.typography.bodyMedium, | ||
| modifier = Modifier.padding(start = 8.dp) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,12 @@ class ContainerInstallationViewModel : ViewModel() { | |
| var enableHwAccess: Boolean by mutableStateOf(false) | ||
| private set | ||
|
|
||
| var enableSensors: Boolean by mutableStateOf(false) | ||
| private set | ||
|
|
||
| var networkMode: String by mutableStateOf("host") | ||
| private set | ||
|
Comment on lines
+37
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate
🔧 Proposed fix (whitelist + normalization + safe fallback) class ContainerInstallationViewModel : ViewModel() {
+ private val allowedNetworkModes = setOf("host", "nat", "macvlan")
+ private val defaultNetworkMode = "host"
+
var tarballUri: Uri? by mutableStateOf(null)
private set
@@
- var networkMode: String by mutableStateOf("host")
+ var networkMode: String by mutableStateOf(defaultNetworkMode)
private set
@@
- this.networkMode = networkMode
+ val normalizedNetworkMode = networkMode.trim().lowercase()
+ this.networkMode = if (normalizedNetworkMode in allowedNetworkModes) {
+ normalizedNetworkMode
+ } else {
+ defaultNetworkMode
+ }
@@
- networkMode = "host"
+ networkMode = defaultNetworkModeAlso applies to: 80-81, 91-91, 115-115, 135-135 🤖 Prompt for AI Agents |
||
|
|
||
| var selinuxPermissive: Boolean by mutableStateOf(false) | ||
| private set | ||
|
|
||
|
|
@@ -70,6 +76,8 @@ class ContainerInstallationViewModel : ViewModel() { | |
| enableIPv6: Boolean, | ||
| enableAndroidStorage: Boolean, | ||
| enableHwAccess: Boolean, | ||
| enableSensors: Boolean, | ||
| networkMode: String, | ||
| selinuxPermissive: Boolean, | ||
| volatileMode: Boolean, | ||
| bindMounts: List<BindMount>, | ||
|
|
@@ -79,6 +87,8 @@ class ContainerInstallationViewModel : ViewModel() { | |
| this.enableIPv6 = enableIPv6 | ||
| this.enableAndroidStorage = enableAndroidStorage | ||
| this.enableHwAccess = enableHwAccess | ||
| this.enableSensors = enableSensors | ||
| this.networkMode = networkMode | ||
| this.selinuxPermissive = selinuxPermissive | ||
| this.volatileMode = volatileMode | ||
| this.bindMounts = bindMounts | ||
|
|
@@ -101,6 +111,8 @@ class ContainerInstallationViewModel : ViewModel() { | |
| enableIPv6 = enableIPv6, | ||
| enableAndroidStorage = enableAndroidStorage, | ||
| enableHwAccess = enableHwAccess, | ||
| enableSensors = enableSensors, | ||
| networkMode = networkMode, | ||
| selinuxPermissive = selinuxPermissive, | ||
| volatileMode = volatileMode, | ||
| bindMounts = bindMounts, | ||
|
|
@@ -119,6 +131,8 @@ class ContainerInstallationViewModel : ViewModel() { | |
| enableIPv6 = false | ||
| enableAndroidStorage = false | ||
| enableHwAccess = false | ||
| enableSensors = false | ||
| networkMode = "host" | ||
| selinuxPermissive = false | ||
| volatileMode = false | ||
| bindMounts = emptyList() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential source of Kotlin compilation issues — refactor nullability handling.
The
targetStoreFileis avar, which prevents Kotlin smart-casting after null checks. The current code uses!!assertions which are error-prone and may be related to the pipeline's "Kotlin type errors."Consider using a local
valto capture the store file safely:🔧 Suggested refactor for safer nullability handling
val debugConfig = getByName("debug") - var targetStoreFile = debugConfig.storeFile - - if (targetStoreFile == null || !targetStoreFile!!.exists()) { + val configuredStoreFile = debugConfig.storeFile + val targetStoreFile: File? = if (configuredStoreFile == null || !configuredStoreFile.exists()) { val localKeystore = rootProject.file("debug.keystore") if (!localKeystore.exists()) { println("Generating temporary debug keystore at ${localKeystore.absolutePath}...") try { exec { commandLine("keytool", "-genkey", "-v", "-keystore", localKeystore.absolutePath, "-storepass", "android", "-alias", "androiddebugkey", "-keypass", "android", "-keyalg", "RSA", "-keysize", "2048", "-validity", "10000", "-dname", "CN=Android Debug,O=Android,C=US") } } catch (e: Exception) { println("Warning: Failed to generate debug keystore: ${e.message}") } } - targetStoreFile = localKeystore - } + localKeystore + } else { + configuredStoreFile + } getByName("debug") { - if (targetStoreFile != null && targetStoreFile!!.exists()) { + if (targetStoreFile != null && targetStoreFile.exists()) { storeFile = targetStoreFile }🤖 Prompt for AI Agents