Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
- Android: Attachments on the scope will now be synced to native ([#5211](https://github.com/getsentry/sentry-java/pull/5211))
- Add THIRD_PARTY_NOTICES.md for vendored third-party code, bundled as SENTRY_THIRD_PARTY_NOTICES.md in the sentry JAR under META-INF ([#5186](https://github.com/getsentry/sentry-java/pull/5186))

### Improvements

- Do not retrieve `ActivityManager` if API < 35 on SDK init ([#5275](https://github.com/getsentry/sentry-java/pull/5275))

## 8.37.1

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,19 +338,20 @@ public void registerLifecycleCallbacks(final @NotNull Application application) {
appLaunchedInForeground.resetValue();
application.registerActivityLifecycleCallbacks(instance);

final @Nullable ActivityManager activityManager =
(ActivityManager) application.getSystemService(Context.ACTIVITY_SERVICE);

if (activityManager != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
final List<ApplicationStartInfo> historicalProcessStartReasons =
activityManager.getHistoricalProcessStartReasons(1);
if (!historicalProcessStartReasons.isEmpty()) {
final @NotNull ApplicationStartInfo info = historicalProcessStartReasons.get(0);
if (info.getStartupState() == ApplicationStartInfo.STARTUP_STATE_STARTED) {
if (info.getStartType() == ApplicationStartInfo.START_TYPE_COLD) {
appStartType = AppStartType.COLD;
} else {
appStartType = AppStartType.WARM;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
final @Nullable ActivityManager activityManager =
(ActivityManager) application.getSystemService(Context.ACTIVITY_SERVICE);
if (activityManager != null) {
final List<ApplicationStartInfo> historicalProcessStartReasons =
activityManager.getHistoricalProcessStartReasons(1);
if (!historicalProcessStartReasons.isEmpty()) {
final @NotNull ApplicationStartInfo info = historicalProcessStartReasons.get(0);
if (info.getStartupState() == ApplicationStartInfo.STARTUP_STATE_STARTED) {
if (info.getStartType() == ApplicationStartInfo.START_TYPE_COLD) {
appStartType = AppStartType.COLD;
} else {
appStartType = AppStartType.WARM;
}
}
}
}
Expand Down
Loading