From f2f1233ac9b272fe3f34264ecf028aa03cae3578 Mon Sep 17 00:00:00 2001 From: Waozi Date: Sat, 10 Oct 2026 12:06:10 -0300 Subject: [PATCH] Include app version, device and system in Lumi reports Lumi feedback context now carries the Inner Breeze version, platform, system version, device model and installed package (Android system properties, Linux os-release and DMI names), with no identifiers or user data, so the developer can see whether a newer release already fixes a report. The confirmation card says what is included, in every locale. --- CHANGELOG.md | 1 + Makefile | 10 ++ locales/cs.txt | 2 +- locales/de.txt | 2 +- locales/en.txt | 2 +- locales/es.txt | 2 +- locales/fr.txt | 2 +- locales/id.txt | 2 +- locales/it.txt | 2 +- locales/ja.txt | 2 +- locales/ko.txt | 2 +- locales/pt.txt | 2 +- locales/ru.txt | 2 +- locales/zh.txt | 2 +- src/cells/app_tools.zi | 15 ++- src/core/device_info.zi | 196 ++++++++++++++++++++++++++++++++++ tests/device_info_behavior.zi | 25 +++++ 17 files changed, 258 insertions(+), 13 deletions(-) create mode 100644 src/core/device_info.zi create mode 100644 tests/device_info_behavior.zi diff --git a/CHANGELOG.md b/CHANGELOG.md index a855d3a86..d235821bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [2.1.27] - 2026-10-10 ### Added - End a held breath from the minimized practice window with Breath, or a double tap. +- Feedback sent through Lumi includes the app version, device and system version, so the developer can tell you when an update already fixes it. ### Fixed - Picture-in-picture opens when you leave for another app or launcher during a practice. - Opening the picture-in-picture window returns to the running practice. diff --git a/Makefile b/Makefile index 8c446a1a6..5f03cf5de 100644 --- a/Makefile +++ b/Makefile @@ -3182,3 +3182,13 @@ lumi-feedback-delivery-test: $(ZIRAN_BIN) $(LIBOQS_A) | build-laws @sh tests/lumi_feedback_delivery_test.sh $(ZIRAN_BIN) $(LIBOQS_A) test: lumi-feedback-delivery-test + +# Lumi reports name the device, system and version (no identifiers). +.PHONY: device-info-test +device-info-test: $(ZIRAN_BIN) + @env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY $(ZIRAN_BIN) build --target=c --define PLATFORM_DESKTOP --root tests \ + --module-path src --module-path build/packages/ziran/std --entry device_info_behavior:Main --exe \ + -o build/device-info-test tests/device_info_behavior.zi + @build/device-info-test/device_info_behavior + +test: device-info-test diff --git a/locales/cs.txt b/locales/cs.txt index 040fbee81..0d7a3aed2 100644 --- a/locales/cs.txt +++ b/locales/cs.txt @@ -2358,7 +2358,7 @@ V tomto období není zaznamenána žádná aktivita. --- [lumi_feedback_confirm] -Odeslat tuto zpětnou vazbu vývojáři? +Odeslat tuto zpětnou vazbu vývojáři? Přiloží se verze aplikace, model zařízení a verze systému. --- [lumi_feedback_yes] diff --git a/locales/de.txt b/locales/de.txt index 82a5d9bb1..ecfeb2d2a 100644 --- a/locales/de.txt +++ b/locales/de.txt @@ -2358,7 +2358,7 @@ Keine aufgezeichnete Aktivität in diesem Zeitraum. --- [lumi_feedback_confirm] -Dieses Feedback an den Entwickler senden? +Dieses Feedback an den Entwickler senden? App-Version, Gerätemodell und Systemversion werden mitgesendet. --- [lumi_feedback_yes] diff --git a/locales/en.txt b/locales/en.txt index 4cfd7483a..f3611e9ef 100644 --- a/locales/en.txt +++ b/locales/en.txt @@ -2357,7 +2357,7 @@ No recorded activity in this period. --- [lumi_feedback_confirm] -Send this feedback to the developer? +Send this feedback to the developer? It includes your app version, device model and system version. --- [lumi_feedback_yes] diff --git a/locales/es.txt b/locales/es.txt index 1e917d10d..4174762fb 100644 --- a/locales/es.txt +++ b/locales/es.txt @@ -2358,7 +2358,7 @@ No hay actividad registrada en este período. --- [lumi_feedback_confirm] -¿Enviar estos comentarios al desarrollador? +¿Enviar estos comentarios al desarrollador? Incluyen la versión de la app, el modelo del dispositivo y la versión del sistema. --- [lumi_feedback_yes] diff --git a/locales/fr.txt b/locales/fr.txt index 1732abcef..fc0fe5b74 100644 --- a/locales/fr.txt +++ b/locales/fr.txt @@ -2358,7 +2358,7 @@ Aucune activité enregistrée sur cette période. --- [lumi_feedback_confirm] -Envoyer ces commentaires au développeur ? +Envoyer ces commentaires au développeur ? Ils incluent la version de l’app, le modèle de l’appareil et la version du système. --- [lumi_feedback_yes] diff --git a/locales/id.txt b/locales/id.txt index d300d43f5..a2985c5b6 100644 --- a/locales/id.txt +++ b/locales/id.txt @@ -2358,7 +2358,7 @@ Tidak ada aktivitas tercatat dalam periode ini. --- [lumi_feedback_confirm] -Kirim masukan ini kepada pengembang? +Kirim masukan ini kepada pengembang? Termasuk versi aplikasi, model perangkat, dan versi sistem. --- [lumi_feedback_yes] diff --git a/locales/it.txt b/locales/it.txt index 1fc47cb13..bee1f59f3 100644 --- a/locales/it.txt +++ b/locales/it.txt @@ -2358,7 +2358,7 @@ Nessuna attività registrata in questo periodo. --- [lumi_feedback_confirm] -Inviare questo feedback allo sviluppatore? +Inviare questo feedback allo sviluppatore? Include la versione dell’app, il modello del dispositivo e la versione del sistema. --- [lumi_feedback_yes] diff --git a/locales/ja.txt b/locales/ja.txt index 3fe52d756..6b759866e 100644 --- a/locales/ja.txt +++ b/locales/ja.txt @@ -2360,7 +2360,7 @@ WHMの最長息止め時間(秒) --- [lumi_feedback_confirm] -このフィードバックを開発者に送信しますか? +このフィードバックを開発者に送信しますか?アプリのバージョン、端末のモデル、システムのバージョンが含まれます。 --- [lumi_feedback_yes] diff --git a/locales/ko.txt b/locales/ko.txt index 96d94f785..dbeeccab2 100644 --- a/locales/ko.txt +++ b/locales/ko.txt @@ -2358,7 +2358,7 @@ WHM 시작 --- [lumi_feedback_confirm] -이 피드백을 개발자에게 보낼까요? +이 피드백을 개발자에게 보낼까요? 앱 버전, 기기 이름, 시스템 버전이 함께 전송됩니다. --- [lumi_feedback_yes] diff --git a/locales/pt.txt b/locales/pt.txt index 5f6aec41a..4fdeedaaa 100644 --- a/locales/pt.txt +++ b/locales/pt.txt @@ -2358,7 +2358,7 @@ Nenhuma atividade registrada neste período. --- [lumi_feedback_confirm] -Enviar este feedback ao desenvolvedor? +Enviar este feedback ao desenvolvedor? Ele inclui a versão do app, o modelo do dispositivo e a versão do sistema. --- [lumi_feedback_yes] diff --git a/locales/ru.txt b/locales/ru.txt index 9054e3b00..d54d50491 100644 --- a/locales/ru.txt +++ b/locales/ru.txt @@ -2358,7 +2358,7 @@ Inner Breeze бесплатное приложение с открытым ис --- [lumi_feedback_confirm] -Отправить этот отзыв разработчику? +Отправить этот отзыв разработчику? К нему прилагаются версия приложения, модель устройства и версия системы. --- [lumi_feedback_yes] diff --git a/locales/zh.txt b/locales/zh.txt index 8ab9c8f22..e1810c011 100644 --- a/locales/zh.txt +++ b/locales/zh.txt @@ -2358,7 +2358,7 @@ WHM 最长屏息时间(秒) --- [lumi_feedback_confirm] -将此反馈发送给开发者吗? +将此反馈发送给开发者吗?应用版本、设备名称和系统版本会一起发送。 --- [lumi_feedback_yes] diff --git a/src/cells/app_tools.zi b/src/cells/app_tools.zi index 03f1e7a37..875ef9859 100644 --- a/src/cells/app_tools.zi +++ b/src/cells/app_tools.zi @@ -28,6 +28,8 @@ #import, file "../app/assets.zi"; #import, file "../app/locale.zi"; #import, file "../app/text_buffers.zi"; +#import, file "../core/device_info.zi"; +#import, file "../core/version.zi"; #import, file "../app/exercise_types.zi"; #import, file "../practices/practice_registry.zi"; #import, file "../app/account_activity.zi"; @@ -78,8 +80,19 @@ AppToolContext :: (app: *InnerBreeze) -> string { AppFeedbackContext :: (app: *InnerBreeze) -> string { out: Vec(u8) // Reports carry diagnostics without copying diary, task or habit contents. - BuilderPrint(*out, "{\"screen\":%,\"apps\":%,\"theme\":\"%\",\"scale\":%}", + // The version, system and device let the developer check whether a newer + // release already fixes the problem. + BuilderPrint(*out, "{\"screen\":%,\"apps\":%,\"theme\":\"%\",\"scale\":%", app.breathing.screen, app.enabled_apps & CellsInstalledMask(), AppThemeName(app.theme_id), app.ui_scale_tenths) + details: DeviceDetails + DeviceDescribe(*details) + BuilderPrint(*out, ",\"version\":\"%\",\"platform\":\"%\",\"system\":", VersionString, DevicePlatform()) + LumiJsonString(*out, DeviceSystem(*details)) + BuilderPrint(*out, ",\"device\":") + LumiJsonString(*out, DeviceModel(*details)) + BuilderPrint(*out, ",\"package\":") + LumiJsonString(*out, DevicePackage(*details)) + BuilderPrint(*out, "}") return BuilderFinish(out) } diff --git a/src/core/device_info.zi b/src/core/device_info.zi new file mode 100644 index 000000000..949759ddb --- /dev/null +++ b/src/core/device_info.zi @@ -0,0 +1,196 @@ +// The phone or computer a Lumi report comes from and this build's version, so +// the developer can tell whether a newer release already fixes the problem. +// Only model, system and package names: never identifiers or user data. +#import "c_string" +#import "byte_text_linux" + +DEVICE_ANDROID :: #defined(ANDROID_BUILD) || #defined(PLATFORM_ANDROID) || #defined(__ANDROID__) +DEVICE_WEB :: #defined(PLATFORM_WEB) || #defined(__EMSCRIPTEN__) +DEVICE_WINDOWS :: #defined(_WIN32) +DEVICE_APPLE :: #defined(__APPLE__) + +DeviceDetails :: struct { + system: [128]u8 + device: [160]u8 + package: [96]u8 + sizes: [3]s32 +} + +device_c :: #system_library "c"; + +#if !DEVICE_WEB && !DEVICE_WINDOWS { + DeviceOpen :: (path: *u8, mode: *u8) -> *void #foreign device_c "fopen"; + DeviceRead :: (buffer: *u8, size: u64, count: u64, file: *void) -> u64 #foreign device_c "fread"; + DeviceClose :: (file: *void) -> s32 #foreign device_c "fclose"; + + // A small system file's first bytes, or 0 when it cannot be read. + DeviceFile :: (path: string, output: []u8) -> s32 { + name: [96]u8 + mode: [4]u8 + if !CopyCString(path, name[:]) || !CopyCString("rb", mode[:]) { + return 0 + } + file := DeviceOpen(*name[0], *mode[0]) + if file == null { + return 0 + } + count := DeviceRead(*output[0], 1, cast(u64)output.count, file) + unused DeviceClose(file) + return cast(s32)count + } +} + +#if DEVICE_ANDROID { + DeviceProperty :: (name: *u8, value: *u8) -> s32 #foreign device_c "__system_property_get"; + + DeviceAndroidProperty :: (name: string, output: []u8) -> string { + key: [48]u8 + // PROP_VALUE_MAX is 92 bytes including its terminator. + if output.count < 92 || !CopyCString(name, key[:]) { + return "" + } + size := DeviceProperty(*key[0], *output[0]) + if size <= 0 || cast(s64)size >= output.count { + return "" + } + return TextFromBytes(output[:size]) + } +} + +// Printable text only, so a report stays one readable line per field. +DeviceAppend :: (target: []u8, size: *s32, value: string) { + for byte: value { + if size.* >= cast(s32)target.count - 1 { + return + } + if byte >= cast(u8)32 && byte != cast(u8)127 { + target[size.*] = byte + size.* += 1 + } + } +} + +DeviceStartsWithFold :: (value: string, prefix: string) -> bool { + if prefix.count == 0 || prefix.count > value.count { + return false + } + for index: cast(s64)0..prefix.count - 1 { + a := value[index] + b := prefix[index] + if a >= cast(u8)65 && a <= cast(u8)90 { a += cast(u8)32 } + if b >= cast(u8)65 && b <= cast(u8)90 { b += cast(u8)32 } + if a != b { + return false + } + } + return true +} + +DevicePlatform :: () -> string { + platform := "linux" + #if DEVICE_ANDROID { + platform = "android" + } + #if DEVICE_WEB { + platform = "web" + } + #if DEVICE_WINDOWS { + platform = "windows" + } + #if DEVICE_APPLE { + platform = "macos" + } + return platform +} + +// Views into the caller's details, which outlive the returned text. +DeviceSystem :: (details: *DeviceDetails) -> string { + return TextFromBytes(BytesFromPointer(*details.system[0], cast(u64)details.sizes[0])) +} +DeviceModel :: (details: *DeviceDetails) -> string { + return TextFromBytes(BytesFromPointer(*details.device[0], cast(u64)details.sizes[1])) +} +DevicePackage :: (details: *DeviceDetails) -> string { + return TextFromBytes(BytesFromPointer(*details.package[0], cast(u64)details.sizes[2])) +} + +// Linux: os-release's PRETTY_NAME, unquoted. +DeviceReleaseName :: (text: string) -> string { + at: s64 = 0 + while at < text.count { + end := at + while end < text.count && text[end] != cast(u8)10 { end += 1 } + line := text[at:end] + if line.count > 12 && DeviceStartsWithFold(line, "PRETTY_NAME=") { + value := line[12:] + if value.count >= 2 && (value[0] == cast(u8)34 || value[0] == cast(u8)39) && value[value.count - 1] == value[0] { + value = value[1:value.count - 1] + } + return value + } + at = end + 1 + } + return "" +} + +DeviceDescribe :: (details: *DeviceDetails) { + details.* = .{} + #if DEVICE_ANDROID { + manufacturer: [96]u8 + model: [96]u8 + release: [96]u8 + sdk: [96]u8 + maker := DeviceAndroidProperty("ro.product.manufacturer", manufacturer[:]) + name := DeviceAndroidProperty("ro.product.model", model[:]) + if maker.count > 0 && !DeviceStartsWithFold(name, maker) { + DeviceAppend(details.device[:], *details.sizes[1], maker) + DeviceAppend(details.device[:], *details.sizes[1], " ") + } + DeviceAppend(details.device[:], *details.sizes[1], name) + DeviceAppend(details.system[:], *details.sizes[0], "Android ") + DeviceAppend(details.system[:], *details.sizes[0], DeviceAndroidProperty("ro.build.version.release", release[:])) + level := DeviceAndroidProperty("ro.build.version.sdk", sdk[:]) + if level.count > 0 { + DeviceAppend(details.system[:], *details.sizes[0], " (SDK ") + DeviceAppend(details.system[:], *details.sizes[0], level) + DeviceAppend(details.system[:], *details.sizes[0], ")") + } + // The process name is the installed package, which tells a debug + // build (xyz.waozi.inbe.debug) from a release. + command: [96]u8 + read := DeviceFile("/proc/self/cmdline", command[:]) + end: s32 = 0 + while end < read && command[end] != 0 { end += 1 } + DeviceAppend(details.package[:], *details.sizes[2], TextFromBytes(command[:end])) + return + } + #if DEVICE_WEB { + DeviceAppend(details.system[:], *details.sizes[0], "Web browser") + return + } + #if DEVICE_WINDOWS { + DeviceAppend(details.system[:], *details.sizes[0], "Windows") + return + } + #if DEVICE_APPLE { + DeviceAppend(details.system[:], *details.sizes[0], "macOS") + return + } + #if !DEVICE_ANDROID && !DEVICE_WEB && !DEVICE_WINDOWS && !DEVICE_APPLE { + release: [1024]u8 + read := DeviceFile("/etc/os-release", release[:]) + name := DeviceReleaseName(TextFromBytes(release[:read])) + DeviceAppend(details.system[:], *details.sizes[0], ifx name.count > 0 then name else "Linux") + vendor: [96]u8 + product: [96]u8 + vendor_size := DeviceFile("/sys/devices/virtual/dmi/id/sys_vendor", vendor[:]) + product_size := DeviceFile("/sys/devices/virtual/dmi/id/product_name", product[:]) + while vendor_size > 0 && vendor[vendor_size - 1] <= cast(u8)32 { vendor_size -= 1 } + while product_size > 0 && product[product_size - 1] <= cast(u8)32 { product_size -= 1 } + DeviceAppend(details.device[:], *details.sizes[1], TextFromBytes(vendor[:vendor_size])) + if vendor_size > 0 && product_size > 0 { + DeviceAppend(details.device[:], *details.sizes[1], " ") + } + DeviceAppend(details.device[:], *details.sizes[1], TextFromBytes(product[:product_size])) + } +} diff --git a/tests/device_info_behavior.zi b/tests/device_info_behavior.zi new file mode 100644 index 000000000..2b20a98a9 --- /dev/null +++ b/tests/device_info_behavior.zi @@ -0,0 +1,25 @@ +// Lumi reports name the device, system and version; never identifiers. +#import "c_string" +#import "byte_text_linux" +#import, file "../src/core/device_info.zi"; +#import, file "../src/core/version.zi"; + +Fail :: (message: string) -> s32 { print("FAIL %\n", message); return 1 } + +Check :: () -> s32 { + if DeviceReleaseName("NAME=Debian\nPRETTY_NAME=\"Debian GNU/Linux 13 (trixie)\"\nID=debian\n") != "Debian GNU/Linux 13 (trixie)" { return Fail("os-release name") } + if DeviceReleaseName("ID=arch\n") != "" { return Fail("missing os-release name") } + if !DeviceStartsWithFold("Google Pixel 3a", "google") || DeviceStartsWithFold("Pixel", "Google") { return Fail("maker prefix") } + details: DeviceDetails + DeviceDescribe(*details) + if DevicePlatform() != "linux" || DeviceSystem(*details).count == 0 { return Fail("desktop system") } + for byte: DeviceModel(*details) { if byte < cast(u8)32 { return Fail("control byte in device") } } + clipped: [8]u8 + size: s32 = 0 + DeviceAppend(clipped[:], *size, "a\nbcdefghijk") + if TextFromBytes(clipped[:size]) != "abcdefg" { return Fail("bounded printable append") } + print("device: % · % · %\n", DeviceModel(*details), DeviceSystem(*details), VersionString) + return 0 +} + +Main :: () -> s32 { return Check() }