Skip to content

Commit

Permalink
Merge a461f7e into f06a948
Browse files Browse the repository at this point in the history
  • Loading branch information
markushi committed Jul 10, 2023
2 parents f06a948 + a461f7e commit cce67e0
Show file tree
Hide file tree
Showing 69 changed files with 1,687 additions and 778 deletions.
23 changes: 23 additions & 0 deletions sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public final class io/sentry/android/core/BuildInfoProvider {
public fun isEmulator ()Ljava/lang/Boolean;
}

public final class io/sentry/android/core/ContextUtils {
}

public class io/sentry/android/core/CurrentActivityHolder {
public fun clearActivity ()V
public fun getActivity ()Landroid/app/Activity;
Expand All @@ -148,6 +151,16 @@ public final class io/sentry/android/core/CurrentActivityIntegration : android/a
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
}

public class io/sentry/android/core/DeviceInfoUtil {
public fun <init> (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;)V
public fun collectDeviceInformation (ZZ)Lio/sentry/protocol/Device;
public static fun getInstance (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;)Lio/sentry/android/core/DeviceInfoUtil;
public final fun getOperatingSystem ()Lio/sentry/protocol/OperatingSystem;
public fun getSideLoadedInfo ()Lio/sentry/android/core/ContextUtils$SideLoadedInfo;
public static fun resetInstance ()V
protected fun retrieveOperatingSystemInformation ()Lio/sentry/protocol/OperatingSystem;
}

public abstract class io/sentry/android/core/EnvelopeFileObserverIntegration : io/sentry/Integration, java/io/Closeable {
public fun <init> ()V
public fun close ()V
Expand All @@ -160,6 +173,16 @@ public abstract interface class io/sentry/android/core/IDebugImagesLoader {
public abstract fun loadDebugImages ()Ljava/util/List;
}

public final class io/sentry/android/core/Installation {
public static fun id (Landroid/content/Context;)Ljava/lang/String;
}

public final class io/sentry/android/core/InternalSentrySdk {
public fun <init> ()V
public static fun getCurrentScope ()Lio/sentry/Scope;
public static fun serializeScope (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/Scope;)Ljava/util/Map;
}

public final class io/sentry/android/core/LoadClass {
public fun <init> ()V
public fun isClassAvailable (Ljava/lang/String;Lio/sentry/ILogger;)Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,12 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {

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

if (sideLoadedInfo != null) {
for (final Map.Entry<String, String> entry : sideLoadedInfo.entrySet()) {
final @NotNull Map<String, String> tags = sideLoadedInfo.asTags();
for (Map.Entry<String, String> entry : tags.entrySet()) {
event.setTag(entry.getKey(), entry.getValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,39 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

final class ContextUtils {
@ApiStatus.Internal
public final class ContextUtils {

static class SideLoadedInfo {
private final boolean isSideLoaded;
private final @Nullable String installerStore;

public SideLoadedInfo(boolean isSideLoaded, @Nullable String installerStore) {
this.isSideLoaded = isSideLoaded;
this.installerStore = installerStore;
}

public boolean isSideLoaded() {
return isSideLoaded;
}

public @Nullable String getInstallerStore() {
return installerStore;
}

public @NotNull Map<String, String> asTags() {
final Map<String, String> data = new HashMap<>();
data.put("isSideLoaded", String.valueOf(isSideLoaded));
if (installerStore != null) {
data.put("installerStore", installerStore);
}
return data;
}
}

private ContextUtils() {}

Expand Down Expand Up @@ -187,8 +216,8 @@ static boolean isForegroundImportance(final @NotNull Context context) {
return defaultVersion;
}

@SuppressWarnings("deprecation")
static @Nullable Map<String, String> getSideLoadedInfo(
@SuppressWarnings({"deprecation"})
static @Nullable SideLoadedInfo retrieveSideLoadedInfo(
final @NotNull Context context,
final @NotNull ILogger logger,
final @NotNull BuildInfoProvider buildInfoProvider) {
Expand All @@ -202,20 +231,10 @@ static boolean isForegroundImportance(final @NotNull Context context) {

// getInstallSourceInfo requires INSTALL_PACKAGES permission which is only given to system
// apps.
// if it's installed via adb, system apps or untrusted sources
// could be amazon, google play etc - or null in case of sideload
final String installerPackageName = packageManager.getInstallerPackageName(packageName);

final Map<String, String> sideLoadedInfo = new HashMap<>();

if (installerPackageName != null) {
sideLoadedInfo.put("isSideLoaded", "false");
// could be amazon, google play etc
sideLoadedInfo.put("installerStore", installerPackageName);
} else {
// if it's installed via adb, system apps or untrusted sources
sideLoadedInfo.put("isSideLoaded", "true");
}

return sideLoadedInfo;
return new SideLoadedInfo(installerPackageName == null, installerPackageName);
}
} catch (IllegalArgumentException e) {
// it'll never be thrown as we are querying its own App's package.
Expand Down

0 comments on commit cce67e0

Please sign in to comment.