Skip to content

Commit cce67e0

Browse files
authored
Merge a461f7e into f06a948
2 parents f06a948 + a461f7e commit cce67e0

File tree

69 files changed

+1687
-778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1687
-778
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ public final class io/sentry/android/core/BuildInfoProvider {
128128
public fun isEmulator ()Ljava/lang/Boolean;
129129
}
130130

131+
public final class io/sentry/android/core/ContextUtils {
132+
}
133+
131134
public class io/sentry/android/core/CurrentActivityHolder {
132135
public fun clearActivity ()V
133136
public fun getActivity ()Landroid/app/Activity;
@@ -148,6 +151,16 @@ public final class io/sentry/android/core/CurrentActivityIntegration : android/a
148151
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
149152
}
150153

154+
public class io/sentry/android/core/DeviceInfoUtil {
155+
public fun <init> (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;)V
156+
public fun collectDeviceInformation (ZZ)Lio/sentry/protocol/Device;
157+
public static fun getInstance (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;)Lio/sentry/android/core/DeviceInfoUtil;
158+
public final fun getOperatingSystem ()Lio/sentry/protocol/OperatingSystem;
159+
public fun getSideLoadedInfo ()Lio/sentry/android/core/ContextUtils$SideLoadedInfo;
160+
public static fun resetInstance ()V
161+
protected fun retrieveOperatingSystemInformation ()Lio/sentry/protocol/OperatingSystem;
162+
}
163+
151164
public abstract class io/sentry/android/core/EnvelopeFileObserverIntegration : io/sentry/Integration, java/io/Closeable {
152165
public fun <init> ()V
153166
public fun close ()V
@@ -160,6 +173,16 @@ public abstract interface class io/sentry/android/core/IDebugImagesLoader {
160173
public abstract fun loadDebugImages ()Ljava/util/List;
161174
}
162175

176+
public final class io/sentry/android/core/Installation {
177+
public static fun id (Landroid/content/Context;)Ljava/lang/String;
178+
}
179+
180+
public final class io/sentry/android/core/InternalSentrySdk {
181+
public fun <init> ()V
182+
public static fun getCurrentScope ()Lio/sentry/Scope;
183+
public static fun serializeScope (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/Scope;)Ljava/util/Map;
184+
}
185+
163186
public final class io/sentry/android/core/LoadClass {
164187
public fun <init> ()V
165188
public fun isClassAvailable (Ljava/lang/String;Lio/sentry/ILogger;)Z

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,12 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
517517

518518
private void setSideLoadedInfo(final @NotNull SentryBaseEvent event) {
519519
try {
520-
final Map<String, String> sideLoadedInfo =
521-
ContextUtils.getSideLoadedInfo(context, options.getLogger(), buildInfoProvider);
520+
final ContextUtils.SideLoadedInfo sideLoadedInfo =
521+
ContextUtils.retrieveSideLoadedInfo(context, options.getLogger(), buildInfoProvider);
522522

523523
if (sideLoadedInfo != null) {
524-
for (final Map.Entry<String, String> entry : sideLoadedInfo.entrySet()) {
524+
final @NotNull Map<String, String> tags = sideLoadedInfo.asTags();
525+
for (Map.Entry<String, String> entry : tags.entrySet()) {
525526
event.setTag(entry.getKey(), entry.getValue());
526527
}
527528
}

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

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,39 @@
2222
import java.util.HashMap;
2323
import java.util.List;
2424
import java.util.Map;
25+
import org.jetbrains.annotations.ApiStatus;
2526
import org.jetbrains.annotations.NotNull;
2627
import org.jetbrains.annotations.Nullable;
2728

28-
final class ContextUtils {
29+
@ApiStatus.Internal
30+
public final class ContextUtils {
31+
32+
static class SideLoadedInfo {
33+
private final boolean isSideLoaded;
34+
private final @Nullable String installerStore;
35+
36+
public SideLoadedInfo(boolean isSideLoaded, @Nullable String installerStore) {
37+
this.isSideLoaded = isSideLoaded;
38+
this.installerStore = installerStore;
39+
}
40+
41+
public boolean isSideLoaded() {
42+
return isSideLoaded;
43+
}
44+
45+
public @Nullable String getInstallerStore() {
46+
return installerStore;
47+
}
48+
49+
public @NotNull Map<String, String> asTags() {
50+
final Map<String, String> data = new HashMap<>();
51+
data.put("isSideLoaded", String.valueOf(isSideLoaded));
52+
if (installerStore != null) {
53+
data.put("installerStore", installerStore);
54+
}
55+
return data;
56+
}
57+
}
2958

3059
private ContextUtils() {}
3160

@@ -187,8 +216,8 @@ static boolean isForegroundImportance(final @NotNull Context context) {
187216
return defaultVersion;
188217
}
189218

190-
@SuppressWarnings("deprecation")
191-
static @Nullable Map<String, String> getSideLoadedInfo(
219+
@SuppressWarnings({"deprecation"})
220+
static @Nullable SideLoadedInfo retrieveSideLoadedInfo(
192221
final @NotNull Context context,
193222
final @NotNull ILogger logger,
194223
final @NotNull BuildInfoProvider buildInfoProvider) {
@@ -202,20 +231,10 @@ static boolean isForegroundImportance(final @NotNull Context context) {
202231

203232
// getInstallSourceInfo requires INSTALL_PACKAGES permission which is only given to system
204233
// apps.
234+
// if it's installed via adb, system apps or untrusted sources
235+
// could be amazon, google play etc - or null in case of sideload
205236
final String installerPackageName = packageManager.getInstallerPackageName(packageName);
206-
207-
final Map<String, String> sideLoadedInfo = new HashMap<>();
208-
209-
if (installerPackageName != null) {
210-
sideLoadedInfo.put("isSideLoaded", "false");
211-
// could be amazon, google play etc
212-
sideLoadedInfo.put("installerStore", installerPackageName);
213-
} else {
214-
// if it's installed via adb, system apps or untrusted sources
215-
sideLoadedInfo.put("isSideLoaded", "true");
216-
}
217-
218-
return sideLoadedInfo;
237+
return new SideLoadedInfo(installerPackageName == null, installerPackageName);
219238
}
220239
} catch (IllegalArgumentException e) {
221240
// it'll never be thrown as we are querying its own App's package.

0 commit comments

Comments
 (0)