From 887c5fc6661c94c15c6bf8f6f244c895d21f1581 Mon Sep 17 00:00:00 2001 From: Enginex0 Date: Mon, 2 Feb 2026 18:43:27 +0100 Subject: [PATCH] fix(config): prevent FileObserver NPE on config file deletion When a config file is deleted, the event handler sets file=null but then force-unwraps it with file!! in the when block, crashing the FileObserver thread. All subsequent config change notifications are silently lost. Replace force-unwrap with safe call, log a warning on deletion. --- .../org/matrix/TEESimulator/config/ConfigurationManager.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/matrix/TEESimulator/config/ConfigurationManager.kt b/app/src/main/java/org/matrix/TEESimulator/config/ConfigurationManager.kt index db68359..698e004 100644 --- a/app/src/main/java/org/matrix/TEESimulator/config/ConfigurationManager.kt +++ b/app/src/main/java/org/matrix/TEESimulator/config/ConfigurationManager.kt @@ -307,8 +307,10 @@ object ConfigurationManager { val file = if (event != DELETE) File(configRoot, path) else null when (path) { - TARGET_PACKAGES_FILE -> loadTargetPackages(file!!) - PATCH_LEVEL_FILE -> loadPatchLevelConfig(file!!) + TARGET_PACKAGES_FILE -> file?.let { loadTargetPackages(it) } + ?: SystemLogger.warning("$TARGET_PACKAGES_FILE was deleted.") + PATCH_LEVEL_FILE -> file?.let { loadPatchLevelConfig(it) } + ?: SystemLogger.warning("$PATCH_LEVEL_FILE was deleted.") // Any change to an XML file is assumed to be a keybox. // The cache in KeyBoxManager will handle reloading it on its next use. else ->