mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
block creation or sending of duplicate channels. (#3913)
This commit is contained in:
parent
499ed58311
commit
7db7f61386
5 changed files with 108 additions and 9 deletions
|
|
@ -89,3 +89,21 @@ fun ChannelSet.qrCode(shouldAdd: Boolean): Bitmap? = try {
|
|||
Timber.e("URL was too complex to render as barcode")
|
||||
null
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the ChannelSet contains any duplicate PSKs.
|
||||
*
|
||||
* @return true if there are duplicate PSKs, false otherwise
|
||||
*/
|
||||
fun ChannelSet.hasDuplicateKeys(): Boolean {
|
||||
val pskList = mutableListOf<ByteArray>()
|
||||
for (setting in settingsList) {
|
||||
val channel = Channel(setting, loraConfig)
|
||||
val pskBytes = channel.psk.toByteArray()
|
||||
if (pskList.any { it contentEquals pskBytes }) {
|
||||
return true
|
||||
}
|
||||
pskList.add(pskBytes)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue