Skip to content

Support DSU update.#260

Open
dingdang66686 wants to merge 1 commit into
VegaBobo:masterfrom
dingdang66686:master
Open

Support DSU update.#260
dingdang66686 wants to merge 1 commit into
VegaBobo:masterfrom
dingdang66686:master

Conversation

@dingdang66686
Copy link
Copy Markdown

Support updating existing dsu installation.
Add an option to preserve userdata.

Co-authored by github copilot.

* 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>
Copilot AI review requested due to automatic review settings February 3, 2026 11:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
text = stringResource(R.string.install),
text = stringResource(R.string.update),

Copilot uses AI. Check for mistakes.
Comment on lines +378 to +383
_uiState.update {
it.copy(
installationCard = InstallationCardState(),
sheetDisplay = SheetDisplayState.NONE,
isDsuInstalled = false,
)
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
_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,
),
)

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +79
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,
)
}
}
}
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants