From 75ac2b9946f211fa82b84fed44e27f710b4b2410 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 05:21:42 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Regression=20Guard:=20Fix=20casc?= =?UTF-8?q?ading=20crashes=20on=20service=20stop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wrap fallback `context.stopService(intent)` calls in try-catch blocks to prevent secondary crashes when cleaning up failed service starts. Co-authored-by: yuga-hashimoto <74749461+yuga-hashimoto@users.noreply.github.com> --- .../com/openclaw/assistant/service/HotwordService.kt | 12 ++++++++++-- .../assistant/service/NodeForegroundService.kt | 12 ++++++++++-- .../assistant/service/SessionForegroundService.kt | 12 ++++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/openclaw/assistant/service/HotwordService.kt b/app/src/main/java/com/openclaw/assistant/service/HotwordService.kt index 42463121..b7d62738 100644 --- a/app/src/main/java/com/openclaw/assistant/service/HotwordService.kt +++ b/app/src/main/java/com/openclaw/assistant/service/HotwordService.kt @@ -55,10 +55,18 @@ class HotwordService : Service(), VoskRecognitionListener { } } catch (e: IllegalStateException) { Log.e(TAG, "Background execution limits prevented starting HotwordService: ${e.message}", e) - context.stopService(intent) + try { + context.stopService(intent) + } catch (ex: Exception) { + android.util.Log.e(TAG, "Failed to stopService: ${ex.message}", ex) + } } catch (e: SecurityException) { Log.e(TAG, "Security limits prevented starting HotwordService: ${e.message}", e) - context.stopService(intent) + try { + context.stopService(intent) + } catch (ex: Exception) { + android.util.Log.e(TAG, "Failed to stopService: ${ex.message}", ex) + } } catch (e: Exception) { Log.e(TAG, "Failed to start HotwordService: ${e.message}", e) } diff --git a/app/src/main/java/com/openclaw/assistant/service/NodeForegroundService.kt b/app/src/main/java/com/openclaw/assistant/service/NodeForegroundService.kt index 031bf835..41b6aa86 100644 --- a/app/src/main/java/com/openclaw/assistant/service/NodeForegroundService.kt +++ b/app/src/main/java/com/openclaw/assistant/service/NodeForegroundService.kt @@ -285,10 +285,18 @@ class NodeForegroundService : Service() { context.startService(intent) } catch (e: IllegalStateException) { android.util.Log.w(TAG, "Failed to send ACTION_STOP via startService, falling back to stopService", e) - context.stopService(intent) + try { + context.stopService(intent) + } catch (ex: Exception) { + android.util.Log.e(TAG, "Failed to stopService: ${ex.message}", ex) + } } catch (e: SecurityException) { android.util.Log.w(TAG, "Failed to send ACTION_STOP via startService, falling back to stopService", e) - context.stopService(intent) + try { + context.stopService(intent) + } catch (ex: Exception) { + android.util.Log.e(TAG, "Failed to stopService: ${ex.message}", ex) + } } catch (e: Exception) { android.util.Log.w(TAG, "Failed to send ACTION_STOP via startService, falling back to stopService", e) try { diff --git a/app/src/main/java/com/openclaw/assistant/service/SessionForegroundService.kt b/app/src/main/java/com/openclaw/assistant/service/SessionForegroundService.kt index 57a0b80e..3e770f73 100644 --- a/app/src/main/java/com/openclaw/assistant/service/SessionForegroundService.kt +++ b/app/src/main/java/com/openclaw/assistant/service/SessionForegroundService.kt @@ -40,10 +40,18 @@ class SessionForegroundService : Service() { } } catch (e: IllegalStateException) { Log.e(TAG, "Background execution limits prevented starting SessionForegroundService: ${e.message}", e) - context.stopService(intent) + try { + context.stopService(intent) + } catch (ex: Exception) { + android.util.Log.e(TAG, "Failed to stopService: ${ex.message}", ex) + } } catch (e: SecurityException) { Log.e(TAG, "Security limits prevented starting SessionForegroundService: ${e.message}", e) - context.stopService(intent) + try { + context.stopService(intent) + } catch (ex: Exception) { + android.util.Log.e(TAG, "Failed to stopService: ${ex.message}", ex) + } } catch (e: Exception) { Log.e(TAG, "Failed to start SessionForegroundService: ${e.message}", e) }