Skip to content

Commit

Permalink
Merge 7501b98 into d5106da
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Apr 16, 2019
2 parents d5106da + 7501b98 commit 2a26643
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,9 @@

## TBD

* Use packageInfo.longVersionCode to collect versionCode on API 28+
[#471](https://github.com/bugsnag/bugsnag-android/pull/471)

### Bug fixes

* [NDK] Fix possible null pointer dereference
Expand Down
10 changes: 9 additions & 1 deletion sdk/src/main/java/com/bugsnag/android/AppData.java
Expand Up @@ -5,6 +5,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
Expand Down Expand Up @@ -137,7 +138,14 @@ private String calculateNotifierType(Configuration config) {
@SuppressWarnings("deprecation")
private Integer calculateVersionCode() {
if (packageInfo != null) {
return packageInfo.versionCode;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
// Android P added an android:versionCodeMajor field for anyone who ran out of
// space in android:versionCode. As it's stored in the upper 32 bits
// we want to ignore those, and retrieve the versionCode value only.
return (int) (packageInfo.getLongVersionCode() & 0x0000FFFFL);
} else {
return packageInfo.versionCode;
}
} else {
return null;
}
Expand Down

0 comments on commit 2a26643

Please sign in to comment.