Skip to content

Commit dcdd715

Browse files
authored
Merge d411f57 into 2de45eb
2 parents 2de45eb + d411f57 commit dcdd715

File tree

12 files changed

+29
-608
lines changed

12 files changed

+29
-608
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
### Unreleased
4+
5+
### Changes
6+
7+
- Reduce the number of broadcasts the SDK is subscribed for ([#4052](https://github.com/getsentry/sentry-java/pull/4052))
8+
- Drop `TempSensorBreadcrumbsIntegration`
9+
- Drop `PhoneStateBreadcrumbsIntegration`
10+
- Reduce number of broadcasts in `SystemEventsBreadcrumbsIntegration`
11+
12+
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:
13+
14+
```kotlin
15+
SentryAndroid.init(context) { options ->
16+
options.integrations.removeAll { it is SystemEventsBreadcrumbsIntegration }
17+
options.integrations.add(SystemEventsBreadcrumbsIntegration(context, SystemEventsBreadcrumbsIntegration.getDefaultActions() + listOf(/* your custom actions */)))
18+
}
19+
```
20+
21+
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).
22+
323
## 7.20.0
424

525
### Features

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,6 @@ public final class io/sentry/android/core/NetworkBreadcrumbsIntegration : io/sen
245245
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
246246
}
247247

248-
public final class io/sentry/android/core/PhoneStateBreadcrumbsIntegration : io/sentry/Integration, java/io/Closeable {
249-
public fun <init> (Landroid/content/Context;)V
250-
public fun close ()V
251-
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
252-
}
253-
254248
public final class io/sentry/android/core/ScreenshotEventProcessor : io/sentry/EventProcessor {
255249
public fun <init> (Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/android/core/BuildInfoProvider;)V
256250
public fun process (Lio/sentry/SentryEvent;Lio/sentry/Hint;)Lio/sentry/SentryEvent;
@@ -379,14 +373,7 @@ public final class io/sentry/android/core/SystemEventsBreadcrumbsIntegration : i
379373
public fun <init> (Landroid/content/Context;)V
380374
public fun <init> (Landroid/content/Context;Ljava/util/List;)V
381375
public fun close ()V
382-
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
383-
}
384-
385-
public final class io/sentry/android/core/TempSensorBreadcrumbsIntegration : android/hardware/SensorEventListener, io/sentry/Integration, java/io/Closeable {
386-
public fun <init> (Landroid/content/Context;)V
387-
public fun close ()V
388-
public fun onAccuracyChanged (Landroid/hardware/Sensor;I)V
389-
public fun onSensorChanged (Landroid/hardware/SensorEvent;)V
376+
public static fun getDefaultActions ()Ljava/util/List;
390377
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
391378
}
392379

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,6 @@ static void installDefaultIntegrations(
301301
options.addIntegration(new SystemEventsBreadcrumbsIntegration(context));
302302
options.addIntegration(
303303
new NetworkBreadcrumbsIntegration(context, buildInfoProvider, options.getLogger()));
304-
options.addIntegration(new TempSensorBreadcrumbsIntegration(context));
305-
options.addIntegration(new PhoneStateBreadcrumbsIntegration(context));
306304
if (isReplayAvailable) {
307305
final ReplayIntegration replay =
308306
new ReplayIntegration(context, CurrentDateProvider.getInstance());

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
44
import static android.content.Context.ACTIVITY_SERVICE;
5-
import static android.content.Context.RECEIVER_EXPORTED;
65
import static android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED;
76

87
import android.annotation.SuppressLint;
@@ -349,7 +348,7 @@ public static boolean isForegroundImportance() {
349348
// If this receiver is listening for broadcasts sent from the system or from other apps, even
350349
// other apps that you own—use the RECEIVER_EXPORTED flag. If instead this receiver is
351350
// listening only for broadcasts sent by your app, use the RECEIVER_NOT_EXPORTED flag.
352-
return context.registerReceiver(receiver, filter, RECEIVER_EXPORTED);
351+
return context.registerReceiver(receiver, filter, Context.RECEIVER_NOT_EXPORTED);
353352
} else {
354353
return context.registerReceiver(receiver, filter);
355354
}

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

Lines changed: 0 additions & 136 deletions
This file was deleted.

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

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,17 @@
11
package io.sentry.android.core;
22

3-
import static android.appwidget.AppWidgetManager.ACTION_APPWIDGET_DELETED;
4-
import static android.appwidget.AppWidgetManager.ACTION_APPWIDGET_DISABLED;
5-
import static android.appwidget.AppWidgetManager.ACTION_APPWIDGET_ENABLED;
6-
import static android.appwidget.AppWidgetManager.ACTION_APPWIDGET_UPDATE;
73
import static android.content.Intent.ACTION_AIRPLANE_MODE_CHANGED;
8-
import static android.content.Intent.ACTION_APP_ERROR;
94
import static android.content.Intent.ACTION_BATTERY_CHANGED;
10-
import static android.content.Intent.ACTION_BATTERY_LOW;
11-
import static android.content.Intent.ACTION_BATTERY_OKAY;
12-
import static android.content.Intent.ACTION_BOOT_COMPLETED;
13-
import static android.content.Intent.ACTION_BUG_REPORT;
145
import static android.content.Intent.ACTION_CAMERA_BUTTON;
156
import static android.content.Intent.ACTION_CONFIGURATION_CHANGED;
167
import static android.content.Intent.ACTION_DATE_CHANGED;
178
import static android.content.Intent.ACTION_DEVICE_STORAGE_LOW;
189
import static android.content.Intent.ACTION_DEVICE_STORAGE_OK;
1910
import static android.content.Intent.ACTION_DOCK_EVENT;
11+
import static android.content.Intent.ACTION_DREAMING_STARTED;
12+
import static android.content.Intent.ACTION_DREAMING_STOPPED;
2013
import static android.content.Intent.ACTION_INPUT_METHOD_CHANGED;
2114
import static android.content.Intent.ACTION_LOCALE_CHANGED;
22-
import static android.content.Intent.ACTION_MEDIA_BAD_REMOVAL;
23-
import static android.content.Intent.ACTION_MEDIA_MOUNTED;
24-
import static android.content.Intent.ACTION_MEDIA_UNMOUNTABLE;
25-
import static android.content.Intent.ACTION_MEDIA_UNMOUNTED;
26-
import static android.content.Intent.ACTION_POWER_CONNECTED;
27-
import static android.content.Intent.ACTION_POWER_DISCONNECTED;
28-
import static android.content.Intent.ACTION_REBOOT;
2915
import static android.content.Intent.ACTION_SCREEN_OFF;
3016
import static android.content.Intent.ACTION_SCREEN_ON;
3117
import static android.content.Intent.ACTION_SHUTDOWN;
@@ -142,52 +128,27 @@ private void startSystemEventsReceiver(
142128
}
143129

144130
@SuppressWarnings("deprecation")
145-
private static @NotNull List<String> getDefaultActions() {
131+
public static @NotNull List<String> getDefaultActions() {
146132
final List<String> actions = new ArrayList<>();
147-
actions.add(ACTION_APPWIDGET_DELETED);
148-
actions.add(ACTION_APPWIDGET_DISABLED);
149-
actions.add(ACTION_APPWIDGET_ENABLED);
150-
actions.add("android.appwidget.action.APPWIDGET_HOST_RESTORED");
151-
actions.add("android.appwidget.action.APPWIDGET_RESTORED");
152-
actions.add(ACTION_APPWIDGET_UPDATE);
153-
actions.add("android.appwidget.action.APPWIDGET_UPDATE_OPTIONS");
154-
actions.add(ACTION_POWER_CONNECTED);
155-
actions.add(ACTION_POWER_DISCONNECTED);
156133
actions.add(ACTION_SHUTDOWN);
157134
actions.add(ACTION_AIRPLANE_MODE_CHANGED);
158-
actions.add(ACTION_BATTERY_LOW);
159-
actions.add(ACTION_BATTERY_OKAY);
160135
actions.add(ACTION_BATTERY_CHANGED);
161-
actions.add(ACTION_BOOT_COMPLETED);
162136
actions.add(ACTION_CAMERA_BUTTON);
163137
actions.add(ACTION_CONFIGURATION_CHANGED);
164-
actions.add("android.intent.action.CONTENT_CHANGED");
165138
actions.add(ACTION_DATE_CHANGED);
166139
actions.add(ACTION_DEVICE_STORAGE_LOW);
167140
actions.add(ACTION_DEVICE_STORAGE_OK);
168141
actions.add(ACTION_DOCK_EVENT);
169-
actions.add("android.intent.action.DREAMING_STARTED");
170-
actions.add("android.intent.action.DREAMING_STOPPED");
142+
actions.add(ACTION_DREAMING_STARTED);
143+
actions.add(ACTION_DREAMING_STOPPED);
171144
actions.add(ACTION_INPUT_METHOD_CHANGED);
172145
actions.add(ACTION_LOCALE_CHANGED);
173-
actions.add(ACTION_REBOOT);
174146
actions.add(ACTION_SCREEN_OFF);
175147
actions.add(ACTION_SCREEN_ON);
176148
actions.add(ACTION_TIMEZONE_CHANGED);
177149
actions.add(ACTION_TIME_CHANGED);
178150
actions.add("android.os.action.DEVICE_IDLE_MODE_CHANGED");
179151
actions.add("android.os.action.POWER_SAVE_MODE_CHANGED");
180-
// The user pressed the "Report" button in the crash/ANR dialog.
181-
actions.add(ACTION_APP_ERROR);
182-
// Show activity for reporting a bug.
183-
actions.add(ACTION_BUG_REPORT);
184-
185-
// consider if somebody mounted or ejected a sdcard
186-
actions.add(ACTION_MEDIA_BAD_REMOVAL);
187-
actions.add(ACTION_MEDIA_MOUNTED);
188-
actions.add(ACTION_MEDIA_UNMOUNTABLE);
189-
actions.add(ACTION_MEDIA_UNMOUNTED);
190-
191152
return actions;
192153
}
193154

0 commit comments

Comments
 (0)