Merge 8387c2de0025ce490172714f9d14d347746b8796 into 598f1826d8b2bc969aace2c6459824737667218c

This commit is contained in:
Goweii 2026-03-20 21:08:31 -07:00 committed by GitHub
commit fd59876e03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 9 deletions

View File

@ -63,7 +63,7 @@ android {
defaultConfig {
applicationId = "ai.openclaw.app"
minSdk = 31
minSdk = 26
targetSdk = 36
versionCode = 2026032000
versionName = "2026.3.20"

View File

@ -8,6 +8,7 @@ import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.ServiceInfo
import android.os.Build
import androidx.core.app.NotificationCompat
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@ -137,7 +138,12 @@ class NodeForegroundService : Service() {
updateNotification(notification)
return
}
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC)
} else {
@Suppress("DEPRECATION")
startForeground(NOTIFICATION_ID, notification)
}
didStartForeground = true
}

View File

@ -6,8 +6,10 @@ import android.net.DnsResolver
import android.net.NetworkCapabilities
import android.net.nsd.NsdManager
import android.net.nsd.NsdServiceInfo
import android.os.Build
import android.os.CancellationSignal
import android.util.Log
import androidx.annotation.RequiresApi
import java.io.IOException
import java.net.InetSocketAddress
import java.nio.ByteBuffer
@ -50,7 +52,7 @@ class GatewayDiscovery(
) {
private val nsd = context.getSystemService(NsdManager::class.java)
private val connectivity = context.getSystemService(ConnectivityManager::class.java)
private val dns = DnsResolver.getInstance()
private val dns = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) DnsResolver.getInstance() else null
private val serviceType = "_openclaw-gw._tcp."
private val wideAreaDomain = System.getenv("OPENCLAW_WIDE_AREA_DOMAIN")
private val logTag = "OpenClaw/GatewayDiscovery"
@ -321,8 +323,11 @@ class GatewayDiscovery(
return null
}
val system = queryViaSystemDns(query)
if (records(system, Section.ANSWER).any { it.type == type }) return system
val system = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val system = queryViaSystemDns(query)
if (records(system, Section.ANSWER).any { it.type == type }) return system
system
} else null
val direct = createDirectResolver() ?: return system
return try {
@ -333,6 +338,7 @@ class GatewayDiscovery(
}
}
@RequiresApi(Build.VERSION_CODES.Q)
private suspend fun queryViaSystemDns(query: Message): Message? {
val network = preferredDnsNetwork()
val bytes =
@ -439,11 +445,12 @@ class GatewayDiscovery(
}
}
private suspend fun rawQuery(network: android.net.Network?, wireQuery: ByteArray): ByteArray =
suspendCancellableCoroutine { cont ->
@RequiresApi(Build.VERSION_CODES.Q)
private suspend fun rawQuery(network: android.net.Network?, wireQuery: ByteArray): ByteArray {
val dns = this.dns ?: throw IOException("DnsResolver not available on this platform")
return suspendCancellableCoroutine { cont ->
val signal = CancellationSignal()
cont.invokeOnCancellation { signal.cancel() }
dns.rawQuery(
network,
wireQuery,
@ -461,6 +468,7 @@ class GatewayDiscovery(
},
)
}
}
private fun txtValue(records: List<TXTRecord>, key: String): String? {
val prefix = "$key="

View File

@ -1,7 +1,12 @@
package ai.openclaw.app.ui
import android.content.Context
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.runtime.Composable
@ -13,7 +18,7 @@ import androidx.compose.ui.platform.LocalContext
fun OpenClawTheme(content: @Composable () -> Unit) {
val context = LocalContext.current
val isDark = isSystemInDarkTheme()
val colorScheme = if (isDark) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
val colorScheme = colorScheme(context, isDark)
val mobileColors = if (isDark) darkMobileColors() else lightMobileColors()
CompositionLocalProvider(LocalMobileColors provides mobileColors) {
@ -21,6 +26,19 @@ fun OpenClawTheme(content: @Composable () -> Unit) {
}
}
private fun colorScheme(context: Context, isDark: Boolean): ColorScheme {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
return when {
isDark -> dynamicDarkColorScheme(context)
else -> dynamicLightColorScheme(context)
}
}
return when {
isDark -> darkColorScheme()
else -> lightColorScheme()
}
}
@Composable
fun overlayContainerColor(): Color {
val scheme = MaterialTheme.colorScheme