@@ -169,13 +169,20 @@ abstract class BaseDeviceInfo {
169
169
170
170
/// Like [device_info_plus.AndroidDeviceInfo] , but without things we don't use.
171
171
class AndroidDeviceInfo extends BaseDeviceInfo {
172
+ /// The user-visible version string.
173
+ ///
174
+ /// E.g., "1.0" or "3.4b5" or "bananas". This field is an opaque string.
175
+ /// Do not assume that its value has any particular structure or that
176
+ /// values of RELEASE from different releases can be somehow ordered.
177
+ final String release;
178
+
172
179
/// The Android SDK version.
173
180
///
174
181
/// Possible values are defined in:
175
182
/// https://developer.android.com/reference/android/os/Build.VERSION_CODES.html
176
183
final int sdkInt;
177
184
178
- AndroidDeviceInfo ({required this .sdkInt});
185
+ AndroidDeviceInfo ({required this .release, required this . sdkInt});
179
186
}
180
187
181
188
/// Like [device_info_plus.IosDeviceInfo] , but without things we don't use.
@@ -188,6 +195,56 @@ class IosDeviceInfo extends BaseDeviceInfo {
188
195
IosDeviceInfo ({required this .systemVersion});
189
196
}
190
197
198
+ /// Like [device_info_plus.MacOsDeviceInfo] , but without things we don't use.
199
+ class MacOsDeviceInfo extends BaseDeviceInfo {
200
+ /// The major release number, such as 10 in version 10.9.3.
201
+ final int majorVersion;
202
+
203
+ /// The minor release number, such as 9 in version 10.9.3.
204
+ final int minorVersion;
205
+
206
+ /// The update release number, such as 3 in version 10.9.3.
207
+ final int patchVersion;
208
+
209
+ MacOsDeviceInfo ({
210
+ required this .majorVersion,
211
+ required this .minorVersion,
212
+ required this .patchVersion,
213
+ });
214
+ }
215
+
216
+ /// Like [device_info_plus.WindowsDeviceInfo] , currently only used to
217
+ /// determine if we're on Windows.
218
+ class WindowsDeviceInfo implements BaseDeviceInfo {}
219
+
220
+ /// Like [device_info_plus.LinuxDeviceInfo] , but without things we don't use.
221
+ ///
222
+ /// See:
223
+ /// https://www.freedesktop.org/software/systemd/man/os-release.html
224
+ class LinuxDeviceInfo implements BaseDeviceInfo {
225
+ /// A string identifying the operating system, without a version component,
226
+ /// and suitable for presentation to the user.
227
+ ///
228
+ /// Examples: 'Fedora', 'Debian GNU/Linux'.
229
+ ///
230
+ /// If not set, defaults to 'Linux'.
231
+ final String name;
232
+
233
+ /// A lower-case string identifying the operating system version, excluding
234
+ /// any OS name information or release code name, and suitable for processing
235
+ /// by scripts or usage in generated filenames.
236
+ ///
237
+ /// The version is mostly numeric, and contains no spaces or other characters
238
+ /// outside of 0–9, a–z, '.', '_' and '-'.
239
+ ///
240
+ /// Examples: '17', '11.04'.
241
+ ///
242
+ /// This field is optional and may be null on some systems.
243
+ final String ? versionId;
244
+
245
+ LinuxDeviceInfo ({required this .name, required this .versionId});
246
+ }
247
+
191
248
/// Like [package_info_plus.PackageInfo] , but without things we don't use.
192
249
class PackageInfo {
193
250
final String version;
@@ -238,9 +295,16 @@ class LiveZulipBinding extends ZulipBinding {
238
295
try {
239
296
final info = await device_info_plus.DeviceInfoPlugin ().deviceInfo;
240
297
_maybeDeviceInfo = switch (info) {
241
- device_info_plus.AndroidDeviceInfo (: var version) => AndroidDeviceInfo (sdkInt: version.sdkInt),
242
- device_info_plus.IosDeviceInfo (: var systemVersion) => IosDeviceInfo (systemVersion: systemVersion),
243
- _ => throw UnimplementedError (),
298
+ device_info_plus.AndroidDeviceInfo () => AndroidDeviceInfo (release: info.version.release,
299
+ sdkInt: info.version.sdkInt),
300
+ device_info_plus.IosDeviceInfo () => IosDeviceInfo (systemVersion: info.systemVersion),
301
+ device_info_plus.MacOsDeviceInfo () => MacOsDeviceInfo (majorVersion: info.majorVersion,
302
+ minorVersion: info.minorVersion,
303
+ patchVersion: info.patchVersion),
304
+ device_info_plus.WindowsDeviceInfo () => WindowsDeviceInfo (),
305
+ device_info_plus.LinuxDeviceInfo () => LinuxDeviceInfo (name: info.name,
306
+ versionId: info.versionId),
307
+ _ => throw UnimplementedError (),
244
308
};
245
309
} catch (e) {
246
310
assert (debugLog ('Failed to prefetch device info: $e ' ));
0 commit comments