Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ed98d11
Various fixes to instrumentations running on the main thread (#4051)
romtsn Jan 16, 2025
e509503
Fix BroadcastReceivers (#4052)
romtsn Jan 16, 2025
0b511c9
Only provide {{auto}} ip-address if sendDefaultPii is enabled
markushi Jan 20, 2025
ef02e3a
Update changelog
markushi Jan 20, 2025
6381921
Reduce the number of IPC calls (#4058)
romtsn Jan 20, 2025
0126da6
release: 7.20.1
getsentry-bot Jan 20, 2025
3cdb905
Only send {{auto}} ip-adress if sendDefaultPii is enabled (7.x.x) (#4…
markushi Jan 20, 2025
e040da6
Merge branch 'release/7.20.1' into markushi/release-branch-for-7.20.1
Jan 20, 2025
af27480
Merge branch 'markushi/release-branch-for-7.20.1' into 7.x.x
markushi Jan 20, 2025
b1c5c1b
release: 7.21.0-beta.1
getsentry-bot Jan 20, 2025
1e796d8
Merge branch 'release/7.21.0-beta.1' into 7.x.x
Jan 20, 2025
5a70546
Prep changelog for 7.21.0 release
markushi Jan 27, 2025
56c8730
release: 7.21.0
getsentry-bot Jan 27, 2025
63342b7
Merge branch 'release/7.21.0' into 7.x.x
Jan 27, 2025
47a3903
Modifier.sentryTag uses Modifier.Node (#4029)
richkzad Feb 6, 2025
1eac2fc
Cherry-pick: Session Replay: Fix various crashes and issues (#4135) (…
romtsn Feb 7, 2025
d714dc8
feat(android-ndk): add api for getting debug images by addresses (#4159)
markushi Feb 11, 2025
8be0587
release: 7.22.0
getsentry-bot Feb 11, 2025
373370e
Merge branch 'release/7.22.0' into 7.x.x
Feb 11, 2025
f10c73c
Fix Ensure app start type is set, even when ActivityLifecycleIntegrat…
markushi Mar 10, 2025
90fd679
Fix properly reset application/content-provider timespans (#4244)
markushi Mar 10, 2025
2384975
release: 7.22.1
getsentry-bot Mar 10, 2025
3bb3cbe
Merge branch 'release/7.22.1' into 7.x.x
Mar 10, 2025
7c028eb
Fix AbstractMethodError when using SentryTraced for Jetpack Compose (…
markushi Mar 13, 2025
434c803
release: 7.22.2
getsentry-bot Mar 13, 2025
391b000
Merge branch 'release/7.22.2' into 7.x.x
Mar 13, 2025
9c964d0
Reduce excessive CPU usage when serializing breadcrumbs to disk (#418…
romtsn Mar 17, 2025
5e52d65
release: 7.22.3
getsentry-bot Mar 17, 2025
b326f55
Merge branch 'release/7.22.3' into 7.x.x
Mar 17, 2025
b14c7bf
Avoid reading floats as ints from the manifest in case it's not neces…
markushi Mar 19, 2025
bd16527
fix(session-replay): Do not crash if navigation breadcrumb has no de…
romtsn Mar 20, 2025
8a2fd32
release: 7.22.4
getsentry-bot Mar 20, 2025
a72b4b1
Merge branch 'release/7.22.4' into 7.x.x
Mar 20, 2025
6e6cea1
fix(replay): Change bitmap config to `ARGB_8888` for screenshots (#42…
romtsn Mar 24, 2025
4727424
release: 7.22.5
getsentry-bot Mar 24, 2025
49f0f1c
Compress Screenshots on a background thread (#4295)
markushi Apr 7, 2025
91015a0
fix(breadcrumbs): Improve low memory breadcrumb capturing (#4325)
romtsn Apr 10, 2025
2ed8422
perf(breadcrumbs): Make SystemEventsBreadcrumbsIntegration faster (#4…
romtsn Apr 14, 2025
46c831a
fix(breadcrumbs): Unregister SystemEventsBroadcastReceiver when enter…
romtsn Apr 17, 2025
940b89a
perf(modules): Pre-load modules on a background thread (#4348)
romtsn Apr 22, 2025
ac2561c
fix(replay): Inconsistent segment_id (#4471)
romtsn Jun 5, 2025
3f751c9
fix(replay): Do not capture replay for cached events (#4474)
romtsn Jun 6, 2025
5b51c8f
fix(replay): Fix crash on devices with the Unisoc/Spreadtrum T606 chi…
romtsn Jun 11, 2025
5546e1e
fix(replay): Use global visible rect when text layout is not laid out…
romtsn Apr 28, 2025
0eb04f5
fix(replay): Mask read-only TextField Composables (#4362)
romtsn Apr 28, 2025
307b057
Determine recording size based on active window (#4354)
markushi Jun 5, 2025
9a31afc
Api dump
romtsn Jul 8, 2025
c738037
Fix replay masking for Jetpack Compose 1.8+ (#4485)
markushi Jun 17, 2025
ba37867
fix(replay): Expand fix for crash on devices to all Unisoc/Spreadtrum…
romtsn Jun 23, 2025
185b5dc
fix(replay): Fix `IllegalArgumentException` when `Bitmap` is initiali…
romtsn Jul 3, 2025
6d183f3
Fix test
romtsn Jul 8, 2025
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
129 changes: 129 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,134 @@
# Changelog

## Unreleased

### Fixes

- Compress Screenshots on a background thread ([#4295](https://github.com/getsentry/sentry-java/pull/4295))
- Improve low memory breadcrumb capturing ([#4325](https://github.com/getsentry/sentry-java/pull/4325))
- Make `SystemEventsBreadcrumbsIntegration` faster ([#4330](https://github.com/getsentry/sentry-java/pull/4330))
- Fix unregister `SystemEventsBroadcastReceiver` when entering background ([#4338](https://github.com/getsentry/sentry-java/pull/4338))
- This should reduce ANRs seen with this class in the stack trace for Android 14 and above
- Pre-load modules on a background thread upon SDK init ([#4348](https://github.com/getsentry/sentry-java/pull/4348))
- Session Replay: Fix inconsistent `segment_id` ([#4471](https://github.com/getsentry/sentry-java/pull/4471))
- Session Replay: Do not capture current replay for cached events from the past ([#4474](https://github.com/getsentry/sentry-java/pull/4474))
- Session Replay: Fix crash on devices with the Unisoc/Spreadtrum T606 chipset ([#4477](https://github.com/getsentry/sentry-java/pull/4477))
- Session Replay: Fix masking of non-styled `Text` Composables ([#4361](https://github.com/getsentry/sentry-java/pull/4361))
- Session Replay: Fix masking read-only `TextField` Composables ([#4362](https://github.com/getsentry/sentry-java/pull/4362))
- Correctly capture Dialogs and non full-sized windows ([#4354](https://github.com/getsentry/sentry-java/pull/4354))
- Fix Session Replay masking for newer versions of Jetpack Compose (1.8+) ([#4485](https://github.com/getsentry/sentry-java/pull/4485))
- Session Replay: Expand fix for crash on devices to all Unisoc/Spreadtrum chipsets ([#4510](https://github.com/getsentry/sentry-java/pull/4510))
- Session Replay: Fix `IllegalArgumentException` when `Bitmap` is initialized with non-positive values ([#4536](https://github.com/getsentry/sentry-java/pull/4536))

## 7.22.5

### Fixes

- Session Replay: Change bitmap config to `ARGB_8888` for screenshots ([#4282](https://github.com/getsentry/sentry-java/pull/4282))

## 7.22.4

### Fixes

- Session Replay: Fix crash when a navigation breadcrumb does not have "to" destination ([#4185](https://github.com/getsentry/sentry-java/pull/4185))
- Session Replay: Cap video segment duration to maximum 5 minutes to prevent endless video encoding in background ([#4185](https://github.com/getsentry/sentry-java/pull/4185))
- Avoid logging an error when a float is passed in the manifest ([#4266](https://github.com/getsentry/sentry-java/pull/4266))

## 7.22.3

### Fixes

- Reduce excessive CPU usage when serializing breadcrumbs to disk for ANRs ([#4181](https://github.com/getsentry/sentry-java/pull/4181))

## 7.22.2

### Fixes

- Fix AbstractMethodError when using SentryTraced for Jetpack Compose ([#4256](https://github.com/getsentry/sentry-java/pull/4256))

## 7.22.1

### Fixes

- Fix Ensure app start type is set, even when ActivityLifecycleIntegration is not running ([#4216](https://github.com/getsentry/sentry-java/pull/4216))
- Fix properly reset application/content-provider timespans for warm app starts ([#4244](https://github.com/getsentry/sentry-java/pull/4244))

## 7.22.0

### Fixes

- Session Replay: Fix various crashes and issues ([#4135](https://github.com/getsentry/sentry-java/pull/4135))
- Fix `FileNotFoundException` when trying to read/write `.ongoing_segment` file
- Fix `IllegalStateException` when registering `onDrawListener`
- Fix SIGABRT native crashes on Motorola devices when encoding a video
- (Jetpack Compose) Modifier.sentryTag now uses Modifier.Node ([#4029](https://github.com/getsentry/sentry-java/pull/4029))
- This allows Composables that use this modifier to be skippable

### Features

- (Internal) Add API to filter native debug images based on stacktrace addresses ([#4159](https://github.com/getsentry/sentry-java/pull/4159))

## 7.21.0

### Fixes

- Do not instrument File I/O operations if tracing is disabled ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Do not instrument User Interaction multiple times ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Speed up view traversal to find touched target in `UserInteractionIntegration` ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Reduce IPC/Binder calls performed by the SDK ([#4058](https://github.com/getsentry/sentry-java/pull/4058))

### Behavioural Changes

- Reduce the number of broadcasts the SDK is subscribed for ([#4052](https://github.com/getsentry/sentry-java/pull/4052))
- Drop `TempSensorBreadcrumbsIntegration`
- Drop `PhoneStateBreadcrumbsIntegration`
- Reduce number of broadcasts in `SystemEventsBreadcrumbsIntegration`

Current list of the broadcast events can be found [here](https://github.com/getsentry/sentry-java/blob/9b8dc0a844d10b55ddeddf55d278c0ab0f86421c/sentry-android-core/src/main/java/io/sentry/android/core/SystemEventsBreadcrumbsIntegration.java#L131-L153). If you'd like to subscribe for more events, consider overriding the `SystemEventsBreadcrumbsIntegration` as follows:

```kotlin
SentryAndroid.init(context) { options ->
options.integrations.removeAll { it is SystemEventsBreadcrumbsIntegration }
options.integrations.add(SystemEventsBreadcrumbsIntegration(context, SystemEventsBreadcrumbsIntegration.getDefaultActions() + listOf(/* your custom actions */)))
}
```

If you would like to keep some of the default broadcast events as breadcrumbs, consider opening a [GitHub issue](https://github.com/getsentry/sentry-java/issues/new).

## 7.21.0-beta.1

### Fixes

- Do not instrument File I/O operations if tracing is disabled ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Do not instrument User Interaction multiple times ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Speed up view traversal to find touched target in `UserInteractionIntegration` ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Reduce IPC/Binder calls performed by the SDK ([#4058](https://github.com/getsentry/sentry-java/pull/4058))

### Behavioural Changes

- Reduce the number of broadcasts the SDK is subscribed for ([#4052](https://github.com/getsentry/sentry-java/pull/4052))
- Drop `TempSensorBreadcrumbsIntegration`
- Drop `PhoneStateBreadcrumbsIntegration`
- Reduce number of broadcasts in `SystemEventsBreadcrumbsIntegration`

Current list of the broadcast events can be found [here](https://github.com/getsentry/sentry-java/blob/9b8dc0a844d10b55ddeddf55d278c0ab0f86421c/sentry-android-core/src/main/java/io/sentry/android/core/SystemEventsBreadcrumbsIntegration.java#L131-L153). If you'd like to subscribe for more events, consider overriding the `SystemEventsBreadcrumbsIntegration` as follows:

```kotlin
SentryAndroid.init(context) { options ->
options.integrations.removeAll { it is SystemEventsBreadcrumbsIntegration }
options.integrations.add(SystemEventsBreadcrumbsIntegration(context, SystemEventsBreadcrumbsIntegration.getDefaultActions() + listOf(/* your custom actions */)))
}
```

If you would like to keep some of the default broadcast events as breadcrumbs, consider opening a [GitHub issue](https://github.com/getsentry/sentry-java/issues/new).

## 7.20.1

### Behavioural Changes

- The user ip-address is now only set to `"{{auto}}"` if sendDefaultPii is enabled ([#4071](https://github.com/getsentry/sentry-java/pull/4071))
- This change gives you control over IP address collection directly on the client

## 7.20.0

### Features
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ object Config {
val javaFaker = "com.github.javafaker:javafaker:1.0.2"
val msgpack = "org.msgpack:msgpack-core:0.9.8"
val leakCanaryInstrumentation = "com.squareup.leakcanary:leakcanary-android-instrumentation:2.14"
val composeUiTestJunit4 = "androidx.compose.ui:ui-test-junit4:$composeVersion"
val okio = "com.squareup.okio:okio:1.13.0"
}

object QualityPlugins {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android.useAndroidX=true
android.defaults.buildfeatures.buildconfig=true

# Release information
versionName=7.20.0
versionName=7.22.5

# Override the SDK name on native crashes on Android
sentryAndroidSdkName=sentry.native.android
Expand Down
34 changes: 17 additions & 17 deletions sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public final class io/sentry/android/core/DeviceInfoUtil {
public static fun getInstance (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;)Lio/sentry/android/core/DeviceInfoUtil;
public fun getOperatingSystem ()Lio/sentry/protocol/OperatingSystem;
public fun getSideLoadedInfo ()Lio/sentry/android/core/ContextUtils$SideLoadedInfo;
public fun getTotalMemory ()Ljava/lang/Long;
public static fun isCharging (Landroid/content/Intent;Lio/sentry/SentryOptions;)Ljava/lang/Boolean;
public static fun resetInstance ()V
}
Expand All @@ -207,6 +208,7 @@ public abstract class io/sentry/android/core/EnvelopeFileObserverIntegration : i
public abstract interface class io/sentry/android/core/IDebugImagesLoader {
public abstract fun clearDebugImages ()V
public abstract fun loadDebugImages ()Ljava/util/List;
public abstract fun loadDebugImagesForAddresses (Ljava/util/Set;)Ljava/util/Set;
}

public final class io/sentry/android/core/InternalSentrySdk {
Expand Down Expand Up @@ -245,12 +247,6 @@ public final class io/sentry/android/core/NetworkBreadcrumbsIntegration : io/sen
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/PhoneStateBreadcrumbsIntegration : io/sentry/Integration, java/io/Closeable {
public fun <init> (Landroid/content/Context;)V
public fun close ()V
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/ScreenshotEventProcessor : io/sentry/EventProcessor {
public fun <init> (Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/android/core/BuildInfoProvider;)V
public fun process (Lio/sentry/SentryEvent;Lio/sentry/Hint;)Lio/sentry/SentryEvent;
Expand Down Expand Up @@ -379,14 +375,7 @@ public final class io/sentry/android/core/SystemEventsBreadcrumbsIntegration : i
public fun <init> (Landroid/content/Context;)V
public fun <init> (Landroid/content/Context;Ljava/util/List;)V
public fun close ()V
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/TempSensorBreadcrumbsIntegration : android/hardware/SensorEventListener, io/sentry/Integration, java/io/Closeable {
public fun <init> (Landroid/content/Context;)V
public fun close ()V
public fun onAccuracyChanged (Landroid/hardware/Sensor;I)V
public fun onSensorChanged (Landroid/hardware/SensorEvent;)V
public static fun getDefaultActions ()Ljava/util/List;
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
}

Expand Down Expand Up @@ -458,15 +447,15 @@ public class io/sentry/android/core/performance/AppStartMetrics : io/sentry/andr
public static fun getInstance ()Lio/sentry/android/core/performance/AppStartMetrics;
public fun getSdkInitTimeSpan ()Lio/sentry/android/core/performance/TimeSpan;
public fun isAppLaunchedInForeground ()Z
public fun isColdStartValid ()Z
public fun onActivityCreated (Landroid/app/Activity;Landroid/os/Bundle;)V
public fun onActivityDestroyed (Landroid/app/Activity;)V
public fun onActivityStarted (Landroid/app/Activity;)V
public fun onAppStartSpansSent ()V
public static fun onApplicationCreate (Landroid/app/Application;)V
public static fun onApplicationPostCreate (Landroid/app/Application;)V
public static fun onContentProviderCreate (Landroid/content/ContentProvider;)V
public static fun onContentProviderPostCreate (Landroid/content/ContentProvider;)V
public fun registerApplicationForegroundCheck (Landroid/app/Application;)V
public fun restartAppStart (J)V
public fun registerLifecycleCallbacks (Landroid/app/Application;)V
public fun setAppLaunchedInForeground (Z)V
public fun setAppStartProfiler (Lio/sentry/ITransactionProfiler;)V
public fun setAppStartSamplingDecision (Lio/sentry/TracesSamplingDecision;)V
Expand Down Expand Up @@ -514,3 +503,14 @@ public class io/sentry/android/core/performance/WindowContentChangedCallback : i
public fun onContentChanged ()V
}

public final class io/sentry/android/core/util/AndroidLazyEvaluator {
public fun <init> (Lio/sentry/android/core/util/AndroidLazyEvaluator$AndroidEvaluator;)V
public fun getValue (Landroid/content/Context;)Ljava/lang/Object;
public fun resetValue ()V
public fun setValue (Ljava/lang/Object;)V
}

public abstract interface class io/sentry/android/core/util/AndroidLazyEvaluator$AndroidEvaluator {
public abstract fun evaluate (Landroid/content/Context;)Ljava/lang/Object;
}

Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ public synchronized void onActivityCreated(
if (!isAllActivityCallbacksAvailable) {
onActivityPreCreated(activity, savedInstanceState);
}
setColdStart(savedInstanceState);
if (hub != null && options != null && options.isEnableScreenTracking()) {
final @Nullable String activityClassName = ClassUtil.getClassName(activity);
hub.configureScope(scope -> scope.setScreen(activityClassName));
Expand Down Expand Up @@ -554,15 +553,13 @@ public synchronized void onActivityDestroyed(final @NotNull Activity activity) {
// if the activity is opened again and not in memory, transactions will be created normally.
activitiesWithOngoingTransactions.remove(activity);

if (activitiesWithOngoingTransactions.isEmpty()) {
if (activitiesWithOngoingTransactions.isEmpty() && !activity.isChangingConfigurations()) {
clear();
}
}

private void clear() {
firstActivityCreated = false;
lastPausedTime = new SentryNanotimeDate(new Date(0), 0);
lastPausedUptimeMillis = 0;
activityLifecycleMap.clear();
}

Expand Down Expand Up @@ -705,27 +702,6 @@ WeakHashMap<Activity, ISpan> getTtfdSpanMap() {
return ttfdSpanMap;
}

private void setColdStart(final @Nullable Bundle savedInstanceState) {
if (!firstActivityCreated) {
final @NotNull TimeSpan appStartSpan = AppStartMetrics.getInstance().getAppStartTimeSpan();
// If the app start span already started and stopped, it means the app restarted without
// killing the process, so we are in a warm start
// If the app has an invalid cold start, it means it was started in the background, like
// via BroadcastReceiver, so we consider it a warm start
if ((appStartSpan.hasStarted() && appStartSpan.hasStopped())
|| (!AppStartMetrics.getInstance().isColdStartValid())) {
AppStartMetrics.getInstance().restartAppStart(lastPausedUptimeMillis);
AppStartMetrics.getInstance().setAppStartType(AppStartMetrics.AppStartType.WARM);
} else {
AppStartMetrics.getInstance()
.setAppStartType(
savedInstanceState == null
? AppStartMetrics.AppStartType.COLD
: AppStartMetrics.AppStartType.WARM);
}
}
}

private @NotNull String getTtidDesc(final @NotNull String activityName) {
return activityName + " initial display";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ static void initializeIntegrationsAndProcessors(
new AndroidConnectionStatusProvider(context, options.getLogger(), buildInfoProvider));
}

if (options.getCacheDirPath() != null) {
options.addScopeObserver(new PersistingScopeObserver(options));
options.addOptionsObserver(new PersistingOptionsObserver(options));
}

options.addEventProcessor(new DeduplicateMultithreadedEventProcessor(options));
options.addEventProcessor(
new DefaultAndroidEventProcessor(context, buildInfoProvider, options));
Expand Down Expand Up @@ -221,13 +226,6 @@ static void initializeIntegrationsAndProcessors(
}
}
options.setTransactionPerformanceCollector(new DefaultTransactionPerformanceCollector(options));

if (options.getCacheDirPath() != null) {
if (options.isEnableScopePersistence()) {
options.addScopeObserver(new PersistingScopeObserver(options));
}
options.addOptionsObserver(new PersistingOptionsObserver(options));
}
}

static void installDefaultIntegrations(
Expand Down Expand Up @@ -273,6 +271,8 @@ static void installDefaultIntegrations(
// AppLifecycleIntegration has to be installed before AnrIntegration, because AnrIntegration
// relies on AppState set by it
options.addIntegration(new AppLifecycleIntegration());
// AnrIntegration must be installed before ReplayIntegration, as ReplayIntegration relies on
// it to set the replayId in case of an ANR
options.addIntegration(AnrIntegrationFactory.create(context, buildInfoProvider));

// registerActivityLifecycleCallbacks is only available if Context is an AppContext
Expand Down Expand Up @@ -301,8 +301,6 @@ static void installDefaultIntegrations(
options.addIntegration(new SystemEventsBreadcrumbsIntegration(context));
options.addIntegration(
new NetworkBreadcrumbsIntegration(context, buildInfoProvider, options.getLogger()));
options.addIntegration(new TempSensorBreadcrumbsIntegration(context));
options.addIntegration(new PhoneStateBreadcrumbsIntegration(context));
if (isReplayAvailable) {
final ReplayIntegration replay =
new ReplayIntegration(context, CurrentDateProvider.getInstance());
Expand All @@ -322,8 +320,8 @@ private static void readDefaultOptionValues(
final @NotNull SentryAndroidOptions options,
final @NotNull Context context,
final @NotNull BuildInfoProvider buildInfoProvider) {
final PackageInfo packageInfo =
ContextUtils.getPackageInfo(context, options.getLogger(), buildInfoProvider);
final @Nullable PackageInfo packageInfo =
ContextUtils.getPackageInfo(context, buildInfoProvider);
if (packageInfo != null) {
// Sets App's release if not set by Manifest
if (options.getRelease() == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package io.sentry.android.core;

import static android.content.Context.ACTIVITY_SERVICE;
import static java.util.concurrent.TimeUnit.SECONDS;

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.os.Process;
Expand Down Expand Up @@ -265,9 +263,12 @@ public synchronized void bindTransaction(final @NotNull ITransaction transaction
transactionsCounter = 0;

String totalMem = "0";
ActivityManager.MemoryInfo memInfo = getMemInfo();
if (memInfo != null) {
totalMem = Long.toString(memInfo.totalMem);
final @Nullable Long memory =
(options instanceof SentryAndroidOptions)
? DeviceInfoUtil.getInstance(context, (SentryAndroidOptions) options).getTotalMemory()
: null;
if (memory != null) {
totalMem = Long.toString(memory);
}
String[] abis = Build.SUPPORTED_ABIS;

Expand Down Expand Up @@ -333,27 +334,6 @@ public void close() {
}
}

/**
* Get MemoryInfo object representing the memory state of the application.
*
* @return MemoryInfo object representing the memory state of the application
*/
private @Nullable ActivityManager.MemoryInfo getMemInfo() {
try {
ActivityManager actManager = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
if (actManager != null) {
actManager.getMemoryInfo(memInfo);
return memInfo;
}
logger.log(SentryLevel.INFO, "Error getting MemoryInfo.");
return null;
} catch (Throwable e) {
logger.log(SentryLevel.ERROR, "Error getting MemoryInfo.", e);
return null;
}
}

@TestOnly
int getTransactionsCounter() {
return transactionsCounter;
Expand Down
Loading