BaseFirmwareFileHandler

abstract class BaseFirmwareFileHandler(client: HttpClient, tempDir: File) : FirmwareFileHandler(source)

The FirmwareFileHandler work the Android and desktop handlers share: HTTP fetches into tempDir, and firmware extraction through the bounded extractFirmwareEntry. Subclasses say how a platform URI is opened.

Inheritors

Constructors

Link copied to clipboard
constructor(client: HttpClient, tempDir: File)

Functions

Link copied to clipboard
open suspend override fun checkUrlExists(url: String): Boolean

Return true if url is reachable (HTTP HEAD check).

Link copied to clipboard
open override fun cleanupAllTemporaryFiles()

Remove all temporary firmware files created during previous update sessions.

Link copied to clipboard
abstract suspend fun copyToUri(source: FirmwareArtifact, destinationUri: com.eygraber.uri.Uri): Long

Copy source to the platform URI destinationUri, returning the number of bytes written.

Link copied to clipboard
abstract suspend fun createDocumentInTree(treeUri: com.eygraber.uri.Uri, fileName: String, mimeType: String): com.eygraber.uri.Uri?

Creates fileName inside treeUri and returns a URI to write to, or null on failure.

Link copied to clipboard
open suspend override fun deleteFile(file: FirmwareArtifact): withContext

Delete a single firmware file from local storage.

Link copied to clipboard
open suspend override fun downloadFile(url: String, fileName: String, onProgress: (Float) -> Unit): FirmwareArtifact?

Download a file from url, saving it as fileName in a temporary directory.

Link copied to clipboard
open suspend override fun extractFirmware(uri: CommonUri, hardware: DeviceHardware, fileExtension: String, preferredFilename: String?): FirmwareArtifact?

abstract suspend fun extractFirmware(uri: com.eygraber.uri.Uri, hardware: org.meshtastic.core.model.DeviceHardware, fileExtension: String, preferredFilename: String? = null): FirmwareArtifact?

Extract a matching firmware binary from a platform URI (e.g. content:// or file://) zip archive.

Link copied to clipboard
open suspend override fun extractFirmwareFromZip(zipFile: FirmwareArtifact, hardware: DeviceHardware, fileExtension: String, preferredFilename: String?): FirmwareArtifact?

abstract suspend fun extractFirmwareFromZip(zipFile: FirmwareArtifact, hardware: org.meshtastic.core.model.DeviceHardware, fileExtension: String, preferredFilename: String? = null): FirmwareArtifact?

Extract a matching firmware binary from a previously-downloaded zip FirmwareArtifact.

Link copied to clipboard
abstract suspend fun extractZipEntries(artifact: FirmwareArtifact): Map<String, ByteArray>

Extract all entries from a zip artifact into a Map<entryName, bytes>. Used by the DFU handler to parse Nordic DFU packages.

Link copied to clipboard
open suspend override fun fetchText(url: String): String?

Fetch the UTF-8 text body of url, returning null on any HTTP or network error.

Link copied to clipboard
abstract suspend fun getDisplayName(uri: com.eygraber.uri.Uri): String?

Resolve a user-visible display filename for uri, or null when the provider does not expose one.

Link copied to clipboard
abstract suspend fun getFileSize(file: FirmwareArtifact): Long

Return the size in bytes of the given firmware file.

Link copied to clipboard
abstract suspend fun importFromUri(uri: com.eygraber.uri.Uri): FirmwareArtifact?

Copy a platform URI into a temporary FirmwareArtifact so it can be read with readBytes. Returns null when the URI cannot be resolved.

Link copied to clipboard
abstract suspend fun isDestinationReadable(destinationUri: com.eygraber.uri.Uri): Boolean

True when destinationUri can still be opened for reading.

Link copied to clipboard
abstract suspend fun isRemovableDestination(destinationUri: com.eygraber.uri.Uri): Boolean

Best-effort check that destinationUri names a location on removable storage — i.e. plausibly a mounted UF2 bootloader drive rather than internal storage.

Link copied to clipboard
abstract suspend fun readBytes(artifact: FirmwareArtifact): ByteArray

Read the raw bytes of a FirmwareArtifact.

Link copied to clipboard
abstract suspend fun readSiblingText(treeUri: com.eygraber.uri.Uri, fileName: String): String?

Reads a file sitting alongside the documents in treeUri, or null when it is absent or unreadable.