Skip to content

Commit

Permalink
Update DSUInstaller.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxRegner1 authored Aug 25, 2024
1 parent 08521b5 commit 5ebde80
Showing 1 changed file with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,29 +252,34 @@ class DSUInstaller(
/**
* Custom GSI installation logic
*/
private fun installGSI() {
Log.d(tag, "Starting GSI installation")

// Perform necessary GSI installation steps
// Example: Handle extra partitions, check conditions, or trigger specific GSI-related installation flows.

val gsiUri: Uri = dsuInstallation.uri // Example GSI URI

// Check if the GSI requires special handling
if (dsuInstallation.requiresGSIHandling) {
Log.d(tag, "Special GSI handling required.")

// Custom partition handling for GSI
val gsiPartitions = listOf("system", "vendor", "product")
gsiPartitions.forEach { partition ->
Log.d(tag, "Installing GSI partition: $partition")
// Assume we use `installImage` for GSI partitions
installImage(partition, dsuInstallation.fileSize, gsiUri)
}
private fun installImage(partitionName: String, uncompressedSize: Long, uri: Uri) {
installImage(
partitionName,
uncompressedSize,
openInputStream(uri),
)
if (installationJob.isCancelled) {
remove()
}
}

Log.d(tag, "GSI installation complete.")
} else {
Log.d(tag, "Standard GSI installation process.")
fun openInputStream(uri: Uri): InputStream {
return application.contentResolver.openInputStream(uri)!!
}

fun createNewPartition(partition: String, partitionSize: Long, readOnly: Boolean) {
val result = createPartition(partition, partitionSize, readOnly)
if (result != IGsiService.INSTALL_OK) {
Log.d(
tag,
"Failed to create $partition partition, error code: $result (check: IGsiService.INSTALL_*)",
)
installationJob.cancel()
onInstallationError(InstallationStep.ERROR_CREATE_PARTITION, partition)
}
}

override fun invoke() {
startInstallation()
}
}

0 comments on commit 5ebde80

Please sign in to comment.