Repository navigation
Keep the job and state through a recreate - #192
Merged
Merged
Conversation
GrblActivity.onDestroy() reset MachineStatusListener, FileSenderListener and ConsoleLoggerListener. After the switch from Bluetooth to USB, the new UsbConnectionActivity reads them in onCreate and the old activity is destroyed after that, so the USB screen kept the replaced objects: its status card stopped updating and the streaming service did not see the selected file. Reset them in onCreate when there is no saved state (a fresh start) instead. A recreate keeps them. Fixes #188
onDestroy() stopped the streaming service and the serial service on every destroy. Android 16 ignores the portrait lock and the resizable flag on large screens, so a fold, rotation or window resize recreated the activity and stopped a running job in the middle. Stop them, and send $10=1, only when the activity is finishing. The serial service is started, so it outlives the unbind and the new activity binds to it again. Fixes #187
Now that a job and the connection survive a recreate, the new activity must show them: - Toolbar: show "Connected" when the USB port or the Bluetooth link is still up after the service binds again. - Keep screen on: set it again when a job is running, as the window is new and StreamingStartedEvent is sent only once. - Battery dialog: ask only on a fresh start, so it does not cover the Stop button in the middle of a job. Refs #187
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #187 and #188. #191 was tested and closed as not a real crash.
#188 - stale state after the switch from Bluetooth to USB
restartInUsbMode()startsUsbConnectionActivityand then finishes. Android destroys the old activity after the new one has readMachineStatusListener,FileSenderListenerandConsoleLoggerListener, and the oldonDestroy()replaced them. The USB screen kept the old objects.GrblActivity.onCreateresets them only on a fresh start (savedInstanceState == null), andonDestroyno longer does.#187 - a fold, rotation or resize stopped a running job
resizeableActivity=falseon large screens, so the activity is recreated.onDestroy()then stopped the streaming service and the serial service, and sent$10=1.isFinishing(). The serial service is started, so it outlives the unbind and the new activity binds to it again.Checked
./gradlew buildpasses.Not covered: on a phone (not a large screen) a display density or size change makes Android restart the whole process, because the activities are non-resizable. That stops a job too, but it is system behaviour, not this code.