detekt cleanup (#2159)

This commit is contained in:
James Rich 2025-06-18 21:19:41 +00:00 committed by GitHub
parent e205f1d6d6
commit ca69051075
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -400,6 +400,7 @@ class RadioConfigViewModel @Inject constructor(
writeSecurityKeysJsonToUri(uri, securityConfig)
}
private val indentSpaces = 4
private suspend fun writeSecurityKeysJsonToUri(uri: Uri, securityConfig: SecurityConfig) =
withContext(Dispatchers.IO) {
try {
@ -408,7 +409,6 @@ class RadioConfigViewModel @Inject constructor(
val privateKeyBytes =
securityConfig.privateKey.toByteArray()
// Convert byte arrays to Base64 strings for human readability in JSON
val publicKeyBase64 = Base64.encodeToString(publicKeyBytes, Base64.NO_WRAP)
val privateKeyBase64 = Base64.encodeToString(privateKeyBytes, Base64.NO_WRAP)
@ -422,7 +422,7 @@ class RadioConfigViewModel @Inject constructor(
// Convert JSON object to a string
val jsonString =
jsonObject.toString(4)
jsonObject.toString(indentSpaces)
app.contentResolver.openFileDescriptor(uri, "wt")?.use { parcelFileDescriptor ->
FileOutputStream(parcelFileDescriptor.fileDescriptor).use { outputStream ->
@ -430,15 +430,12 @@ class RadioConfigViewModel @Inject constructor(
}
}
setResponseStateSuccess()
} catch (ex: Exception) {
val errorMessage = "Can't write security keys JSON error: ${ex.message}"
errormsg(errorMessage)
sendError(ex.customMessage)
}
}
fun installProfile(protobuf: DeviceProfile) = with(protobuf) {
meshService?.beginEditSettings()
if (hasLongName() || hasShortName()) {