From a4360399b386ae9b9c592afad617be4a3780b4c9 Mon Sep 17 00:00:00 2001 From: crc-32 Date: Fri, 29 Nov 2024 17:50:01 +0000 Subject: [PATCH] truncate timezone ID if too long --- .../bridges/ui/FirmwareUpdateControlFlutterBridge.kt | 3 ++- .../io/rebble/cobble/shared/handlers/SystemHandler.kt | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/kotlin/io/rebble/cobble/bridges/ui/FirmwareUpdateControlFlutterBridge.kt b/android/app/src/main/kotlin/io/rebble/cobble/bridges/ui/FirmwareUpdateControlFlutterBridge.kt index 13322610..bfe8769a 100644 --- a/android/app/src/main/kotlin/io/rebble/cobble/bridges/ui/FirmwareUpdateControlFlutterBridge.kt +++ b/android/app/src/main/kotlin/io/rebble/cobble/bridges/ui/FirmwareUpdateControlFlutterBridge.kt @@ -8,6 +8,7 @@ import io.rebble.cobble.pigeons.BooleanWrapper import io.rebble.cobble.pigeons.Pigeons import io.rebble.cobble.shared.domain.state.ConnectionStateManager import io.rebble.cobble.shared.domain.state.watchOrNull +import io.rebble.cobble.shared.handlers.SystemHandler import io.rebble.cobble.shared.util.zippedSource import io.rebble.cobble.util.launchPigeonResult import io.rebble.libpebblecommon.metadata.WatchHardwarePlatform @@ -84,7 +85,7 @@ class FirmwareUpdateControlFlutterBridge @Inject constructor( val updateTimePacket = TimeMessage.SetUTC( now.toUInt(), offsetMinutes.toShort(), - timezone.id + timezone.id.take(SystemHandler.MAX_TIMEZONE_NAME_LENGTH) ) ConnectionStateManager.connectionState.value.watchOrNull?.systemService?.send(updateTimePacket) diff --git a/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/handlers/SystemHandler.kt b/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/handlers/SystemHandler.kt index e32a0801..a5aa83fb 100644 --- a/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/handlers/SystemHandler.kt +++ b/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/handlers/SystemHandler.kt @@ -39,6 +39,10 @@ class SystemHandler( } } + companion object { + const val MAX_TIMEZONE_NAME_LENGTH = 32 + } + fun negotiationsComplete(watch: PebbleDevice) { if (ConnectionStateManager.connectionState.value is ConnectionState.Negotiating) { ConnectionStateManager.connectionState.value = ConnectionState.Connected(watch) @@ -118,11 +122,11 @@ class SystemHandler( val timezone = TimeZone.currentSystemDefault() val now = Clock.System.now() val timezoneOffsetMinutes = timezone.offsetAt(now).totalSeconds.seconds.inWholeMinutes - Logging.i("Sending current time to watch: $now, timezone: $timezone, offset: $timezoneOffsetMinutes") + Logging.i("Sending current time to watch: $now, timezone: ${timezone.id} (truncated: ${timezone.id.take(MAX_TIMEZONE_NAME_LENGTH)}), offset: $timezoneOffsetMinutes") val updateTimePacket = TimeMessage.SetUTC( now.epochSeconds.toUInt(), timezoneOffsetMinutes.toShort(), - timezone.id + timezone.id.take(MAX_TIMEZONE_NAME_LENGTH) ) systemService.send(updateTimePacket)