Support DSU update.#260
Conversation
* Initial plan * Add preserve userdata feature for root DSU updates Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Add Chinese translations for preserve userdata feature Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Fix preserve userdata logic to always start installation session Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Improve UI to hide userdata size input when preserving Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Improve code clarity with better comments and logic order Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Allow file selection when DSU is installed for update flow Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Add comprehensive DSU installed UI with update and remove options Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Improve button text to show Install/Update based on file selection state Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Improve code comments for clarity Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Restructure DSU installed UI as requested: 3 buttons card + preserve userdata card Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Add validation and improve state management for DSU update flow Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Clarify comment about isEnabled parameter meaning Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Remove isUpdatingDsu state and simplify DSU update flow Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> * Fix clear button incorrectly resetting DSU installed state Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: dingdang66686 <42102822+dingdang66686@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds support for updating existing DSU installations without discarding them first, along with an option to preserve userdata during updates. When a DSU is already installed, users can now select a new image file and update to it while preserving their existing userdata partition. By default, the preserve userdata option is enabled when a DSU installation is detected.
Changes:
- Added UI state tracking for DSU installation status and preserve userdata preference
- Created new dedicated UI card (DsuInstalledCardContent) for the DSU already installed state with update capabilities
- Modified DSU installer to support updating without recreating userdata partition when preserve option is enabled
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/main/res/values/strings.xml | Added "Update" button text and preserve userdata option strings |
| app/src/main/res/values-zh-rCN/strings.xml | Added Chinese translations for new strings |
| app/src/main/java/vegabobo/dsusideloader/ui/screen/home/HomeViewModel.kt | Added logic to track DSU installation state, handle preserve userdata preference, and maintain state through installation lifecycle |
| app/src/main/java/vegabobo/dsusideloader/ui/screen/home/HomeUiState.kt | Added isDsuInstalled flag and preserveSelected to userdata card state; updated isInstalling() to exclude DSU_ALREADY_INSTALLED state |
| app/src/main/java/vegabobo/dsusideloader/ui/screen/home/HomeScreen.kt | Passed isDsuInstalled flag and preserve userdata callback to UserdataCard |
| app/src/main/java/vegabobo/dsusideloader/ui/cards/installation/content/DsuInstalledCardContent.kt | New component displaying file selection, install/update button, and reboot/discard actions when DSU is installed |
| app/src/main/java/vegabobo/dsusideloader/ui/cards/installation/InstallationCardStep.kt | Updated to use DsuInstalledCardContent for DSU_ALREADY_INSTALLED state |
| app/src/main/java/vegabobo/dsusideloader/ui/cards/UserdataCard.kt | Added simplified preserve userdata UI when DSU is installed, showing toggle and conditional userdata size input |
| app/src/main/java/vegabobo/dsusideloader/model/Session.kt | Added preserveUserdata boolean to InstallationPreferences |
| app/src/main/java/vegabobo/dsusideloader/installer/root/DSUInstaller.kt | Modified to allow updates when preserve is enabled and skip userdata partition creation when preserving |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Spacer(modifier = Modifier.padding(end = 6.dp)) | ||
| } | ||
| PrimaryButton( | ||
| text = stringResource(R.string.install), |
There was a problem hiding this comment.
The button text should display "Update" instead of "Install" when DSU is already installed, to accurately reflect that the operation is updating an existing installation. The "update" string resource is already defined at line 36 of strings.xml but is not being used here.
| text = stringResource(R.string.install), | |
| text = stringResource(R.string.update), |
| _uiState.update { | ||
| it.copy( | ||
| installationCard = InstallationCardState(), | ||
| sheetDisplay = SheetDisplayState.NONE, | ||
| isDsuInstalled = false, | ||
| ) |
There was a problem hiding this comment.
When discarding DSU, the preserveSelected flag in userDataCard is not reset to false. This means if a user discards DSU and then installs a new one, the preserve option will remain true from the previous state. Consider resetting userDataCard state or at least the preserveSelected field to false when discarding DSU.
| _uiState.update { | |
| it.copy( | |
| installationCard = InstallationCardState(), | |
| sheetDisplay = SheetDisplayState.NONE, | |
| isDsuInstalled = false, | |
| ) | |
| _uiState.update { | |
| it.copy( | |
| installationCard = InstallationCardState(), | |
| sheetDisplay = SheetDisplayState.NONE, | |
| isDsuInstalled = false, | |
| userDataCard = it.userDataCard.copy( | |
| preserveSelected = false, | |
| ), | |
| ) |
| AnimatedVisibility(visible = !uiState.preserveSelected) { | ||
| Column { | ||
| FileSelectionBox( | ||
| modifier = Modifier.padding(top = 8.dp, bottom = 4.dp), | ||
| isEnabled = !isEnabled, | ||
| isError = uiState.isError, | ||
| keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), | ||
| textFieldValue = uiState.text, | ||
| textFieldTitle = stringResource(id = R.string.userdata_size_info), | ||
| onValueChange = onValueChange, | ||
| ) | ||
| AnimatedVisibility(visible = uiState.isError) { | ||
| Text( | ||
| modifier = Modifier.padding(start = 1.dp), | ||
| text = stringResource( | ||
| id = R.string.allowed_userdata_allocation, | ||
| uiState.maximumAllowed, | ||
| ), | ||
| color = MaterialTheme.colorScheme.error, | ||
| lineHeight = 14.sp, | ||
| fontSize = 14.sp, | ||
| ) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
When DSU is installed and preserve userdata is disabled (preserveSelected = false), the userdata size input field is shown. However, the isSelected property of userDataCard is not being considered. In the normal flow (when DSU is not installed), users must explicitly enable the userdata size option via a toggle before they can input a size. This inconsistency could lead to confusion. Consider whether the isSelected check should also apply to the preserve userdata scenario, or if the current behavior is intentional for updating scenarios.
Support updating existing dsu installation.
Add an option to preserve userdata.
Co-authored by github copilot.