FirmwareUpdateViewModel

class FirmwareUpdateViewModel(firmwareReleaseRepository: FirmwareReleaseRepository, deviceHardwareRepository: DeviceHardwareRepository, maintenanceUf2Repository: MaintenanceUf2Repository, nodeRepository: NodeRepository, radioController: RadioController, radioPrefs: RadioPrefs, bootloaderWarningDataSource: BootloaderWarningDataSource, firmwareRecoveryDataSource: FirmwareRecoveryDataSource, firmwareUpdateManager: FirmwareUpdateManager, usbManager: FirmwareUsbManager, fileHandler: FirmwareFileHandler, firmwareRetriever: FirmwareRetriever, radioOperationLock: RadioOperationLock, applicationScope: ApplicationCoroutineScope, hiddenFeaturesUnlock: HiddenFeaturesUnlock, analytics: PlatformAnalytics, nodeRestartTracker: NodeRestartTracker, bluetoothRepository: BluetoothRepository, firmwareUpdateStatusRepository: FirmwareUpdateStatusRepository, uiPrefs: UiPrefs) : ViewModel(source)

ViewModel driving the firmware update screen. Coordinates release checking, file retrieval, transport-specific update execution, and post-update device verification.

Constructors

Link copied to clipboard
constructor(firmwareReleaseRepository: FirmwareReleaseRepository, deviceHardwareRepository: DeviceHardwareRepository, maintenanceUf2Repository: MaintenanceUf2Repository, nodeRepository: NodeRepository, radioController: RadioController, radioPrefs: RadioPrefs, bootloaderWarningDataSource: BootloaderWarningDataSource, firmwareRecoveryDataSource: FirmwareRecoveryDataSource, firmwareUpdateManager: FirmwareUpdateManager, usbManager: FirmwareUsbManager, fileHandler: FirmwareFileHandler, firmwareRetriever: FirmwareRetriever, radioOperationLock: RadioOperationLock, applicationScope: ApplicationCoroutineScope, hiddenFeaturesUnlock: HiddenFeaturesUnlock, analytics: PlatformAnalytics, nodeRestartTracker: NodeRestartTracker, bluetoothRepository: BluetoothRepository, firmwareUpdateStatusRepository: FirmwareUpdateStatusRepository, uiPrefs: UiPrefs)

Properties

Link copied to clipboard
Link copied to clipboard
val chirpyHopBestScore: StateFlow<Int>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val nightlyUnlocked: StateFlow<Boolean>

The version-row easter egg also unlocks the nightly preview channel, like the web flasher's konami code.

Link copied to clipboard

True where the USB firmware pass is written by picking the device's drive, so INFO_UF2.TXT is read and the drive vetted first. Elsewhere the image is saved through a file picker, which grants access to that file only.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val state: StateFlow<FirmwareUpdateState>

Functions

Link copied to clipboard
expect open fun addCloseable(closeable: AutoCloseable)
expect fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Writes the reviewed bootloader upgrade to the drive the review read.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
expect fun <T : AutoCloseable> getCloseable(key: String): T?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Waits again for a flashed device to come back after FirmwareUpdateState.VerificationFailed.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Moves on to reinstalling the firmware without writing the bootloader, so nothing destructive has happened.

Link copied to clipboard

Upgrades the bootloader over BLE with the Ready state's package, then reinstalls the selected release.

Link copied to clipboard
Link copied to clipboard
fun startUpdate(wipeDevice: Boolean = false)
Link copied to clipboard

Resumes a maintenance sequence once the user has pointed at the device's UF2 volume.

Link copied to clipboard
fun writeToVolume(treeUri: CommonUri)

Writes the pending USB pass to the drive the user picked: the next maintenance pass, or a plain update.