Skip to content

Commit 7e764ee

Browse files
authored
Merge 1335a5c into 29a4185
2 parents 29a4185 + 1335a5c commit 7e764ee

File tree

38 files changed

+505
-787
lines changed

38 files changed

+505
-787
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- Do not instrument File I/O operations if tracing is disabled ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
8+
- Do not instrument User Interaction multiple times ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
9+
- Speed up view traversal to find touched target in `UserInteractionIntegration` ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
10+
- Reduce IPC/Binder calls performed by the SDK ([#4058](https://github.com/getsentry/sentry-java/pull/4058))
11+
12+
### Behavioural Changes
13+
14+
- Reduce the number of broadcasts the SDK is subscribed for ([#4052](https://github.com/getsentry/sentry-java/pull/4052))
15+
- Drop `TempSensorBreadcrumbsIntegration`
16+
- Drop `PhoneStateBreadcrumbsIntegration`
17+
- Reduce number of broadcasts in `SystemEventsBreadcrumbsIntegration`
18+
19+
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:
20+
21+
```kotlin
22+
SentryAndroid.init(context) { options ->
23+
options.integrations.removeAll { it is SystemEventsBreadcrumbsIntegration }
24+
options.integrations.add(SystemEventsBreadcrumbsIntegration(context, SystemEventsBreadcrumbsIntegration.getDefaultActions() + listOf(/* your custom actions */)))
25+
}
26+
```
27+
28+
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).
29+
530
### Features
631

732
- Add `options.ignoredErrors` to filter out errors that match a certain String or Regex ([#4083](https://github.com/getsentry/sentry-java/pull/4083))

sentry-android-core/api/sentry-android-core.api

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public final class io/sentry/android/core/DeviceInfoUtil {
195195
public static fun getInstance (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;)Lio/sentry/android/core/DeviceInfoUtil;
196196
public fun getOperatingSystem ()Lio/sentry/protocol/OperatingSystem;
197197
public fun getSideLoadedInfo ()Lio/sentry/android/core/ContextUtils$SideLoadedInfo;
198+
public fun getTotalMemory ()Ljava/lang/Long;
198199
public static fun isCharging (Landroid/content/Intent;Lio/sentry/SentryOptions;)Ljava/lang/Boolean;
199200
public static fun resetInstance ()V
200201
}
@@ -248,12 +249,6 @@ public final class io/sentry/android/core/NetworkBreadcrumbsIntegration : io/sen
248249
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
249250
}
250251

251-
public final class io/sentry/android/core/PhoneStateBreadcrumbsIntegration : io/sentry/Integration, java/io/Closeable {
252-
public fun <init> (Landroid/content/Context;)V
253-
public fun close ()V
254-
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
255-
}
256-
257252
public final class io/sentry/android/core/ScreenshotEventProcessor : io/sentry/EventProcessor {
258253
public fun <init> (Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/android/core/BuildInfoProvider;)V
259254
public fun getOrder ()Ljava/lang/Long;
@@ -382,14 +377,7 @@ public final class io/sentry/android/core/SystemEventsBreadcrumbsIntegration : i
382377
public fun <init> (Landroid/content/Context;)V
383378
public fun <init> (Landroid/content/Context;Ljava/util/List;)V
384379
public fun close ()V
385-
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
386-
}
387-
388-
public final class io/sentry/android/core/TempSensorBreadcrumbsIntegration : android/hardware/SensorEventListener, io/sentry/Integration, java/io/Closeable {
389-
public fun <init> (Landroid/content/Context;)V
390-
public fun close ()V
391-
public fun onAccuracyChanged (Landroid/hardware/Sensor;I)V
392-
public fun onSensorChanged (Landroid/hardware/SensorEvent;)V
380+
public static fun getDefaultActions ()Ljava/util/List;
393381
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
394382
}
395383

@@ -535,3 +523,14 @@ public class io/sentry/android/core/performance/WindowContentChangedCallback : i
535523
public fun onContentChanged ()V
536524
}
537525

526+
public final class io/sentry/android/core/util/AndroidLazyEvaluator {
527+
public fun <init> (Lio/sentry/android/core/util/AndroidLazyEvaluator$AndroidEvaluator;)V
528+
public fun getValue (Landroid/content/Context;)Ljava/lang/Object;
529+
public fun resetValue ()V
530+
public fun setValue (Ljava/lang/Object;)V
531+
}
532+
533+
public abstract interface class io/sentry/android/core/util/AndroidLazyEvaluator$AndroidEvaluator {
534+
public abstract fun evaluate (Landroid/content/Context;)Ljava/lang/Object;
535+
}
536+

sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,6 @@ static void installDefaultIntegrations(
305305
options.addIntegration(new SystemEventsBreadcrumbsIntegration(context));
306306
options.addIntegration(
307307
new NetworkBreadcrumbsIntegration(context, buildInfoProvider, options.getLogger()));
308-
options.addIntegration(new TempSensorBreadcrumbsIntegration(context));
309-
options.addIntegration(new PhoneStateBreadcrumbsIntegration(context));
310308
if (isReplayAvailable) {
311309
final ReplayIntegration replay =
312310
new ReplayIntegration(context, CurrentDateProvider.getInstance());
@@ -326,8 +324,8 @@ private static void readDefaultOptionValues(
326324
final @NotNull SentryAndroidOptions options,
327325
final @NotNull Context context,
328326
final @NotNull BuildInfoProvider buildInfoProvider) {
329-
final PackageInfo packageInfo =
330-
ContextUtils.getPackageInfo(context, options.getLogger(), buildInfoProvider);
327+
final @Nullable PackageInfo packageInfo =
328+
ContextUtils.getPackageInfo(context, buildInfoProvider);
331329
if (packageInfo != null) {
332330
// Sets App's release if not set by Manifest
333331
if (options.getRelease() == null) {

sentry-android-core/src/main/java/io/sentry/android/core/AndroidTransactionProfiler.java

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package io.sentry.android.core;
22

3-
import static android.content.Context.ACTIVITY_SERVICE;
43
import static java.util.concurrent.TimeUnit.SECONDS;
54

65
import android.annotation.SuppressLint;
7-
import android.app.ActivityManager;
86
import android.content.Context;
97
import android.os.Build;
108
import android.os.Process;
@@ -258,9 +256,12 @@ public void bindTransaction(final @NotNull ITransaction transaction) {
258256
transactionsCounter = 0;
259257

260258
String totalMem = "0";
261-
ActivityManager.MemoryInfo memInfo = getMemInfo();
262-
if (memInfo != null) {
263-
totalMem = Long.toString(memInfo.totalMem);
259+
final @Nullable Long memory =
260+
(options instanceof SentryAndroidOptions)
261+
? DeviceInfoUtil.getInstance(context, (SentryAndroidOptions) options).getTotalMemory()
262+
: null;
263+
if (memory != null) {
264+
totalMem = Long.toString(memory);
264265
}
265266
String[] abis = Build.SUPPORTED_ABIS;
266267

@@ -327,27 +328,6 @@ public void close() {
327328
}
328329
}
329330

330-
/**
331-
* Get MemoryInfo object representing the memory state of the application.
332-
*
333-
* @return MemoryInfo object representing the memory state of the application
334-
*/
335-
private @Nullable ActivityManager.MemoryInfo getMemInfo() {
336-
try {
337-
ActivityManager actManager = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
338-
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
339-
if (actManager != null) {
340-
actManager.getMemoryInfo(memInfo);
341-
return memInfo;
342-
}
343-
logger.log(SentryLevel.INFO, "Error getting MemoryInfo.");
344-
return null;
345-
} catch (Throwable e) {
346-
logger.log(SentryLevel.ERROR, "Error getting MemoryInfo.", e);
347-
return null;
348-
}
349-
}
350-
351331
@TestOnly
352332
int getTransactionsCounter() {
353333
return transactionsCounter;

sentry-android-core/src/main/java/io/sentry/android/core/AnrV2EventProcessor.java

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,13 @@ private void setApp(final @NotNull SentryBaseEvent event, final @NotNull Object
374374
if (app == null) {
375375
app = new App();
376376
}
377-
app.setAppName(ContextUtils.getApplicationName(context, options.getLogger()));
377+
app.setAppName(ContextUtils.getApplicationName(context));
378378
// TODO: not entirely correct, because we define background ANRs as not the ones of
379379
// IMPORTANCE_FOREGROUND, but this doesn't mean the app was in foreground when an ANR happened
380380
// but it's our best effort for now. We could serialize AppState in theory.
381381
app.setInForeground(!isBackgroundAnr(hint));
382382

383-
final PackageInfo packageInfo =
384-
ContextUtils.getPackageInfo(context, options.getLogger(), buildInfoProvider);
383+
final PackageInfo packageInfo = ContextUtils.getPackageInfo(context, buildInfoProvider);
385384
if (packageInfo != null) {
386385
app.setAppIdentifier(packageInfo.packageName);
387386
}
@@ -597,8 +596,7 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
597596
private void setSideLoadedInfo(final @NotNull SentryBaseEvent event) {
598597
try {
599598
final ContextUtils.SideLoadedInfo sideLoadedInfo =
600-
ContextUtils.retrieveSideLoadedInfo(context, options.getLogger(), buildInfoProvider);
601-
599+
DeviceInfoUtil.getInstance(context, options).getSideLoadedInfo();
602600
if (sideLoadedInfo != null) {
603601
final @NotNull Map<String, String> tags = sideLoadedInfo.asTags();
604602
for (Map.Entry<String, String> entry : tags.entrySet()) {
@@ -667,7 +665,8 @@ private void setDevice(final @NotNull SentryBaseEvent event) {
667665

668666
private void mergeOS(final @NotNull SentryBaseEvent event) {
669667
final OperatingSystem currentOS = event.getContexts().getOperatingSystem();
670-
final OperatingSystem androidOS = getOperatingSystem();
668+
final OperatingSystem androidOS =
669+
DeviceInfoUtil.getInstance(context, options).getOperatingSystem();
671670

672671
// make Android OS the main OS using the 'os' key
673672
event.getContexts().setOperatingSystem(androidOS);
@@ -683,20 +682,5 @@ private void mergeOS(final @NotNull SentryBaseEvent event) {
683682
event.getContexts().put(osNameKey, currentOS);
684683
}
685684
}
686-
687-
private @NotNull OperatingSystem getOperatingSystem() {
688-
OperatingSystem os = new OperatingSystem();
689-
os.setName("Android");
690-
os.setVersion(Build.VERSION.RELEASE);
691-
os.setBuild(Build.DISPLAY);
692-
693-
try {
694-
os.setKernelVersion(ContextUtils.getKernelVersion(options.getLogger()));
695-
} catch (Throwable e) {
696-
options.getLogger().log(SentryLevel.ERROR, "Error getting OperatingSystem.", e);
697-
}
698-
699-
return os;
700-
}
701685
// endregion
702686
}

0 commit comments

Comments
 (0)