fix: stop foreground service immediately on null/unknown action
If onStartCommand received a null intent (possible when START_STICKY restarts a killed service) or an unrecognized action, the service would start foreground (showing a persistent notification) but never call stopSelf(), leaving it running indefinitely. Added an else branch to call stopSelf(startId) immediately in these cases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
4e14adfc01
commit
34031fe89d
1 file changed
+5
@@ -99,6 +99,11 @@ class WallpaperChangeService : Service() {
|
||||
} ?: ScreenType.BOTH
|
||||
handleReapplyEffects(screenType, startId)
|
||||
}
|
||||
else -> {
|
||||
// Unknown or null action — stop immediately to avoid a stuck foreground service
|
||||
Log.w(TAG, "Unknown action: ${intent?.action}")
|
||||
stopSelf(startId)
|
||||
}
|
||||
}
|
||||
|
||||
return START_NOT_STICKY
|
||||
|
||||
Reference in new issue
Block a user