From f7e7b0b60c2e91865cc9fd1c18eaa7eb88ff9879 Mon Sep 17 00:00:00 2001 From: goenning Date: Tue, 28 Mar 2023 18:11:54 +0100 Subject: [PATCH 1/5] add major, minor and patch versions to macos --- .../lib/src/model/macos_device_info.dart | 15 +++++++++++++++ .../macos/Classes/DeviceInfoPlusMacosPlugin.swift | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/packages/device_info_plus/device_info_plus/lib/src/model/macos_device_info.dart b/packages/device_info_plus/device_info_plus/lib/src/model/macos_device_info.dart index cf7035f996..40f9354557 100644 --- a/packages/device_info_plus/device_info_plus/lib/src/model/macos_device_info.dart +++ b/packages/device_info_plus/device_info_plus/lib/src/model/macos_device_info.dart @@ -15,6 +15,9 @@ class MacOsDeviceInfo extends BaseDeviceInfo { required this.model, required this.kernelVersion, required this.osRelease, + required this.majorVersion, + required this.minorVersion, + required this.patchVersion, required this.activeCPUs, required this.memorySize, required this.cpuFrequency, @@ -43,6 +46,15 @@ class MacOsDeviceInfo extends BaseDeviceInfo { /// Operating system release number final String osRelease; + /// The major release number, such as 10 in version 10.9.3. + final String majorVersion; + + /// The minor release number, such as 9 in version 10.9.3. + final String minorVersion; + + /// The update release number, such as 3 in version 10.9.3. + final String patchVersion; + /// Number of active CPUs final int activeCPUs; @@ -65,6 +77,9 @@ class MacOsDeviceInfo extends BaseDeviceInfo { model: map['model'], kernelVersion: map['kernelVersion'], osRelease: map['osRelease'], + majorVersion: map['majorVersion'], + minorVersion: map['minorVersion'], + patchVersion: map['patchVersion'], activeCPUs: map['activeCPUs'], memorySize: map['memorySize'], cpuFrequency: map['cpuFrequency'], diff --git a/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift b/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift index e2a0e0c275..7f4864afd9 100644 --- a/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift +++ b/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift @@ -18,12 +18,17 @@ public class DeviceInfoPlusMacosPlugin: NSObject, FlutterPlugin { } private func handleDeviceInfo(result: @escaping FlutterResult)-> Void{ + let osVersion = ProcessInfo.processInfo.operatingSystemVersion; + let computerName = Host.current().localizedName ?? Sysctl.hostName let hostName = Sysctl.osType let arch = Sysctl.machine let model = Sysctl.model let kernelVersion = Sysctl.version let osRelease = ProcessInfo.processInfo.operatingSystemVersionString + let majorVersion = osVersion.majorVersion, + let minorVersion = osVersion.minorVersion, + let patchVersion = osVersion.patchVersion, let activeCPUs = Sysctl.activeCPUs let memorySize = Sysctl.memSize let cpuFrequency = Sysctl.cpuFreq @@ -36,6 +41,9 @@ public class DeviceInfoPlusMacosPlugin: NSObject, FlutterPlugin { "model": model, "kernelVersion": kernelVersion, "osRelease": osRelease, + "majorVersion": majorVersion, + "minorVersion": minorVersion, + "patchVersion": patchVersion, "activeCPUs": activeCPUs, "memorySize": memorySize, "cpuFrequency": cpuFrequency, From 2721f74e8938c0ccc2bb134a61318a5f6ecab471 Mon Sep 17 00:00:00 2001 From: goenning Date: Tue, 28 Mar 2023 18:18:08 +0100 Subject: [PATCH 2/5] fix tests --- .../device_info_plus/lib/src/model/macos_device_info.dart | 6 +++--- .../device_info_plus/test/model/macos_device_info_test.dart | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/device_info_plus/device_info_plus/lib/src/model/macos_device_info.dart b/packages/device_info_plus/device_info_plus/lib/src/model/macos_device_info.dart index 40f9354557..40d3d75e10 100644 --- a/packages/device_info_plus/device_info_plus/lib/src/model/macos_device_info.dart +++ b/packages/device_info_plus/device_info_plus/lib/src/model/macos_device_info.dart @@ -47,13 +47,13 @@ class MacOsDeviceInfo extends BaseDeviceInfo { final String osRelease; /// The major release number, such as 10 in version 10.9.3. - final String majorVersion; + final int majorVersion; /// The minor release number, such as 9 in version 10.9.3. - final String minorVersion; + final int minorVersion; /// The update release number, such as 3 in version 10.9.3. - final String patchVersion; + final int patchVersion; /// Number of active CPUs final int activeCPUs; diff --git a/packages/device_info_plus/device_info_plus/test/model/macos_device_info_test.dart b/packages/device_info_plus/device_info_plus/test/model/macos_device_info_test.dart index 3969da3181..0f466608e5 100644 --- a/packages/device_info_plus/device_info_plus/test/model/macos_device_info_test.dart +++ b/packages/device_info_plus/device_info_plus/test/model/macos_device_info_test.dart @@ -14,6 +14,9 @@ void main() { 'cpuFrequency': 2, 'hostName': 'hostName', 'osRelease': 'osRelease', + 'majorVersion': 10, + 'minorVersion': 9, + 'patchVersion': 3, 'computerName': 'computerName', 'kernelVersion': 'kernelVersion', 'systemGUID': null, @@ -29,6 +32,9 @@ void main() { expect(macosDeviceInfo.cpuFrequency, 2); expect(macosDeviceInfo.hostName, 'hostName'); expect(macosDeviceInfo.osRelease, 'osRelease'); + expect(macosDeviceInfo.majorVersion, 10); + expect(macosDeviceInfo.minorVersion, 9); + expect(macosDeviceInfo.patchVersion, 3); expect(macosDeviceInfo.systemGUID, isNull); }); From 84575eedc9a9a7095faacd60f99b416b952d6657 Mon Sep 17 00:00:00 2001 From: goenning Date: Wed, 29 Mar 2023 10:03:26 +0100 Subject: [PATCH 3/5] fi --- .../macos/Classes/DeviceInfoPlusMacosPlugin.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift b/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift index 7f4864afd9..78f8087d1e 100644 --- a/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift +++ b/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift @@ -26,9 +26,9 @@ public class DeviceInfoPlusMacosPlugin: NSObject, FlutterPlugin { let model = Sysctl.model let kernelVersion = Sysctl.version let osRelease = ProcessInfo.processInfo.operatingSystemVersionString - let majorVersion = osVersion.majorVersion, - let minorVersion = osVersion.minorVersion, - let patchVersion = osVersion.patchVersion, + let majorVersion = osVersion.majorVersion + let minorVersion = osVersion.minorVersion + let patchVersion = osVersion.patchVersion let activeCPUs = Sysctl.activeCPUs let memorySize = Sysctl.memSize let cpuFrequency = Sysctl.cpuFreq From a87d4fd089c1f661cf09dacd6b0a24f2e7bb4468 Mon Sep 17 00:00:00 2001 From: goenning Date: Tue, 4 Apr 2023 22:04:38 +0100 Subject: [PATCH 4/5] add versions to example --- .../device_info_plus/device_info_plus/example/lib/main.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/device_info_plus/device_info_plus/example/lib/main.dart b/packages/device_info_plus/device_info_plus/example/lib/main.dart index b69bc04ab5..adcff431ed 100644 --- a/packages/device_info_plus/device_info_plus/example/lib/main.dart +++ b/packages/device_info_plus/device_info_plus/example/lib/main.dart @@ -172,6 +172,9 @@ class _MyAppState extends State { 'arch': data.arch, 'model': data.model, 'kernelVersion': data.kernelVersion, + 'majorVersion': data.majorVersion, + 'minorVersion': data.minorVersion, + 'patchVersion': data.patchVersion, 'osRelease': data.osRelease, 'activeCPUs': data.activeCPUs, 'memorySize': data.memorySize, From 1f509fd60f09055e157d5999879471b2cdebc33d Mon Sep 17 00:00:00 2001 From: goenning Date: Wed, 5 Apr 2023 07:51:26 +0100 Subject: [PATCH 5/5] remove emptyline --- .../macos/Classes/DeviceInfoPlusMacosPlugin.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift b/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift index 78f8087d1e..8dbeb74203 100644 --- a/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift +++ b/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift @@ -18,14 +18,13 @@ public class DeviceInfoPlusMacosPlugin: NSObject, FlutterPlugin { } private func handleDeviceInfo(result: @escaping FlutterResult)-> Void{ - let osVersion = ProcessInfo.processInfo.operatingSystemVersion; - let computerName = Host.current().localizedName ?? Sysctl.hostName let hostName = Sysctl.osType let arch = Sysctl.machine let model = Sysctl.model let kernelVersion = Sysctl.version let osRelease = ProcessInfo.processInfo.operatingSystemVersionString + let osVersion = ProcessInfo.processInfo.operatingSystemVersion; let majorVersion = osVersion.majorVersion let minorVersion = osVersion.minorVersion let patchVersion = osVersion.patchVersion