diff --git a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java index a90347741..4c3eb1b6f 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java @@ -6,6 +6,7 @@ import io.xpipe.app.core.*; import io.xpipe.app.issue.*; import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.storage.DataStorage; +import io.xpipe.app.update.XPipeDistributionType; import io.xpipe.app.util.LicenseProvider; import io.xpipe.app.util.FileBridge; import io.xpipe.app.util.LockedSecretValue; @@ -47,6 +48,7 @@ public class BaseMode extends OperationMode { LicenseProvider.get().init(); AppAntivirusAlert.showIfNeeded(); LocalStore.init(); + XPipeDistributionType.init(); AppPrefs.init(); AppCharsets.init(); AppCharsetter.init(); diff --git a/app/src/main/java/io/xpipe/app/update/XPipeDistributionType.java b/app/src/main/java/io/xpipe/app/update/XPipeDistributionType.java index 8665ac508..fa5ed0762 100644 --- a/app/src/main/java/io/xpipe/app/update/XPipeDistributionType.java +++ b/app/src/main/java/io/xpipe/app/update/XPipeDistributionType.java @@ -30,13 +30,14 @@ public enum XPipeDistributionType { this.updateHandlerSupplier = updateHandlerSupplier; } - public static XPipeDistributionType get() { + public static void init() { if (type != null) { - return type; + return; } if (!ModuleHelper.isImage()) { - return (type = DEVELOPMENT); + type = DEVELOPMENT; + return; } if (!XPipeSession.get().isNewBuildSession()) { @@ -47,19 +48,29 @@ public enum XPipeDistributionType { .findAny() .orElse(null); if (cachedType != null) { - return (type = cachedType); + type = cachedType; + return; } } var det = determine(); + // Don't cache unknown type if (det == UNKNOWN) { - return UNKNOWN; + return; } type = det; AppCache.update("dist", type.getId()); TrackEvent.withInfo("Determined distribution type").tag("type",type.getId()).handle(); + } + + public static XPipeDistributionType get() { + if (type == null) { + TrackEvent.withWarn("Distribution type requested before init").handle(); + return UNKNOWN; + } + return type; }