Compare commits

...

3 Commits

Author SHA1 Message Date
Adam Gastineau
e1a344b882 Properly rethrow HTTP errors 2025-11-17 21:23:09 -08:00
Adam Gastineau
215825dcbb Add script to restart whole SDK from host 2025-10-12 18:46:00 -07:00
Adam Gastineau
b04ef40746 Disable web server temperature monitoring to view CPU impact 2025-10-12 07:16:19 -07:00
3 changed files with 21 additions and 8 deletions

View File

@ -125,7 +125,8 @@ class SettingsRegistry(
// Reference to web server for broadcasting (set by SettingsService)
private var webServer: SettingsWebServer? = null
private val _settingsFlow = MutableStateFlow<SettingsUpdate>(SettingsUpdate(emptyMap(), emptyList()))
private val _settingsFlow =
MutableStateFlow<SettingsUpdate>(SettingsUpdate(emptyMap(), emptyList()))
val settingsFlow: StateFlow<SettingsUpdate> = _settingsFlow.asStateFlow()
private val json = Json {
@ -136,7 +137,7 @@ class SettingsRegistry(
init {
loadSavedSettings()
initializeSystemSettingsSync()
setupTemperatureMonitoring()
// setupTemperatureMonitoring()
}
suspend fun initialize() {
@ -353,7 +354,7 @@ class SettingsRegistry(
suspend fun updateSystemSetting(key: String, value: Any): Boolean {
if (validateSystemSetting(key, value)) {
val previousValue = systemSettings[key]
// Apply the setting to Android system if it's a system setting
val success = if (isAndroidSystemSetting(key)) {
applyAndroidSystemSetting(key, value)
@ -612,7 +613,8 @@ class SettingsRegistry(
temperatureController.temperatureFlow.collect { temperature ->
val previousValue = systemSettings["device.temperature"]
systemSettings["device.temperature"] = temperature
val change = SettingChange("system", "", "device.temperature", temperature, previousValue)
val change =
SettingChange("system", "", "device.temperature", temperature, previousValue)
updateSettingsFlow(listOf(change))
}
}

8
scripts/restart-sdk.sh Executable file
View File

@ -0,0 +1,8 @@
adb shell /data/local/tmp/bin/pinitd-cli stop bridge-settings-service
adb shell /data/local/tmp/bin/pinitd-cli stop bridge-shell-service
adb shell /data/local/tmp/bin/pinitd-cli stop bridge-system-service
adb shell /data/local/tmp/bin/pinitd-cli restart bridge-service
adb shell /data/local/tmp/bin/pinitd-cli start bridge-settings-service
adb shell /data/local/tmp/bin/pinitd-cli start bridge-shell-service
adb shell /data/local/tmp/bin/pinitd-cli start bridge-system-service

View File

@ -20,7 +20,6 @@ import io.ktor.util.AttributeKey
import io.ktor.util.date.GMTDate
import io.ktor.utils.io.ByteChannel
import io.ktor.utils.io.InternalAPI
import io.ktor.utils.io.close
import io.ktor.utils.io.writeStringUtf8
/**
@ -91,24 +90,28 @@ class HttpClientPlugin(private val penumbraClient: PenumbraClient) {
}
is HttpStreamResponse.Complete -> {
Log.i("HttpClientPlugin", "Stream complete")
streamingByteChannel.flushAndClose()
}
is HttpStreamResponse.Error -> {
streamingByteChannel.close(RuntimeException("Stream error: ${response.message}"))
Log.e("HttpClientPlugin", "Stream error: ${response.message}")
streamingByteChannel.close()
throw RuntimeException("Stream error: ${response.message}")
}
}
}
} catch (e: Exception) {
Log.e("HttpClientPlugin", "Exception in streaming flow", e)
streamingByteChannel.close(e)
streamingByteChannel.close()
throw e
}
val headersList = mutableListOf<Pair<String, List<String>>>()
for (header in headers) {
headersList.add(Pair(header.key, listOf(header.value)))
}
HttpClientCall(
scope,
request.build(),