forked from getsentry/sentry-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevice.java
More file actions
382 lines (305 loc) · 8.58 KB
/
Device.java
File metadata and controls
382 lines (305 loc) · 8.58 KB
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
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.TestOnly;
public final class Device implements IUnknownPropertiesConsumer, Cloneable {
public static final String TYPE = "device";
/** Name of the device. */
private String name;
/** Manufacturer of the device. */
private String manufacturer;
/** Brand of the device. */
private 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 String family;
/**
* Device model.
*
* <p>This, for example, can be `Samsung Galaxy S3`.
*/
private String model;
/**
* Device model (internal identifier).
*
* <p>An internal hardware revision to identify the device exactly.
*/
private String modelId;
/** Supported CPU architectures of the device. */
private 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 Float batteryLevel;
/** Whether the device was charging or not. */
private Boolean charging;
/** Whether the device was online or not. */
private Boolean online;
/**
* Current screen orientation.
*
* <p>This can be a string `portrait` or `landscape` to define the orientation of a device.
*/
private DeviceOrientation orientation;
/** Simulator/prod indicator. */
private Boolean simulator;
/** Total memory available in bytes. */
private Long memorySize;
/** How much memory is still available in bytes. */
private Long freeMemory;
/** How much memory is usable for the app in bytes. */
private Long usableMemory;
/** Whether the device was low on memory. */
private Boolean lowMemory;
/** Total storage size of the device in bytes. */
private Long storageSize;
/** How much storage is free in bytes. */
private Long freeStorage;
/** Total size of the attached external storage in bytes (eg: android SDK card). */
private Long externalStorageSize;
/** Free size of the attached external storage in bytes (eg: android SDK card). */
private Long externalFreeStorage;
/** Device width screen resolution. */
private Integer screenWidthPixels;
/** Device Height screen resolution. */
private Integer screenHeightPixels;
/** Device screen density. */
private Float screenDensity;
/** Screen density as dots-per-inch. */
private Integer screenDpi;
/** Indicator when the device was booted. */
private Date bootTime;
/** Timezone of the device. */
private TimeZone timezone;
private String id;
private String language;
private String connectionType;
/** battery's temperature in celsius */
private Float batteryTemperature;
@SuppressWarnings("unused")
private Map<String, Object> unknown;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getManufacturer() {
return manufacturer;
}
public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getFamily() {
return family;
}
public void setFamily(String family) {
this.family = family;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getModelId() {
return modelId;
}
public void setModelId(String modelId) {
this.modelId = modelId;
}
public Float getBatteryLevel() {
return batteryLevel;
}
public void setBatteryLevel(Float batteryLevel) {
this.batteryLevel = batteryLevel;
}
public Boolean isCharging() {
return charging;
}
public void setCharging(Boolean charging) {
this.charging = charging;
}
public Boolean isOnline() {
return online;
}
public void setOnline(Boolean online) {
this.online = online;
}
public DeviceOrientation getOrientation() {
return orientation;
}
public void setOrientation(DeviceOrientation orientation) {
this.orientation = orientation;
}
public Boolean isSimulator() {
return simulator;
}
public void setSimulator(Boolean simulator) {
this.simulator = simulator;
}
public Long getMemorySize() {
return memorySize;
}
public void setMemorySize(Long memorySize) {
this.memorySize = memorySize;
}
public Long getFreeMemory() {
return freeMemory;
}
public void setFreeMemory(Long freeMemory) {
this.freeMemory = freeMemory;
}
public Long getUsableMemory() {
return usableMemory;
}
public void setUsableMemory(Long usableMemory) {
this.usableMemory = usableMemory;
}
public Boolean isLowMemory() {
return lowMemory;
}
public void setLowMemory(Boolean lowMemory) {
this.lowMemory = lowMemory;
}
public Long getStorageSize() {
return storageSize;
}
public void setStorageSize(Long storageSize) {
this.storageSize = storageSize;
}
public Long getFreeStorage() {
return freeStorage;
}
public void setFreeStorage(Long freeStorage) {
this.freeStorage = freeStorage;
}
public Long getExternalStorageSize() {
return externalStorageSize;
}
public void setExternalStorageSize(Long externalStorageSize) {
this.externalStorageSize = externalStorageSize;
}
public Long getExternalFreeStorage() {
return externalFreeStorage;
}
public void setExternalFreeStorage(Long externalFreeStorage) {
this.externalFreeStorage = externalFreeStorage;
}
public Float getScreenDensity() {
return screenDensity;
}
public void setScreenDensity(Float screenDensity) {
this.screenDensity = screenDensity;
}
public Integer getScreenDpi() {
return screenDpi;
}
public void setScreenDpi(Integer screenDpi) {
this.screenDpi = screenDpi;
}
@SuppressWarnings("JdkObsolete")
public Date getBootTime() {
final Date bootTimeRef = bootTime;
return bootTimeRef != null ? (Date) bootTimeRef.clone() : null;
}
public void setBootTime(Date bootTime) {
this.bootTime = bootTime;
}
public TimeZone getTimezone() {
return timezone;
}
public void setTimezone(TimeZone timezone) {
this.timezone = timezone;
}
public String[] getArchs() {
return archs;
}
public void setArchs(String[] archs) {
this.archs = archs;
}
public Integer getScreenWidthPixels() {
return screenWidthPixels;
}
public void setScreenWidthPixels(Integer screenWidthPixels) {
this.screenWidthPixels = screenWidthPixels;
}
public Integer getScreenHeightPixels() {
return screenHeightPixels;
}
public void setScreenHeightPixels(Integer screenHeightPixels) {
this.screenHeightPixels = screenHeightPixels;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getConnectionType() {
return connectionType;
}
public void setConnectionType(String connectionType) {
this.connectionType = connectionType;
}
public Float getBatteryTemperature() {
return batteryTemperature;
}
public void setBatteryTemperature(Float batteryTemperature) {
this.batteryTemperature = batteryTemperature;
}
@TestOnly
Map<String, Object> getUnknown() {
return unknown;
}
@ApiStatus.Internal
@Override
public void acceptUnknownProperties(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 ? this.archs.clone() : null;
final TimeZone timezoneRef = this.timezone;
clone.timezone = timezoneRef != null ? (TimeZone) this.timezone.clone() : null;
clone.unknown = CollectionUtils.shallowCopy(unknown);
return clone;
}
public enum DeviceOrientation {
PORTRAIT,
LANDSCAPE
}
}