@@ -38,39 +38,63 @@ class AndroidDeviceInfo {
38
38
final AndroidBuildVersion version;
39
39
40
40
/// The name of the underlying board, like "goldfish".
41
+ ///
42
+ /// The value is an empty String if it is not available.
41
43
final String board;
42
44
43
45
/// The system bootloader version number.
46
+ ///
47
+ /// The value is an empty String if it is not available.
44
48
final String bootloader;
45
49
46
50
/// The consumer-visible brand with which the product/hardware will be associated, if any.
51
+ ///
52
+ /// The value is an empty String if it is not available.
47
53
final String brand;
48
54
49
55
/// The name of the industrial design.
56
+ ///
57
+ /// The value is an empty String if it is not available.
50
58
final String device;
51
59
52
60
/// A build ID string meant for displaying to the user.
61
+ ///
62
+ /// The value is an empty String if it is not available.
53
63
final String display;
54
64
55
65
/// A string that uniquely identifies this build.
66
+ ///
67
+ /// The value is an empty String if it is not available.
56
68
final String fingerprint;
57
69
58
70
/// The name of the hardware (from the kernel command line or /proc).
71
+ ///
72
+ /// The value is an empty String if it is not available.
59
73
final String hardware;
60
74
61
75
/// Hostname.
76
+ ///
77
+ /// The value is an empty String if it is not available.
62
78
final String host;
63
79
64
80
/// Either a changelist number, or a label like "M4-rc20".
81
+ ///
82
+ /// The value is an empty String if it is not available.
65
83
final String id;
66
84
67
85
/// The manufacturer of the product/hardware.
86
+ ///
87
+ /// The value is an empty String if it is not available.
68
88
final String manufacturer;
69
89
70
90
/// The end-user-visible name for the end product.
91
+ ///
92
+ /// The value is an empty String if it is not available.
71
93
final String model;
72
94
73
95
/// The name of the overall product.
96
+ ///
97
+ /// The value is an empty String if it is not available.
74
98
final String product;
75
99
76
100
/// An ordered list of 32 bit ABIs supported by this device.
@@ -83,15 +107,23 @@ class AndroidDeviceInfo {
83
107
final List <String > supportedAbis;
84
108
85
109
/// Comma-separated tags describing the build, like "unsigned,debug".
110
+ ///
111
+ /// The value is an empty String if it is not available.
86
112
final String tags;
87
113
88
114
/// The type of build, like "user" or "eng".
115
+ ///
116
+ /// The value is an empty String if it is not available.
89
117
final String type;
90
118
91
- /// `false` if the application is running in an emulator, `true` otherwise.
119
+ /// The value is `true` if the application is running on a physical device.
120
+ ///
121
+ /// The value is `false` when the application is running on a emulator, or the value is unavailable.
92
122
final bool isPhysicalDevice;
93
123
94
124
/// The Android hardware device ID that is unique between the device + user and app signing.
125
+ ///
126
+ /// The value is an empty String if it is not available.
95
127
final String androidId;
96
128
97
129
/// Describes what features are available on the current device.
@@ -113,35 +145,41 @@ class AndroidDeviceInfo {
113
145
/// Deserializes from the message received from [_kChannel] .
114
146
static AndroidDeviceInfo fromMap (Map <String , dynamic > map) {
115
147
return AndroidDeviceInfo (
116
- version:
117
- AndroidBuildVersion ._fromMap (map['version' ]! .cast <String , dynamic >()),
118
- board: map['board' ]! ,
119
- bootloader: map['bootloader' ]! ,
120
- brand: map['brand' ]! ,
121
- device: map['device' ]! ,
122
- display: map['display' ]! ,
123
- fingerprint: map['fingerprint' ]! ,
124
- hardware: map['hardware' ]! ,
125
- host: map['host' ]! ,
126
- id: map['id' ]! ,
127
- manufacturer: map['manufacturer' ]! ,
128
- model: map['model' ]! ,
129
- product: map['product' ]! ,
130
- supported32BitAbis: _fromList (map['supported32BitAbis' ]! ),
131
- supported64BitAbis: _fromList (map['supported64BitAbis' ]! ),
132
- supportedAbis: _fromList (map['supportedAbis' ]! ),
133
- tags: map['tags' ]! ,
134
- type: map['type' ]! ,
135
- isPhysicalDevice: map['isPhysicalDevice' ]! ,
136
- androidId: map['androidId' ]! ,
137
- systemFeatures: _fromList (map['systemFeatures' ]! ),
148
+ version: AndroidBuildVersion ._fromMap (map['version' ] != null
149
+ ? map['version' ].cast <String , dynamic >()
150
+ : < String , dynamic > {}),
151
+ board: map['board' ] ?? '' ,
152
+ bootloader: map['bootloader' ] ?? '' ,
153
+ brand: map['brand' ] ?? '' ,
154
+ device: map['device' ] ?? '' ,
155
+ display: map['display' ] ?? '' ,
156
+ fingerprint: map['fingerprint' ] ?? '' ,
157
+ hardware: map['hardware' ] ?? '' ,
158
+ host: map['host' ] ?? '' ,
159
+ id: map['id' ] ?? '' ,
160
+ manufacturer: map['manufacturer' ] ?? '' ,
161
+ model: map['model' ] ?? '' ,
162
+ product: map['product' ] ?? '' ,
163
+ supported32BitAbis: _fromList (map['supported32BitAbis' ]),
164
+ supported64BitAbis: _fromList (map['supported64BitAbis' ]),
165
+ supportedAbis: _fromList (map['supportedAbis' ]),
166
+ tags: map['tags' ] ?? '' ,
167
+ type: map['type' ] ?? '' ,
168
+ isPhysicalDevice: map['isPhysicalDevice' ] ?? false ,
169
+ androidId: map['androidId' ] ?? '' ,
170
+ systemFeatures: _fromList (map['systemFeatures' ]),
138
171
);
139
172
}
140
173
141
174
/// Deserializes message as List<String>
142
175
static List <String > _fromList (dynamic message) {
143
- final List <dynamic > list = message;
144
- return List <String >.from (list);
176
+ if (message == null ) {
177
+ return < String > [];
178
+ }
179
+ assert (message is List <dynamic >);
180
+ final List <dynamic > list = List <dynamic >.from (message)
181
+ ..removeWhere ((value) => value == null );
182
+ return list.cast <String >();
145
183
}
146
184
}
147
185
@@ -173,17 +211,25 @@ class AndroidBuildVersion {
173
211
final String ? securityPatch;
174
212
175
213
/// The current development codename, or the string "REL" if this is a release build.
214
+ ///
215
+ /// The value is an empty String if it is not available.
176
216
final String codename;
177
217
178
218
/// The internal value used by the underlying source control to represent this build.
219
+ ///
220
+ /// The value is an empty String if it is not available.
179
221
final String incremental;
180
222
181
223
/// The user-visible version string.
224
+ ///
225
+ /// The value is an empty String if it is not available.
182
226
final String release;
183
227
184
228
/// The user-visible SDK version of the framework.
185
229
///
186
230
/// Possible values are defined in: https://developer.android.com/reference/android/os/Build.VERSION_CODES.html
231
+ ///
232
+ /// The value is -1 if it is unavailable.
187
233
final int sdkInt;
188
234
189
235
/// Deserializes from the map message received from [_kChannel] .
@@ -192,10 +238,10 @@ class AndroidBuildVersion {
192
238
baseOS: map['baseOS' ],
193
239
previewSdkInt: map['previewSdkInt' ],
194
240
securityPatch: map['securityPatch' ],
195
- codename: map['codename' ]! ,
196
- incremental: map['incremental' ]! ,
197
- release: map['release' ]! ,
198
- sdkInt: map['sdkInt' ]! ,
241
+ codename: map['codename' ] ?? '' ,
242
+ incremental: map['incremental' ] ?? '' ,
243
+ release: map['release' ] ?? '' ,
244
+ sdkInt: map['sdkInt' ] ?? - 1 ,
199
245
);
200
246
}
201
247
}
0 commit comments