Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BroadcastReceivers #4052

Merged
merged 8 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
# Changelog

## Unreleased
### Unreleased
romtsn marked this conversation as resolved.
Show resolved Hide resolved

### 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))

### Changes
romtsn marked this conversation as resolved.
Show resolved Hide resolved

- 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.0

### Features
Expand Down
15 changes: 1 addition & 14 deletions sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,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 +373,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
Original file line number Diff line number Diff line change
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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
import static android.content.Context.ACTIVITY_SERVICE;
import static android.content.Context.RECEIVER_EXPORTED;
import static android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED;

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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
package io.sentry.android.core;

import static android.appwidget.AppWidgetManager.ACTION_APPWIDGET_DELETED;
import static android.appwidget.AppWidgetManager.ACTION_APPWIDGET_DISABLED;
import static android.appwidget.AppWidgetManager.ACTION_APPWIDGET_ENABLED;
import static android.appwidget.AppWidgetManager.ACTION_APPWIDGET_UPDATE;
import static android.content.Intent.ACTION_AIRPLANE_MODE_CHANGED;
import static android.content.Intent.ACTION_APP_ERROR;
import static android.content.Intent.ACTION_BATTERY_CHANGED;
import static android.content.Intent.ACTION_BATTERY_LOW;
import static android.content.Intent.ACTION_BATTERY_OKAY;
import static android.content.Intent.ACTION_BOOT_COMPLETED;
import static android.content.Intent.ACTION_BUG_REPORT;
import static android.content.Intent.ACTION_CAMERA_BUTTON;
import static android.content.Intent.ACTION_CONFIGURATION_CHANGED;
import static android.content.Intent.ACTION_DATE_CHANGED;
import static android.content.Intent.ACTION_DEVICE_STORAGE_LOW;
import static android.content.Intent.ACTION_DEVICE_STORAGE_OK;
import static android.content.Intent.ACTION_DOCK_EVENT;
import static android.content.Intent.ACTION_DREAMING_STARTED;
import static android.content.Intent.ACTION_DREAMING_STOPPED;
import static android.content.Intent.ACTION_INPUT_METHOD_CHANGED;
import static android.content.Intent.ACTION_LOCALE_CHANGED;
import static android.content.Intent.ACTION_MEDIA_BAD_REMOVAL;
import static android.content.Intent.ACTION_MEDIA_MOUNTED;
import static android.content.Intent.ACTION_MEDIA_UNMOUNTABLE;
import static android.content.Intent.ACTION_MEDIA_UNMOUNTED;
import static android.content.Intent.ACTION_POWER_CONNECTED;
import static android.content.Intent.ACTION_POWER_DISCONNECTED;
import static android.content.Intent.ACTION_REBOOT;
import static android.content.Intent.ACTION_SCREEN_OFF;
import static android.content.Intent.ACTION_SCREEN_ON;
import static android.content.Intent.ACTION_SHUTDOWN;
Expand Down Expand Up @@ -142,52 +128,27 @@ private void startSystemEventsReceiver(
}

@SuppressWarnings("deprecation")
private static @NotNull List<String> getDefaultActions() {
public static @NotNull List<String> getDefaultActions() {
final List<String> actions = new ArrayList<>();
actions.add(ACTION_APPWIDGET_DELETED);
actions.add(ACTION_APPWIDGET_DISABLED);
actions.add(ACTION_APPWIDGET_ENABLED);
actions.add("android.appwidget.action.APPWIDGET_HOST_RESTORED");
actions.add("android.appwidget.action.APPWIDGET_RESTORED");
actions.add(ACTION_APPWIDGET_UPDATE);
actions.add("android.appwidget.action.APPWIDGET_UPDATE_OPTIONS");
actions.add(ACTION_POWER_CONNECTED);
actions.add(ACTION_POWER_DISCONNECTED);
actions.add(ACTION_SHUTDOWN);
actions.add(ACTION_AIRPLANE_MODE_CHANGED);
actions.add(ACTION_BATTERY_LOW);
actions.add(ACTION_BATTERY_OKAY);
actions.add(ACTION_BATTERY_CHANGED);
actions.add(ACTION_BOOT_COMPLETED);
actions.add(ACTION_CAMERA_BUTTON);
actions.add(ACTION_CONFIGURATION_CHANGED);
actions.add("android.intent.action.CONTENT_CHANGED");
actions.add(ACTION_DATE_CHANGED);
actions.add(ACTION_DEVICE_STORAGE_LOW);
actions.add(ACTION_DEVICE_STORAGE_OK);
actions.add(ACTION_DOCK_EVENT);
actions.add("android.intent.action.DREAMING_STARTED");
actions.add("android.intent.action.DREAMING_STOPPED");
actions.add(ACTION_DREAMING_STARTED);
actions.add(ACTION_DREAMING_STOPPED);
actions.add(ACTION_INPUT_METHOD_CHANGED);
actions.add(ACTION_LOCALE_CHANGED);
actions.add(ACTION_REBOOT);
actions.add(ACTION_SCREEN_OFF);
actions.add(ACTION_SCREEN_ON);
actions.add(ACTION_TIMEZONE_CHANGED);
actions.add(ACTION_TIME_CHANGED);
actions.add("android.os.action.DEVICE_IDLE_MODE_CHANGED");
actions.add("android.os.action.POWER_SAVE_MODE_CHANGED");
// The user pressed the "Report" button in the crash/ANR dialog.
actions.add(ACTION_APP_ERROR);
// Show activity for reporting a bug.
actions.add(ACTION_BUG_REPORT);

// consider if somebody mounted or ejected a sdcard
actions.add(ACTION_MEDIA_BAD_REMOVAL);
actions.add(ACTION_MEDIA_MOUNTED);
actions.add(ACTION_MEDIA_UNMOUNTABLE);
actions.add(ACTION_MEDIA_UNMOUNTED);

return actions;
}

Expand Down
Loading
Loading