From 4d058d87aebaa1d3d47a835559dfa0fe0d8b7b74 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ishii Date: Mon, 7 Oct 2024 16:25:28 +0900 Subject: Settings: Parse version strings from text files Version strings displayed on the settings page were tentatively implemented as constant strings and were not updated. Let's implement a small piece of code to parse text files, similar to how the Qt-version of settings app did. Bug-AGL: SPEC-5256 Change-Id: I6d3669bff5299c818c3a9f1c5439ddf1ab952760 Signed-off-by: Hiroyuki Ishii --- lib/core/constants/constants.dart | 2 -- .../version_info/version_info_screend.dart | 30 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/core/constants/constants.dart b/lib/core/constants/constants.dart index 65aa680..edee874 100644 --- a/lib/core/constants/constants.dart +++ b/lib/core/constants/constants.dart @@ -2,8 +2,6 @@ import '../../export.dart'; const splashWarning = 'Please use the IVI system responsibly while driving. Keep your attention on the road, and use voice commands or hands-free controls when interacting with the system. Distracted driving can lead to accidents and serious injury. Follow all traffic laws and drive safely.'; -const aglVeriosn = 'AGL 16.0.2 (pike)'; -const kernelVeriosn = 'Kernel: 5.10.41.-yocto-standard'; const maxFuelLevel = 100.0; const maxSpeed = 240.0; const maxRpm = 8000; diff --git a/lib/presentation/screens/settings/settings_screens/version_info/version_info_screend.dart b/lib/presentation/screens/settings/settings_screens/version_info/version_info_screend.dart index fce1837..c5e571d 100644 --- a/lib/presentation/screens/settings/settings_screens/version_info/version_info_screend.dart +++ b/lib/presentation/screens/settings/settings_screens/version_info/version_info_screend.dart @@ -1,6 +1,32 @@ import 'package:flutter_ics_homescreen/export.dart'; class VersionInfoPage extends ConsumerWidget { + static String aglVersionFilePath = '/etc/os-release'; + static String kernelVersionFilePath = '/proc/version'; + + static String aglVersion() { + try { + final file = File(aglVersionFilePath); + final data = file.readAsStringSync().split("\n"); + if (!data[1].contains('Automotive Grade Linux')) { + throw 'Non-AGL distribution'; + } + return "AGL: " + data[2].split('"')[1]; + } catch (_) { + return ''; + } + } + + static String kernelVersion() { + try { + final file = File(kernelVersionFilePath); + final data = file.readAsStringSync().split(" "); + return "Kernel: " + data[2]; + } catch (_) { + return ''; + } + } + const VersionInfoPage({super.key}); static Page page() => @@ -43,7 +69,7 @@ class VersionInfoPage extends ConsumerWidget { child: ListTile( contentPadding: const EdgeInsets.only(top: 50, left: 25), leading: Text( - aglVeriosn, + aglVersion(), style: Theme.of(context).textTheme.titleMedium, ), ), @@ -64,7 +90,7 @@ class VersionInfoPage extends ConsumerWidget { contentPadding: const EdgeInsets.only(top: 50, left: 25), leading: Text( - kernelVeriosn, + kernelVersion(), style: Theme.of(context).textTheme.titleMedium, ), ), -- cgit 1.2.3-korg