Skip to content

Commit 70c11a0

Browse files
authored
Drop device name (#4179)
* Drop device name * Update Changelog * Update Changelog
1 parent 0e7364a commit 70c11a0

File tree

5 files changed

+4
-43
lines changed

5 files changed

+4
-43
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
- Reduce excessive CPU usage when serializing breadcrumbs to disk for ANRs ([#4181](https://github.com/getsentry/sentry-java/pull/4181))
88
- Ensure app start type is set, even when ActivityLifecycleIntegration is not running ([#4250](https://github.com/getsentry/sentry-java/pull/4250))
99

10+
### Behavioral Changes
11+
12+
- The user's `device.name` is not reported anymore via the device context, even if `options.isSendDefaultPii` is enabled ([#4179](https://github.com/getsentry/sentry-java/pull/4179))
13+
1014
### Dependencies
1115

1216
- Bump Gradle from v8.12.1 to v8.13.0 ([#4209](https://github.com/getsentry/sentry-java/pull/4209))

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,6 @@ private void setDevice(final @NotNull SentryBaseEvent event) {
639639
@SuppressLint("NewApi")
640640
private @NotNull Device getDevice() {
641641
Device device = new Device();
642-
if (options.isSendDefaultPii()) {
643-
device.setName(ContextUtils.getDeviceName(context));
644-
}
645642
device.setManufacturer(Build.MANUFACTURER);
646643
device.setBrand(Build.BRAND);
647644
device.setFamily(ContextUtils.getFamily(options.getLogger()));

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import android.content.pm.PackageInfo;
1515
import android.content.pm.PackageManager;
1616
import android.os.Build;
17-
import android.provider.Settings;
1817
import android.util.DisplayMetrics;
1918
import io.sentry.ILogger;
2019
import io.sentry.SentryLevel;
@@ -90,10 +89,6 @@ private ContextUtils() {}
9089
// to avoid doing a bunch of Binder calls we use LazyEvaluator to cache the values that are static
9190
// during the app process running
9291

93-
private static final @NotNull AndroidLazyEvaluator<String> deviceName =
94-
new AndroidLazyEvaluator<>(
95-
(context) -> Settings.Global.getString(context.getContentResolver(), "device_name"));
96-
9792
private static final @NotNull LazyEvaluator<Boolean> isForegroundImportance =
9893
new LazyEvaluator<>(
9994
() -> {
@@ -403,10 +398,6 @@ public static boolean isForegroundImportance() {
403398
}
404399
}
405400

406-
static @Nullable String getDeviceName(final @NotNull Context context) {
407-
return deviceName.getValue(context);
408-
}
409-
410401
static @NotNull String[] getArchitectures() {
411402
return Build.SUPPORTED_ABIS;
412403
}
@@ -521,7 +512,6 @@ public static Context getApplicationContext(final @NotNull Context context) {
521512

522513
@TestOnly
523514
static void resetInstance() {
524-
deviceName.resetValue();
525515
isForegroundImportance.resetValue();
526516
staticPackageInfo33.resetValue();
527517
staticPackageInfo.resetValue();

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ public Device collectDeviceInformation(
101101
final boolean collectDeviceIO, final boolean collectDynamicData) {
102102
// TODO: missing usable memory
103103
final @NotNull Device device = new Device();
104-
105-
if (options.isSendDefaultPii()) {
106-
device.setName(ContextUtils.getDeviceName(context));
107-
}
108104
device.setManufacturer(Build.MANUFACTURER);
109105
device.setBrand(Build.BRAND);
110106
device.setFamily(ContextUtils.getFamily(options.getLogger()));

sentry-android-core/src/test/java/io/sentry/android/core/DeviceInfoUtilTest.kt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package io.sentry.android.core
33
import android.content.Context
44
import android.content.Intent
55
import android.os.BatteryManager
6-
import android.provider.Settings
76
import androidx.test.core.app.ApplicationProvider
87
import androidx.test.ext.junit.runners.AndroidJUnit4
98
import io.sentry.android.core.internal.util.CpuInfoUtils
@@ -29,7 +28,6 @@ class DeviceInfoUtilTest {
2928
75
3029
).putExtra(BatteryManager.EXTRA_PLUGGED, 0)
3130
)
32-
Settings.Global.putString(context.contentResolver, "device_name", "sentry")
3331
DeviceInfoUtil.resetInstance()
3432
}
3533

@@ -51,30 +49,6 @@ class DeviceInfoUtilTest {
5149
assertNotNull(deviceInfo.memorySize)
5250
}
5351

54-
@Test
55-
fun `does not include device name when PII is disabled`() {
56-
val deviceInfoUtil = DeviceInfoUtil.getInstance(
57-
context,
58-
SentryAndroidOptions().apply {
59-
isSendDefaultPii = false
60-
}
61-
)
62-
val deviceInfo = deviceInfoUtil.collectDeviceInformation(false, false)
63-
assertNull(deviceInfo.name)
64-
}
65-
66-
@Test
67-
fun `does include device name when pii is enabled`() {
68-
val deviceInfoUtil = DeviceInfoUtil.getInstance(
69-
context,
70-
SentryAndroidOptions().apply {
71-
isSendDefaultPii = true
72-
}
73-
)
74-
val deviceInfo = deviceInfoUtil.collectDeviceInformation(false, false)
75-
assertNotNull(deviceInfo.name)
76-
}
77-
7852
@Test
7953
fun `does include cpu data`() {
8054
CpuInfoUtils.getInstance().setCpuMaxFrequencies(listOf(1024))

0 commit comments

Comments
 (0)