From b8a981eb1f18199fe0983b5400c7aae000c539f8 Mon Sep 17 00:00:00 2001 From: crschnick Date: Sat, 31 Aug 2024 08:21:36 +0000 Subject: [PATCH] Check for startup when receiving shutdown notice --- app/src/main/java/io/xpipe/app/core/mode/OperationMode.java | 6 ++++++ .../main/java/io/xpipe/app/issue/SentryErrorHandler.java | 1 + 2 files changed, 7 insertions(+) diff --git a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java index 5d0e33fb4..ac3a76040 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java @@ -255,6 +255,12 @@ public abstract class OperationMode { } public static void shutdown(boolean inShutdownHook, boolean hasError) { + // We can receive shutdown events while we are still starting up + // In that case ignore them until we are finished + if (isInStartup()) { + return; + } + // In case we are stuck while in shutdown, instantly exit this application if (inShutdown && inShutdownHook) { TrackEvent.info("Received another shutdown request while in shutdown hook. Halting ..."); diff --git a/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java b/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java index 4ce84dad9..16834c4ff 100644 --- a/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java +++ b/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java @@ -157,6 +157,7 @@ public class SentryErrorHandler implements ErrorHandler { "logs", Boolean.toString( ee.isShouldSendDiagnostics() && !ee.getAttachments().isEmpty())); + s.setTag("inStartup", Boolean.toString(OperationMode.isInStartup())); s.setTag("inShutdown", Boolean.toString(OperationMode.isInShutdown())); s.setTag("unhandled", Boolean.toString(ee.isUnhandled()));