Skip to content

Commit 9cf5463

Browse files
committed
Format code
1 parent a3ab661 commit 9cf5463

1 file changed

Lines changed: 39 additions & 42 deletions

File tree

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

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import io.sentry.util.HintUtils;
2020
import io.sentry.util.LazyEvaluator;
2121
import io.sentry.util.Objects;
22-
2322
import java.util.Collections;
2423
import java.util.List;
2524
import java.util.Locale;
@@ -28,31 +27,29 @@
2827
import java.util.concurrent.Executors;
2928
import java.util.concurrent.Future;
3029
import java.util.concurrent.RejectedExecutionException;
31-
3230
import org.jetbrains.annotations.NotNull;
3331
import org.jetbrains.annotations.Nullable;
3432
import org.jetbrains.annotations.TestOnly;
3533

3634
final class DefaultAndroidEventProcessor implements EventProcessor {
3735

38-
@TestOnly
39-
final Context context;
36+
@TestOnly final Context context;
4037

4138
private final @NotNull BuildInfoProvider buildInfoProvider;
4239
private final @NotNull SentryAndroidOptions options;
4340
private final @Nullable Future<DeviceInfoUtil> deviceInfoUtil;
4441
private final @NotNull LazyEvaluator<String> deviceFamily =
45-
new LazyEvaluator<>(() -> ContextUtils.getFamily(NoOpLogger.getInstance()));
42+
new LazyEvaluator<>(() -> ContextUtils.getFamily(NoOpLogger.getInstance()));
4643

4744
public DefaultAndroidEventProcessor(
48-
final @NotNull Context context,
49-
final @NotNull BuildInfoProvider buildInfoProvider,
50-
final @NotNull SentryAndroidOptions options) {
45+
final @NotNull Context context,
46+
final @NotNull BuildInfoProvider buildInfoProvider,
47+
final @NotNull SentryAndroidOptions options) {
5148
this.context =
52-
Objects.requireNonNull(
53-
ContextUtils.getApplicationContext(context), "The application context is required.");
49+
Objects.requireNonNull(
50+
ContextUtils.getApplicationContext(context), "The application context is required.");
5451
this.buildInfoProvider =
55-
Objects.requireNonNull(buildInfoProvider, "The BuildInfoProvider is required.");
52+
Objects.requireNonNull(buildInfoProvider, "The BuildInfoProvider is required.");
5653
this.options = Objects.requireNonNull(options, "The options object is required.");
5754

5855
// don't ref. to method reference, theres a bug on it
@@ -62,7 +59,7 @@ public DefaultAndroidEventProcessor(
6259
final @NotNull ExecutorService executorService = Executors.newSingleThreadExecutor();
6360
try {
6461
deviceInfoUtil =
65-
executorService.submit(() -> DeviceInfoUtil.getInstance(this.context, options));
62+
executorService.submit(() -> DeviceInfoUtil.getInstance(this.context, options));
6663
} catch (RejectedExecutionException e) {
6764
deviceInfoUtil = null;
6865
options.getLogger().log(SentryLevel.WARNING, "Device info caching task rejected.", e);
@@ -121,7 +118,7 @@ private static void fixExceptionOrder(final @NotNull SentryEvent event) {
121118
if (frames != null) {
122119
for (final @NotNull SentryStackFrame frame : frames) {
123120
if ("com.android.internal.os.RuntimeInit$MethodAndArgsCaller"
124-
.equals(frame.getModule())) {
121+
.equals(frame.getModule())) {
125122
reverseExceptions = true;
126123
break;
127124
}
@@ -137,25 +134,25 @@ private static void fixExceptionOrder(final @NotNull SentryEvent event) {
137134
}
138135

139136
private void setCommons(
140-
final @NotNull SentryBaseEvent event,
141-
final boolean errorEvent,
142-
final boolean applyScopeData) {
137+
final @NotNull SentryBaseEvent event,
138+
final boolean errorEvent,
139+
final boolean applyScopeData) {
143140
mergeUser(event);
144141
setDevice(event, errorEvent, applyScopeData);
145142
setSideLoadedInfo(event);
146143
}
147144

148145
private boolean shouldApplyScopeData(
149-
final @NotNull SentryBaseEvent event, final @NotNull Hint hint) {
146+
final @NotNull SentryBaseEvent event, final @NotNull Hint hint) {
150147
if (HintUtils.shouldApplyScopeData(hint)) {
151148
return true;
152149
} else {
153150
options
154-
.getLogger()
155-
.log(
156-
SentryLevel.DEBUG,
157-
"Event was cached so not applying data relevant to the current app execution/version: %s",
158-
event.getEventId());
151+
.getLogger()
152+
.log(
153+
SentryLevel.DEBUG,
154+
"Event was cached so not applying data relevant to the current app execution/version: %s",
155+
event.getEventId());
159156
return false;
160157
}
161158
}
@@ -177,15 +174,15 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
177174
}
178175

179176
private void setDevice(
180-
final @NotNull SentryBaseEvent event,
181-
final boolean errorEvent,
182-
final boolean applyScopeData) {
177+
final @NotNull SentryBaseEvent event,
178+
final boolean errorEvent,
179+
final boolean applyScopeData) {
183180
if (event.getContexts().getDevice() == null) {
184181
if (deviceInfoUtil != null) {
185182
try {
186183
event
187-
.getContexts()
188-
.setDevice(deviceInfoUtil.get().collectDeviceInformation(errorEvent, applyScopeData));
184+
.getContexts()
185+
.setDevice(deviceInfoUtil.get().collectDeviceInformation(errorEvent, applyScopeData));
189186
} catch (Throwable e) {
190187
options.getLogger().log(SentryLevel.ERROR, "Failed to retrieve device info", e);
191188
}
@@ -226,14 +223,14 @@ private void mergeOS(final @NotNull SentryBaseEvent event) {
226223
private void setDevice(final @NotNull SentryLogEvent event) {
227224
try {
228225
event.setAttribute(
229-
"device.brand",
230-
new SentryLogEventAttributeValue(SentryAttributeType.STRING, Build.BRAND));
226+
"device.brand",
227+
new SentryLogEventAttributeValue(SentryAttributeType.STRING, Build.BRAND));
231228
event.setAttribute(
232-
"device.model",
233-
new SentryLogEventAttributeValue(SentryAttributeType.STRING, Build.MODEL));
229+
"device.model",
230+
new SentryLogEventAttributeValue(SentryAttributeType.STRING, Build.MODEL));
234231
event.setAttribute(
235-
"device.family",
236-
new SentryLogEventAttributeValue(SentryAttributeType.STRING, deviceFamily.getValue()));
232+
"device.family",
233+
new SentryLogEventAttributeValue(SentryAttributeType.STRING, deviceFamily.getValue()));
237234
} catch (Throwable e) {
238235
options.getLogger().log(SentryLevel.ERROR, "Failed to retrieve device info", e);
239236
}
@@ -242,18 +239,18 @@ private void setDevice(final @NotNull SentryLogEvent event) {
242239
private void setOs(final @NotNull SentryLogEvent event) {
243240
try {
244241
event.setAttribute(
245-
"os.name", new SentryLogEventAttributeValue(SentryAttributeType.STRING, "Android"));
242+
"os.name", new SentryLogEventAttributeValue(SentryAttributeType.STRING, "Android"));
246243
event.setAttribute(
247-
"os.version",
248-
new SentryLogEventAttributeValue(SentryAttributeType.STRING, Build.VERSION.RELEASE));
244+
"os.version",
245+
new SentryLogEventAttributeValue(SentryAttributeType.STRING, Build.VERSION.RELEASE));
249246
} catch (Throwable e) {
250247
options.getLogger().log(SentryLevel.ERROR, "Failed to retrieve os system", e);
251248
}
252249
}
253250

254251
// Data to be applied to events that was created in the running process
255252
private void processNonCachedEvent(
256-
final @NotNull SentryBaseEvent event, final @NotNull Hint hint) {
253+
final @NotNull SentryBaseEvent event, final @NotNull Hint hint) {
257254
App app = event.getContexts().getApp();
258255
if (app == null) {
259256
app = new App();
@@ -285,8 +282,8 @@ private void setThreads(final @NotNull SentryEvent event, final @NotNull Hint hi
285282

286283
private void setPackageInfo(final @NotNull SentryBaseEvent event, final @NotNull App app) {
287284
final PackageInfo packageInfo =
288-
ContextUtils.getPackageInfo(
289-
context, PackageManager.GET_PERMISSIONS, options.getLogger(), buildInfoProvider);
285+
ContextUtils.getPackageInfo(
286+
context, PackageManager.GET_PERMISSIONS, options.getLogger(), buildInfoProvider);
290287
if (packageInfo != null) {
291288
String versionCode = ContextUtils.getVersionCode(packageInfo, buildInfoProvider);
292289

@@ -316,7 +313,7 @@ private void setDist(final @NotNull SentryBaseEvent event, final @NotNull String
316313
private void setAppExtras(final @NotNull App app, final @NotNull Hint hint) {
317314
app.setAppName(ContextUtils.getApplicationName(context));
318315
final @NotNull TimeSpan appStartTimeSpan =
319-
AppStartMetrics.getInstance().getAppStartTimeSpanWithFallback(options);
316+
AppStartMetrics.getInstance().getAppStartTimeSpanWithFallback(options);
320317
if (appStartTimeSpan.hasStarted()) {
321318
app.setAppStartTime(DateUtils.toUtilDate(appStartTimeSpan.getStartTimestamp()));
322319
}
@@ -363,7 +360,7 @@ private void setSideLoadedInfo(final @NotNull SentryBaseEvent event) {
363360

364361
@Override
365362
public @NotNull SentryTransaction process(
366-
final @NotNull SentryTransaction transaction, final @NotNull Hint hint) {
363+
final @NotNull SentryTransaction transaction, final @NotNull Hint hint) {
367364
final boolean applyScopeData = shouldApplyScopeData(transaction, hint);
368365

369366
if (applyScopeData) {
@@ -377,7 +374,7 @@ private void setSideLoadedInfo(final @NotNull SentryBaseEvent event) {
377374

378375
@Override
379376
public @NotNull SentryReplayEvent process(
380-
final @NotNull SentryReplayEvent event, final @NotNull Hint hint) {
377+
final @NotNull SentryReplayEvent event, final @NotNull Hint hint) {
381378
final boolean applyScopeData = shouldApplyScopeData(event, hint);
382379
if (applyScopeData) {
383380
processNonCachedEvent(event, hint);

0 commit comments

Comments
 (0)