-
-
Notifications
You must be signed in to change notification settings - Fork 427
/
Device.java
384 lines (307 loc) · 9.74 KB
/
Device.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
package io.sentry.protocol;
import io.sentry.IUnknownPropertiesConsumer;
import io.sentry.util.CollectionUtils;
import java.util.Date;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
public final class Device implements IUnknownPropertiesConsumer, Cloneable {
public static final String TYPE = "device";
/** Name of the device. */
private @Nullable String name;
/** Manufacturer of the device. */
private @Nullable String manufacturer;
/** Brand of the device. */
private @Nullable String brand;
/**
* Family of the device model.
*
* <p>This is usually the common part of model names across generations. For instance, `iPhone`
* would be a reasonable family, so would be `Samsung Galaxy`.
*/
private @Nullable String family;
/**
* Device model.
*
* <p>This, for example, can be `Samsung Galaxy S3`.
*/
private @Nullable String model;
/**
* Device model (internal identifier).
*
* <p>An internal hardware revision to identify the device exactly.
*/
private @Nullable String modelId;
/** Supported CPU architectures of the device. */
private @Nullable String[] archs;
/**
* Current battery level in %.
*
* <p>If the device has a battery, this can be a floating point value defining the battery level
* (in the range 0-100).
*/
private @Nullable Float batteryLevel;
/** Whether the device was charging or not. */
private @Nullable Boolean charging;
/** Whether the device was online or not. */
private @Nullable Boolean online;
/**
* Current screen orientation.
*
* <p>This can be a string `portrait` or `landscape` to define the orientation of a device.
*/
private @Nullable DeviceOrientation orientation;
/** Simulator/prod indicator. */
private @Nullable Boolean simulator;
/** Total memory available in bytes. */
private @Nullable Long memorySize;
/** How much memory is still available in bytes. */
private @Nullable Long freeMemory;
/** How much memory is usable for the app in bytes. */
private @Nullable Long usableMemory;
/** Whether the device was low on memory. */
private @Nullable Boolean lowMemory;
/** Total storage size of the device in bytes. */
private @Nullable Long storageSize;
/** How much storage is free in bytes. */
private @Nullable Long freeStorage;
/** Total size of the attached external storage in bytes (eg: android SDK card). */
private @Nullable Long externalStorageSize;
/** Free size of the attached external storage in bytes (eg: android SDK card). */
private @Nullable Long externalFreeStorage;
/** Device width screen resolution. */
private @Nullable Integer screenWidthPixels;
/** Device Height screen resolution. */
private @Nullable Integer screenHeightPixels;
/** Device screen density. */
private @Nullable Float screenDensity;
/** Screen density as dots-per-inch. */
private @Nullable Integer screenDpi;
/** Indicator when the device was booted. */
private @Nullable Date bootTime;
/** Timezone of the device. */
private @Nullable TimeZone timezone;
private @Nullable String id;
private @Nullable String language;
private @Nullable String connectionType;
/** battery's temperature in celsius */
private @Nullable Float batteryTemperature;
@SuppressWarnings("unused")
private @Nullable Map<String, @NotNull Object> unknown;
public @Nullable String getName() {
return name;
}
public void setName(final @Nullable String name) {
this.name = name;
}
public @Nullable String getManufacturer() {
return manufacturer;
}
public void setManufacturer(final @Nullable String manufacturer) {
this.manufacturer = manufacturer;
}
public @Nullable String getBrand() {
return brand;
}
public void setBrand(final @Nullable String brand) {
this.brand = brand;
}
public @Nullable String getFamily() {
return family;
}
public void setFamily(final @Nullable String family) {
this.family = family;
}
public @Nullable String getModel() {
return model;
}
public void setModel(final @Nullable String model) {
this.model = model;
}
public @Nullable String getModelId() {
return modelId;
}
public void setModelId(final @Nullable String modelId) {
this.modelId = modelId;
}
public @Nullable Float getBatteryLevel() {
return batteryLevel;
}
public void setBatteryLevel(final @Nullable Float batteryLevel) {
this.batteryLevel = batteryLevel;
}
public @Nullable Boolean isCharging() {
return charging;
}
public void setCharging(final @Nullable Boolean charging) {
this.charging = charging;
}
public @Nullable Boolean isOnline() {
return online;
}
public void setOnline(final @Nullable Boolean online) {
this.online = online;
}
public @Nullable DeviceOrientation getOrientation() {
return orientation;
}
public void setOrientation(final @Nullable DeviceOrientation orientation) {
this.orientation = orientation;
}
public @Nullable Boolean isSimulator() {
return simulator;
}
public void setSimulator(final @Nullable Boolean simulator) {
this.simulator = simulator;
}
public @Nullable Long getMemorySize() {
return memorySize;
}
public void setMemorySize(final @Nullable Long memorySize) {
this.memorySize = memorySize;
}
public @Nullable Long getFreeMemory() {
return freeMemory;
}
public void setFreeMemory(final @Nullable Long freeMemory) {
this.freeMemory = freeMemory;
}
public @Nullable Long getUsableMemory() {
return usableMemory;
}
public void setUsableMemory(final @Nullable Long usableMemory) {
this.usableMemory = usableMemory;
}
public @Nullable Boolean isLowMemory() {
return lowMemory;
}
public void setLowMemory(final @Nullable Boolean lowMemory) {
this.lowMemory = lowMemory;
}
public @Nullable Long getStorageSize() {
return storageSize;
}
public void setStorageSize(final @Nullable Long storageSize) {
this.storageSize = storageSize;
}
public @Nullable Long getFreeStorage() {
return freeStorage;
}
public void setFreeStorage(final @Nullable Long freeStorage) {
this.freeStorage = freeStorage;
}
public @Nullable Long getExternalStorageSize() {
return externalStorageSize;
}
public void setExternalStorageSize(final @Nullable Long externalStorageSize) {
this.externalStorageSize = externalStorageSize;
}
public @Nullable Long getExternalFreeStorage() {
return externalFreeStorage;
}
public void setExternalFreeStorage(final @Nullable Long externalFreeStorage) {
this.externalFreeStorage = externalFreeStorage;
}
public @Nullable Float getScreenDensity() {
return screenDensity;
}
public void setScreenDensity(final @Nullable Float screenDensity) {
this.screenDensity = screenDensity;
}
public @Nullable Integer getScreenDpi() {
return screenDpi;
}
public void setScreenDpi(final @Nullable Integer screenDpi) {
this.screenDpi = screenDpi;
}
@SuppressWarnings({"JdkObsolete", "JavaUtilDate"})
public @Nullable Date getBootTime() {
final Date bootTimeRef = bootTime;
return bootTimeRef != null ? (Date) bootTimeRef.clone() : null;
}
public void setBootTime(final @Nullable Date bootTime) {
this.bootTime = bootTime;
}
public @Nullable TimeZone getTimezone() {
return timezone;
}
public void setTimezone(final @Nullable TimeZone timezone) {
this.timezone = timezone;
}
public @Nullable String[] getArchs() {
return archs;
}
public void setArchs(final @Nullable String[] archs) {
this.archs = archs;
}
public @Nullable Integer getScreenWidthPixels() {
return screenWidthPixels;
}
public void setScreenWidthPixels(final @Nullable Integer screenWidthPixels) {
this.screenWidthPixels = screenWidthPixels;
}
public @Nullable Integer getScreenHeightPixels() {
return screenHeightPixels;
}
public void setScreenHeightPixels(final @Nullable Integer screenHeightPixels) {
this.screenHeightPixels = screenHeightPixels;
}
public @Nullable String getId() {
return id;
}
public void setId(final @Nullable String id) {
this.id = id;
}
public @Nullable String getLanguage() {
return language;
}
public void setLanguage(final @Nullable String language) {
this.language = language;
}
public @Nullable String getConnectionType() {
return connectionType;
}
public void setConnectionType(final @Nullable String connectionType) {
this.connectionType = connectionType;
}
public @Nullable Float getBatteryTemperature() {
return batteryTemperature;
}
public void setBatteryTemperature(final @Nullable Float batteryTemperature) {
this.batteryTemperature = batteryTemperature;
}
@TestOnly
@Nullable
Map<String, Object> getUnknown() {
return unknown;
}
@ApiStatus.Internal
@Override
public void acceptUnknownProperties(final @NotNull Map<String, Object> unknown) {
this.unknown = new ConcurrentHashMap<>(unknown);
}
/**
* Clones a Device aka deep copy
*
* @return the cloned Device
* @throws CloneNotSupportedException if object is not cloneable
*/
@Override
public @NotNull Device clone() throws CloneNotSupportedException {
final Device clone = (Device) super.clone();
final String[] archsRef = this.archs;
clone.archs = archsRef != null ? archsRef.clone() : null;
final TimeZone timezoneRef = this.timezone;
clone.timezone = timezoneRef != null ? (TimeZone) timezoneRef.clone() : null;
clone.unknown = CollectionUtils.newConcurrentHashMap(unknown);
return clone;
}
public enum DeviceOrientation {
PORTRAIT,
LANDSCAPE
}
}