Skip to content

Commit

Permalink
Add emulator to device metadata (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench authored and kattrali committed Feb 13, 2018
1 parent 537947b commit 7613240
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sdk/src/main/java/com/bugsnag/android/DeviceData.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void toStream(@NonNull JsonStream writer) throws IOException {
.name("locale").value(locale)
.name("screenDensity").value(screenDensity)
.name("dpi").value(dpi)
.name("emulator").value(isEmulator())
.name("screenResolution").value(screenResolution);

writer.name("cpuAbi").beginArray();
Expand All @@ -109,6 +110,18 @@ void setId(@Nullable String id) {
this.id = id;
}

/**
* Guesses whether the current device is an emulator or not, erring on the side of caution
*
* @return true if the current device is an emulator
*/
private boolean isEmulator() {
String fingerprint = Build.FINGERPRINT;
return fingerprint.startsWith("unknown")
|| fingerprint.contains("generic")
|| fingerprint.contains("vbox"); // genymotion
}

/**
* The screen density scaling factor of the current Android device
*/
Expand Down

0 comments on commit 7613240

Please sign in to comment.