Skip to content

Commit 2748875

Browse files
markushiromtsngetsentry-botstefanosiano
authored
Re-apply 7.x.x changes (#4124)
* Various fixes to instrumentations running on the main thread (#4051) * Get rid of redundant requireNonNull * Do not instrument Window.Callback multiple times * Do not instrument FileIO if tracing is disabled * Do not traverse children if a touch event is not within view groups bounds * Add test for SentryFileOutputStream * Fix test * Fix test * Changelog * pr id * Fix api dump * Fix BroadcastReceivers (#4052) * Drop TempSesnorBreadcrumbIntegration * Drop PhoneStateBreadcrumbsIntegration * Reduce number of system events we're listening to and use RECEIVER_NOT_EXPORTED * Format code * Changelog * Update CHANGELOG.md Co-authored-by: Stefano <[email protected]> * Update CHANGELOG.md Co-authored-by: Stefano <[email protected]> --------- Co-authored-by: Sentry Github Bot <[email protected]> Co-authored-by: Stefano <[email protected]> * Only provide {{auto}} ip-address if sendDefaultPii is enabled * Update changelog * Reduce the number of IPC calls (#4058) * Remove binder call for external storage * Remove binder call for memory in profiler * Cache static values to avoid binder calls * Comment * Changelog * Formatting * Fix tests * Minor fixes * change protected method in final class to private --------- Co-authored-by: Markus Hintersteiner <[email protected]> Co-authored-by: stefanosiano <[email protected]> * Update Changelog * Fix tests --------- Co-authored-by: Roman Zavarnitsyn <[email protected]> Co-authored-by: Sentry Github Bot <[email protected]> Co-authored-by: Stefano <[email protected]>
1 parent a9719c7 commit 2748875

38 files changed

+564
-787
lines changed

CHANGELOG.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@
1919
- Remove `java.lang.ClassNotFoundException` debug logs when searching for OpenTelemetry marker classes ([#4091](https://github.com/getsentry/sentry-java/pull/4091))
2020
- There was up to three of these, one for `io.sentry.opentelemetry.agent.AgentMarker`, `io.sentry.opentelemetry.agent.AgentlessMarker` and `io.sentry.opentelemetry.agent.AgentlessSpringMarker`.
2121
- These were not indicators of something being wrong but rather the SDK looking at what is available at runtime to configure itself accordingly.
22+
- Do not instrument File I/O operations if tracing is disabled ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
23+
- Do not instrument User Interaction multiple times ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
24+
- Speed up view traversal to find touched target in `UserInteractionIntegration` ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
25+
- Reduce IPC/Binder calls performed by the SDK ([#4058](https://github.com/getsentry/sentry-java/pull/4058))
26+
27+
### Behavioural Changes
28+
29+
- Reduce the number of broadcasts the SDK is subscribed for ([#4052](https://github.com/getsentry/sentry-java/pull/4052))
30+
- Drop `TempSensorBreadcrumbsIntegration`
31+
- Drop `PhoneStateBreadcrumbsIntegration`
32+
- Reduce number of broadcasts in `SystemEventsBreadcrumbsIntegration`
33+
34+
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:
35+
36+
```kotlin
37+
SentryAndroid.init(context) { options ->
38+
options.integrations.removeAll { it is SystemEventsBreadcrumbsIntegration }
39+
options.integrations.add(SystemEventsBreadcrumbsIntegration(context, SystemEventsBreadcrumbsIntegration.getDefaultActions() + listOf(/* your custom actions */)))
40+
}
41+
```
42+
43+
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).
2244
- Set mechanism `type` to `suppressed` for suppressed exceptions ([#4125](https://github.com/getsentry/sentry-java/pull/4125))
2345
- This helps to distinguish an exceptions cause from any suppressed exceptions in the Sentry UI
2446

@@ -330,6 +352,68 @@ If you have been using `8.0.0-rc.4` of the Java SDK, here's the new changes that
330352
- We are planning to improve this in the future but opted for this fix first.
331353
- Fix swallow NDK loadLibrary errors ([#4082](https://github.com/getsentry/sentry-java/pull/4082))
332354

355+
## 7.21.0
356+
357+
### Fixes
358+
359+
- Do not instrument File I/O operations if tracing is disabled ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
360+
- Do not instrument User Interaction multiple times ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
361+
- Speed up view traversal to find touched target in `UserInteractionIntegration` ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
362+
- Reduce IPC/Binder calls performed by the SDK ([#4058](https://github.com/getsentry/sentry-java/pull/4058))
363+
364+
### Behavioural Changes
365+
366+
- Reduce the number of broadcasts the SDK is subscribed for ([#4052](https://github.com/getsentry/sentry-java/pull/4052))
367+
- Drop `TempSensorBreadcrumbsIntegration`
368+
- Drop `PhoneStateBreadcrumbsIntegration`
369+
- Reduce number of broadcasts in `SystemEventsBreadcrumbsIntegration`
370+
371+
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:
372+
373+
```kotlin
374+
SentryAndroid.init(context) { options ->
375+
options.integrations.removeAll { it is SystemEventsBreadcrumbsIntegration }
376+
options.integrations.add(SystemEventsBreadcrumbsIntegration(context, SystemEventsBreadcrumbsIntegration.getDefaultActions() + listOf(/* your custom actions */)))
377+
}
378+
```
379+
380+
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).
381+
382+
## 7.21.0-beta.1
383+
384+
### Fixes
385+
386+
- Do not instrument File I/O operations if tracing is disabled ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
387+
- Do not instrument User Interaction multiple times ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
388+
- Speed up view traversal to find touched target in `UserInteractionIntegration` ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
389+
- Reduce IPC/Binder calls performed by the SDK ([#4058](https://github.com/getsentry/sentry-java/pull/4058))
390+
391+
### Behavioural Changes
392+
393+
- Reduce the number of broadcasts the SDK is subscribed for ([#4052](https://github.com/getsentry/sentry-java/pull/4052))
394+
- Drop `TempSensorBreadcrumbsIntegration`
395+
- Drop `PhoneStateBreadcrumbsIntegration`
396+
- Reduce number of broadcasts in `SystemEventsBreadcrumbsIntegration`
397+
398+
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:
399+
400+
```kotlin
401+
SentryAndroid.init(context) { options ->
402+
options.integrations.removeAll { it is SystemEventsBreadcrumbsIntegration }
403+
options.integrations.add(SystemEventsBreadcrumbsIntegration(context, SystemEventsBreadcrumbsIntegration.getDefaultActions() + listOf(/* your custom actions */)))
404+
}
405+
```
406+
407+
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).
408+
409+
## 7.20.1
410+
411+
### Behavioural Changes
412+
413+
- The user ip-address is now only set to `"{{auto}}"` if sendDefaultPii is enabled ([#4071](https://github.com/getsentry/sentry-java/pull/4071))
414+
- This change gives you control over IP address collection directly on the client
415+
416+
333417
## 7.20.0
334418

335419
### Features

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)