Skip to content

Commit 055da82

Browse files
[device_info_plus] Added more information for Windows (#814)
* [device_info_plus] update WindowsDeviceInfo model to include more attributes * [device_info_plus] update example application * [device_info_plus_windows] add more info (#177) * [device_info_plus] userName attribute in WindowsDeviceInfo * update windows_device_info_test.dart & bump to 2.4.0 * [device_info_plus] update changelog & bump version * [device_info_plus_platform_interface] update changelog * [device_info_plus] add deviceId to WindowsDeviceInfo * [device_info_plus] refactor: clean-up windows implementation * [device_info_plus_windows] improve tests * [device_info_plus_windows] fix tests * [device_info_plus] fix: windows tests & bump version * Update CHANGELOG.md Co-authored-by: Miguel Beltran <[email protected]>
1 parent 2030813 commit 055da82

File tree

11 files changed

+508
-11
lines changed

11 files changed

+508
-11
lines changed

packages/device_info_plus/device_info_plus/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.0.2
2+
3+
- Added more information to `WindowsDeviceInfo`.
4+
15
## 4.0.1
26

37
- Update dependencies

packages/device_info_plus/device_info_plus/example/lib/main.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,28 @@ class _MyAppState extends State<MyApp> {
177177
'numberOfCores': data.numberOfCores,
178178
'computerName': data.computerName,
179179
'systemMemoryInMegabytes': data.systemMemoryInMegabytes,
180+
'userName': data.userName,
181+
'majorVersion': data.majorVersion,
182+
'minorVersion': data.minorVersion,
183+
'buildNumber': data.buildNumber,
184+
'platformId': data.platformId,
185+
'csdVersion': data.csdVersion,
186+
'servicePackMajor': data.servicePackMajor,
187+
'servicePackMinor': data.servicePackMinor,
188+
'suitMask': data.suitMask,
189+
'productType': data.productType,
190+
'reserved': data.reserved,
191+
'buildLab': data.buildLab,
192+
'buildLabEx': data.buildLabEx,
193+
'digitalProductId': data.digitalProductId,
194+
'displayVersion': data.displayVersion,
195+
'editionId': data.editionId,
196+
'installDate': data.installDate,
197+
'productId': data.productId,
198+
'productName': data.productName,
199+
'registeredOwner': data.registeredOwner,
200+
'releaseId': data.releaseId,
201+
'deviceId': data.deviceId,
180202
};
181203
}
182204

packages/device_info_plus/device_info_plus/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: device_info_plus
22
description: Flutter plugin providing detailed information about the device
33
(make, model, etc.), and Android or iOS version the app is running on.
4-
version: 4.0.1
4+
version: 4.0.2
55
homepage: https://plus.fluttercommunity.dev/
66
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/
77

@@ -25,11 +25,11 @@ flutter:
2525
dependencies:
2626
flutter:
2727
sdk: flutter
28-
device_info_plus_platform_interface: ^2.3.0
28+
device_info_plus_platform_interface: ^2.4.0
2929
device_info_plus_macos: ^2.2.3
3030
device_info_plus_linux: ^2.1.1
3131
device_info_plus_web: ^2.1.0
32-
device_info_plus_windows: ^3.0.1
32+
device_info_plus_windows: ^3.0.2
3333

3434
dev_dependencies:
3535
flutter_test:

packages/device_info_plus/device_info_plus_platform_interface/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.4.0
2+
3+
- Windows: Add userName, majorVersion, minorVersion, buildNumber, platformId, csdVersion, servicePackMajor, servicePackMinor, suitMask, productType, reserved, buildLab, buildLabEx, digitalProductId, displayVersion, editionId, installDate, productId, productName, registeredOwner, releaseId, deviceId to WindowsDeviceInfo.
4+
15
## 2.3.0+1
26

37
- Fix LinuxDeviceInfo.name docs

packages/device_info_plus/device_info_plus_platform_interface/lib/model/windows_device_info.dart

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'dart:typed_data';
6+
57
import 'base_device_info.dart';
68

79
/// Object encapsulating WINDOWS device information.
@@ -11,6 +13,28 @@ class WindowsDeviceInfo implements BaseDeviceInfo {
1113
required this.computerName,
1214
required this.numberOfCores,
1315
required this.systemMemoryInMegabytes,
16+
required this.userName,
17+
required this.majorVersion,
18+
required this.minorVersion,
19+
required this.buildNumber,
20+
required this.platformId,
21+
required this.csdVersion,
22+
required this.servicePackMajor,
23+
required this.servicePackMinor,
24+
required this.suitMask,
25+
required this.productType,
26+
required this.reserved,
27+
required this.buildLab,
28+
required this.buildLabEx,
29+
required this.digitalProductId,
30+
required this.displayVersion,
31+
required this.editionId,
32+
required this.installDate,
33+
required this.productId,
34+
required this.productName,
35+
required this.registeredOwner,
36+
required this.releaseId,
37+
required this.deviceId,
1438
});
1539

1640
/// The computer's fully-qualified DNS name, where available.
@@ -23,13 +47,124 @@ class WindowsDeviceInfo implements BaseDeviceInfo {
2347
/// This may not be the same as available memory.
2448
final int systemMemoryInMegabytes;
2549

50+
final String userName;
51+
52+
/// The major version number of the operating system.
53+
/// For example, for Windows 2000, the major version number is five.
54+
/// For more information, see the table in Remarks.
55+
/// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_osversioninfoexw#remarks
56+
final int majorVersion;
57+
58+
/// The minor version number of the operating system.
59+
/// For example, for Windows 2000, the minor version number is zero.
60+
/// For more information, see the table in Remarks.
61+
/// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_osversioninfoexw#remarks
62+
final int minorVersion;
63+
64+
/// The build number of the operating system.
65+
/// For example:
66+
/// - `22000` or greater for Windows 11.
67+
/// - `10240` or greator for Windows 10.
68+
final int buildNumber;
69+
70+
/// The operating system platform.
71+
/// For Win32 on NT-based operating systems, RtlGetVersion returns the value `VER_PLATFORM_WIN32_NT`.
72+
final int platformId;
73+
74+
/// The service-pack version string.
75+
/// This member contains a null-terminated string, such as "Service Pack 3", which indicates the latest service pack installed on the system.
76+
/// If no service pack is installed, RtlGetVersion might not initialize this string. Initialize szCSDVersion to zero (empty string) before the call to RtlGetVersion.
77+
final String csdVersion;
78+
79+
/// The major version number of the latest service pack installed on the system.
80+
/// For example, for Service Pack 3, the major version number is three.
81+
/// If no service pack has been installed, the value is zero.
82+
final int servicePackMajor;
83+
84+
/// The minor version number of the latest service pack installed on the system.
85+
/// For example, for Service Pack 3, the minor version number is zero.
86+
final int servicePackMinor;
87+
88+
/// The product suites available on the system.
89+
final int suitMask;
90+
91+
/// The product type. This member contains additional information about the system.
92+
final int productType;
93+
94+
/// Reserved for future use.
95+
final int reserved;
96+
97+
/// Value of `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\BuildLab` registry key.
98+
/// For example: `22000.co_release.210604-1628`.
99+
final String buildLab;
100+
101+
/// Value of `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\BuildLabEx` registry key.
102+
/// For example: `22000.1.amd64fre.co_release.210604-1628`.
103+
final String buildLabEx;
104+
105+
/// Value of `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId` registry key.
106+
final Uint8List digitalProductId;
107+
108+
/// Value of `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DisplayVersion` registry key.
109+
/// For example: `21H2`.
110+
final String displayVersion;
111+
112+
/// Value of `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\EditionID` registry key.
113+
final String editionId;
114+
115+
/// Value of `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate` registry key.
116+
final DateTime installDate;
117+
118+
/// Displayed as "Product ID" in Windows Settings.
119+
/// Value of `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId` registry key.
120+
/// For example: `00000-00000-0000-AAAAA`.
121+
final String productId;
122+
123+
/// Value of `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName` registry key.
124+
/// For example: `Windows 10 Home Single Language`.
125+
final String productName;
126+
127+
/// Value of `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOwner` registry key.
128+
/// For example: `Microsoft Corporation`.
129+
final String registeredOwner;
130+
131+
/// Value of `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ReleaseId` registry key.
132+
/// For example: `1903`.
133+
final String releaseId;
134+
135+
/// Displayed as "Device ID" in Windows Settings.
136+
/// Value of `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SQMClient\MachineId` registry key.
137+
final String deviceId;
138+
26139
/// Serializes [WindowsDeviceInfo] to a map.
27140
@override
28141
Map<String, dynamic> toMap() {
29142
return {
30143
'computerName': computerName,
31144
'numberOfCores': numberOfCores,
32145
'systemMemoryInMegabytes': systemMemoryInMegabytes,
146+
'userName': userName,
147+
'majorVersion': majorVersion,
148+
'minorVersion': minorVersion,
149+
'buildNumber': buildNumber,
150+
'platformId': platformId,
151+
'csdVersion': csdVersion,
152+
'servicePackMajor': servicePackMajor,
153+
'servicePackMinor': servicePackMinor,
154+
'suitMask': suitMask,
155+
'productType': productType,
156+
'reserved': reserved,
157+
'buildLab': buildLab,
158+
'buildLabEx': buildLabEx,
159+
'digitalProductId': digitalProductId,
160+
'displayVersion': displayVersion,
161+
'editionId': editionId,
162+
'installDate': installDate,
163+
'productId': productId,
164+
'productName': productName,
165+
'registeredOwner': registeredOwner,
166+
'releaseId': releaseId,
167+
'deviceId': deviceId,
33168
};
34169
}
35170
}

packages/device_info_plus/device_info_plus_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: device_info_plus_platform_interface
22
description: A common platform interface for the device_info_plus plugin.
3-
version: 2.3.0+1
3+
version: 2.4.0
44
homepage: https://plus.fluttercommunity.dev/
55
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/
66

packages/device_info_plus/device_info_plus_platform_interface/test/model/windows_device_info_test.dart

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'dart:typed_data';
12
import 'package:device_info_plus_platform_interface/model/windows_device_info.dart';
23
import 'package:flutter_test/flutter_test.dart';
34

@@ -8,12 +9,56 @@ void main() {
89
computerName: 'computerName',
910
numberOfCores: 4,
1011
systemMemoryInMegabytes: 16,
12+
userName: 'userName',
13+
majorVersion: 10,
14+
minorVersion: 0,
15+
buildNumber: 10240,
16+
platformId: 1,
17+
csdVersion: 'csdVersion',
18+
servicePackMajor: 1,
19+
servicePackMinor: 0,
20+
suitMask: 1,
21+
productType: 1,
22+
reserved: 1,
23+
buildLab: '22000.co_release.210604-1628',
24+
buildLabEx: '22000.1.amd64fre.co_release.210604-1628',
25+
digitalProductId: Uint8List.fromList([]),
26+
displayVersion: '21H2',
27+
editionId: 'Pro',
28+
installDate: DateTime(2022, 04, 02),
29+
productId: '00000-00000-0000-AAAAA',
30+
productName: 'Windows 10 Pro',
31+
registeredOwner: 'registeredOwner',
32+
releaseId: 'releaseId',
33+
deviceId: 'deviceId',
1134
);
1235

1336
expect(windowsDeviceInfo.toMap(), {
1437
'computerName': 'computerName',
1538
'numberOfCores': 4,
1639
'systemMemoryInMegabytes': 16,
40+
'userName': 'userName',
41+
'majorVersion': 10,
42+
'minorVersion': 0,
43+
'buildNumber': 10240,
44+
'platformId': 1,
45+
'csdVersion': 'csdVersion',
46+
'servicePackMajor': 1,
47+
'servicePackMinor': 0,
48+
'suitMask': 1,
49+
'productType': 1,
50+
'reserved': 1,
51+
'buildLab': '22000.co_release.210604-1628',
52+
'buildLabEx': '22000.1.amd64fre.co_release.210604-1628',
53+
'digitalProductId': Uint8List.fromList([]),
54+
'displayVersion': '21H2',
55+
'editionId': 'Pro',
56+
'installDate': DateTime(2022, 04, 02),
57+
'productId': '00000-00000-0000-AAAAA',
58+
'productName': 'Windows 10 Pro',
59+
'registeredOwner': 'registeredOwner',
60+
'releaseId': 'releaseId',
61+
'deviceId': 'deviceId',
1762
});
1863
});
1964
});

packages/device_info_plus/device_info_plus_windows/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.0.2
2+
3+
- Add more information to WindowsDeviceInfo.
4+
15
## 3.0.1
26

37
- Update ffi to 2.0.1

0 commit comments

Comments
 (0)